Skip to content

Commit

Permalink
#969 close Feldspar app and return to Tasklist - Part II
Browse files Browse the repository at this point in the history
  • Loading branch information
mellelieuwes committed Oct 3, 2024
1 parent 7d77692 commit 7cadfd5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion core/assets/js/pdf_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const pdfjs = require("../node_modules/pdfjs-dist");
const worker = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjsVersion}/pdf.worker.min.js`;

function renderPages(hook) {
hook.renderPagesIfNeeded();
hook.renderPages();
}

export const PDFViewer = {
Expand Down
18 changes: 14 additions & 4 deletions core/systems/assignment/crew_page.ex
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,13 @@ defmodule Systems.Assignment.CrewPage do
@impl true
def handle_event(
"prepare_modal",
%{live_component: %{id: modal_id}} = modal,
%{assigns: %{modal: %{id: current_modal_id}, modal_visible: modal_visible}} = socket
%{live_component: %{ref: %{id: modal_id}}} = modal,
%{
assigns: %{
modal: %{live_component: %{ref: %{id: current_modal_id}}},
modal_visible: modal_visible
}
} = socket
) do
if modal_id == current_modal_id do
{:noreply, socket |> assign(modal: modal)}
Expand All @@ -179,8 +184,13 @@ defmodule Systems.Assignment.CrewPage do
@impl true
def handle_event(
"show_modal",
%{live_component: %{id: modal_id}} = modal,
%{assigns: %{modal: %{id: current_modal_id}, modal_visible: modal_visible}} = socket
%{live_component: %{ref: %{id: modal_id}}} = modal,
%{
assigns: %{
modal: %{live_component: %{ref: %{id: current_modal_id}}},
modal_visible: modal_visible
}
} = socket
) do
if modal_id == current_modal_id do
{:noreply, socket |> assign(modal: modal, modal_visible: true)}
Expand Down
23 changes: 7 additions & 16 deletions core/systems/assignment/crew_work_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule Systems.Assignment.CrewWorkView do
) do
tool_started = Map.get(socket.assigns, :tool_started, false)
tool_initialized = Map.get(socket.assigns, :tool_initialized, false)
first_time? = not Map.has_key?(socket.assigns, :work_items)
tasks_finished? = Map.get(socket.assigns, :tasks_finished?, tasks_finished?(work_items))

{
:ok,
Expand All @@ -51,24 +51,19 @@ defmodule Systems.Assignment.CrewWorkView do
tester?: tester?,
panel_info: panel_info,
tool_started: tool_started,
tool_initialized: tool_initialized
tool_initialized: tool_initialized,
tasks_finished?: tasks_finished?
)
|> update_tasks_finished()
|> update_selected_item_id()
|> update_selected_item()
|> compose_child(:work_list_view)
|> compose_child(:start_view)
|> compose_child(:context_menu)
|> update_tool_ref_view()
|> update_child(:finished_view)
|> handle_finished_state(first_time?)
}
end

defp update_tasks_finished(%{assigns: %{work_items: work_items}} = socket) do
socket |> assign(tasks_finished: tasks_finished?(work_items))
end

defp tasks_finished?(work_items) do
task_ids = Enum.map(work_items, fn {_, task} -> task.id end)
Crew.Public.tasks_finished?(task_ids)
Expand Down Expand Up @@ -539,23 +534,19 @@ defmodule Systems.Assignment.CrewWorkView do
socket |> assign(selected_item_id: selected_item_id)
end

defp handle_finished_state(socket, false) do
# Dont show finished view after first load
defp handle_finished_state(%{assigns: %{panel_info: %{embedded?: true}}} = socket) do
# Dont show finished view when embedded in external panel UI
socket
end

defp handle_finished_state(socket, true) do
handle_finished_state(socket)
end

defp handle_finished_state(%{assigns: %{panel_info: %{embedded?: true}}} = socket) do
# Dont show finished view when embedded in external panel UI
defp handle_finished_state(%{assigns: %{tasks_finished?: true}} = socket) do
socket
end

defp handle_finished_state(%{assigns: %{work_items: work_items}} = socket) do
if tasks_finished?(work_items) do
socket
|> assign(tasks_finished?: true)
|> signal_tasks_finished()
|> compose_child(:finished_view)
|> show_modal(:finished_view, :sheet)
Expand Down
2 changes: 1 addition & 1 deletion core/systems/feldspar/app_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule Systems.Feldspar.AppView do
@impl true
def render(assigns) do
~H"""
<div class="p-4 lg:p-8">
<div class="px-4 pb-4 lg:px-8 lg:pb-8">
<%!-- Ensure that updates don't alter the hierarchy in front of the iframe.
Changing the preceding siblings of the iframe would result in a reload of the iframe
due to Morphdom (https://github.com/patrick-steele-idem/morphdom/issues/200).
Expand Down

0 comments on commit 7cadfd5

Please sign in to comment.