diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 594f80111..eb6d7265f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -29,6 +29,8 @@ "vscode": { "extensions": [ "jakebecker.elixir-ls", + "mhutchie.git-graph", + "cweijan.vscode-database-client2" ], }, }, diff --git a/core/priv/gettext/de/LC_MESSAGES/eyra-imagecatalog.po b/core/priv/gettext/de/LC_MESSAGES/eyra-imagecatalog.po index 91d9b96ec..61414e033 100644 --- a/core/priv/gettext/de/LC_MESSAGES/eyra-imagecatalog.po +++ b/core/priv/gettext/de/LC_MESSAGES/eyra-imagecatalog.po @@ -19,13 +19,13 @@ msgstr "" msgid "search.image.title" msgstr "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "images.found.message" msgid_plural "images.found.message.%{count}" msgstr[0] "" msgstr[1] "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "page.info.message" msgid_plural "page.info.message.%{count}" msgstr[0] "" diff --git a/core/priv/gettext/de/LC_MESSAGES/eyra-marketplace.po b/core/priv/gettext/de/LC_MESSAGES/eyra-marketplace.po index ca5adceeb..7cc1f1236 100644 --- a/core/priv/gettext/de/LC_MESSAGES/eyra-marketplace.po +++ b/core/priv/gettext/de/LC_MESSAGES/eyra-marketplace.po @@ -43,7 +43,7 @@ msgstr "" msgid "assignment.status.rejected.subtitle" msgstr "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "Awarded 1 credit" msgid_plural "Awarded %{count} credits" msgstr[0] "" diff --git a/core/priv/gettext/de/LC_MESSAGES/eyra-project.po b/core/priv/gettext/de/LC_MESSAGES/eyra-project.po index 09f424cf4..84e3d3f64 100644 --- a/core/priv/gettext/de/LC_MESSAGES/eyra-project.po +++ b/core/priv/gettext/de/LC_MESSAGES/eyra-project.po @@ -63,10 +63,6 @@ msgstr "" msgid "form.title" msgstr "" -#, elixir-autogen, elixir-format -msgid "node.nodes.title" -msgstr "" - #, elixir-autogen, elixir-format msgid "add.new.item.button" msgstr "" @@ -91,14 +87,6 @@ msgstr "" msgid "label.online" msgstr "" -#, elixir-autogen, elixir-format -msgid "create.item.button" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "create.item.button.short" -msgstr "" - #, elixir-autogen, elixir-format msgid "create.item.title" msgstr "" @@ -154,3 +142,23 @@ msgstr "" #, elixir-autogen, elixir-format msgid "first.breadcrumb.label" msgstr "" + +#, elixir-autogen, elixir-format +msgid "node.data.empty.create-storage" +msgstr "Erstellen Sie jetzt einen Speicher." + +#, elixir-autogen, elixir-format +msgid "node.data.empty.create-storage-failed" +msgstr "Leider konnten wir keinen Speicher für Sie erstellen." + +#, elixir-autogen, elixir-format +msgid "node.data.empty.create-storage-success" +msgstr "Ihr Speicher wurde erstellt." + +#, elixir-autogen, elixir-format, fuzzy +msgid "node.data.empty.description" +msgstr "Ihr Projekt hat noch keinen Speicher." + +#, elixir-autogen, elixir-format, fuzzy +msgid "node.data.empty.title" +msgstr "Kein Speicher erstellt" \ No newline at end of file diff --git a/core/priv/gettext/de/LC_MESSAGES/eyra-projects.po b/core/priv/gettext/de/LC_MESSAGES/eyra-projects.po new file mode 100644 index 000000000..07aa4b413 --- /dev/null +++ b/core/priv/gettext/de/LC_MESSAGES/eyra-projects.po @@ -0,0 +1,16 @@ +## "msgid"s in this file come from POT (.pot) files. +### +### Do not add, change, or remove "msgid"s manually here as +### they're tied to the ones in the corresponding POT file +### (with the same domain). +### +### Use "mix gettext.extract --merge" or "mix gettext.merge" +### to merge POT files into PO files. +msgid "" +msgstr "" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#, elixir-autogen, elixir-format +msgid "items.overview" +msgstr "" diff --git a/core/priv/gettext/de/LC_MESSAGES/link-lab.po b/core/priv/gettext/de/LC_MESSAGES/link-lab.po index 157b47e40..4ab81489a 100644 --- a/core/priv/gettext/de/LC_MESSAGES/link-lab.po +++ b/core/priv/gettext/de/LC_MESSAGES/link-lab.po @@ -43,13 +43,13 @@ msgstr "" msgid "time.slot.item.available.label" msgstr "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "1 reservation" msgid_plural "%{count} reservations" msgstr[0] "" msgstr[1] "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "1 seat" msgid_plural "%{count} seats" msgstr[0] "" @@ -59,7 +59,7 @@ msgstr[1] "" msgid "day.schedule.byline" msgstr "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "1 time slot" msgid_plural "%{count} time slots" msgstr[0] "" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-imagecatalog.po b/core/priv/gettext/en/LC_MESSAGES/eyra-imagecatalog.po index 5692b179d..e9a2cc4c3 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-imagecatalog.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-imagecatalog.po @@ -18,13 +18,13 @@ msgstr "No images found" msgid "search.image.title" msgstr "Search and select an image" -#, elixir-format +#, elixir-format, elixir-autogen msgid "images.found.message" msgid_plural "images.found.message.%{count}" msgstr[0] "1 image found:" msgstr[1] "%{count} images found:" -#, elixir-format +#, elixir-format, elixir-autogen msgid "page.info.message" msgid_plural "page.info.message.%{count}" msgstr[0] "1 image" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-marketplace.po b/core/priv/gettext/en/LC_MESSAGES/eyra-marketplace.po index 103676a02..9bf1f1551 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-marketplace.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-marketplace.po @@ -42,7 +42,7 @@ msgstr "Awaiting your contribution" msgid "assignment.status.rejected.subtitle" msgstr "No credits awarded" -#, elixir-format +#, elixir-format, elixir-autogen msgid "Awarded 1 credit" msgid_plural "Awarded %{count} credits" msgstr[0] "" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-project.po b/core/priv/gettext/en/LC_MESSAGES/eyra-project.po index 5418fd84a..cf77b9b29 100644 --- a/core/priv/gettext/en/LC_MESSAGES/eyra-project.po +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-project.po @@ -63,10 +63,6 @@ msgstr "Items" msgid "form.title" msgstr "Rename" -#, elixir-autogen, elixir-format, fuzzy -msgid "node.nodes.title" -msgstr "Groups" - #, elixir-autogen, elixir-format, fuzzy msgid "add.new.item.button" msgstr "Add item" @@ -91,14 +87,6 @@ msgstr "Offline" msgid "label.online" msgstr "Online" -#, elixir-autogen, elixir-format, fuzzy -msgid "create.item.button" -msgstr "Retract" - -#, elixir-autogen, elixir-format -msgid "create.item.button.short" -msgstr "" - #, elixir-autogen, elixir-format, fuzzy msgid "create.item.title" msgstr "Select type" @@ -154,3 +142,23 @@ msgstr "People working on this project" #, elixir-autogen, elixir-format msgid "first.breadcrumb.label" msgstr "Projects" + +#, elixir-autogen, elixir-format +msgid "node.data.empty.create-storage" +msgstr "Create a storage now." + +#, elixir-autogen, elixir-format +msgid "node.data.empty.create-storage-failed" +msgstr "Unfortunately, we could not create a storage for you." + +#, elixir-autogen, elixir-format +msgid "node.data.empty.create-storage-success" +msgstr "Your storage has been created." + +#, elixir-autogen, elixir-format, fuzzy +msgid "node.data.empty.description" +msgstr "Your project does not have a storage yet." + +#, elixir-autogen, elixir-format, fuzzy +msgid "node.data.empty.title" +msgstr "No storage created" diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-projects.po b/core/priv/gettext/en/LC_MESSAGES/eyra-projects.po new file mode 100644 index 000000000..6e82eb31d --- /dev/null +++ b/core/priv/gettext/en/LC_MESSAGES/eyra-projects.po @@ -0,0 +1,16 @@ +## "msgid"s in this file come from POT (.pot) files. +### +### Do not add, change, or remove "msgid"s manually here as +### they're tied to the ones in the corresponding POT file +### (with the same domain). +### +### Use "mix gettext.extract --merge" or "mix gettext.merge" +### to merge POT files into PO files. +msgid "" +msgstr "" +"Language: en\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#, elixir-autogen, elixir-format +msgid "items.overview" +msgstr "Overview" diff --git a/core/priv/gettext/en/LC_MESSAGES/link-lab.po b/core/priv/gettext/en/LC_MESSAGES/link-lab.po index 8fd4a6376..28ed42a87 100644 --- a/core/priv/gettext/en/LC_MESSAGES/link-lab.po +++ b/core/priv/gettext/en/LC_MESSAGES/link-lab.po @@ -42,13 +42,13 @@ msgstr "Confirm schedule" msgid "time.slot.item.available.label" msgstr "Not planned" -#, elixir-format +#, elixir-format, elixir-autogen msgid "1 reservation" msgid_plural "%{count} reservations" msgstr[0] "" msgstr[1] "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "1 seat" msgid_plural "%{count} seats" msgstr[0] "" @@ -58,7 +58,7 @@ msgstr[1] "" msgid "day.schedule.byline" msgstr "Day schedule: %{time_slots} with %{seats} in total." -#, elixir-format +#, elixir-format, elixir-autogen msgid "1 time slot" msgid_plural "%{count} time slots" msgstr[0] "" diff --git a/core/priv/gettext/eyra-imagecatalog.pot b/core/priv/gettext/eyra-imagecatalog.pot index 28791aba3..4058c6ded 100644 --- a/core/priv/gettext/eyra-imagecatalog.pot +++ b/core/priv/gettext/eyra-imagecatalog.pot @@ -18,13 +18,13 @@ msgstr "" msgid "search.image.title" msgstr "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "images.found.message" msgid_plural "images.found.message.%{count}" msgstr[0] "" msgstr[1] "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "page.info.message" msgid_plural "page.info.message.%{count}" msgstr[0] "" diff --git a/core/priv/gettext/eyra-marketplace.pot b/core/priv/gettext/eyra-marketplace.pot index 325a45bfb..dce023a28 100644 --- a/core/priv/gettext/eyra-marketplace.pot +++ b/core/priv/gettext/eyra-marketplace.pot @@ -42,7 +42,7 @@ msgstr "" msgid "assignment.status.rejected.subtitle" msgstr "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "Awarded 1 credit" msgid_plural "Awarded %{count} credits" msgstr[0] "" diff --git a/core/priv/gettext/eyra-project.pot b/core/priv/gettext/eyra-project.pot index 4c36ed2cd..0b7dacf4d 100644 --- a/core/priv/gettext/eyra-project.pot +++ b/core/priv/gettext/eyra-project.pot @@ -63,10 +63,6 @@ msgstr "" msgid "form.title" msgstr "" -#, elixir-autogen, elixir-format -msgid "node.nodes.title" -msgstr "" - #, elixir-autogen, elixir-format msgid "add.new.item.button" msgstr "" @@ -91,14 +87,6 @@ msgstr "" msgid "label.online" msgstr "" -#, elixir-autogen, elixir-format -msgid "create.item.button" -msgstr "" - -#, elixir-autogen, elixir-format -msgid "create.item.button.short" -msgstr "" - #, elixir-autogen, elixir-format msgid "create.item.title" msgstr "" @@ -154,3 +142,23 @@ msgstr "" #, elixir-autogen, elixir-format msgid "first.breadcrumb.label" msgstr "" + +#, elixir-autogen, elixir-format +msgid "node.data.empty.create-storage" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "node.data.empty.create-storage-failed" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "node.data.empty.create-storage-success" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "node.data.empty.description" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "node.data.empty.title" +msgstr "" diff --git a/core/priv/gettext/eyra-projects.pot b/core/priv/gettext/eyra-projects.pot new file mode 100644 index 000000000..82adea73a --- /dev/null +++ b/core/priv/gettext/eyra-projects.pot @@ -0,0 +1,16 @@ +## This file is a PO Template file. +## +## "msgid"s here are often extracted from source code. +## Add new messages manually only if they're dynamic +## messages that can't be statically extracted. +## +## Run "mix gettext.extract" to bring this file up to +## date. Leave "msgstr"s empty as changing them here has no +## effect: edit them in PO (.po) files instead. +# +msgid "" +msgstr "" + +#, elixir-autogen, elixir-format +msgid "items.overview" +msgstr "" diff --git a/core/priv/gettext/link-lab.pot b/core/priv/gettext/link-lab.pot index 951c14533..7ac10c381 100644 --- a/core/priv/gettext/link-lab.pot +++ b/core/priv/gettext/link-lab.pot @@ -42,13 +42,13 @@ msgstr "" msgid "time.slot.item.available.label" msgstr "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "1 reservation" msgid_plural "%{count} reservations" msgstr[0] "" msgstr[1] "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "1 seat" msgid_plural "%{count} seats" msgstr[0] "" @@ -58,7 +58,7 @@ msgstr[1] "" msgid "day.schedule.byline" msgstr "" -#, elixir-format +#, elixir-format, elixir-autogen msgid "1 time slot" msgid_plural "%{count} time slots" msgstr[0] "" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-imagecatalog.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-imagecatalog.po index 9c986cc78..3c2575d2d 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-imagecatalog.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-imagecatalog.po @@ -18,13 +18,13 @@ msgstr "Geen afbeeldingen gevonden" msgid "search.image.title" msgstr "Zoek een afbeelding" -#, elixir-format +#, elixir-format, elixir-autogen msgid "images.found.message" msgid_plural "images.found.message.%{count}" msgstr[0] "1 afbeelding:" msgstr[1] "%{count} afbeeldingen:" -#, elixir-format +#, elixir-format, elixir-autogen msgid "page.info.message" msgid_plural "page.info.message.%{count}" msgstr[0] "1 afbeelding" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-marketplace.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-marketplace.po index cb9c327cb..9fb1e74f2 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-marketplace.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-marketplace.po @@ -42,7 +42,7 @@ msgstr "In afwachting van jouw bijdrage" msgid "assignment.status.rejected.subtitle" msgstr "Geen credits toegekend" -#, elixir-format +#, elixir-format, elixir-autogen msgid "Awarded 1 credit" msgid_plural "Awarded %{count} credits" msgstr[0] "1 credit verdiend" diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-project.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-project.po index 5a252ae43..554a5d5f9 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/eyra-project.po +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-project.po @@ -63,10 +63,6 @@ msgstr "Items" msgid "form.title" msgstr "Project instellingen" -#, elixir-autogen, elixir-format, fuzzy -msgid "node.nodes.title" -msgstr "Groepen" - #, elixir-autogen, elixir-format, fuzzy msgid "add.new.item.button" msgstr "Item toevoegen" @@ -91,14 +87,6 @@ msgstr "Offline" msgid "label.online" msgstr "Online" -#, elixir-autogen, elixir-format, fuzzy -msgid "create.item.button" -msgstr "Trek terug" - -#, elixir-autogen, elixir-format -msgid "create.item.button.short" -msgstr "" - #, elixir-autogen, elixir-format, fuzzy msgid "create.item.title" msgstr "Kies type" @@ -154,3 +142,23 @@ msgstr "" #, elixir-autogen, elixir-format msgid "first.breadcrumb.label" msgstr "" + +#, elixir-autogen, elixir-format +msgid "node.data.empty.create-storage" +msgstr "Maak nu een opslag aan." + +#, elixir-autogen, elixir-format +msgid "node.data.empty.create-storage-failed" +msgstr "Helaas konden we geen opslag voor je aanmaken." + +#, elixir-autogen, elixir-format +msgid "node.data.empty.create-storage-success" +msgstr "Je opslag is aangemaakt." + +#, elixir-autogen, elixir-format, fuzzy +msgid "node.data.empty.description" +msgstr "Je project heeft nog geen opslag." + +#, elixir-autogen, elixir-format, fuzzy +msgid "node.data.empty.title" +msgstr "Geen opslag aangemaakt" \ No newline at end of file diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-projects.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-projects.po new file mode 100644 index 000000000..dd5836fbd --- /dev/null +++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-projects.po @@ -0,0 +1,16 @@ +## "msgid"s in this file come from POT (.pot) files. +### +### Do not add, change, or remove "msgid"s manually here as +### they're tied to the ones in the corresponding POT file +### (with the same domain). +### +### Use "mix gettext.extract --merge" or "mix gettext.merge" +### to merge POT files into PO files. +msgid "" +msgstr "" +"Language: nl\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#, elixir-autogen, elixir-format +msgid "items.overview" +msgstr "" diff --git a/core/priv/gettext/nl/LC_MESSAGES/link-lab.po b/core/priv/gettext/nl/LC_MESSAGES/link-lab.po index ba5ef3456..17f8cfaa9 100644 --- a/core/priv/gettext/nl/LC_MESSAGES/link-lab.po +++ b/core/priv/gettext/nl/LC_MESSAGES/link-lab.po @@ -42,13 +42,13 @@ msgstr "Bevestig planning" msgid "time.slot.item.available.label" msgstr "Niet ingepland" -#, elixir-format +#, elixir-format, elixir-autogen msgid "1 reservation" msgid_plural "%{count} reservations" msgstr[0] "1 reservering" msgstr[1] "%{count} reserveringen" -#, elixir-format +#, elixir-format, elixir-autogen msgid "1 seat" msgid_plural "%{count} seats" msgstr[0] "1 plaats" @@ -58,7 +58,7 @@ msgstr[1] "%{count} plaatsen" msgid "day.schedule.byline" msgstr "Dagplanning: %{time_slots} met in totaal %{seats}." -#, elixir-format +#, elixir-format, elixir-autogen msgid "1 time slot" msgid_plural "%{count} time slots" msgstr[0] "1 tijdslot" diff --git a/core/systems/project/_assembly.ex b/core/systems/project/_assembly.ex index cae058ea0..3049edf6d 100644 --- a/core/systems/project/_assembly.ex +++ b/core/systems/project/_assembly.ex @@ -1,13 +1,15 @@ defmodule Systems.Project.Assembly do import Ecto.Query, warn: false + use Gettext, backend: CoreWeb.Gettext + require Logger alias Core.Authorization alias Core.Repo alias Ecto.Changeset alias Ecto.Multi alias Frameworks.Signal alias Frameworks.Utility.EctoHelper - + alias Systems.Storage alias Systems.Assignment alias Systems.Project @@ -41,11 +43,43 @@ defmodule Systems.Project.Assembly do |> Repo.transaction() end + @spec create(any(), any(), :empty) :: any() def create(name, user, :empty) do - project = prepare_project(name, [], user) + project_changeset = prepare_project(name, [], user) + + Multi.new() + |> Multi.insert(:project, project_changeset) + |> Multi.run(:storage_setup, fn _repo, %{project: new_project} -> + case attach_storage_to_project(new_project) do + {:ok, %{storage_endpoint: endpoint, storage_item: item}} -> + {:ok, %{endpoint: endpoint, item: item}} + + {:error, _, reason, _} -> + {:error, reason} + end + end) + |> EctoHelper.run(:auth, &update_auth/2) + |> Repo.transaction() + end + def attach_storage_to_project(%Project.Model{} = project) do Multi.new() - |> Multi.insert(:project, project) + |> Multi.run(:project, fn _repo, _changes -> + {:ok, Repo.preload(project, :root)} + end) + |> Multi.insert(:storage_endpoint, fn %{project: project} -> + key = "project_node=#{project.root.id}" + + Storage.Public.prepare_endpoint(:builtin, %{key: key}) + |> Ecto.Changeset.unique_constraint(:key, name: :storage_endpoints_builtin_key_index) + end) + |> Multi.insert(:storage_item, fn %{project: project, storage_endpoint: endpoint} -> + Project.Public.prepare_item( + %{name: dgettext("eyra-storage", "default.name"), project_path: []}, + endpoint + ) + |> Ecto.Changeset.put_assoc(:node, project.root) + end) |> EctoHelper.run(:auth, &update_auth/2) |> Repo.transaction() end diff --git a/core/systems/project/_public.ex b/core/systems/project/_public.ex index 6a73c41b4..68b2610e3 100644 --- a/core/systems/project/_public.ex +++ b/core/systems/project/_public.ex @@ -266,6 +266,10 @@ defmodule Systems.Project.Public do |> Ecto.Changeset.put_assoc(:auth_node, auth_node) end + def prepare_item(attrs, %Storage.EndpointModel{} = endpoint) do + prepare_item(attrs, :storage_endpoint, endpoint) + end + def prepare_item(attrs, %Workflow.ToolRefModel{} = tool_ref) do prepare_item(attrs, :tool_ref, tool_ref) end diff --git a/core/systems/project/model.ex b/core/systems/project/model.ex index dd3a89e09..46104fbad 100644 --- a/core/systems/project/model.ex +++ b/core/systems/project/model.ex @@ -105,7 +105,12 @@ defmodule Systems.Project.Model do end end - defp info([_item]), do: "1 item" - defp info(items) when is_list(items), do: "#{Enum.count(items)} items" + defp info(items) when is_list(items) do + items = Enum.reject(items, fn item -> item.name == "Data" end) + + count = Enum.count(items) + item_label = if count > 1 || count == 0, do: "items", else: "item" + "#{count} #{item_label}" + end end end diff --git a/core/systems/project/node_model.ex b/core/systems/project/node_model.ex index efaffee9d..042f4cad4 100644 --- a/core/systems/project/node_model.ex +++ b/core/systems/project/node_model.ex @@ -64,7 +64,7 @@ defmodule Systems.Project.NodeModel do defimpl Frameworks.Utility.ViewModelBuilder do use CoreWeb, :verified_routes - def view_model(%Project.NodeModel{} = node, page, %{current_user: user}) do + def view_model(%Project.NodeModel{} = node, page, %{user: user}) do vm(node, page, user) end diff --git a/core/systems/project/node_page.ex b/core/systems/project/node_page.ex index 15cdb36c0..8e2de1b69 100644 --- a/core/systems/project/node_page.ex +++ b/core/systems/project/node_page.ex @@ -1,10 +1,6 @@ defmodule Systems.Project.NodePage do use Systems.Content.Composer, :live_workspace - import Frameworks.Pixel.Empty - import Frameworks.Pixel.Line - alias Frameworks.Pixel.Grid - alias Frameworks.Pixel.Breadcrumbs alias Systems.Project @impl true @@ -19,171 +15,26 @@ defmodule Systems.Project.NodePage do @impl true def mount(_params, _session, socket) do - {:ok, socket} - end - - # Childs - - @impl true - def compose(:project_item_form, %{focussed_item: item}) do - %{ - module: Project.ItemForm, - params: %{item: item} - } - end - - @impl true - def compose(:create_item_view, %{vm: %{node: node}}) do - %{ - module: Project.CreateItemView, - params: %{node: node} - } - end - - # Events - - @impl true - def handle_event("rename", %{"item" => item_id}, socket) do - item = Project.Public.get_item!(String.to_integer(item_id)) - - { - :noreply, - socket - |> assign(focussed_item: item) - |> compose_child(:project_item_form) - |> show_modal(:project_item_form, :dialog) - } - end - - @impl true - def handle_event("delete", %{"item" => item_id}, socket) do - Project.Public.delete_item(String.to_integer(item_id)) - { - :noreply, + :ok, socket - |> update_view_model() - |> update_menus() } end - @impl true - def handle_event("create_item", _params, socket) do - { - :noreply, - socket - |> compose_child(:create_item_view) - |> show_modal(:create_item_view, :dialog) - } - end - - @impl true - def handle_event( - "card_clicked", - %{"item" => card_id}, - %{assigns: %{vm: %{item_cards: item_cards, node_cards: node_cards}}} = socket - ) do - card_id = String.to_integer(card_id) - %{path: path} = Enum.find(item_cards ++ node_cards, &(&1.id == card_id)) - {:noreply, push_navigate(socket, to: path)} - end - - @impl true - def handle_event("saved", %{source: %{name: modal_view}}, socket) do - {:noreply, socket |> hide_modal(modal_view)} - end - @impl true def render(assigns) do ~H""" -