From 0185a563d1dec5abb4d51212fe13ceb553a6abad Mon Sep 17 00:00:00 2001 From: Joaquin Correa Date: Fri, 28 Feb 2025 11:28:07 -0300 Subject: [PATCH] Ignore admin holds for other instrument coloring --- app/presenters/calendar_events_presenter.rb | 9 ++------- app/presenters/reservations/calendar_presenter.rb | 6 ++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/presenters/calendar_events_presenter.rb b/app/presenters/calendar_events_presenter.rb index 6444e7a78d..7edbfea725 100644 --- a/app/presenters/calendar_events_presenter.rb +++ b/app/presenters/calendar_events_presenter.rb @@ -51,13 +51,7 @@ def unavailable_events def reservation_events reservations.map do |reservation| - event_data = reservation.as_calendar_object(calendar_opts) - - if params[:with_details] && reservation.product_id != instrument.id - event_data[:className] = "other-instrument" - end - - event_data + reservation.as_calendar_object(calendar_opts) end end @@ -66,6 +60,7 @@ def calendar_opts start_at:, end_at:, with_details: params[:with_details], + instrument_id: instrument.id, } end diff --git a/app/presenters/reservations/calendar_presenter.rb b/app/presenters/reservations/calendar_presenter.rb index 5ef25d30e5..23c2ed7c79 100644 --- a/app/presenters/reservations/calendar_presenter.rb +++ b/app/presenters/reservations/calendar_presenter.rb @@ -41,6 +41,10 @@ def as_calendar_object(options = {}) return ret if options[:with_details].blank? + if options[:with_details] && options[:instrument_id].present? && product_id != options[:instrument_id] + ret[:className] = "other-instrument" + end + ret.merge( title: order.user.full_name, email: order.user.email, @@ -60,8 +64,10 @@ def as_calendar_object(_options = {}) if expires_mins_before.present? hash[:expiration] = "Expires #{MinutesToTimeFormatter.new(expires_mins_before)} prior" end + hash[:className] = "unavailable" if __getobj__.is_a?(AdminReservation) end end end + end