shift73k/lib/shift73k_web/live/shift_template_live/index.html.leex

135 lines
5.6 KiB
Text
Raw Normal View History

2021-03-11 14:05:22 -05:00
<%= 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">
2021-03-11 13:30:30 -05:00
<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 %>
2021-03-16 11:00:33 -04:00
<%= icon_div @socket, "bi-plus-circle-dotted", [class: "icon baseline"] %>
New Shift Template
<% end %>
</div>
2021-03-08 07:39:41 -05:00
<div class="row">
<%= 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 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>
<%= icon_div @socket, "bi-tag", [class: "icon baseline me-1"] %>
<div class="w-100"><%= template.subject %></div>
<%= if template.id == @current_user.fave_shift_template_id do %>
2021-03-15 15:46:59 -04:00
<%= icon_div @socket, "bi-star-fill", [class: "icon baseline text-primary align-self-start ms-2"], [role: "img", aria_hidden: false, aria_label: "Unset as favorite", phx_click: "unset-user-fave-shift-template", class: "cursor-pointer"] %>
<% else %>
2021-03-15 15:46:59 -04:00
<%= icon_div @socket, "bi-star", [class: "icon baseline text-primary align-self-start ms-2"], [role: "img", aria_hidden: false, aria_label: "Set as favorite", phx_click: "set-user-fave-shift-template", phx_value_id: template.id, class: "cursor-pointer"] %>
<% end %>
2021-03-08 07:39:41 -05:00
</h5>
<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">
2021-03-15 15:46:59 -04:00
<%= icon_div @socket, "bi-hourglass", [class: "icon baseline text-muted"] %>
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
&mdash;
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>
(<%= format_shift_length(template) %>)
2021-03-11 13:30:30 -05:00
</span>
<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">
<%= icon_div @socket, "bi-geo", [class: "icon baseline text-muted"] %>
2021-03-11 13:30:30 -05:00
<span class="visually-hidden">Location:</span>
2021-03-08 07:39:41 -05:00
</th>
<td>
<%= 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">
<%= icon_div @socket, "bi-justify-left", [class: "icon baseline text-muted"] %>
2021-03-11 13:30:30 -05:00
<span class="visually-hidden">Description:</span>
2021-03-08 07:39:41 -05:00
</th>
<td>
<%= 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>
<%= 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 %>
2021-03-16 11:00:33 -04:00
<%= icon_div @socket, "bi-pencil", [class: "icon baseline"] %>
Edit
2021-03-08 07:39:41 -05:00
<% end %>
<% end %>
<%= 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 %>
2021-03-16 11:00:33 -04:00
<%= icon_div @socket, "bi-clipboard-plus", [class: "icon baseline"] %>
2021-03-11 14:05:22 -05:00
Clone
<% end %>
<% end %>
<%#= button "" %>
<%= if Roles.can?(@current_user, template, :delete) do %>
<button class="btn btn-outline-danger btn-sm text-nowrap" phx-click="delete-modal" phx-value-id="<%= template.id %>">
2021-03-16 11:00:33 -04:00
<%= icon_div @socket, "bi-trash", [class: "icon baseline"] %>
Delete
</button>
<% end %>
2021-03-08 07:39:41 -05:00
</div>
</div>
2021-03-08 07:39:41 -05:00
</div>
2021-03-08 07:39:41 -05:00
<% end %>
</div>
</div>
</div>