Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

6.0 KB
Raw Blame
<%# locals: (meeting:, token:, targets:, impact:, errors: []) %>
<%# The "move" dialog of a meeting (doc/meeting_verschieben_plan.md). Content of the
    frame #meeting-move-modal-<id> in the lane head; the trigger there loads
    meetings#move_preflight into it. The root carries the id of THIS opening (token):
    a refused move replaces exactly it with the message. Shape and lifecycle after
    README_MODAL_PATTERN.md.

    A meeting with linked tickets, or with a published analysis that draws on this
    project, cannot move: the dialog says why and offers no form.
    The form goes to _top, so a successful move is a visit to the meeting in its new
    place; a refusal answers with a stream into this opening. %>
<% mm = 'views.organisations.meetings.move' %>
<% modal_id = meeting_move_modal_id(meeting) %>
<% field_class = 'w-full rounded border border-cream-300 bg-surface-raised px-3 py-2 text-sm focus:border-ink focus:outline-none focus:ring-1 focus:ring-ink' %>
<% cancel_class = 'h-9 rounded border border-cream-300 bg-cream-100 px-4 text-sm font-medium text-cream-800 hover:bg-cream-200' %>
<% linked = impact[:ticket_links_count] %>
<% bound = impact[:bound_analyses_count] %>
<div id="<%= meeting_move_modal_instance_id(meeting, token) %>"
     data-controller="meeting-move-modal"
     data-meeting-move-modal-return-id-value="<%= meeting_move_trigger_id(meeting) %>"
     data-action="keydown@window->meeting-move-modal#closeOnEscape keydown@window->meeting-move-modal#trapFocus">
  <div class="fixed inset-0 z-50 overflow-y-auto"
       data-action="click->meeting-move-modal#closeOnBackdrop">
    <div class="fixed inset-0 bg-gray-500 bg-opacity-60 backdrop-blur-sm" aria-hidden="true"></div>
    <div class="relative flex min-h-screen items-center justify-center p-4"
         data-action="click->meeting-move-modal#closeOnBackdrop">
      <div class="relative w-full max-w-md rounded-lg border border-slate-200 bg-surface-raised shadow-xl"
           role="dialog" aria-modal="true" aria-labelledby="<%= modal_id %>-title"
           data-meeting-move-modal-target="card">
        <div class="flex items-center justify-between border-b border-slate-200 p-4">
          <h3 id="<%= modal_id %>-title" class="text-lg font-bold text-cream-900">
            <i class="bi bi-arrow-right-square mr-1" aria-hidden="true"></i>
            <%= t("#{mm}.title") %>
          </h3>
          <button type="button" class="text-gray-400 hover:text-gray-600"
                  title="<%= t("#{mm}.close") %>" aria-label="<%= t("#{mm}.close") %>"
                  data-action="click->meeting-move-modal#close">
            <i class="bi bi-x-lg" aria-hidden="true"></i>
          </button>
        </div>

        <div class="space-y-4 p-5">
          <% if errors.any? %>
            <div class="rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-800" role="alert">
              <% errors.each do |message| %>
                <p><%= message %></p>
              <% end %>
            </div>
          <% end %>

          <% if linked.positive? || bound.positive? %>
            <% if linked.positive? %>
              <p class="text-sm text-cream-800"><%= t("#{mm}.has_ticket_links", count: linked) %></p>
            <% end %>
            <% if bound.positive? %>
              <p class="text-sm text-cream-800"><%= t("#{mm}.published_analyses_bound", count: bound) %></p>
            <% end %>
            <div class="flex justify-end border-t border-cream-200 pt-3">
              <button type="button" class="<%= cancel_class %>" data-meeting-move-modal-target="first"
                      data-action="click->meeting-move-modal#close">
                <%= t("#{mm}.close") %>
              </button>
            </div>
          <% elsif targets.none? %>
            <p class="text-sm text-cream-800"><%= t("#{mm}.no_targets") %></p>
            <div class="flex justify-end border-t border-cream-200 pt-3">
              <button type="button" class="<%= cancel_class %>" data-meeting-move-modal-target="first"
                      data-action="click->meeting-move-modal#close">
                <%= t("#{mm}.close") %>
              </button>
            </div>
          <% else %>
            <%= form_with url: move_organisation_project_meeting_path(current_organisation, meeting.project, meeting),
                          method: :post, class: 'space-y-4', data: { turbo_frame: '_top' } do %>
              <%= hidden_field_tag :modal_token, token, id: nil %>
              <%= meeting_list_hidden_fields %>

              <div>
                <label for="<%= modal_id %>-target" class="mb-1 block text-sm font-medium text-cream-800"><%= t("#{mm}.target") %></label>
                <%= select_tag :target_project_id,
                               options_from_collection_for_select(targets, :id, :name),
                               id: "#{modal_id}-target", class: field_class,
                               data: { meeting_move_modal_target: 'first' } %>
              </div>

              <ul class="list-disc space-y-1 pl-5 text-sm text-cream-700">
                <li><%= t("#{mm}.time_sessions", count: impact[:time_sessions_count], billed: impact[:billed_time_sessions_count]) %></li>
                <% if impact[:open_suggestions_count].positive? %>
                  <li><%= t("#{mm}.open_suggestions", count: impact[:open_suggestions_count]) %></li>
                <% end %>
                <li><%= t("#{mm}.rights") %></li>
              </ul>

              <div class="flex justify-end gap-2 border-t border-cream-200 pt-3">
                <button type="button" class="<%= cancel_class %>" data-action="click->meeting-move-modal#close">
                  <%= t("#{mm}.cancel") %>
                </button>
                <button type="submit"
                        class="h-9 rounded border border-ink bg-lime-300 px-4 text-sm font-bold text-ink hover:bg-lime-400">
                  <%= t("#{mm}.submit") %>
                </button>
              </div>
            <% end %>
          <% end %>
        </div>
      </div>
    </div>
  </div>
</div>