From 1454041207c5bea850b80fd41f128bfbf79f8568 Mon Sep 17 00:00:00 2001 From: Emiel Date: Thu, 14 Nov 2024 13:40:00 +0100 Subject: [PATCH 1/2] #997 Add possibility to skip finished page --- core/systems/assignment/external_panel_controller.ex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/systems/assignment/external_panel_controller.ex b/core/systems/assignment/external_panel_controller.ex index 5ad747d63..f54580322 100644 --- a/core/systems/assignment/external_panel_controller.ex +++ b/core/systems/assignment/external_panel_controller.ex @@ -54,6 +54,9 @@ defmodule Systems.Assignment.ExternalPanelController do String.length(id) <= @id_max_lenght and Regex.match?(@id_valid_regex, id) end + # FIXME: This is a temporary solution to allow embeds to work + defp has_no_access?(_, %{"embed" => "true"}), do: false + defp has_no_access?(%{external_panel: external_panel}, params) do external_panel = Atom.to_string(external_panel) external_panel != get_panel(params) @@ -117,5 +120,6 @@ defmodule Systems.Assignment.ExternalPanelController do defp get_participant(_), do: nil defp embedded?(%{"entry" => "liss"}), do: true + defp embedded?(%{"embed" => "true"}), do: true defp embedded?(_), do: false end From 1ca5ff8222f90576d2316091abfb04a4fb6e91ec Mon Sep 17 00:00:00 2001 From: Emiel Date: Fri, 15 Nov 2024 11:00:27 +0100 Subject: [PATCH 2/2] #997 Fixed hiding tool-ref modal view --- core/systems/assignment/crew_work_view.ex | 29 ++++++++++++------- .../assignment/external_panel_controller.ex | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/core/systems/assignment/crew_work_view.ex b/core/systems/assignment/crew_work_view.ex index e13f3ff63..8d4abf77d 100644 --- a/core/systems/assignment/crew_work_view.ex +++ b/core/systems/assignment/crew_work_view.ex @@ -535,11 +535,17 @@ defmodule Systems.Assignment.CrewWorkView do defp handle_complete_task(%{assigns: %{selected_item: {_, task}}} = socket) do {:ok, %{crew_task: updated_task}} = Crew.Public.complete_task(task) - socket - |> hide_modal(:tool_ref_view) - |> update_task(updated_task) - |> handle_finished_state() - |> select_next_item() + if embedded?(socket) and singleton?(socket) do + # Keep tool_ref view open and prevent finished view from being shown + # FIXME: This is a temporary solution to allow embeds to work https://github.com/eyra/mono/issues/997 + socket + else + socket + |> update_task(updated_task) + |> hide_modal(:tool_ref_view) + |> handle_finished_state() + |> select_next_item() + end end defp update_task(%{assigns: %{work_items: work_items}} = socket, updated_task) do @@ -596,11 +602,6 @@ defmodule Systems.Assignment.CrewWorkView do socket |> assign(selected_item_id: selected_item_id) end - 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(%{assigns: %{retry?: true}} = socket), do: socket defp handle_finished_state(%{assigns: %{work_items: work_items}} = socket) do @@ -645,6 +646,14 @@ defmodule Systems.Assignment.CrewWorkView do |> Concept.ToolModel.launcher() end + defp embedded?(%{assigns: %{panel_info: %{embedded?: embedded?}}}) do + embedded? + end + + defp singleton?(%{assigns: %{work_items: work_items}}) do + length(work_items) == 1 + end + @impl true @spec render(any()) :: Phoenix.LiveView.Rendered.t() def render(assigns) do diff --git a/core/systems/assignment/external_panel_controller.ex b/core/systems/assignment/external_panel_controller.ex index f54580322..d3270aeef 100644 --- a/core/systems/assignment/external_panel_controller.ex +++ b/core/systems/assignment/external_panel_controller.ex @@ -54,7 +54,7 @@ defmodule Systems.Assignment.ExternalPanelController do String.length(id) <= @id_max_lenght and Regex.match?(@id_valid_regex, id) end - # FIXME: This is a temporary solution to allow embeds to work + # FIXME: This is a temporary solution to allow embeds to work https://github.com/eyra/mono/issues/997 defp has_no_access?(_, %{"embed" => "true"}), do: false defp has_no_access?(%{external_panel: external_panel}, params) do