134 lines
5.5 KiB
Text
134 lines
5.5 KiB
Text
<%= if @live_action in [:new, :edit, :clone] do %>
|
|
<%= live_modal @socket, Shift73kWeb.ShiftTemplateLive.FormComponent,
|
|
id: @shift_template.id || :new,
|
|
title: @page_title,
|
|
action: @live_action,
|
|
shift_template: @shift_template,
|
|
current_user: @current_user %>
|
|
<% end %>
|
|
|
|
<%= if @delete_shift_template do %>
|
|
<%= live_modal @socket, Shift73kWeb.ShiftTemplateLive.DeleteComponent,
|
|
id: @delete_shift_template.id,
|
|
title: "Delete Shift Template",
|
|
delete_shift_template: @delete_shift_template,
|
|
current_user: @current_user %>
|
|
<% end %>
|
|
|
|
|
|
<div class="row justify-content-start justify-content-sm-center">
|
|
<div class="col-md-10 col-xl-10">
|
|
|
|
<div class="d-flex flex-column flex-sm-row justify-content-between align-items-start align-items-sm-center">
|
|
<h2 class="mb-3 mb-sm-0">
|
|
<%= icon_div @socket, "bi-clock-history", [class: "icon baseline"] %>
|
|
My Shift Templates
|
|
</h2>
|
|
<%= live_patch to: Routes.shift_template_index_path(@socket, :new), class: "btn btn-primary" do %>
|
|
<%= icon_div @socket, "bi-plus-circle-dotted", [class: "icon baseline me-1"] %>
|
|
New Shift Template
|
|
<% end %>
|
|
</div>
|
|
|
|
|
|
<div class="row">
|
|
|
|
<%= for shift <- @shift_templates do %>
|
|
|
|
<div class="col-12 col-lg-6">
|
|
|
|
<div class="card mt-4">
|
|
<h5 class="card-header d-flex justify-content-between align-items-start">
|
|
<div class="visually-hidden">Subject:</div>
|
|
<%= shift.subject %>
|
|
<%= if shift.id == @current_user.fave_shift_template_id do %>
|
|
<%= icon_div @socket, "bi-star-fill", [class: "icon baseline text-primary align-self-start ms-2", phx_click: "unset-user-fave-shift-template"] %>
|
|
<% else %>
|
|
<%= icon_div @socket, "bi-star", [class: "icon baseline text-primary align-self-start ms-2", phx_click: "set-user-fave-shift-template", phx_value_id: shift.id] %>
|
|
<% end %>
|
|
</h5>
|
|
<div class="card-body">
|
|
|
|
<table class="table table-borderless table-nonfluid table-sm">
|
|
<tbody>
|
|
<tr>
|
|
<th scope="row" class="text-end">
|
|
<%= icon_div @socket, "bi-hourglass", [class: "icon text-muted"] %>
|
|
<span class="visually-hidden">Hours:</span>
|
|
</th>
|
|
<td>
|
|
<%= shift.time_start |> Calendar.strftime("%I:%M%P") %>
|
|
—
|
|
<%= shift.time_end |> Calendar.strftime("%I:%M%P") %>
|
|
<span class="text-muted">
|
|
<span class="visually-hidden">Shift length:</span>
|
|
<% shift_length = ShiftTemplate.shift_length_h_m_tuple(shift.time_start, shift.time_end) %>
|
|
(<%= shift_length |> elem(0) %>h <%= shift_length |> elem(1) %>m)
|
|
</span>
|
|
<span class="valid-feedback d-block text-muted mt-n1">TZ: <%= shift.time_zone %></span>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th scope="row" class="text-end">
|
|
<%= icon_div @socket, "bi-geo", [class: "icon baseline text-muted"] %>
|
|
<span class="visually-hidden">Location:</span>
|
|
</th>
|
|
<td>
|
|
<%= if shift.location do %>
|
|
<%= shift.location %>
|
|
<% else %>
|
|
<span class="text-muted fst-italic">none</span>
|
|
<% end %>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" class="text-end">
|
|
<%= icon_div @socket, "bi-justify-left", [class: "icon baseline text-muted"] %>
|
|
<span class="visually-hidden">Description:</span>
|
|
</th>
|
|
<td>
|
|
<%= if shift.description do %>
|
|
<%= text_to_html shift.description %>
|
|
<% else %>
|
|
<span class="text-muted fst-italic">none</span>
|
|
<% end %>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<%= if Roles.can?(@current_user, shift, :edit) do %>
|
|
<%= live_patch to: Routes.shift_template_index_path(@socket, :edit, shift), class: "btn btn-primary btn-sm text-nowrap" do %>
|
|
<%= icon_div @socket, "bi-pencil", [class: "icon baseline", style: "margin-right:0.125rem;"] %>
|
|
Edit
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<%= if Roles.can?(@current_user, shift, :clone) do %>
|
|
<%= live_patch to: Routes.shift_template_index_path(@socket, :clone, shift), class: "btn btn-outline-primary btn-sm text-nowrap" do %>
|
|
<%= icon_div @socket, "bi-clipboard-plus", [class: "icon baseline", style: "margin-right:0.125rem;"] %>
|
|
Clone
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<%#= button "" %>
|
|
|
|
<%= if Roles.can?(@current_user, shift, :delete) do %>
|
|
<button class="btn btn-outline-danger btn-sm text-nowrap" phx-click="delete-modal" phx-value-id="<%= shift.id %>">
|
|
<%= icon_div @socket, "bi-trash", [class: "icon baseline", style: "margin-right:0.125rem;"] %>
|
|
Delete
|
|
</button>
|
|
<% end %>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|