Reservations now show on calendar

This commit is contained in:
Senad Uka
2024-09-08 14:00:15 +02:00
parent b258de57fb
commit ef4243ee2a
4 changed files with 11 additions and 10 deletions

10
.idea/workspace.xml generated
View File

@@ -5,12 +5,10 @@
</component>
<component name="ChangeListManager">
<list default="true" id="4396ea83-1b77-4c6e-9398-0afe5751bc17" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/terminator.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/terminator.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Gemfile.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Gemfile.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/assets/stylesheets/application.tailwind.css" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/stylesheets/application.tailwind.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/views/layouts/calendar.html.erb" beforeDir="false" afterPath="$PROJECT_DIR$/app/views/layouts/calendar.html.erb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/controllers/reservations_controller.rb" beforeDir="false" afterPath="$PROJECT_DIR$/app/controllers/reservations_controller.rb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/javascript/controllers/main_calendar_controller.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/javascript/controllers/main_calendar_controller.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/models/reservation.rb" beforeDir="false" afterPath="$PROJECT_DIR$/app/models/reservation.rb" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -300,7 +298,7 @@
<workItem from="1723563784398" duration="15000" />
<workItem from="1723887734623" duration="12035000" />
<workItem from="1725691855747" duration="173000" />
<workItem from="1725692047994" duration="973000" />
<workItem from="1725692047994" duration="3679000" />
</task>
<servers />
</component>

View File

@@ -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

View File

@@ -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,

View File

@@ -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