+ """
+ end
+end
diff --git a/core/systems/benchmark/_public.ex b/core/systems/benchmark/_public.ex
index 9db15c9a9..a5ed64563 100644
--- a/core/systems/benchmark/_public.ex
+++ b/core/systems/benchmark/_public.ex
@@ -49,7 +49,7 @@ defmodule Systems.Benchmark.Public do
|> set_tool_status(status)
end
- def prepare_tool(%{} = attrs, auth_node \\ Core.Authorization.make_node()) do
+ def prepare_tool(%{} = attrs, auth_node \\ Core.Authorization.prepare_node()) do
attrs = Map.put(attrs, :status, :concept)
%Benchmark.ToolModel{}
@@ -61,7 +61,7 @@ defmodule Systems.Benchmark.Public do
tool = Benchmark.Public.get_tool!(tool_id)
Multi.new()
- |> Multi.insert(:auth_node, Authorization.make_node())
+ |> Multi.insert(:auth_node, Authorization.prepare_node())
|> Multi.insert(:spot, fn %{auth_node: auth_node} ->
%Benchmark.SpotModel{}
|> Benchmark.SpotModel.changeset(%{name: displayname})
diff --git a/core/systems/benchmark/tool_model.ex b/core/systems/benchmark/tool_model.ex
index 6bf1e1173..ed65b60ee 100644
--- a/core/systems/benchmark/tool_model.ex
+++ b/core/systems/benchmark/tool_model.ex
@@ -78,6 +78,7 @@ defmodule Systems.Benchmark.ToolModel do
def open_label(_), do: dgettext("eyra-benchmark", "open.cta.title")
def ready?(tool), do: Benchmark.ToolModel.ready?(tool)
def form(_), do: Benchmark.Form
+ def launcher(_), do: %{function: fn _ -> nil end, props: %{}}
def task_labels(_) do
%{
diff --git a/core/systems/campaign/_switch.ex b/core/systems/campaign/_switch.ex
index 118a084d3..dd22f2ce4 100644
--- a/core/systems/campaign/_switch.ex
+++ b/core/systems/campaign/_switch.ex
@@ -9,10 +9,9 @@ defmodule Systems.Campaign.Switch do
@impl true
def intercept({:assignment, _} = signal, %{assignment: assignment} = message) do
- handle(signal, message)
-
if campaign =
Campaign.Public.get_by_promotable(assignment, Campaign.Model.preload_graph(:down)) do
+ handle(signal, message)
dispatch!({:campaign, signal}, Map.merge(message, %{campaign: campaign}))
end
end
@@ -64,9 +63,5 @@ defmodule Systems.Campaign.Switch do
end
end
- defp handle({:assignment, :accepted}, %{assignment: assignment, users: users}) do
- Enum.each(users, &Campaign.Public.payout_participant(assignment, &1))
- end
-
defp handle({_, _}, _), do: nil
end
diff --git a/core/systems/campaign/builders/promotion_landing_page.ex b/core/systems/campaign/builders/promotion_landing_page.ex
index a45899034..b191a0b6a 100644
--- a/core/systems/campaign/builders/promotion_landing_page.ex
+++ b/core/systems/campaign/builders/promotion_landing_page.ex
@@ -82,7 +82,7 @@ defmodule Systems.Campaign.Builders.PromotionLandingPage do
defp apply_call_to_action(%{workflow: workflow} = assignment, user) do
[tool | _] = Workflow.Model.flatten(workflow)
- task_identifier = Assignment.Public.task_identifier(tool, user)
+ task_identifier = Assignment.Private.task_identifier(tool, user)
%{
label: Frameworks.Concept.ToolModel.apply_label(tool),
diff --git a/core/systems/campaign/model.ex b/core/systems/campaign/model.ex
index df0ea6a74..d275931d2 100644
--- a/core/systems/campaign/model.ex
+++ b/core/systems/campaign/model.ex
@@ -307,7 +307,7 @@ defimpl Frameworks.Utility.ViewModelBuilder, for: Systems.Campaign.Model do
%{
id: id,
- path: ~p"/assignment/#{assignment.id}",
+ path: ~p"/assignment/#{assignment.id}/landing",
title: title,
subtitle: subtitle,
tag: tag,
@@ -408,7 +408,7 @@ defimpl Frameworks.Utility.ViewModelBuilder, for: Systems.Campaign.Model do
{Link.Console.Page, :contribution},
user
) do
- path = ~p"/assignment/#{assignment.id}"
+ path = ~p"/assignment/#{assignment.id}/landing"
vm(campaign, :contribution, user, path)
end
diff --git a/core/systems/crew/_public.ex b/core/systems/crew/_public.ex
index 418d03b6a..2d1266281 100644
--- a/core/systems/crew/_public.ex
+++ b/core/systems/crew/_public.ex
@@ -95,6 +95,13 @@ defmodule Systems.Crew.Public do
|> Repo.all()
end
+ def list_tasks_by_template(crew, task_template, order_by \\ {:desc, :id}) do
+ from(t in task_query_by_template(crew, task_template),
+ order_by: ^order_by
+ )
+ |> Repo.all()
+ end
+
def list_tasks_for_user(crew, user_ref, order_by \\ {:desc, :id}) do
from(t in task_query(crew, user_ref, false), order_by: ^order_by)
|> Repo.all()
@@ -132,6 +139,13 @@ defmodule Systems.Crew.Public do
)
end
+ def task_query_by_template(crew, task_template) when is_list(task_template) do
+ from(task in Crew.TaskModel,
+ where: task.crew_id == ^crew.id,
+ where: fragment("?::text[] @> ?", task.identifier, ^task_template)
+ )
+ end
+
def count_tasks(crew, status_list) do
from(t in task_query(crew, status_list, false),
select: count(t.id)
@@ -184,11 +198,11 @@ defmodule Systems.Crew.Public do
end
def cancel_task(%Crew.TaskModel{} = task) do
- update_task(task, %{started_at: nil})
+ update_task(task, %{started_at: nil}, :canceled)
end
def lock_task(%Crew.TaskModel{} = task) do
- update_task(task, %{started_at: Timestamp.naive_now()})
+ update_task(task, %{started_at: Timestamp.naive_now()}, :locked)
end
def activate_task(%Crew.TaskModel{status: status, started_at: started_at} = task) do
@@ -198,35 +212,45 @@ defmodule Systems.Crew.Public do
:pending ->
case started_at do
nil ->
- update_task(task, %{
- status: :completed,
- started_at: timestamp,
- completed_at: timestamp
- })
+ update_task(
+ task,
+ %{
+ status: :completed,
+ started_at: timestamp,
+ completed_at: timestamp
+ },
+ :completed
+ )
_ ->
- update_task(task, %{status: :completed, completed_at: timestamp})
+ update_task(task, %{status: :completed, completed_at: timestamp}, :completed)
end
_ ->
- {:ok, %{task: task}}
+ {:ok, %{crew_task: task}}
end
end
def activate_task!(%Crew.TaskModel{} = task) do
case Crew.Public.activate_task(task) do
- {:ok, %{task: task}} -> task
+ {:ok, %{crew_task: task}} -> task
_ -> nil
end
end
def reject_task(multi, %Crew.TaskModel{} = task, %{category: category, message: message}) do
- multi_update(multi, :task, task, %{
- status: :rejected,
- rejected_at: Timestamp.naive_now(),
- rejected_category: category,
- rejected_message: message
- })
+ multi_update(
+ multi,
+ :task,
+ task,
+ %{
+ status: :rejected,
+ rejected_at: Timestamp.naive_now(),
+ rejected_category: category,
+ rejected_message: message
+ },
+ :rejected
+ )
end
def reject_task(multi, id, rejection) do
@@ -247,10 +271,14 @@ defmodule Systems.Crew.Public do
end
def accept_task(%Crew.TaskModel{} = task) do
- update_task(task, %{
- status: :accepted,
- accepted_at: Timestamp.naive_now()
- })
+ update_task(
+ task,
+ %{
+ status: :accepted,
+ accepted_at: Timestamp.naive_now()
+ },
+ :accepted
+ )
end
def accept_task(id) do
@@ -258,25 +286,25 @@ defmodule Systems.Crew.Public do
|> accept_task()
end
- def update_task(%Crew.TaskModel{} = task, attrs) do
+ def update_task(%Crew.TaskModel{} = task, attrs, event) do
Multi.new()
- |> multi_update(:task, task, attrs)
+ |> multi_update(:task, task, attrs, event)
|> Repo.transaction()
end
- def multi_update(multi, :task, task, attrs) do
+ def multi_update(multi, :task, task, attrs, event) do
changeset = Crew.TaskModel.changeset(task, attrs)
- multi_update(multi, :task, changeset)
+ multi_update(multi, :task, changeset, event)
end
- def multi_update(multi, :task, changeset) do
+ def multi_update(multi, :task, changeset, event \\ :updated) do
multi
- |> Multi.update(:task, changeset)
- |> Signal.Public.multi_dispatch({:crew_task, :updated}, changeset)
+ |> Multi.update(:crew_task, changeset)
+ |> Signal.Public.multi_dispatch({:crew_task, event}, %{changeset: changeset})
end
def delete_task(%Crew.TaskModel{} = task) do
- update_task(task, %{expired: true})
+ update_task(task, %{expired: true}, :deleted)
end
def delete_task(_), do: nil
@@ -332,7 +360,7 @@ defmodule Systems.Crew.Public do
else
Multi.new()
|> insert(:member, crew, user, %{expire_at: expire_at})
- |> insert(:task, crew, user, %{
+ |> insert(:crew_task, crew, user, %{
identifier: identifier,
status: :pending,
expire_at: expire_at
@@ -342,6 +370,23 @@ defmodule Systems.Crew.Public do
end
end
+ def apply_member_with_role(
+ %Crew.Model{} = crew,
+ %User{} = user,
+ role \\ :participant,
+ expire_at \\ nil
+ ) do
+ if member = get_expired_member(crew, user, [:crew]) do
+ member = reset_member(member, expire_at)
+ {:ok, %{member: member}}
+ else
+ Multi.new()
+ |> insert(:member, crew, user, %{expire_at: expire_at})
+ |> insert(:role_assignment, crew, user, role)
+ |> Repo.transaction()
+ end
+ end
+
defp insert(multi, :member = name, crew, %User{} = user, attrs) do
Multi.insert(
multi,
@@ -357,7 +402,7 @@ defmodule Systems.Crew.Public do
Multi.insert(multi, name, Authorization.build_role_assignment(user, crew, role))
end
- defp insert(multi, :task = name, crew, %User{} = user, attrs) do
+ defp insert(multi, :crew_task = name, crew, %User{} = user, attrs) do
Multi.insert(
multi,
name,
diff --git a/core/systems/document/_public.ex b/core/systems/document/_public.ex
index e186a2b1e..636bed344 100644
--- a/core/systems/document/_public.ex
+++ b/core/systems/document/_public.ex
@@ -11,7 +11,7 @@ defmodule Systems.Document.Public do
|> Repo.get!(id)
end
- def prepare_tool(attrs, auth_node \\ Core.Authorization.make_node()) do
+ def prepare_tool(attrs, auth_node \\ Core.Authorization.prepare_node()) do
%Document.ToolModel{}
|> Document.ToolModel.changeset(attrs)
|> Ecto.Changeset.put_assoc(:auth_node, auth_node)
diff --git a/core/systems/document/pdf_view.ex b/core/systems/document/pdf_view.ex
new file mode 100644
index 000000000..3371aa514
--- /dev/null
+++ b/core/systems/document/pdf_view.ex
@@ -0,0 +1,22 @@
+defmodule Systems.Document.PDFView do
+ use CoreWeb, :html
+
+ import Frameworks.Pixel.Line
+
+ attr(:title, :string, required: true)
+ attr(:url, :string, required: true)
+
+ def pdf_view(assigns) do
+ send(self(), {:complete_task, %{}})
+
+ ~H"""
+
+ <%= @title %>
+ <.line />
+
+
+
+
+ """
+ end
+end
diff --git a/core/systems/document/tool_form.ex b/core/systems/document/tool_form.ex
index 14af0b290..2c5546ac3 100644
--- a/core/systems/document/tool_form.ex
+++ b/core/systems/document/tool_form.ex
@@ -2,6 +2,8 @@ defmodule Systems.Document.ToolForm do
use CoreWeb.LiveForm
use CoreWeb.FileUploader, ~w(.pdf)
+ alias CoreWeb.Endpoint
+
alias Systems.{
Document
}
@@ -9,10 +11,12 @@ defmodule Systems.Document.ToolForm do
@impl true
def process_file(
%{assigns: %{entity: entity}} = socket,
- {_local_relative_path, local_full_path, remote_file}
+ {local_relative_path, _local_full_path, remote_file}
) do
+ ref = "#{Endpoint.url()}#{local_relative_path}"
+
socket
- |> save(entity, %{ref: local_full_path, name: remote_file})
+ |> save(entity, %{ref: ref, name: remote_file})
end
@impl true
diff --git a/core/systems/document/tool_model.ex b/core/systems/document/tool_model.ex
index c6045f9fb..27f411107 100644
--- a/core/systems/document/tool_model.ex
+++ b/core/systems/document/tool_model.ex
@@ -46,6 +46,12 @@ defmodule Systems.Document.ToolModel do
def ready?(tool), do: Document.ToolModel.ready?(tool)
def form(_), do: Document.ToolForm
+ def launcher(%{ref: ref}),
+ do: %{
+ function: &Document.PDFView.pdf_view/1,
+ props: %{url: ref, title: dgettext("eyra-document", "component.title")}
+ }
+
def task_labels(_) do
%{
pending: dgettext("eyra-document", "pending.label"),
diff --git a/core/systems/feldspar/internal.ex b/core/systems/feldspar/_private.ex
similarity index 74%
rename from core/systems/feldspar/internal.ex
rename to core/systems/feldspar/_private.ex
index edaf4f6a3..105ec0036 100644
--- a/core/systems/feldspar/internal.ex
+++ b/core/systems/feldspar/_private.ex
@@ -1,4 +1,4 @@
-defmodule Systems.Feldspar.Internal do
+defmodule Systems.Feldspar.Private do
def get_backend do
:core
|> Application.fetch_env!(:feldspar)
diff --git a/core/systems/feldspar/_public.ex b/core/systems/feldspar/_public.ex
index 053e0edb7..a2b305430 100644
--- a/core/systems/feldspar/_public.ex
+++ b/core/systems/feldspar/_public.ex
@@ -6,14 +6,14 @@ defmodule Systems.Feldspar.Public do
Feldspar
}
- import Feldspar.Internal, only: [get_backend: 0]
+ import Feldspar.Private, only: [get_backend: 0]
def get_tool!(id, preload \\ []) do
from(tool in Feldspar.ToolModel, preload: ^preload)
|> Repo.get!(id)
end
- def prepare_tool(attrs, auth_node \\ Core.Authorization.make_node()) do
+ def prepare_tool(attrs, auth_node \\ Core.Authorization.prepare_node()) do
%Feldspar.ToolModel{}
|> Feldspar.ToolModel.changeset(attrs)
|> Ecto.Changeset.put_assoc(:auth_node, auth_node)
diff --git a/core/systems/feldspar/_routes.ex b/core/systems/feldspar/_routes.ex
index e2136d1d1..883880a55 100644
--- a/core/systems/feldspar/_routes.ex
+++ b/core/systems/feldspar/_routes.ex
@@ -1,9 +1,9 @@
defmodule Systems.Feldspar.Routes do
defmacro routes() do
quote do
- scope "/apps", Systems.Feldspar do
+ scope "/feldspar", Systems.Feldspar do
pipe_through([:browser])
- live("/:id", AppPage)
+ live("/apps/:id", AppPage)
end
end
end
diff --git a/core/systems/feldspar/app_page.ex b/core/systems/feldspar/app_page.ex
index 6f2eae6cf..6106aeab8 100644
--- a/core/systems/feldspar/app_page.ex
+++ b/core/systems/feldspar/app_page.ex
@@ -1,37 +1,52 @@
defmodule Systems.Feldspar.AppPage do
alias Systems.Feldspar
use CoreWeb, :live_view
+ use CoreWeb.Layouts.Stripped.Component, :projects
+
+ import Feldspar.AppView
@impl true
def mount(%{"id" => app_id}, _session, socket) do
app_url = Feldspar.Public.get_public_url(app_id) <> "/index.html"
- {:ok, assign(socket, app_url: app_url, error: nil)}
+ {
+ :ok,
+ socket
+ |> update_menus()
+ |> assign(app_url: app_url, error: nil)
+ }
end
- @impl true
- def handle_uri(socket), do: socket
-
@impl true
def render(assigns) do
~H"""
-
- <%!-- 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).
- --%>
-
-
<%= @error %>
-
-
-
-
-
+ <.stripped menus={@menus} footer?={false}>
+ <.app_view url={@app_url} />
+
"""
end
@impl true
- def handle_event("app_event", params, socket) do
- {:noreply, assign(socket, :error, "Unsupported message: #{inspect(params)}")}
+ def handle_event("app_event", %{"__type__" => type, "json_string" => event}, socket) do
+ {
+ :noreply,
+ socket |> handle(type, event)
+ }
+ end
+
+ @impl true
+ def handle_event("app_event", event, socket) do
+ {
+ :noreply,
+ socket |> handle(nil, inspect(event))
+ }
+ end
+
+ defp handle(socket, "CommandSystemDonate", event) do
+ Frameworks.Pixel.Flash.put_error(socket, "Unsupported donation " <> event)
+ end
+
+ defp handle(socket, _, event) do
+ Frameworks.Pixel.Flash.put_error(socket, "Unsupported " <> event)
end
end
diff --git a/core/systems/feldspar/app_view.ex b/core/systems/feldspar/app_view.ex
new file mode 100644
index 000000000..4ec810bab
--- /dev/null
+++ b/core/systems/feldspar/app_view.ex
@@ -0,0 +1,19 @@
+defmodule Systems.Feldspar.AppView do
+ use CoreWeb, :html
+
+ attr(:url, :string, required: true)
+
+ def app_view(assigns) do
+ ~H"""
+
+ <%!-- 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).
+ --%>
+
+
+
+
+ """
+ end
+end
diff --git a/core/systems/feldspar/local_fs.ex b/core/systems/feldspar/local_fs.ex
index 114360def..96c168601 100644
--- a/core/systems/feldspar/local_fs.ex
+++ b/core/systems/feldspar/local_fs.ex
@@ -14,7 +14,7 @@ defmodule Systems.Feldspar.LocalFS do
end
def get_public_url(id) do
- "#{Endpoint.url()}/#{static_path()}/#{id}"
+ "#{Endpoint.url()}/#{public_path()}/#{id}"
end
def remove(id) do
@@ -33,5 +33,5 @@ defmodule Systems.Feldspar.LocalFS do
|> Access.fetch!(:local_fs_root_path)
end
- def static_path, do: "/feldspar_apps"
+ def public_path, do: "/feldspar/apps"
end
diff --git a/core/systems/feldspar/plugs.ex b/core/systems/feldspar/plug.ex
similarity index 80%
rename from core/systems/feldspar/plugs.ex
rename to core/systems/feldspar/plug.ex
index 3fa8a29e0..8fd01567d 100644
--- a/core/systems/feldspar/plugs.ex
+++ b/core/systems/feldspar/plug.ex
@@ -3,7 +3,7 @@ defmodule Systems.Feldspar.Plug do
defmacro setup() do
quote do
- plug(Systems.Feldspar.Plug, at: Systems.Feldspar.LocalFS.static_path())
+ plug(Systems.Feldspar.Plug, at: Systems.Feldspar.LocalFS.public_path())
end
end
@@ -20,7 +20,7 @@ defmodule Systems.Feldspar.Plug do
conn,
options
) do
- call(Systems.Feldspar.Internal.get_backend(), conn, options)
+ call(Systems.Feldspar.Private.get_backend(), conn, options)
end
def call(Systems.Feldspar.LocalFS, conn, options) do
diff --git a/core/systems/feldspar/tool_form.ex b/core/systems/feldspar/tool_form.ex
index e53ab1213..5342aba47 100644
--- a/core/systems/feldspar/tool_form.ex
+++ b/core/systems/feldspar/tool_form.ex
@@ -11,8 +11,12 @@ defmodule Systems.Feldspar.ToolForm do
%{assigns: %{entity: entity}} = socket,
{_local_relative_path, local_full_path, remote_file}
) do
+ archive_ref =
+ Feldspar.Public.store(local_full_path)
+ |> Feldspar.Public.get_public_url()
+
socket
- |> save(entity, %{archive_ref: local_full_path, archive_name: remote_file})
+ |> save(entity, %{archive_ref: archive_ref, archive_name: remote_file})
end
@impl true
diff --git a/core/systems/feldspar/tool_model.ex b/core/systems/feldspar/tool_model.ex
index 05de500b5..b9d68fd46 100644
--- a/core/systems/feldspar/tool_model.ex
+++ b/core/systems/feldspar/tool_model.ex
@@ -47,6 +47,15 @@ defmodule Systems.Feldspar.ToolModel do
def ready?(tool), do: Feldspar.ToolModel.ready?(tool)
def form(_), do: Feldspar.ToolForm
+ def launcher(%{archive_ref: archive_ref}) when is_binary(archive_ref) do
+ %{
+ function: &Feldspar.AppView.app_view/1,
+ props: %{url: archive_ref <> "/index.html"}
+ }
+ end
+
+ def launcher(_), do: nil
+
def task_labels(_) do
%{
pending: dgettext("eyra-feldspar", "pending.label"),
diff --git a/core/systems/lab/_public.ex b/core/systems/lab/_public.ex
index 45c8eeba0..c27277079 100644
--- a/core/systems/lab/_public.ex
+++ b/core/systems/lab/_public.ex
@@ -23,7 +23,7 @@ defmodule Systems.Lab.Public do
|> filter_double_time_slots()
end
- def prepare_tool(attrs, auth_node \\ Core.Authorization.make_node()) do
+ def prepare_tool(attrs, auth_node \\ Core.Authorization.prepare_node()) do
%Lab.ToolModel{}
|> Lab.ToolModel.changeset(:mount, attrs)
|> Ecto.Changeset.put_assoc(:auth_node, auth_node)
diff --git a/core/systems/lab/tool_model.ex b/core/systems/lab/tool_model.ex
index cb61dd806..c7be6c7d0 100644
--- a/core/systems/lab/tool_model.ex
+++ b/core/systems/lab/tool_model.ex
@@ -83,6 +83,7 @@ defmodule Systems.Lab.ToolModel do
def open_label(_), do: dgettext("link-lab", "open.cta.title")
def ready?(tool), do: Lab.ToolModel.ready?(tool)
def form(_), do: Lab.Form
+ def launcher(_), do: %{function: fn _ -> nil end, props: %{}}
def task_labels(_) do
%{
diff --git a/core/systems/next_action/_public.ex b/core/systems/next_action/_public.ex
index 132d40dd5..cf2611bac 100644
--- a/core/systems/next_action/_public.ex
+++ b/core/systems/next_action/_public.ex
@@ -71,7 +71,7 @@ defmodule Systems.NextAction.Public do
conflict_target: {:unsafe_fragment, conflict_target_fragment}
)
|> tap(
- &Signal.Public.dispatch!(:next_action_created, %{
+ &Signal.Public.dispatch!({:next_action, :created}, %{
action_type: action,
user: user,
action: &1,
@@ -94,7 +94,11 @@ defmodule Systems.NextAction.Public do
|> where_key_is(key)
|> Repo.delete_all()
|> tap(fn _ ->
- Signal.Public.dispatch!(:next_action_cleared, %{user: user, action_type: action, key: key})
+ Signal.Public.dispatch!({:next_action, :cleared}, %{
+ user: user,
+ action_type: action,
+ key: key
+ })
end)
end
diff --git a/core/systems/next_action/_switch.ex b/core/systems/next_action/_switch.ex
index 2eb1b9fe9..9aa82a4ab 100644
--- a/core/systems/next_action/_switch.ex
+++ b/core/systems/next_action/_switch.ex
@@ -5,11 +5,11 @@ defmodule Systems.NextAction.Switch do
NextAction
}
- def intercept(:next_action_created, %{user: user, action: _action}) do
+ def intercept({:next_action, :created}, %{user: user, action: _action}) do
NextAction.Presenter.update(user, user, NextAction.OverviewPage)
end
- def intercept(:next_action_cleared, %{user: user, action_type: _action_type}) do
+ def intercept({:next_action, :cleared}, %{user: user, action_type: _action_type}) do
NextAction.Presenter.update(user, user, NextAction.OverviewPage)
end
end
diff --git a/core/systems/notification/_public.ex b/core/systems/notification/_public.ex
index a7831508a..fc45e8437 100644
--- a/core/systems/notification/_public.ex
+++ b/core/systems/notification/_public.ex
@@ -102,7 +102,7 @@ defmodule Systems.Notification.Public do
{:ok, box} =
%Box{}
|> Box.changeset(%{})
- |> Ecto.Changeset.put_assoc(:auth_node, Authorization.make_node())
+ |> Ecto.Changeset.put_assoc(:auth_node, Authorization.prepare_node())
|> Repo.insert()
|> Authorization.assign_role(user, :owner)
diff --git a/core/systems/project/_assembly.ex b/core/systems/project/_assembly.ex
index 90f6e64b9..1979da06f 100644
--- a/core/systems/project/_assembly.ex
+++ b/core/systems/project/_assembly.ex
@@ -13,7 +13,7 @@ defmodule Systems.Project.Assembly do
}
def delete(%Project.Model{auth_node: %{id: node_id}}) do
- from(ra in Core.Authorization.RoleAssignment,
+ from(ra in Authorization.RoleAssignment,
where: ra.node_id == ^node_id
)
|> Repo.delete_all()
@@ -27,25 +27,21 @@ defmodule Systems.Project.Assembly do
end
def create(name, user, :empty) do
- project = prepare_project(name, [])
+ project = prepare_project(name, [], user)
Multi.new()
- |> Multi.put(:user, user)
|> Multi.insert(:project, project)
- |> EctoHelper.run(:assign_role, &assign_role/1)
|> Repo.transaction()
end
def create(name, user, template) do
items = prepare_items(template)
- project = prepare_project(name, items)
+ project = prepare_project(name, items, user)
Multi.new()
- |> Multi.put(:user, user)
|> Multi.insert(:project, project)
|> EctoHelper.run(:auth, &update_auth/2)
|> EctoHelper.run(:path, &update_path/2)
- |> EctoHelper.run(:assign_role, &assign_role/1)
|> Repo.transaction()
end
@@ -71,8 +67,8 @@ defmodule Systems.Project.Assembly do
# PREPARE
- defp prepare_project(name, items) when is_list(items) do
- Project.Public.prepare(%{name: name}, items)
+ defp prepare_project(name, items, user) when is_list(items) do
+ Project.Public.prepare(%{name: name}, items, user)
end
defp prepare_items(:data_donation) do
@@ -167,26 +163,22 @@ defmodule Systems.Project.Assembly do
# AUTHORIZATION
- def assign_role(%{user: user, project: project}) do
- {:ok, Authorization.assign_role(user, project, :owner)}
- end
-
def update_auth(multi, %{project: project}), do: update_auth(multi, project)
def update_auth(multi, %{node: node}), do: update_auth(multi, node)
def update_auth(multi, %{item: item}), do: update_auth(multi, item)
def update_auth(multi, %Project.Model{} = project) do
auth_tree = Project.Model.auth_tree(project)
- Core.Authorization.link(multi, auth_tree)
+ Authorization.link(multi, auth_tree)
end
def update_auth(multi, %Project.NodeModel{} = project) do
auth_tree = Project.NodeModel.auth_tree(project)
- Core.Authorization.link(multi, auth_tree)
+ Authorization.link(multi, auth_tree)
end
def update_auth(multi, %Project.ItemModel{} = project) do
auth_tree = Project.ItemModel.auth_tree(project)
- Core.Authorization.link(multi, auth_tree)
+ Authorization.link(multi, auth_tree)
end
end
diff --git a/core/systems/project/_public.ex b/core/systems/project/_public.ex
index e9e28f982..420e87ca4 100644
--- a/core/systems/project/_public.ex
+++ b/core/systems/project/_public.ex
@@ -62,11 +62,11 @@ defmodule Systems.Project.Public do
|> Repo.one()
end
- def get_tool_refs_by_tool(%{id: id} = tool, preload \\ []) do
+ def get_tool_ref_by_tool(%{id: id} = tool, preload \\ []) do
field = Project.ToolRefModel.tool_id_field(tool)
query_tool_refs_by_tool(id, field, preload)
- |> Repo.all()
+ |> Repo.one()
end
def query_tool_refs_by_tool(tool_id, field, preload \\ [])
@@ -109,20 +109,21 @@ defmodule Systems.Project.Public do
def prepare(
%{name: _name} = attrs,
- items
+ items,
+ user
)
when is_list(items) do
{:ok, root} =
prepare_node(%{name: "Project", project_path: []}, items)
|> Ecto.Changeset.apply_action(:prepare)
- prepare(attrs, root)
+ prepare(attrs, root, Authorization.prepare_node(user, :owner))
end
def prepare(
%{name: _name} = attrs,
%Project.NodeModel{} = root,
- %Authorization.Node{} = auth_node \\ Authorization.make_node()
+ %Authorization.Node{} = auth_node
) do
%Project.Model{}
|> Project.Model.changeset(attrs)
@@ -133,7 +134,7 @@ defmodule Systems.Project.Public do
def prepare_node(
%{name: _, project_path: _} = attrs,
items,
- auth_node \\ Authorization.make_node()
+ auth_node \\ Authorization.prepare_node()
)
when is_list(items) do
%Project.NodeModel{}
diff --git a/core/systems/project/_switch.ex b/core/systems/project/_switch.ex
index b9aad0836..a5a5fc15a 100644
--- a/core/systems/project/_switch.ex
+++ b/core/systems/project/_switch.ex
@@ -43,8 +43,8 @@ defmodule Systems.Project.Switch do
end
defp handle({:tool, signal}, %{tool: tool} = message) do
- Project.Public.get_tool_refs_by_tool(tool)
- |> Enum.each(&dispatch!({:tool_ref, signal}, Map.merge(message, %{tool_ref: &1})))
+ Project.Public.get_tool_ref_by_tool(tool)
+ |> then(&dispatch!({:tool_ref, signal}, Map.merge(message, %{tool_ref: &1})))
end
defp update_pages(%Project.ItemModel{} = item) do
diff --git a/core/systems/project/overview_page.ex b/core/systems/project/overview_page.ex
index 99b483671..47aa9ef44 100644
--- a/core/systems/project/overview_page.ex
+++ b/core/systems/project/overview_page.ex
@@ -152,6 +152,14 @@ defmodule Systems.Project.OverviewPage do
}
end
+ @impl true
+ def handle_info(%{auto_save: _status}, socket) do
+ {
+ :noreply,
+ socket
+ }
+ end
+
@impl true
def handle_info({:handle_auto_save_done, :project_overview_popup}, socket) do
{
diff --git a/core/systems/project/tool_ref_view.ex b/core/systems/project/tool_ref_view.ex
new file mode 100644
index 000000000..724461531
--- /dev/null
+++ b/core/systems/project/tool_ref_view.ex
@@ -0,0 +1,29 @@
+defmodule Systems.Project.ToolRefView do
+ use CoreWeb, :html
+
+ alias Frameworks.Concept
+
+ alias Systems.{
+ Project
+ }
+
+ defp get_tool(tool_ref), do: Project.ToolRefModel.tool(tool_ref)
+ defp get_work(tool), do: Concept.ToolModel.launcher(tool)
+
+ attr(:tool_ref, :map, required: true)
+ attr(:task, :map, required: true)
+
+ def tool_ref_view(%{tool_ref: tool_ref} = assigns) do
+ assigns =
+ tool_ref
+ |> get_tool()
+ |> get_work()
+ |> then(&assign(assigns, :work, &1))
+
+ ~H"""
+
+ Advertenties worden op de marktplaats gezet om deelnemers te werven. Bekijk de voorbeeld pagina om te zien hoe deelnemers jouw advertentie pagina zien als ze op jouw marktplaats tegel klikken.
+
+ Opdracht
+
+ Opdracht
+
+ Criteria
+
+
+ Op basis van de geselecteerde criteria, kunnen 0 van de 0 mensen in de pool meedoen aan jouw studie.
+
+
+ Inclusie
+
+ Selecteer hieronder de inclusiecriteria voor je studie. Geen selectie betekend dat iedereen in de pool mee mag doen.
+
+ Geslacht
+
+ M
+
+ V
+
+ X
+
+ Exclusie
+
+ Wil je deelnemers die je in voorgaande campagnes geworven hebt excluderen? Selecteer dan één of meerdere campagnes hieronder.
+