Calendar is fullscreen
This commit is contained in:
@@ -2,4 +2,4 @@
|
||||
//= link_directory ../stylesheets .css
|
||||
//= link_tree ../../javascript .js
|
||||
//= link_tree ../../../vendor/javascript .js
|
||||
//= link_tree ../builds
|
||||
//= link_tree ../builds
|
||||
@@ -1 +0,0 @@
|
||||
//require 'toastui-calendar.min.js'
|
||||
File diff suppressed because one or more lines are too long
@@ -11,3 +11,11 @@
|
||||
}
|
||||
|
||||
*/
|
||||
body {
|
||||
height: 100vw;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
toastui-calendar-time {
|
||||
height: 100% !important;
|
||||
}
|
||||
0
app/assets/stylesheets/reservations.tailwind.css
Normal file
0
app/assets/stylesheets/reservations.tailwind.css
Normal file
File diff suppressed because one or more lines are too long
@@ -1,72 +0,0 @@
|
||||
class PlacesController < ApplicationController
|
||||
before_action :set_company
|
||||
before_action :set_place, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /places or /places.json
|
||||
def index
|
||||
@places = Place.all
|
||||
end
|
||||
|
||||
# GET /places/1 or /places/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /places/new
|
||||
def new
|
||||
@place = Place.new
|
||||
end
|
||||
|
||||
# GET /places/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /places or /places.json
|
||||
def create
|
||||
@place = Place.new(place_params)
|
||||
@place.company = @company
|
||||
|
||||
respond_to do |format|
|
||||
if @place.save
|
||||
format.html { redirect_to place_url(@place), notice: "Place was successfully created." }
|
||||
format.json { render :show, status: :created, location: @place }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @place.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /places/1 or /places/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @place.update(place_params)
|
||||
format.html { redirect_to place_url(@place), notice: "Place was successfully updated." }
|
||||
format.json { render :show, status: :ok, location: @place }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @place.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /places/1 or /places/1.json
|
||||
def destroy
|
||||
@place.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to places_url, notice: "Place was successfully destroyed." }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_place
|
||||
@place = Place.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def place_params
|
||||
params.require(:place).permit(:name, :company_id)
|
||||
end
|
||||
end
|
||||
@@ -2,8 +2,10 @@ class ReservationsController < ApplicationController
|
||||
before_action :set_company
|
||||
before_action :set_reservation, only: %i[ show edit update destroy ]
|
||||
|
||||
layout :determine_layout
|
||||
# GET /reservations or /reservations.json
|
||||
def index
|
||||
|
||||
@reservations = Reservation.all
|
||||
end
|
||||
|
||||
@@ -70,4 +72,9 @@ class ReservationsController < ApplicationController
|
||||
def reservation_params
|
||||
params.require(:reservation).permit(:company_id, :customer_id, :place_id, :title, :description, :start_time, :end_time)
|
||||
end
|
||||
|
||||
def determine_layout
|
||||
action_name == 'index' ? 'calendar' : 'application'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
70
app/controllers/teams_controller.rb
Normal file
70
app/controllers/teams_controller.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
class TeamsController < ApplicationController
|
||||
before_action :set_team, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /teams or /teams.json
|
||||
def index
|
||||
@teams = Team.all
|
||||
end
|
||||
|
||||
# GET /teams/1 or /teams/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /teams/new
|
||||
def new
|
||||
@team = Team.new
|
||||
end
|
||||
|
||||
# GET /teams/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /teams or /teams.json
|
||||
def create
|
||||
@team = Team.new(team_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @team.save
|
||||
format.html { redirect_to team_url(@team), notice: "Team was successfully created." }
|
||||
format.json { render :show, status: :created, location: @team }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @team.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /teams/1 or /teams/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @team.update(team_params)
|
||||
format.html { redirect_to team_url(@team), notice: "Team was successfully updated." }
|
||||
format.json { render :show, status: :ok, location: @team }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @team.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /teams/1 or /teams/1.json
|
||||
def destroy
|
||||
@team.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to teams_url, notice: "Team was successfully destroyed." }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_team
|
||||
@team = Team.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def team_params
|
||||
params.fetch(:team, {})
|
||||
end
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module PlacesHelper
|
||||
end
|
||||
2
app/helpers/teams_helper.rb
Normal file
2
app/helpers/teams_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module TeamsHelper
|
||||
end
|
||||
@@ -1,3 +1,2 @@
|
||||
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
|
||||
import "@hotwired/turbo-rails"
|
||||
import "controllers"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Application } from "@hotwired/stimulus"
|
||||
|
||||
|
||||
const application = Application.start()
|
||||
|
||||
// Configure Stimulus development experience
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
this.element.textContent = "Hello World!"
|
||||
}
|
||||
}
|
||||
26
app/javascript/controllers/main_calendar_controller.js
Normal file
26
app/javascript/controllers/main_calendar_controller.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import {Controller} from "@hotwired/stimulus"
|
||||
// Connects to data-controller="main-calendar"
|
||||
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
const calendar = new tui.Calendar(this.element, {
|
||||
defaultView: 'week',
|
||||
usageStatistics: false,
|
||||
week: {
|
||||
taskView: false,
|
||||
eventView: true,
|
||||
milestone: false,
|
||||
scheduleView: ['time'], // This will hide the all-day section
|
||||
},
|
||||
calendars: [
|
||||
{
|
||||
id: 'cal1',
|
||||
name: 'Work',
|
||||
backgroundColor: '#00a9ff',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
calendar.render();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
class Company < ApplicationRecord
|
||||
has_many :customers, dependent: :destroy
|
||||
has_many :reservations, dependent: :destroy
|
||||
has_many :places, dependent: :destroy
|
||||
has_many :teams, dependent: :destroy
|
||||
end
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
class Place < ApplicationRecord
|
||||
belongs_to :company
|
||||
end
|
||||
2
app/models/team.rb
Normal file
2
app/models/team.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Team < ApplicationRecord
|
||||
end
|
||||
@@ -5,14 +5,16 @@
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
<link rel="stylesheet" href="https://uicdn.toast.com/calendar/latest/toastui-calendar.min.css" />
|
||||
<script src="https://uicdn.toast.com/calendar/latest/toastui-calendar.min.js"></script>
|
||||
<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %>
|
||||
|
||||
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
||||
|
||||
<%= javascript_importmap_tags %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="container mx-auto mt-28 px-5 flex">
|
||||
<main class="container mx-auto mt-28 px-5" style="height: 100vh;">
|
||||
<%= yield %>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
21
app/views/layouts/calendar.html.erb
Normal file
21
app/views/layouts/calendar.html.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Terminator</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
<link rel="stylesheet" href="https://uicdn.toast.com/calendar/latest/toastui-calendar.min.css" />
|
||||
<script src="https://uicdn.toast.com/calendar/latest/toastui-calendar.min.js"></script>
|
||||
<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %>
|
||||
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
||||
|
||||
<%= javascript_importmap_tags %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main style="height: 100vw;">
|
||||
<%= yield %>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,22 +0,0 @@
|
||||
<%= form_with(model: place, class: "contents") do |form| %>
|
||||
<% if place.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(place.errors.count, "error") %> prohibited this place from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% place.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</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>
|
||||
<% end %>
|
||||
@@ -1,12 +0,0 @@
|
||||
<div id="<%= dom_id place %>">
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Name:</strong>
|
||||
<%= place.name %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Company:</strong>
|
||||
<%= place.company_id %>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
@@ -1,2 +0,0 @@
|
||||
json.extract! place, :id, :name, :company_id, :created_at, :updated_at
|
||||
json.url place_url(place, format: :json)
|
||||
@@ -1,8 +0,0 @@
|
||||
<div class="mx-auto md:w-2/3 w-full">
|
||||
<h1 class="font-bold text-4xl">Editing place</h1>
|
||||
|
||||
<%= render "form", place: @place %>
|
||||
|
||||
<%= link_to "Show this place", @place, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<%= link_to "Back to places", places_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</div>
|
||||
@@ -1,21 +0,0 @@
|
||||
<div class="w-full">
|
||||
<% if notice.present? %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<% content_for :title, "Places" %>
|
||||
|
||||
<div class="flex justify-between items-center">
|
||||
<h1 class="font-bold text-4xl">Places</h1>
|
||||
<%= link_to "New place", new_place_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
|
||||
</div>
|
||||
|
||||
<div id="places" class="min-w-full">
|
||||
<% @places.each do |place| %>
|
||||
<%= render place %>
|
||||
<p>
|
||||
<%= link_to "Show this place", place, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1 +0,0 @@
|
||||
json.array! @places, partial: "places/place", as: :place
|
||||
@@ -1,7 +0,0 @@
|
||||
<div class="mx-auto md:w-2/3 w-full">
|
||||
<h1 class="font-bold text-4xl">New place</h1>
|
||||
|
||||
<%= render "form", place: @place %>
|
||||
|
||||
<%= link_to "Back to places", places_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</div>
|
||||
@@ -1,15 +0,0 @@
|
||||
<div class="mx-auto md:w-2/3 w-full flex">
|
||||
<div class="mx-auto">
|
||||
<% if notice.present? %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<%= render @place %>
|
||||
|
||||
<%= link_to "Edit this place", edit_place_path(@place), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<%= link_to "Back to places", places_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<div class="inline-block ml-2">
|
||||
<%= button_to "Destroy this place", @place, method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1 +0,0 @@
|
||||
json.partial! "places/place", place: @place
|
||||
@@ -17,8 +17,8 @@
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :place_id %>
|
||||
<%= form.collection_select :place_id, @company.places, :id, :name, prompt: "Select a Place", class:"block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
<%= 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" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="w-full">
|
||||
<div class="w-full" style="height: 100%">
|
||||
<% if notice.present? %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
@@ -10,12 +10,8 @@
|
||||
<%= link_to "New reservation", new_reservation_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
|
||||
</div>
|
||||
|
||||
<div id="reservations" class="min-w-full">
|
||||
<% @reservations.each do |reservation| %>
|
||||
<%= render reservation %>
|
||||
<p>
|
||||
<%= link_to "Show this reservation", reservation, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</p>
|
||||
<% end %>
|
||||
<div data-controller="main-calendar" class="min-w-full" style="height: 100%" >
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
17
app/views/teams/_form.html.erb
Normal file
17
app/views/teams/_form.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<%= form_with(model: team, class: "contents") do |form| %>
|
||||
<% 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>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="inline">
|
||||
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
|
||||
</div>
|
||||
<% end %>
|
||||
2
app/views/teams/_team.html.erb
Normal file
2
app/views/teams/_team.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<div id="<%= dom_id team %>">
|
||||
</div>
|
||||
2
app/views/teams/_team.json.jbuilder
Normal file
2
app/views/teams/_team.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! team, :id, :created_at, :updated_at
|
||||
json.url team_url(team, format: :json)
|
||||
8
app/views/teams/edit.html.erb
Normal file
8
app/views/teams/edit.html.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
<div class="mx-auto md:w-2/3 w-full">
|
||||
<h1 class="font-bold text-4xl">Editing team</h1>
|
||||
|
||||
<%= render "form", team: @team %>
|
||||
|
||||
<%= link_to "Show this team", @team, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<%= link_to "Back to teams", teams_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</div>
|
||||
21
app/views/teams/index.html.erb
Normal file
21
app/views/teams/index.html.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
<div class="w-full">
|
||||
<% if notice.present? %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<% content_for :title, "Teams" %>
|
||||
|
||||
<div class="flex justify-between items-center">
|
||||
<h1 class="font-bold text-4xl">Teams</h1>
|
||||
<%= link_to "New team", new_team_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
|
||||
</div>
|
||||
|
||||
<div id="teams" class="min-w-full">
|
||||
<% @teams.each do |team| %>
|
||||
<%= render team %>
|
||||
<p>
|
||||
<%= link_to "Show this team", team, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/teams/index.json.jbuilder
Normal file
1
app/views/teams/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @teams, partial: "teams/team", as: :team
|
||||
7
app/views/teams/new.html.erb
Normal file
7
app/views/teams/new.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="mx-auto md:w-2/3 w-full">
|
||||
<h1 class="font-bold text-4xl">New team</h1>
|
||||
|
||||
<%= render "form", team: @team %>
|
||||
|
||||
<%= link_to "Back to teams", teams_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</div>
|
||||
15
app/views/teams/show.html.erb
Normal file
15
app/views/teams/show.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<div class="mx-auto md:w-2/3 w-full flex">
|
||||
<div class="mx-auto">
|
||||
<% if notice.present? %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<%= render @team %>
|
||||
|
||||
<%= link_to "Edit this team", edit_team_path(@team), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<%= link_to "Back to teams", teams_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<div class="inline-block ml-2">
|
||||
<%= button_to "Destroy this team", @team, method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/teams/show.json.jbuilder
Normal file
1
app/views/teams/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "teams/team", team: @team
|
||||
Reference in New Issue
Block a user