From ef4243ee2a78defacb4f1069697ccf8c05f76a51 Mon Sep 17 00:00:00 2001 From: Senad Uka Date: Sun, 8 Sep 2024 14:00:15 +0200 Subject: [PATCH] Reservations now show on calendar --- .idea/workspace.xml | 10 ++++------ app/controllers/reservations_controller.rb | 1 - app/javascript/controllers/main_calendar_controller.js | 6 +++--- app/models/reservation.rb | 4 ++++ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2382a62..ca39362 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,12 +5,10 @@ - - - - - + + + diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb index c9bfab0..20e02f3 100644 --- a/app/controllers/reservations_controller.rb +++ b/app/controllers/reservations_controller.rb @@ -5,7 +5,6 @@ class ReservationsController < ApplicationController layout :determine_layout # GET /reservations or /reservations.json def index - @reservations = Reservation.all.includes(:team, :customer).where(company: @company) @reservations = ActiveModelSerializers::SerializableResource.new(@reservations).as_json end diff --git a/app/javascript/controllers/main_calendar_controller.js b/app/javascript/controllers/main_calendar_controller.js index 8f88137..627ff1b 100644 --- a/app/javascript/controllers/main_calendar_controller.js +++ b/app/javascript/controllers/main_calendar_controller.js @@ -27,7 +27,7 @@ export default class extends Controller { ], }); - this.calendar = calendar; + window.calendar = calendar; this.getCalendardata(); calendar.render(); } @@ -36,11 +36,11 @@ export default class extends Controller { var reservations = JSON.parse(document.querySelector("#main-calendar").dataset.reservations); window.reservations = reservations; reservations.forEach(reservation => { - this.calendar.createSchedules([ + window.calendar.createEvents([ { id: reservation.id, calendarId: 'cal1', - title: reservation.customer, + title: reservation.customer.name, category: 'time', dueDateClass: reservation.dueDateClass, location: reservation.team.name, diff --git a/app/models/reservation.rb b/app/models/reservation.rb index 98514c9..51cbd91 100644 --- a/app/models/reservation.rb +++ b/app/models/reservation.rb @@ -7,3 +7,7 @@ class Reservation < ApplicationRecord validates :customer_id, presence: true validates :team_id, presence: true end + +class ReservationSerializer < ActiveModel::Serializer + attributes :id, :company, :customer, :team, :start_time, :end_time +end \ No newline at end of file