<%= if @live_action in [:new, :edit, :clone] do %> <.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 ]} /> <% end %> <%= if @delete_shift_template do %> <.live_component module={Shift73kWeb.ModalComponent} id="modal" component={Shift73kWeb.ShiftTemplateLive.DeleteComponent} opts={[ id: @delete_shift_template.id, title: "Delete Shift Template", delete_shift_template: @delete_shift_template ]} /> <% end %>

My Shift Templates

<%= live_patch to: Routes.shift_template_index_path(@socket, :new), class: "btn btn-primary" do %> New Shift Template <% end %>
<%= for template <- @shift_templates do %>
Subject:
<%= template.subject %>
<% 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"} %>
Hours: <%= format_shift_time(template.time_start) %> — <%= format_shift_time(template.time_end) %> Shift length: (<%= format_shift_length(template) %>) TZ: <%= template.time_zone %>
Location: <%= if template.location do %> <%= template.location %> <% else %> none <% end %>
Description: <%= if template.description do %> <%= text_to_html template.description %> <% else %> none <% end %>
<%= 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 %> Edit <% 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 %> Clone <% end %> <% end %> <%= if Roles.can?(@current_user, template, :delete) do %> <% end %>
<% end %>