Skip to content

Commit

Permalink
Only allow admins to discriminate shared calendar events
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinco committed Feb 28, 2025
1 parent fd1189f commit 9a62410
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
12 changes: 7 additions & 5 deletions app/assets/stylesheets/calendar/fullcalendar.extensions.scss
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// Colors taken from google calendar which presumably
// follow accessibility good practices
$event-color: #039be5;
$event-color2: #DBDBDB;
$event-color3: #F6BF26;
$event-color4: #7CB342;
$event-color2: #c2c2c2;
$event-color3: #f6bf26;
$event-color4: #7cb342;

$event-text-color: white;

.fc-event {
background-color: $event-color;
border-color: $event-color;
color: black;
color: $event-text-color;
transition: box-shadow 50ms linear;

&:hover {
color: black;
color: $event-text-color;
box-shadow: 0px 6px 10px 0px rgba(0,0,0,.14),0px 1px 18px 0px rgba(0,0,0,.12),0px 3px 5px -1px rgba(0,0,0,.2);
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/reservations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def index

@show_details = params[:with_details] == "true" && (@instrument.show_details? || can?(:administer, Reservation))

discriminate = params[:discriminate] == "true" && can?(:administer, Reservation)

respond_to do |format|
format.js do
render(
Expand All @@ -70,6 +72,7 @@ def index
start_at: @start_at,
end_at: @end_at,
with_details: @show_details,
discriminate:,
view: params[:view]
).to_json
)
Expand Down
7 changes: 2 additions & 5 deletions app/presenters/calendar_events_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ def reservation_events

def calendar_opts
{
start_at:,
end_at:,
with_details: params[:with_details],
instrument_id: instrument.id,
}
start_at:, end_at:, instrument_id: instrument.id,
}.merge(params.slice(:with_details, :discriminate))
end

def monthly_view?
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/reservations/calendar_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class OrderCalendarPresenter < CalendarPresenter
def as_calendar_object(options = {})
ret = super

return ret if options[:with_details].blank?

if options[:with_details] && options[:instrument_id].present? && product_id != options[:instrument_id]
if options[:discriminate] && options[:instrument_id].present? && product_id != options[:instrument_id]
ret[:className] = "other-instrument"
end

return ret if options[:with_details].blank?

ret.merge(
title: order.user.full_name,
email: order.user.email,
Expand Down
2 changes: 1 addition & 1 deletion app/views/instruments/schedule.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
= render "admin/shared/tabnav_product", secondary_tab: "reservations"

:javascript
var events_path = "#{calendar_events_path(current_facility, @product, with_details: true)}";
var events_path = "#{calendar_events_path(current_facility, @product, with_details: true, discriminate: true)}";
var orders_path_base = "#{facility_orders_path(current_facility)}";
var dailyBooking = #{@product.daily_booking?};

Expand Down

0 comments on commit 9a62410

Please sign in to comment.