Calendar is shown
This commit is contained in:
2
.idea/dataSources.local.xml
generated
2
.idea/dataSources.local.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="dataSourceStorageLocal" created-in="RM-241.19072.21">
|
||||
<component name="dataSourceStorageLocal" created-in="RM-242.20224.338">
|
||||
<data-source name="terminator: development" uuid="ce60eea1-83d5-4fbb-b43b-1f9f5b2dec38">
|
||||
<database-info product="" version="" jdbc-version="" driver-name="" driver-version="" dbms="SQLITE" />
|
||||
<auth-provider>no-auth</auth-provider>
|
||||
|
||||
3
.idea/terminator.iml
generated
3
.idea/terminator.iml
generated
@@ -35,6 +35,7 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="actionpack (v7.1.3.3, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="actiontext (v7.1.3.3, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="actionview (v7.1.3.3, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="active_model_serializers (v0.10.14, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="activejob (v7.1.3.3, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="activemodel (v7.1.3.3, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="activerecord (v7.1.3.3, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
@@ -49,6 +50,7 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="builder (v3.2.4, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.4.19, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="capybara (v3.40.0, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="case_transform (v0.2, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.2.3, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="connection_pool (v2.4.1, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="crass (v1.0.6, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
@@ -62,6 +64,7 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="io-console (v0.7.2, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="irb (v1.13.1, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="jbuilder (v2.12.0, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="jsonapi-renderer (v0.2.2, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="loofah (v2.22.0, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="mail (v2.8.1, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="marcel (v1.0.4, RVM: ruby-3.2.4) [gem]" level="application" />
|
||||
|
||||
81
.idea/workspace.xml
generated
81
.idea/workspace.xml
generated
@@ -5,44 +5,24 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="4396ea83-1b77-4c6e-9398-0afe5751bc17" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/app/assets/stylesheets/reservations.tailwind.css" afterDir="false" />
|
||||
<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" beforeDir="false" afterPath="$PROJECT_DIR$/Gemfile" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/assets/config/manifest.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/assets/config/manifest.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/assets/javascripts/application.js" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/assets/javascripts/toastui-calendar.min.js" beforeDir="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/assets/stylesheets/toastui-calendar.min.css" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/controllers/places_controller.rb" beforeDir="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/helpers/places_helper.rb" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/javascript/application.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/javascript/application.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/javascript/controllers/application.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/javascript/controllers/application.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/javascript/controllers/hello_controller.js" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/models/company.rb" beforeDir="false" afterPath="$PROJECT_DIR$/app/models/company.rb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/models/place.rb" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/controllers/teams_controller.rb" beforeDir="false" afterPath="$PROJECT_DIR$/app/controllers/teams_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" />
|
||||
<change beforePath="$PROJECT_DIR$/app/models/team.rb" beforeDir="false" afterPath="$PROJECT_DIR$/app/models/team.rb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/layouts/application.html.erb" beforeDir="false" afterPath="$PROJECT_DIR$/app/views/layouts/application.html.erb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/places/_form.html.erb" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/places/_place.html.erb" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/places/_place.json.jbuilder" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/places/edit.html.erb" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/places/index.html.erb" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/places/index.json.jbuilder" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/places/new.html.erb" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/places/show.html.erb" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/places/show.json.jbuilder" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/reservations/_form.html.erb" beforeDir="false" afterPath="$PROJECT_DIR$/app/views/reservations/_form.html.erb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/reservations/_reservation.html.erb" beforeDir="false" afterPath="$PROJECT_DIR$/app/views/reservations/_reservation.html.erb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/reservations/index.html.erb" beforeDir="false" afterPath="$PROJECT_DIR$/app/views/reservations/index.html.erb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/config/importmap.rb" beforeDir="false" afterPath="$PROJECT_DIR$/config/importmap.rb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/config/initializers/content_security_policy.rb" beforeDir="false" afterPath="$PROJECT_DIR$/config/initializers/content_security_policy.rb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/config/routes.rb" beforeDir="false" afterPath="$PROJECT_DIR$/config/routes.rb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/db/migrate/20240804060103_create_places.rb" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/views/teams/_form.html.erb" beforeDir="false" afterPath="$PROJECT_DIR$/app/views/teams/_form.html.erb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/db/migrate/20240810054948_create_teams.rb" beforeDir="false" afterPath="$PROJECT_DIR$/db/migrate/20240810054948_create_teams.rb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/db/schema.rb" beforeDir="false" afterPath="$PROJECT_DIR$/db/schema.rb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test/controllers/places_controller_test.rb" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test/fixtures/places.yml" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test/models/place_test.rb" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test/system/places_test.rb" beforeDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -77,24 +57,25 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"Rails.terminator.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"last_opened_file_path": "/home/hamo/projects/kbr4/terminator/app/views/layouts",
|
||||
"list.type.of.created.stylesheet": "CSS",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"ruby.structure.view.model.defaults.configured": "true",
|
||||
"settings.editor.selected.configurable": "org.jetbrains.plugins.ruby.settings.RubyActiveModuleSdkConfigurable",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"Rails.terminator.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "master",
|
||||
"last_opened_file_path": "/home/hamo/projects/kbr4/terminator/app/views/layouts",
|
||||
"list.type.of.created.stylesheet": "CSS",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"ruby.structure.view.model.defaults.configured": "true",
|
||||
"settings.editor.selected.configurable": "org.jetbrains.plugins.ruby.settings.RubyActiveModuleSdkConfigurable",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/app/views/layouts" />
|
||||
@@ -186,7 +167,7 @@
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-js-predefined-1d06a55b98c1-0b3e54e931b4-JavaScript-RM-241.19072.21" />
|
||||
<option value="bundled-js-predefined-d6986cc7102b-410509235cf1-JavaScript-RM-242.20224.338" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
@@ -209,7 +190,9 @@
|
||||
<workItem from="1722663174775" duration="24000" />
|
||||
<workItem from="1722663205967" duration="8991000" />
|
||||
<workItem from="1722916917136" duration="11564000" />
|
||||
<workItem from="1723264782460" duration="19165000" />
|
||||
<workItem from="1723264782460" duration="22567000" />
|
||||
<workItem from="1723563784398" duration="15000" />
|
||||
<workItem from="1723887734623" duration="12035000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@@ -217,6 +200,6 @@
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||
<SUITE FILE_PATH="coverage/terminator@terminator.rcov" NAME="terminator Coverage Results" MODIFIED="1722664264870" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="terminator" />
|
||||
<SUITE FILE_PATH="coverage/terminator@terminator.rcov" NAME="terminator Coverage Results" MODIFIED="1724021198613" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="terminator" />
|
||||
</component>
|
||||
</project>
|
||||
1
Gemfile
1
Gemfile
@@ -46,6 +46,7 @@ gem "bootsnap", require: false
|
||||
|
||||
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
|
||||
# gem "image_processing", "~> 1.2"
|
||||
gem "active_model_serializers"
|
||||
|
||||
group :development, :test do
|
||||
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
|
||||
|
||||
@@ -50,6 +50,11 @@ GEM
|
||||
erubi (~> 1.11)
|
||||
rails-dom-testing (~> 2.2)
|
||||
rails-html-sanitizer (~> 1.6)
|
||||
active_model_serializers (0.10.14)
|
||||
actionpack (>= 4.1)
|
||||
activemodel (>= 4.1)
|
||||
case_transform (>= 0.2)
|
||||
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
||||
activejob (7.1.3.3)
|
||||
activesupport (= 7.1.3.3)
|
||||
globalid (>= 0.3.6)
|
||||
@@ -93,6 +98,8 @@ GEM
|
||||
rack-test (>= 0.6.3)
|
||||
regexp_parser (>= 1.5, < 3.0)
|
||||
xpath (~> 3.2)
|
||||
case_transform (0.2)
|
||||
activesupport
|
||||
concurrent-ruby (1.2.3)
|
||||
connection_pool (2.4.1)
|
||||
crass (1.0.6)
|
||||
@@ -117,6 +124,7 @@ GEM
|
||||
jbuilder (2.12.0)
|
||||
actionview (>= 5.0.0)
|
||||
activesupport (>= 5.0.0)
|
||||
jsonapi-renderer (0.2.2)
|
||||
loofah (2.22.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.12.0)
|
||||
@@ -244,6 +252,7 @@ PLATFORMS
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
active_model_serializers
|
||||
bcrypt (~> 3.1.7)
|
||||
bootsnap
|
||||
capybara
|
||||
|
||||
@@ -18,4 +18,7 @@ body {
|
||||
|
||||
toastui-calendar-time {
|
||||
height: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
.toastui-calendar-timegrid { height: 100%; }
|
||||
.toastui-calendar-panel.toastui-calendar-time { overflow-y: inherit; }
|
||||
@@ -6,7 +6,8 @@ class ReservationsController < ApplicationController
|
||||
# GET /reservations or /reservations.json
|
||||
def index
|
||||
|
||||
@reservations = Reservation.all
|
||||
@reservations = Reservation.all.includes(:team, :customer).where(company: @company)
|
||||
@reservations = ActiveModelSerializers::SerializableResource.new(@reservations).as_json
|
||||
end
|
||||
|
||||
# GET /reservations/1 or /reservations/1.json
|
||||
@@ -16,7 +17,7 @@ class ReservationsController < ApplicationController
|
||||
# GET /reservations/new
|
||||
def new
|
||||
@reservation = Reservation.new
|
||||
@reservation.place = @company.places.first
|
||||
@reservation.team = @company.teams.first
|
||||
end
|
||||
|
||||
# GET /reservations/1/edit
|
||||
@@ -70,7 +71,7 @@ class ReservationsController < ApplicationController
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def reservation_params
|
||||
params.require(:reservation).permit(:company_id, :customer_id, :place_id, :title, :description, :start_time, :end_time)
|
||||
params.require(:reservation).permit(:company_id, :customer_id, :team_id, :title, :description, :start_time, :end_time)
|
||||
end
|
||||
|
||||
def determine_layout
|
||||
|
||||
@@ -22,6 +22,7 @@ class TeamsController < ApplicationController
|
||||
# POST /teams or /teams.json
|
||||
def create
|
||||
@team = Team.new(team_params)
|
||||
@team.company = Company.first
|
||||
|
||||
respond_to do |format|
|
||||
if @team.save
|
||||
@@ -36,6 +37,7 @@ class TeamsController < ApplicationController
|
||||
|
||||
# PATCH/PUT /teams/1 or /teams/1.json
|
||||
def update
|
||||
@team.company = Company.first
|
||||
respond_to do |format|
|
||||
if @team.update(team_params)
|
||||
format.html { redirect_to team_url(@team), notice: "Team was successfully updated." }
|
||||
@@ -65,6 +67,6 @@ class TeamsController < ApplicationController
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def team_params
|
||||
params.fetch(:team, {})
|
||||
params.require(:team).permit(:name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,14 +3,20 @@ import {Controller} from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
const calendar = new tui.Calendar(this.element, {
|
||||
const calendar = new tui.Calendar(document.getElementById('main-calendar'), {
|
||||
defaultView: 'week',
|
||||
usageStatistics: false,
|
||||
week: {
|
||||
taskView: false,
|
||||
eventView: true,
|
||||
milestone: false,
|
||||
scheduleView: ['time'], // This will hide the all-day section
|
||||
scheduleView: false,
|
||||
eventView: ['time'],
|
||||
hourStart: 4,
|
||||
hourEnd: 21,
|
||||
},
|
||||
template: {
|
||||
timegridDisplayPrimaryTime({time}) {
|
||||
return `${time.getHours()} sati`;
|
||||
}
|
||||
},
|
||||
calendars: [
|
||||
{
|
||||
@@ -21,6 +27,27 @@ export default class extends Controller {
|
||||
],
|
||||
});
|
||||
|
||||
this.calendar = calendar;
|
||||
this.getCalendardata();
|
||||
calendar.render();
|
||||
}
|
||||
|
||||
getCalendardata() {
|
||||
var reservations = JSON.parse(document.querySelector("#main-calendar").dataset.reservations);
|
||||
window.reservations = reservations;
|
||||
reservations.forEach(reservation => {
|
||||
this.calendar.createSchedules([
|
||||
{
|
||||
id: reservation.id,
|
||||
calendarId: 'cal1',
|
||||
title: reservation.customer,
|
||||
category: 'time',
|
||||
dueDateClass: reservation.dueDateClass,
|
||||
location: reservation.team.name,
|
||||
start: reservation.start_time,
|
||||
end: reservation.end_time
|
||||
}
|
||||
])
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class Reservation < ApplicationRecord
|
||||
belongs_to :company
|
||||
belongs_to :customer
|
||||
belongs_to :place
|
||||
belongs_to :team
|
||||
|
||||
validates :company_id, presence: true
|
||||
validates :customer_id, presence: true
|
||||
validates :place_id, presence: true
|
||||
validates :team_id, presence: true
|
||||
end
|
||||
|
||||
@@ -1,2 +1,7 @@
|
||||
class Team < ApplicationRecord
|
||||
belongs_to :company
|
||||
has_many :reservations, dependent: :destroy
|
||||
|
||||
validates :name, presence: true
|
||||
validates :company_id, presence: true
|
||||
end
|
||||
|
||||
6
app/serializers/reservatiopn_serializer.rb
Normal file
6
app/serializers/reservatiopn_serializer.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class ReservationSerializer < ActiveModel::Serializer
|
||||
attributes :id, :company_id, :customer_id, :team_id, :title, :description, :start_time, :end_time
|
||||
|
||||
belongs_to :team
|
||||
belongs_to :customer
|
||||
end
|
||||
@@ -14,7 +14,7 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="container mx-auto mt-28 px-5" style="height: 100vh;">
|
||||
<main class="container mx-auto mt-28 px-5 flex">
|
||||
<%= yield %>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
@@ -13,23 +13,14 @@
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :customer_id %>
|
||||
<%= form.collection_select :customer_id, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
<%= form.collection_select :customer_id, @company.customers, :id, :name, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :team_id %>
|
||||
<%= form.collection_select :place_id, @company.teams, :id, :name, prompt: "Select a Team", class:"block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
<%= form.collection_select :team_id, @company.teams, :id, :name, prompt: "Select a Team", class:"block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :title %>
|
||||
<%= form.text_field :title, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :description %>
|
||||
<%= form.text_area :description, rows: 4, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :start_time %>`
|
||||
|
||||
@@ -10,18 +10,8 @@
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Place:</strong>
|
||||
<%= reservation.place_id %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Title:</strong>
|
||||
<%= reservation.title %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Description:</strong>
|
||||
<%= reservation.description %>
|
||||
<strong class="block font-medium mb-1">Team:</strong>
|
||||
<%= reservation.team.name %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
<%= link_to "New reservation", new_reservation_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
|
||||
</div>
|
||||
|
||||
<div data-controller="main-calendar" class="min-w-full" style="height: 100%" >
|
||||
|
||||
|
||||
<div data-controller="main-calendar" class="min-w-full" style="height: 90vh;" >
|
||||
<%= tag.div nil, data: {reservations: @reservations.to_json}, id: "main-calendar"%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<% if team.errors.any? %>
|
||||
<div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-lg mt-3">
|
||||
<h2><%= pluralize(team.errors.count, "error") %> prohibited this team from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% team.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
@@ -11,6 +10,11 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :name %>
|
||||
<%= form.text_field :name, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="inline">
|
||||
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
class CreateTeams < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :teams do |t|
|
||||
|
||||
t.string :name
|
||||
t.references :company, null: false, foreign_key: true
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class ChangePlaceToTeamInReservations < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
remove_reference :reservations, :place, foreign_key: true
|
||||
add_reference :reservations, :team, null: false, foreign_key: true
|
||||
end
|
||||
end
|
||||
12
db/schema.rb
generated
12
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_08_10_054948) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_08_18_063444) do
|
||||
create_table "companies", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "id_number"
|
||||
@@ -47,23 +47,27 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_10_054948) do
|
||||
create_table "reservations", force: :cascade do |t|
|
||||
t.integer "company_id", null: false
|
||||
t.integer "customer_id", null: false
|
||||
t.integer "place_id", null: false
|
||||
t.datetime "start_time"
|
||||
t.datetime "end_time"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "team_id", null: false
|
||||
t.index ["company_id"], name: "index_reservations_on_company_id"
|
||||
t.index ["customer_id"], name: "index_reservations_on_customer_id"
|
||||
t.index ["place_id"], name: "index_reservations_on_place_id"
|
||||
t.index ["team_id"], name: "index_reservations_on_team_id"
|
||||
end
|
||||
|
||||
create_table "teams", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.integer "company_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["company_id"], name: "index_teams_on_company_id"
|
||||
end
|
||||
|
||||
add_foreign_key "places", "companies"
|
||||
add_foreign_key "reservations", "companies"
|
||||
add_foreign_key "reservations", "customers"
|
||||
add_foreign_key "reservations", "places"
|
||||
add_foreign_key "reservations", "teams"
|
||||
add_foreign_key "teams", "companies"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user