Rezervacije
This commit is contained in:
47
app/views/reservations/_form.html.erb
Normal file
47
app/views/reservations/_form.html.erb
Normal file
@@ -0,0 +1,47 @@
|
||||
<%= form_with(model: reservation, class: "contents") do |form| %>
|
||||
<% if reservation.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(reservation.errors.count, "error") %> prohibited this reservation from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% reservation.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<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" %>
|
||||
</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" %>
|
||||
</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 %>`
|
||||
<%= form.datetime_field :start_time, 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 :end_time %>
|
||||
<%= form.datetime_field :end_time, 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 %>
|
||||
37
app/views/reservations/_reservation.html.erb
Normal file
37
app/views/reservations/_reservation.html.erb
Normal file
@@ -0,0 +1,37 @@
|
||||
<div id="<%= dom_id reservation %>">
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Company:</strong>
|
||||
<%= reservation.company_id %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Customer:</strong>
|
||||
<%= reservation.customer_id %>
|
||||
</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 %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Start time:</strong>
|
||||
<%= reservation.start_time %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">End time:</strong>
|
||||
<%= reservation.end_time %>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
2
app/views/reservations/_reservation.json.jbuilder
Normal file
2
app/views/reservations/_reservation.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! reservation, :id, :company_id, :customer_id, :place_id, :title, :description, :start_time, :end_time, :created_at, :updated_at
|
||||
json.url reservation_url(reservation, format: :json)
|
||||
8
app/views/reservations/edit.html.erb
Normal file
8
app/views/reservations/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 reservation</h1>
|
||||
|
||||
<%= render "form", reservation: @reservation %>
|
||||
|
||||
<%= link_to "Show this reservation", @reservation, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<%= link_to "Back to reservations", reservations_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</div>
|
||||
21
app/views/reservations/index.html.erb
Normal file
21
app/views/reservations/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, "Reservations" %>
|
||||
|
||||
<div class="flex justify-between items-center">
|
||||
<h1 class="font-bold text-4xl">Reservations</h1>
|
||||
<%= 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>
|
||||
</div>
|
||||
1
app/views/reservations/index.json.jbuilder
Normal file
1
app/views/reservations/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @reservations, partial: "reservations/reservation", as: :reservation
|
||||
7
app/views/reservations/new.html.erb
Normal file
7
app/views/reservations/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 reservation</h1>
|
||||
|
||||
<%= render "form", reservation: @reservation %>
|
||||
|
||||
<%= link_to "Back to reservations", reservations_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</div>
|
||||
15
app/views/reservations/show.html.erb
Normal file
15
app/views/reservations/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 @reservation %>
|
||||
|
||||
<%= link_to "Edit this reservation", edit_reservation_path(@reservation), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<%= link_to "Back to reservations", reservations_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 reservation", @reservation, method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/reservations/show.json.jbuilder
Normal file
1
app/views/reservations/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "reservations/reservation", reservation: @reservation
|
||||
Reference in New Issue
Block a user