shift73k/lib/shift73k_web/live/shift_live/index.html.heex

133 lines
5.2 KiB
Plaintext

<%= if @delete_shift do %>
<.live_component
module={Shift73kWeb.ModalComponent}
id="modal"
component={Shift73kWeb.ShiftLive.DeleteComponent}
opts={[
id: @delete_shift.id,
title: "Delete Shift Template",
delete_shift: @delete_shift
]}
/>
<% end %>
<div class="row justify-content-start justify-content-sm-center">
<div class="col-md-10 col-xl-10">
<h2 class="mb-3 mb-sm-0">
<i class="bi bi-card-list me-1"></i> My Shifts
</h2>
<div class="row justify-content-start justify-content-sm-center">
<div class="col-md-10 col-xl-10">
<%# month navigation %>
<div class="d-flex justify-content-between align-items-end my-4">
<h3 class="text-muted mb-0">
<%= Calendar.strftime(@cursor_date, "%B %Y") %>
</h3>
<div>
<button type="button" phx-click="month-nav" phx-value-month="now" class="btn btn-info text-white" disabled={if Map.get(@cursor_date, :month) == Map.get(Date.utc_today(), :month), do: :true, else: :false}>
<i class="bi bi-asterisk me-sm-1"></i>
<span class="d-none d-sm-inline">Today</span>
</button>
<button type="button" phx-click="month-nav" phx-value-month="prev" class="btn btn-primary">
<i class="bi bi-chevron-left me-sm-1"></i>
<span class="d-none d-sm-inline">Prev</span>
</button>
<button type="button" phx-click="month-nav" phx-value-month="next" class="btn btn-primary">
<span class="d-none d-sm-inline">Next</span>
<i class="bi bi-chevron-right ms-sm-1"></i>
</button>
</div>
</div>
<%= for day <- Enum.to_list(@date_range) do %>
<%= if Date.day_of_week(day, @current_user.week_start_at) == 1 do %>
<div class="border-top mt-4 mb-4"></div>
<% end %>
<h4>
<%= Calendar.strftime(day, "%A, %b %-d") %>
</h4>
<% day_shifts = Enum.filter(@shifts, fn s -> s.date == day end) %>
<%= if !Enum.empty?(day_shifts) do %>
<%= for shift <- day_shifts do %>
<div class="card mt-2 mb-4 col-12 ms-sm-3 ms-md-4 col-lg-10 ms-lg-5 col-xxl-8" id={"shift-#{shift.id}"}>
<div class="card-body">
<h5 class="card-title">
<i class="bi bi-tag text-muted me-1"></i>
<%= shift.subject %>
</h5>
<table class="table table-borderless table-nonfluid table-sm">
<tbody>
<tr>
<th scope="row" class="text-end">
<i class="bi bi-hourglass text-muted"></i>
<span class="visually-hidden">Hours:</span>
</th>
<td>
<%= format_shift_time(shift.time_start) %>
&mdash;
<%= format_shift_time(shift.time_end) %>
<span class="text-muted">
<span class="visually-hidden">Shift length:</span>
(<%= format_shift_length(shift) %>)
</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">
<i class="bi bi-geo text-muted"></i>
<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">
<i class="bi bi-justify-left text-muted"></i>
<span class="visually-hidden">Description:</span>
</th>
<td class="shift-description">
<%= if shift.description do %>
<%= text_to_html shift.description %>
<% else %>
<span class="text-muted fst-italic">none</span>
<% end %>
</td>
</tr>
</tbody>
</table>
<button class="btn btn-outline-danger btn-sm text-nowrap" phx-click="delete-modal" phx-value-id={shift.id}>
<i class="bi bi-trash me-1"></i> Delete
</button>
</div>
</div>
<% end %>
<% else %>
<p class="text-muted"><em>Nothing scheduled</em></p>
<% end %>
<% end %>
</div>
</div>
</div>
</div>