Calendar is fullscreen

This commit is contained in:
2024-08-11 14:18:36 +02:00
parent 6d5509856f
commit e0d9d3a6b9
57 changed files with 431 additions and 362 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="dataSourceStorageLocal" created-in="RM-241.18034.63">
<component name="dataSourceStorageLocal" created-in="RM-241.19072.21">
<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>

88
.idea/workspace.xml generated
View File

@@ -5,17 +5,57 @@
</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/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/controllers/application_controller.rb" beforeDir="false" afterPath="$PROJECT_DIR$/app/controllers/application_controller.rb" 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$/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/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/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$/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" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="CSS File" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
@@ -30,32 +70,41 @@
&quot;associatedIndex&quot;: 7
}</component>
<component name="ProjectId" id="2gedovkte8bzmZcBk7eIpAhGZCK" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
&quot;ASKED_SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;Rails.terminator.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/hamo/projects/kbr4/terminator/app/assets/stylesheets&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;ruby.structure.view.model.defaults.configured&quot;: &quot;true&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;org.jetbrains.plugins.ruby.settings.RubyActiveModuleSdkConfigurable&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
<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>
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/app/views/layouts" />
<recent name="$PROJECT_DIR$/app/assets/stylesheets" />
<recent name="$PROJECT_DIR$/app/assets/javascripts" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/app/assets/javascripts" />
<recent name="$PROJECT_DIR$/app/javascript/custom" />
</key>
</component>
<component name="RunManager" selected="Rails.terminator">
<configuration name="terminator" type="RailsRunConfigurationType" factoryName="Rails">
@@ -137,7 +186,7 @@
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-js-predefined-1d06a55b98c1-0b3e54e931b4-JavaScript-RM-241.18034.63" />
<option value="bundled-js-predefined-1d06a55b98c1-0b3e54e931b4-JavaScript-RM-241.19072.21" />
</set>
</attachedChunks>
</component>
@@ -159,7 +208,8 @@
<workItem from="1722023923709" duration="4524000" />
<workItem from="1722663174775" duration="24000" />
<workItem from="1722663205967" duration="8991000" />
<workItem from="1722916917136" duration="1229000" />
<workItem from="1722916917136" duration="11564000" />
<workItem from="1723264782460" duration="19165000" />
</task>
<servers />
</component>

View File

@@ -44,10 +44,6 @@ gem "tzinfo-data", platforms: %i[ windows jruby ]
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
gem 'stimulus-rails'
gem "hotwire_combobox"
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

View File

@@ -2,4 +2,4 @@
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js
//= link_tree ../builds
//= link_tree ../builds

View File

@@ -1 +0,0 @@
//require 'toastui-calendar.min.js'

File diff suppressed because one or more lines are too long

View File

@@ -11,3 +11,11 @@
}
*/
body {
height: 100vw;
overflow: hidden;
}
toastui-calendar-time {
height: 100% !important;
}

File diff suppressed because one or more lines are too long

View File

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

View File

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

View 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

View File

@@ -1,2 +0,0 @@
module PlacesHelper
end

View File

@@ -0,0 +1,2 @@
module TeamsHelper
end

View File

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

View File

@@ -1,5 +1,6 @@
import { Application } from "@hotwired/stimulus"
const application = Application.start()
// Configure Stimulus development experience

View File

@@ -1,7 +0,0 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
this.element.textContent = "Hello World!"
}
}

View 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();
}
}

View File

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

View File

@@ -1,3 +0,0 @@
class Place < ApplicationRecord
belongs_to :company
end

2
app/models/team.rb Normal file
View File

@@ -0,0 +1,2 @@
class Team < ApplicationRecord
end

View File

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

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

View File

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

View File

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

View File

@@ -1,2 +0,0 @@
json.extract! place, :id, :name, :company_id, :created_at, :updated_at
json.url place_url(place, format: :json)

View File

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

View File

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

View File

@@ -1 +0,0 @@
json.array! @places, partial: "places/place", as: :place

View File

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

View File

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

View File

@@ -1 +0,0 @@
json.partial! "places/place", place: @place

View File

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

View File

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

View 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 %>

View File

@@ -0,0 +1,2 @@
<div id="<%= dom_id team %>">
</div>

View File

@@ -0,0 +1,2 @@
json.extract! team, :id, :created_at, :updated_at
json.url team_url(team, format: :json)

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

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

View File

@@ -0,0 +1 @@
json.array! @teams, partial: "teams/team", as: :team

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

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

View File

@@ -0,0 +1 @@
json.partial! "teams/team", team: @team

View File

@@ -1,7 +1,6 @@
# Pin npm packages by running ./bin/importmap
pin "application"
pin "@hotwired/turbo-rails", to: "turbo.min.js"
pin "@hotwired/stimulus", to: "stimulus.min.js"
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
pin "application"
pin_all_from "app/javascript/controllers", under: "controllers"

View File

@@ -5,21 +5,21 @@
# https://guides.rubyonrails.org/security.html#content-security-policy-header
# Rails.application.configure do
# config.content_security_policy do |policy|
# policy.default_src :self, :https
# policy.font_src :self, :https, :data
# policy.img_src :self, :https, :data
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# end
#
# # Generate session nonces for permitted importmap, inline scripts, and inline styles.
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
# config.content_security_policy_nonce_directives = %w(script-src style-src)
#
# # Report violations without enforcing the policy.
# # config.content_security_policy_report_only = true
# config.content_security_policy do |policy|
# policy.default_src :self, :http, :unsafe_eval, :unsafe_inline
# policy.font_src :self, :http, :data
# policy.img_src :self, :http, :data
# policy.object_src :none
# policy.script_src :self, :unsafe_eval, :unsafe_inline
# policy.style_src :self, :http
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# end
# #
# # # Generate session nonces for permitted importmap, inline scripts, and inline styles.
# # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
# # config.content_security_policy_nonce_directives = %w(script-src style-src)
# #
# # # Report violations without enforcing the policy.
# # # config.content_security_policy_report_only = true
# end

View File

@@ -1,6 +1,6 @@
Rails.application.routes.draw do
resources :teams
resources :reservations
resources :places
resources :customers
resources :companies
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

View File

@@ -1,10 +0,0 @@
class CreatePlaces < ActiveRecord::Migration[7.1]
def change
create_table :places do |t|
t.string :name
t.references :company, null: false, foreign_key: true
t.timestamps
end
end
end

View File

@@ -0,0 +1,6 @@
class RemoveTitleAndDescriptionFromReservations < ActiveRecord::Migration[7.1]
def change
remove_column :reservations, :title, :string
remove_column :reservations, :description, :text
end
end

View File

@@ -0,0 +1,8 @@
class CreateTeams < ActiveRecord::Migration[7.1]
def change
create_table :teams do |t|
t.timestamps
end
end
end

9
db/schema.rb generated
View File

@@ -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_04_060112) do
ActiveRecord::Schema[7.1].define(version: 2024_08_10_054948) do
create_table "companies", force: :cascade do |t|
t.string "name"
t.string "id_number"
@@ -48,8 +48,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_04_060112) do
t.integer "company_id", null: false
t.integer "customer_id", null: false
t.integer "place_id", null: false
t.string "title"
t.text "description"
t.datetime "start_time"
t.datetime "end_time"
t.datetime "created_at", null: false
@@ -59,6 +57,11 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_04_060112) do
t.index ["place_id"], name: "index_reservations_on_place_id"
end
create_table "teams", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_foreign_key "places", "companies"
add_foreign_key "reservations", "companies"
add_foreign_key "reservations", "customers"

View File

@@ -1,48 +0,0 @@
require "test_helper"
class PlacesControllerTest < ActionDispatch::IntegrationTest
setup do
@place = places(:one)
end
test "should get index" do
get places_url
assert_response :success
end
test "should get new" do
get new_place_url
assert_response :success
end
test "should create place" do
assert_difference("Place.count") do
post places_url, params: { place: { company_id: @place.company_id, name: @place.name } }
end
assert_redirected_to place_url(Place.last)
end
test "should show place" do
get place_url(@place)
assert_response :success
end
test "should get edit" do
get edit_place_url(@place)
assert_response :success
end
test "should update place" do
patch place_url(@place), params: { place: { company_id: @place.company_id, name: @place.name } }
assert_redirected_to place_url(@place)
end
test "should destroy place" do
assert_difference("Place.count", -1) do
delete place_url(@place)
end
assert_redirected_to places_url
end
end

View File

@@ -0,0 +1,48 @@
require "test_helper"
class TeamsControllerTest < ActionDispatch::IntegrationTest
setup do
@team = teams(:one)
end
test "should get index" do
get teams_url
assert_response :success
end
test "should get new" do
get new_team_url
assert_response :success
end
test "should create team" do
assert_difference("Team.count") do
post teams_url, params: { team: { } }
end
assert_redirected_to team_url(Team.last)
end
test "should show team" do
get team_url(@team)
assert_response :success
end
test "should get edit" do
get edit_team_url(@team)
assert_response :success
end
test "should update team" do
patch team_url(@team), params: { team: { } }
assert_redirected_to team_url(@team)
end
test "should destroy team" do
assert_difference("Team.count", -1) do
delete team_url(@team)
end
assert_redirected_to teams_url
end
end

View File

@@ -1,9 +0,0 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
company: one
two:
name: MyString
company: two

11
test/fixtures/teams.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# This model initially had no columns defined. If you add columns to the
# model remove the "{}" from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value

View File

@@ -1,6 +1,6 @@
require "test_helper"
class PlaceTest < ActiveSupport::TestCase
class TeamTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end

View File

@@ -1,43 +0,0 @@
require "application_system_test_case"
class PlacesTest < ApplicationSystemTestCase
setup do
@place = places(:one)
end
test "visiting the index" do
visit places_url
assert_selector "h1", text: "Places"
end
test "should create place" do
visit places_url
click_on "New place"
fill_in "Company", with: @place.company_id
fill_in "Name", with: @place.name
click_on "Create Place"
assert_text "Place was successfully created"
click_on "Back"
end
test "should update Place" do
visit place_url(@place)
click_on "Edit this place", match: :first
fill_in "Company", with: @place.company_id
fill_in "Name", with: @place.name
click_on "Update Place"
assert_text "Place was successfully updated"
click_on "Back"
end
test "should destroy Place" do
visit place_url(@place)
click_on "Destroy this place", match: :first
assert_text "Place was successfully destroyed"
end
end

39
test/system/teams_test.rb Normal file
View File

@@ -0,0 +1,39 @@
require "application_system_test_case"
class TeamsTest < ApplicationSystemTestCase
setup do
@team = teams(:one)
end
test "visiting the index" do
visit teams_url
assert_selector "h1", text: "Teams"
end
test "should create team" do
visit teams_url
click_on "New team"
click_on "Create Team"
assert_text "Team was successfully created"
click_on "Back"
end
test "should update Team" do
visit team_url(@team)
click_on "Edit this team", match: :first
click_on "Update Team"
assert_text "Team was successfully updated"
click_on "Back"
end
test "should destroy Team" do
visit team_url(@team)
click_on "Destroy this team", match: :first
assert_text "Team was successfully destroyed"
end
end