2021-03-11 14:05:22 -05:00
|
|
|
<%= if @live_action in [:new, :edit, :clone] do %>
|
2022-08-14 12:49:25 -04:00
|
|
|
<.live_component
|
|
|
|
module={Shift73kWeb.ModalComponent}
|
|
|
|
id="modal"
|
|
|
|
component={Shift73kWeb.ShiftTemplateLive.FormComponent}
|
|
|
|
opts={[
|
|
|
|
id: @shift_template.id || :new,
|
|
|
|
title: @page_title,
|
|
|
|
action: @live_action,
|
|
|
|
shift_template: @shift_template,
|
|
|
|
current_user: @current_user
|
|
|
|
]}
|
|
|
|
/>
|
2021-03-06 13:48:13 -05:00
|
|
|
<% end %>
|
|
|
|
|
2021-03-09 20:55:59 -05:00
|
|
|
<%= if @delete_shift_template do %>
|
2022-08-14 12:49:25 -04:00
|
|
|
<.live_component
|
|
|
|
module={Shift73kWeb.ModalComponent}
|
|
|
|
id="modal"
|
|
|
|
component={Shift73kWeb.ShiftTemplateLive.DeleteComponent}
|
|
|
|
opts={[
|
2021-03-09 20:55:59 -05:00
|
|
|
id: @delete_shift_template.id,
|
|
|
|
title: "Delete Shift Template",
|
2022-08-14 12:49:25 -04:00
|
|
|
delete_shift_template: @delete_shift_template
|
|
|
|
]}
|
|
|
|
/>
|
2021-03-09 20:55:59 -05:00
|
|
|
<% end %>
|
|
|
|
|
2021-03-06 20:16:56 -05:00
|
|
|
|
2021-03-09 20:18:56 -05:00
|
|
|
<div class="row justify-content-start justify-content-sm-center">
|
2021-03-11 13:30:30 -05:00
|
|
|
<div class="col-md-10 col-xl-10">
|
2021-03-07 08:01:46 -05:00
|
|
|
|
2021-03-09 20:18:56 -05:00
|
|
|
<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">
|
2022-08-14 09:49:34 -04:00
|
|
|
<i class="bi bi-clock-history me-1"></i> My Shift Templates
|
2021-03-07 08:01:46 -05:00
|
|
|
</h2>
|
2021-03-09 20:18:56 -05:00
|
|
|
<%= live_patch to: Routes.shift_template_index_path(@socket, :new), class: "btn btn-primary" do %>
|
2022-08-14 09:49:34 -04:00
|
|
|
<i class="bi bi-plus-circle-dotted me-1"></i> New Shift Template
|
2021-03-09 20:18:56 -05:00
|
|
|
<% end %>
|
2021-03-07 08:01:46 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
2021-03-08 07:39:41 -05:00
|
|
|
<div class="row">
|
2021-03-07 08:01:46 -05:00
|
|
|
|
2021-03-12 09:41:41 -05:00
|
|
|
<%= for template <- @shift_templates do %>
|
2021-03-08 07:39:41 -05:00
|
|
|
|
2021-03-11 13:30:30 -05:00
|
|
|
<div class="col-12 col-lg-6">
|
2021-03-07 08:01:46 -05:00
|
|
|
|
2021-03-07 11:06:55 -05:00
|
|
|
<div class="card mt-4">
|
2021-03-15 15:46:59 -04:00
|
|
|
<h5 class="card-header d-flex justify-content-between align-items-center">
|
|
|
|
<span class="visually-hidden">Subject:</span>
|
2022-08-14 09:49:34 -04:00
|
|
|
<i class="bi bi-tag me-1"></i>
|
2021-03-15 15:46:59 -04:00
|
|
|
<div class="w-100"><%= template.subject %></div>
|
2022-08-14 09:49:34 -04:00
|
|
|
<% fav_icon_data = if template.id == @current_user.fave_shift_template_id, do:
|
|
|
|
{"bi-star-fill", "Unset as favorite", "unset-user-fave-shift-template"}, else:
|
|
|
|
{"bi-star", "Set as favorite", "set-user-fave-shift-template"}
|
|
|
|
%>
|
|
|
|
<i class={"bi #{elem(fav_icon_data, 0)} text-primary align-self-start ms-2 cursor-pointer"} role="img" aria-hidden="false" aria-label={elem(fav_icon_data, 1)} phx-click={elem(fav_icon_data, 2)} phx-value-id={template.id}></i>
|
2021-03-08 07:39:41 -05:00
|
|
|
</h5>
|
2021-03-07 08:01:46 -05:00
|
|
|
<div class="card-body">
|
2021-03-08 07:39:41 -05:00
|
|
|
|
|
|
|
<table class="table table-borderless table-nonfluid table-sm">
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<th scope="row" class="text-end">
|
2022-08-14 09:49:34 -04:00
|
|
|
<i class="bi bi-hourglass text-muted"></i>
|
2021-03-11 13:30:30 -05:00
|
|
|
<span class="visually-hidden">Hours:</span>
|
2021-03-08 07:39:41 -05:00
|
|
|
</th>
|
|
|
|
<td>
|
2021-03-15 15:46:59 -04:00
|
|
|
<%= format_shift_time(template.time_start) %>
|
2021-03-08 07:39:41 -05:00
|
|
|
—
|
2021-03-15 15:46:59 -04:00
|
|
|
<%= format_shift_time(template.time_end) %>
|
2021-03-11 13:30:30 -05:00
|
|
|
<span class="text-muted">
|
|
|
|
<span class="visually-hidden">Shift length:</span>
|
2021-03-12 12:47:06 -05:00
|
|
|
(<%= format_shift_length(template) %>)
|
2021-03-11 13:30:30 -05:00
|
|
|
</span>
|
2021-03-12 09:41:41 -05:00
|
|
|
<span class="valid-feedback d-block text-muted mt-n1">TZ: <%= template.time_zone %></span>
|
2021-03-08 07:39:41 -05:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<th scope="row" class="text-end">
|
2022-08-14 09:49:34 -04:00
|
|
|
<i class="bi bi-geo text-muted"></i>
|
2021-03-11 13:30:30 -05:00
|
|
|
<span class="visually-hidden">Location:</span>
|
2021-03-08 07:39:41 -05:00
|
|
|
</th>
|
|
|
|
<td>
|
2021-03-12 09:41:41 -05:00
|
|
|
<%= if template.location do %>
|
|
|
|
<%= template.location %>
|
2021-03-08 07:39:41 -05:00
|
|
|
<% else %>
|
|
|
|
<span class="text-muted fst-italic">none</span>
|
|
|
|
<% end %>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row" class="text-end">
|
2022-08-14 09:49:34 -04:00
|
|
|
<i class="bi bi-justify-left text-muted"></i>
|
2021-03-11 13:30:30 -05:00
|
|
|
<span class="visually-hidden">Description:</span>
|
2021-03-08 07:39:41 -05:00
|
|
|
</th>
|
|
|
|
<td>
|
2021-03-12 09:41:41 -05:00
|
|
|
<%= if template.description do %>
|
|
|
|
<%= text_to_html template.description %>
|
2021-03-08 07:39:41 -05:00
|
|
|
<% else %>
|
|
|
|
<span class="text-muted fst-italic">none</span>
|
|
|
|
<% end %>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
2021-03-12 09:41:41 -05:00
|
|
|
<%= if Roles.can?(@current_user, template, :edit) do %>
|
|
|
|
<%= live_patch to: Routes.shift_template_index_path(@socket, :edit, template), class: "btn btn-primary btn-sm text-nowrap" do %>
|
2022-08-14 09:49:34 -04:00
|
|
|
<i class="bi bi-pencil me-1"></i> Edit
|
2021-03-08 07:39:41 -05:00
|
|
|
<% end %>
|
2021-03-09 20:55:59 -05:00
|
|
|
<% end %>
|
|
|
|
|
2021-03-12 09:41:41 -05:00
|
|
|
<%= if Roles.can?(@current_user, template, :clone) do %>
|
|
|
|
<%= live_patch to: Routes.shift_template_index_path(@socket, :clone, template), class: "btn btn-outline-primary btn-sm text-nowrap" do %>
|
2022-08-14 09:49:34 -04:00
|
|
|
<i class="bi bi-clipboard-plus me-1"></i> Clone
|
2021-03-11 14:05:22 -05:00
|
|
|
<% end %>
|
|
|
|
<% end %>
|
|
|
|
|
2021-03-12 09:41:41 -05:00
|
|
|
<%= if Roles.can?(@current_user, template, :delete) do %>
|
2022-08-14 09:49:34 -04:00
|
|
|
<button class="btn btn-outline-danger btn-sm text-nowrap" phx-click="delete-modal" phx-value-id={template.id}>
|
|
|
|
<i class="bi bi-trash me-1"></i> Delete
|
2021-03-09 20:55:59 -05:00
|
|
|
</button>
|
|
|
|
<% end %>
|
2021-03-08 07:39:41 -05:00
|
|
|
|
2021-03-07 08:01:46 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-03-08 07:39:41 -05:00
|
|
|
</div>
|
2021-03-07 08:01:46 -05:00
|
|
|
|
2021-03-08 07:39:41 -05:00
|
|
|
<% end %>
|
2021-03-07 08:01:46 -05:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
2021-03-06 20:16:56 -05:00
|
|
|
</div>
|