<%= dgettext("eyra-project", "overview.header.title") %>
- <%= Enum.count(@cards) %>
+ <%= Enum.count(@vm.cards) %>
@@ -266,7 +267,7 @@ defmodule Systems.Project.OverviewPage do
- <%= for card <- @cards do %>
+ <%= for card <- @vm.cards do %>
<% end %>
@@ -276,11 +277,10 @@ defmodule Systems.Project.OverviewPage do
title={dgettext("eyra-project", "overview.empty.title")}
body={dgettext("eyra-project", "overview.empty.description")}
illustration="cards"
- />
- <.spacing value="L" />
-
<% end %>
diff --git a/core/systems/project/overview_page_builder.ex b/core/systems/project/overview_page_builder.ex
new file mode 100644
index 000000000..f53370685
--- /dev/null
+++ b/core/systems/project/overview_page_builder.ex
@@ -0,0 +1,32 @@
+defmodule Systems.Project.OverviewPageBuilder do
+ alias Frameworks.Utility.ViewModelBuilder
+
+ alias Systems.{
+ Project
+ }
+
+ def view_model(
+ user,
+ assigns
+ ) do
+ projects = projects(user)
+ cards = cards(projects, assigns)
+
+ %{
+ projects: projects,
+ cards: cards
+ }
+ end
+
+ defp projects(user) do
+ preload = Project.Model.preload_graph(:down)
+ Project.Public.list_owned_projects(user, preload: preload)
+ end
+
+ defp cards(projects, assigns) do
+ Enum.map(
+ projects,
+ &ViewModelBuilder.view_model(&1, {Systems.Project.OverviewPage, :card}, assigns)
+ )
+ end
+end
diff --git a/core/systems/project/tool_ref_model.ex b/core/systems/project/tool_ref_model.ex
index bf87337cf..1934d4539 100644
--- a/core/systems/project/tool_ref_model.ex
+++ b/core/systems/project/tool_ref_model.ex
@@ -3,6 +3,7 @@ defmodule Systems.Project.ToolRefModel do
use Frameworks.Utility.Schema
import Ecto.Changeset
+ import CoreWeb.Gettext
alias Frameworks.Concept
@@ -83,4 +84,14 @@ defmodule Systems.Project.ToolRefModel do
def tool(%{document_tool: %{id: _id} = tool}), do: tool
def tool(%{lab_tool: %{id: _id} = tool}), do: tool
def tool(%{benchmark_tool: %{id: _id} = tool}), do: tool
+
+ def tag(%Project.ToolRefModel{special: :questionnaire}),
+ do: dgettext("eyra-project", "tool_ref.tag.questionnaire")
+
+ def tag(%Project.ToolRefModel{special: :benchmark}),
+ do: dgettext("eyra-project", "tool_ref.tag.benchmark")
+
+ def tag(%Project.ToolRefModel{special: _special}) do
+ dgettext("eyra-project", "tool_ref.tag.default")
+ end
end
diff --git a/core/systems/promotion/_presenter.ex b/core/systems/promotion/_presenter.ex
index cef338448..ca2920d5c 100644
--- a/core/systems/promotion/_presenter.ex
+++ b/core/systems/promotion/_presenter.ex
@@ -4,7 +4,8 @@ defmodule Systems.Promotion.Presenter do
alias Systems.Promotion
@impl true
- def view_model(%Promotion.Model{director: director} = promotion, page, assigns) do
- Frameworks.Concept.System.presenter(director).view_model(promotion, page, assigns)
+ def view_model(page, %Promotion.Model{director: director} = promotion, assigns) do
+ presenter = Frameworks.Concept.System.presenter(director)
+ apply(presenter, :view_model, [page, promotion, assigns])
end
end
diff --git a/core/systems/promotion/landing_page.ex b/core/systems/promotion/landing_page.ex
index 4405ea6f1..e9390aa29 100644
--- a/core/systems/promotion/landing_page.ex
+++ b/core/systems/promotion/landing_page.ex
@@ -77,8 +77,6 @@ defmodule Systems.Promotion.LandingPage do
|> assign(image_info: image_info)
end
- defoverridable handle_view_model_updated: 1
-
def handle_view_model_updated(socket) do
socket
|> update_image_info()
@@ -133,11 +131,6 @@ defmodule Systems.Promotion.LandingPage do
defp grid_cols(2), do: "grid-cols-1 sm:grid-cols-2"
defp grid_cols(_), do: "grid-cols-1 sm:grid-cols-3"
- # data(preview, :boolean)
- # data(model, :map)
- # data(image_info, :map)
- # data(back_path, :any)
-
@impl true
def render(assigns) do
~H"""
diff --git a/core/systems/student/_presenter.ex b/core/systems/student/_presenter.ex
index 95681c1be..fbd212689 100644
--- a/core/systems/student/_presenter.ex
+++ b/core/systems/student/_presenter.ex
@@ -7,12 +7,12 @@ defmodule Systems.Student.Presenter do
}
@impl true
- def view_model(%Pool.SubmissionModel{} = submission, Pool.SubmissionPage, assigns) do
+ def view_model(Pool.SubmissionPage, %Pool.SubmissionModel{} = submission, assigns) do
Student.Pool.SubmissionPageBuilder.view_model(submission, assigns)
end
@impl true
- def view_model(%Pool.Model{} = pool, Pool.DetailPage, assigns) do
+ def view_model(Pool.DetailPage, %Pool.Model{} = pool, assigns) do
Student.Pool.DetailPageBuilder.view_model(pool, assigns)
end
end
diff --git a/core/systems/test/_presenter.ex b/core/systems/test/_presenter.ex
index 06503ed16..1ab3cd2bf 100644
--- a/core/systems/test/_presenter.ex
+++ b/core/systems/test/_presenter.ex
@@ -4,14 +4,12 @@ defmodule Systems.Test.Presenter do
alias Systems.Observatory
@impl true
- def view_model(%Systems.Test.Model{} = model, page, assigns) do
- model
- |> Builder.view_model(page, assigns)
+ def view_model(page, %Systems.Test.Model{} = model, assigns) do
+ Builder.view_model(model, page, assigns)
end
- def view_model(id, page, assigns) when is_binary(id) do
- Systems.Test.Public.get(id)
- |> Builder.view_model(page, assigns)
+ def view_model(page, id, assigns) when is_binary(id) do
+ Builder.view_model(Systems.Test.Public.get(id), page, assigns)
end
def update(Systems.Test.Page = page, model) do
diff --git a/core/systems/test/page.ex b/core/systems/test/page.ex
index 5cfd3d3a9..c41c14c9e 100644
--- a/core/systems/test/page.ex
+++ b/core/systems/test/page.ex
@@ -20,7 +20,6 @@ defmodule Systems.Test.Page do
}
end
- defoverridable handle_view_model_updated: 1
def handle_view_model_updated(socket), do: socket
# data(model, :map)
diff --git a/core/test/systems/consent/_public_test.exs b/core/test/systems/consent/_public_test.exs
index b41ed419f..423e3f037 100644
--- a/core/test/systems/consent/_public_test.exs
+++ b/core/test/systems/consent/_public_test.exs
@@ -17,22 +17,25 @@ defmodule Systems.Consent.PublicTest do
{:ok, _} =
Multi.new()
|> Multi.insert(:agreement, Consent.Public.prepare_agreement(Authorization.prepare_node()))
- |> Multi.insert(:revision1, fn %{agreement: agreement} ->
- Consent.Public.prepare_revision(agreement, "revision1")
- end)
|> Multi.insert(:revision2, fn %{agreement: agreement} ->
Consent.Public.prepare_revision(agreement, "revision2")
end)
+ |> Multi.insert(:revision3, fn %{agreement: agreement} ->
+ Consent.Public.prepare_revision(agreement, "revision3")
+ end)
|> Repo.transaction()
assert [
%Systems.Consent.AgreementModel{
revisions: [
%Systems.Consent.RevisionModel{
- source: "revision1"
+ source: _
},
%Systems.Consent.RevisionModel{
source: "revision2"
+ },
+ %Systems.Consent.RevisionModel{
+ source: "revision3"
}
]
}
@@ -47,26 +50,26 @@ defmodule Systems.Consent.PublicTest do
{:ok, _} =
Multi.new()
|> Multi.insert(:agreement, Consent.Public.prepare_agreement(Authorization.prepare_node()))
- |> Multi.insert(:revision1, fn %{agreement: agreement} ->
- Consent.Public.prepare_revision(agreement, "revision1")
- end)
- |> Multi.insert(:signatureA1, fn %{revision1: revision1} ->
- Consent.Public.prepare_signature(revision1, user_a)
- end)
- |> Multi.insert(:signatureB1, fn %{revision1: revision1} ->
- Consent.Public.prepare_signature(revision1, user_b)
- end)
|> Multi.insert(:revision2, fn %{agreement: agreement} ->
Consent.Public.prepare_revision(agreement, "revision2")
end)
- |> Multi.insert(:signatureA2, fn %{revision2: revision2} ->
+ |> Multi.insert(:signatureA1, fn %{revision2: revision2} ->
Consent.Public.prepare_signature(revision2, user_a)
end)
- |> Multi.insert(:signatureB2, fn %{revision2: revision2} ->
+ |> Multi.insert(:signatureB1, fn %{revision2: revision2} ->
Consent.Public.prepare_signature(revision2, user_b)
end)
- |> Multi.insert(:signatureC2, fn %{revision2: revision2} ->
- Consent.Public.prepare_signature(revision2, user_c)
+ |> Multi.insert(:revision3, fn %{agreement: agreement} ->
+ Consent.Public.prepare_revision(agreement, "revision3")
+ end)
+ |> Multi.insert(:signatureA2, fn %{revision3: revision3} ->
+ Consent.Public.prepare_signature(revision3, user_a)
+ end)
+ |> Multi.insert(:signatureB2, fn %{revision3: revision3} ->
+ Consent.Public.prepare_signature(revision3, user_b)
+ end)
+ |> Multi.insert(:signatureC2, fn %{revision3: revision3} ->
+ Consent.Public.prepare_signature(revision3, user_c)
end)
|> Repo.transaction()
@@ -74,14 +77,18 @@ defmodule Systems.Consent.PublicTest do
%Systems.Consent.AgreementModel{
revisions: [
%Systems.Consent.RevisionModel{
- source: "revision1",
+ source: _source,
+ signatures: []
+ },
+ %Systems.Consent.RevisionModel{
+ source: "revision2",
signatures: [
%Systems.Consent.SignatureModel{user_id: ^user_a_id},
%Systems.Consent.SignatureModel{user_id: ^user_b_id}
]
},
%Systems.Consent.RevisionModel{
- source: "revision2",
+ source: "revision3",
signatures: [
%Systems.Consent.SignatureModel{user_id: ^user_a_id},
%Systems.Consent.SignatureModel{user_id: ^user_b_id},