From c2b68b857d14280eeaeca300580c5925285ac8cc Mon Sep 17 00:00:00 2001 From: Jannik Streek Date: Tue, 17 Dec 2024 12:08:28 +0100 Subject: [PATCH 01/21] add hooks --- .cursorignore | 11 +++++ assets/js/app.js | 48 +++++++++++++++++++ .../static_page_html/home.html.heex | 35 +++++--------- .../live/brainstorming_live/show.ex | 3 +- .../live/brainstorming_live/show.html.heex | 9 +++- .../templates/layout/app.html.heex | 4 +- 6 files changed, 84 insertions(+), 26 deletions(-) create mode 100644 .cursorignore diff --git a/.cursorignore b/.cursorignore new file mode 100644 index 00000000..8f943e77 --- /dev/null +++ b/.cursorignore @@ -0,0 +1,11 @@ +!*.heex +!*.ex +!*.exs +!*.json +!*.js +!*.jsx +!*.ts +!*.tsx +!*.scss +!*.css +!*.html diff --git a/assets/js/app.js b/assets/js/app.js index aa76c854..b5decbfd 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -131,6 +131,54 @@ Hooks.SetIdeaLabelBackgroundColor = { } }; +Hooks.LoadBrainstormingLinks = { + mounted() { + if(this.el) { + const recentBrainstormings = JSON.parse(localStorage.getItem('brainstormings') || '{}'); + Object.values(recentBrainstormings) + .sort((a, b) => new Date(b.lastAccessedAt) - new Date(a.lastAccessedAt)) + .slice(0, 5) + .forEach(brainstorming => { + const newListEl = document.createElement('li') + newListEl.classList.add('list-group-item', 'border-0', 'bg-transparent') + + const newLink = document.createElement('a') + newLink.href = `/brainstormings/${brainstorming.id}/#${brainstorming.adminUrlId}` + newLink.textContent = brainstorming.name; + + newListEl.append(newLink); + this.el.append(newListEl); + }); + } + } +}; + +Hooks.StoreRecentBrainstorming = { + mounted() { + const brainstormingId = this.el.dataset.id; + const recentBrainstormings = JSON.parse(localStorage.getItem('brainstormings') || '{}'); + + recentBrainstormings[brainstormingId] = { + id: brainstormingId, + adminUrlId: this.el.dataset.adminUrlId, + name: this.el.dataset.name, + lastAccessedAt: this.el.dataset.lastAccessedAt + } + localStorage.setItem('brainstormings', JSON.stringify(recentBrainstormings)); + } +}; + +Hooks.RemoveMissingBrainstorming = { + mounted() { + const missingId = this.el.dataset.missingId; + if (missingId) { + const recentBrainstormings = JSON.parse(localStorage.getItem('brainstormings') || '{}'); + delete recentBrainstormings[missingId] + localStorage.setItem('brainstormings', JSON.stringify(recentBrainstormings)); + } + } +}; + // The brainstorming secret from the url ("#123") is added as well to the socket. The secret is not available on the server side by default. let liveSocket = new LiveSocket("/live", Socket, { hooks: Hooks, params: { _csrf_token: csrfToken, adminSecret: window.location.hash.substring(1) } diff --git a/lib/mindwendel_web/controllers/static_page_html/home.html.heex b/lib/mindwendel_web/controllers/static_page_html/home.html.heex index 8e3d2a68..e4d19173 100644 --- a/lib/mindwendel_web/controllers/static_page_html/home.html.heex +++ b/lib/mindwendel_web/controllers/static_page_html/home.html.heex @@ -44,29 +44,20 @@ - <%= if @current_user && !Enum.empty?(@current_user.brainstormings) do %> -
-
-

{gettext("Your latest brainstormings")}

- <%= for brainstorming <- list_brainstormings_for(@current_user) do %> -
- <.link href={~p"/brainstormings/#{brainstorming.id}"}> - {brainstorming.name} - - - {Timex.format!(brainstorming.inserted_at, "{relative}", :relative)} - -
- <% end %> -

- {gettext( - "Attention: Brainstormings will be deleted %{available_until} after last access!", - available_until: brainstormings_available_until() - )} -

-
+
+
+

{gettext("Your latest brainstormings")}

+ +

+ {gettext( + "Attention: Brainstormings will be deleted %{available_until} after last access!", + available_until: brainstormings_available_until() + )} +

- <% end %> +
Made with ❤️ in the 🇪🇺 diff --git a/lib/mindwendel_web/live/brainstorming_live/show.ex b/lib/mindwendel_web/live/brainstorming_live/show.ex index fcd0e751..9f86c6d2 100644 --- a/lib/mindwendel_web/live/brainstorming_live/show.ex +++ b/lib/mindwendel_web/live/brainstorming_live/show.ex @@ -42,8 +42,9 @@ defmodule MindwendelWeb.BrainstormingLive.Show do {:error, _} -> {:ok, socket + |> put_flash(:missing_brainstorming_id, id) |> put_flash(:error, gettext("Brainstorming not found")) - |> push_navigate(to: "/")} + |> redirect(to: "/")} end end diff --git a/lib/mindwendel_web/live/brainstorming_live/show.html.heex b/lib/mindwendel_web/live/brainstorming_live/show.html.heex index c88bbc13..7a5bd367 100644 --- a/lib/mindwendel_web/live/brainstorming_live/show.html.heex +++ b/lib/mindwendel_web/live/brainstorming_live/show.html.heex @@ -10,7 +10,14 @@
<% end %> -
+
diff --git a/lib/mindwendel_web/templates/layout/app.html.heex b/lib/mindwendel_web/templates/layout/app.html.heex index 5342567b..2a5a0f7c 100644 --- a/lib/mindwendel_web/templates/layout/app.html.heex +++ b/lib/mindwendel_web/templates/layout/app.html.heex @@ -1,9 +1,9 @@
<%= if Phoenix.Flash.get(@flash, :info) do %> - + <% end %> <%= if Phoenix.Flash.get(@flash, :error) do %> - + <% end %> {@inner_content}
From 4a3017cde96f4662b47b76316b921a986b9a22d1 Mon Sep 17 00:00:00 2001 From: Jannik Streek Date: Tue, 17 Dec 2024 16:36:08 +0100 Subject: [PATCH 02/21] landing page works --- assets/js/app.js | 42 +++++--- lib/mindwendel_web.ex | 2 +- lib/mindwendel_web/components/layouts.ex | 5 +- .../static_page_html/home.html.heex | 7 +- .../live/admin/brainstorming_live/edit.ex | 1 + .../live/brainstorming_live/show.ex | 11 +++ .../live/brainstorming_live/show.html.heex | 10 +- .../templates/layout/app.html.heex | 99 ++++++++++++++++++- .../templates/layout/live.html.heex | 13 --- .../templates/layout/root.html.heex | 87 ---------------- priv/gettext/de/LC_MESSAGES/default.po | 50 +++++----- priv/gettext/default.pot | 50 +++++----- priv/gettext/en/LC_MESSAGES/default.po | 50 +++++----- 13 files changed, 226 insertions(+), 201 deletions(-) delete mode 100644 lib/mindwendel_web/templates/layout/live.html.heex diff --git a/assets/js/app.js b/assets/js/app.js index b5decbfd..3be1c37b 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,7 +1,7 @@ import { Modal, Tooltip } from "bootstrap" import Sortable from 'sortablejs'; import { setIdeaLabelBackgroundColor } from "./label" - +import { getRelativeTimeString } from "./timeUtils" // activate all tooltips: const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]'); [...tooltipTriggerList].map(tooltipTriggerEl => new Tooltip(tooltipTriggerEl)); @@ -131,24 +131,32 @@ Hooks.SetIdeaLabelBackgroundColor = { } }; +// Only used for the landing page Hooks.LoadBrainstormingLinks = { mounted() { if(this.el) { const recentBrainstormings = JSON.parse(localStorage.getItem('brainstormings') || '{}'); - Object.values(recentBrainstormings) - .sort((a, b) => new Date(b.lastAccessedAt) - new Date(a.lastAccessedAt)) - .slice(0, 5) - .forEach(brainstorming => { - const newListEl = document.createElement('li') - newListEl.classList.add('list-group-item', 'border-0', 'bg-transparent') - - const newLink = document.createElement('a') - newLink.href = `/brainstormings/${brainstorming.id}/#${brainstorming.adminUrlId}` - newLink.textContent = brainstorming.name; - - newListEl.append(newLink); - this.el.append(newListEl); + const newListItems = Object.values(recentBrainstormings) + .sort((a, b) => new Date(b.last_accessed_at) - new Date(a.last_accessed_at)) + .slice(0, 5) + .map(brainstorming => { + const newListEl = document.createElement('li') + newListEl.classList.add('list-group-item', 'border-0', 'bg-transparent', 'h5', 'm-1', 'p-0') + + const newLink = document.createElement('a') + newLink.href = `/brainstormings/${brainstorming.id}/#${brainstorming.admin_url_id}` + newLink.textContent = brainstorming.name; + + const timeBadge = document.createElement('span') + timeBadge.classList.add('badge', 'rounded-pill', 'bg-light', 'text-dark') + timeBadge.textContent = getRelativeTimeString(new Date(brainstorming.last_accessed_at), this.el.dataset.language) + + newListEl.append(newLink); + newListEl.append(timeBadge); + return newListEl; }); + + newListItems.length > 0 ? this.el.append(...newListItems) : this.el.append(document.createElement('p').textContent = "-") } } }; @@ -160,11 +168,13 @@ Hooks.StoreRecentBrainstorming = { recentBrainstormings[brainstormingId] = { id: brainstormingId, - adminUrlId: this.el.dataset.adminUrlId, + admin_url_id: this.el.dataset.adminUrlId, name: this.el.dataset.name, - lastAccessedAt: this.el.dataset.lastAccessedAt + last_accessed_at: this.el.dataset.lastAccessedAt } localStorage.setItem('brainstormings', JSON.stringify(recentBrainstormings)); + const lastSortedBrainstormings = Object.values(recentBrainstormings).sort((a, b) => new Date(b.last_accessed_at) - new Date(a.last_accessed_at)).slice(0, 10) + this.pushEventTo(this.el,"brainstormings_from_local_storage", lastSortedBrainstormings) } }; diff --git a/lib/mindwendel_web.ex b/lib/mindwendel_web.ex index e2be4f44..1e1db20a 100644 --- a/lib/mindwendel_web.ex +++ b/lib/mindwendel_web.ex @@ -40,7 +40,7 @@ defmodule MindwendelWeb do quote do use Phoenix.Controller, formats: [:html, :json], - layouts: [html: MindwendelWeb.Layouts] + layouts: [html: {MindwendelWeb.Layouts, :app_static}] import Plug.Conn use Gettext, backend: MindwendelWeb.Gettext diff --git a/lib/mindwendel_web/components/layouts.ex b/lib/mindwendel_web/components/layouts.ex index f2f55c8e..f49e777e 100644 --- a/lib/mindwendel_web/components/layouts.ex +++ b/lib/mindwendel_web/components/layouts.ex @@ -18,8 +18,7 @@ defmodule MindwendelWeb.Layouts do Brainstormings.list_brainstormings_for(user.id, limit) end - def admin_route(conn) do - route_scope = conn.request_path |> String.split("/", trim: true) |> List.first() - route_scope == "admin" + def admin_view(current_view) do + current_view == MindwendelWeb.Admin.BrainstormingLive.Edit end end diff --git a/lib/mindwendel_web/controllers/static_page_html/home.html.heex b/lib/mindwendel_web/controllers/static_page_html/home.html.heex index e4d19173..8786e0df 100644 --- a/lib/mindwendel_web/controllers/static_page_html/home.html.heex +++ b/lib/mindwendel_web/controllers/static_page_html/home.html.heex @@ -47,7 +47,12 @@

{gettext("Your latest brainstormings")}

-
<% end %> -
diff --git a/lib/mindwendel_web/templates/layout/app.html.heex b/lib/mindwendel_web/templates/layout/app.html.heex index 2a5a0f7c..d4128ec8 100644 --- a/lib/mindwendel_web/templates/layout/app.html.heex +++ b/lib/mindwendel_web/templates/layout/app.html.heex @@ -1,9 +1,104 @@ +
<%= if Phoenix.Flash.get(@flash, :info) do %> - + <% end %> <%= if Phoenix.Flash.get(@flash, :error) do %> - + <% end %> {@inner_content}
diff --git a/lib/mindwendel_web/templates/layout/live.html.heex b/lib/mindwendel_web/templates/layout/live.html.heex deleted file mode 100644 index 45e8abf9..00000000 --- a/lib/mindwendel_web/templates/layout/live.html.heex +++ /dev/null @@ -1,13 +0,0 @@ -
- <%= if Phoenix.Flash.get(@flash, :info) do %> - - <% end %> - <%= if Phoenix.Flash.get(@flash, :error) do %> - - <% end %> - {@inner_content} -
diff --git a/lib/mindwendel_web/templates/layout/root.html.heex b/lib/mindwendel_web/templates/layout/root.html.heex index fb4ffa1d..6f274e1d 100644 --- a/lib/mindwendel_web/templates/layout/root.html.heex +++ b/lib/mindwendel_web/templates/layout/root.html.heex @@ -17,93 +17,6 @@ - {@inner_content} diff --git a/priv/gettext/de/LC_MESSAGES/default.po b/priv/gettext/de/LC_MESSAGES/default.po index 79c5f79d..b06e9552 100644 --- a/priv/gettext/de/LC_MESSAGES/default.po +++ b/priv/gettext/de/LC_MESSAGES/default.po @@ -26,12 +26,12 @@ msgstr "Wie können wir ..." msgid "Ready?" msgstr "Fertig?" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:184 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:196 #, elixir-autogen, elixir-format msgid "%{name} - Edit" msgstr "%{name} - Editieren" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:161 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:173 #, elixir-autogen, elixir-format msgid "%{name} - New Idea" msgstr "%{name} - Neue Idee" @@ -102,12 +102,12 @@ msgstr "Keine Ideen? Hier gibts Gedankenanstöße!" msgid "Idea created successfully" msgstr "Idee erstellt" -#: lib/mindwendel_web/templates/layout/root.html.heex:53 +#: lib/mindwendel_web/templates/layout/app.html.heex:34 #, elixir-autogen, elixir-format msgid "New brainstorming" msgstr "Neues Brainstorming" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:80 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:91 #, elixir-autogen, elixir-format msgid "New idea" msgstr "Neue Idee" @@ -148,7 +148,7 @@ msgstr "Sortiere nach Label" msgid "Sort by likes" msgstr "Sortiere nach Likes" -#: lib/mindwendel_web/templates/layout/root.html.heex:66 +#: lib/mindwendel_web/templates/layout/app.html.heex:47 #, elixir-autogen, elixir-format msgid "Your brainstormings" msgstr "Deine Brainstormings" @@ -178,7 +178,7 @@ msgstr "Editiere Brainstorming" msgid "Export" msgstr "Export" -#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:50 +#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:49 #, elixir-autogen msgid "Your latest brainstormings" msgstr "Deine letzten Brainstormings" @@ -236,9 +236,9 @@ msgstr "Rot" msgid "yellow" msgstr "Gelb" -#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:74 -#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:114 -#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:153 +#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:75 +#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:115 +#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:154 #, elixir-autogen, elixir-format msgid "Your brainstorming was not saved." msgstr "Dein Brainstorming wurde nicht gespeichert." @@ -253,12 +253,12 @@ msgstr "Trete meinem Brainstorming bei." msgid "Mindwendel Brainstorming" msgstr "Mindwendel Brainstorming" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:35 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:46 #, elixir-autogen, elixir-format msgid "Share" msgstr "Teilen" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:164 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:175 #, elixir-autogen, elixir-format msgid "Share brainstorming" msgstr "Teile Dein Brainstorming" @@ -278,7 +278,7 @@ msgstr "Download als SVG" msgid "Brainstorming delete are you sure" msgstr "Bist du sicher, dass das Brainstorming gelöscht werden soll?" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:131 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:142 #, elixir-autogen, elixir-format msgid "Update idea" msgstr "Idee bearbeiten" @@ -304,7 +304,7 @@ msgstr "Leere das Brainstorming" msgid "Brainstorming will be deleted %{days}" msgstr "Brainstorming wird gelöscht %{days}" -#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:62 +#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:59 #, elixir-autogen, elixir-format msgid "Attention: Brainstormings will be deleted %{available_until} after last access!" msgstr "Achtung: Brainstormings werden %{available_until} nach dem letzten Zugriff gelöscht!" @@ -314,7 +314,7 @@ msgstr "Achtung: Brainstormings werden %{available_until} nach dem letzten Zugri msgid "Allow users to change the order of ideas" msgstr "Nutzern das Verschieben und Sortieren von Ideen erlauben" -#: lib/mindwendel_web/templates/layout/root.html.heex:29 +#: lib/mindwendel_web/templates/layout/app.html.heex:10 #, elixir-autogen, elixir-format msgid "Back" msgstr "Zurück" @@ -385,7 +385,7 @@ msgstr "Löschen" msgid "Type the label name" msgstr "Gebe dem Label einen Namen" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:171 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:183 #, elixir-autogen, elixir-format, fuzzy msgid "%{name} - New Lane" msgstr "%{name} - Neue Idee" @@ -400,15 +400,15 @@ msgstr "Spalte erfolgreich erstellt" msgid "Name" msgstr "Name" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:26 -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:28 -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:114 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:37 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:39 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:125 #: lib/mindwendel_web/live/lane_live/index_component.html.heex:130 #, elixir-autogen, elixir-format msgid "New lane" msgstr "Neue Spalte" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:148 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:159 #, elixir-autogen, elixir-format, fuzzy msgid "Update lane" msgstr "Spalte bearbeiten" @@ -541,19 +541,19 @@ msgstr "Zeige Idee" msgid "Your comment" msgstr "Kommentar" -#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:75 -#: lib/mindwendel_web/templates/layout/root.html.heex:86 +#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:71 +#: lib/mindwendel_web/templates/layout/app.html.heex:69 #, elixir-autogen, elixir-format msgid "Legal Disclosure" msgstr "Impressum" -#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:76 -#: lib/mindwendel_web/templates/layout/root.html.heex:82 +#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:72 +#: lib/mindwendel_web/templates/layout/app.html.heex:65 #, elixir-autogen, elixir-format msgid "Privacy" msgstr "Datenschutzerklärung" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:97 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:108 #, elixir-autogen, elixir-format msgid "Idea details" msgstr "Detailansicht" @@ -563,7 +563,7 @@ msgstr "Detailansicht" msgid "Give moderating permissions" msgstr "Änderungen erlauben" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:45 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:48 #, elixir-autogen, elixir-format, fuzzy msgid "Brainstorming not found" msgstr "Brainstorming konnte nicht gefunden werden" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 830fd1b7..1f605370 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -25,12 +25,12 @@ msgstr "" msgid "Ready?" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:184 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:196 #, elixir-autogen, elixir-format msgid "%{name} - Edit" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:161 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:173 #, elixir-autogen, elixir-format msgid "%{name} - New Idea" msgstr "" @@ -101,12 +101,12 @@ msgstr "" msgid "Idea created successfully" msgstr "" -#: lib/mindwendel_web/templates/layout/root.html.heex:53 +#: lib/mindwendel_web/templates/layout/app.html.heex:34 #, elixir-autogen, elixir-format msgid "New brainstorming" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:80 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:91 #, elixir-autogen, elixir-format msgid "New idea" msgstr "" @@ -147,7 +147,7 @@ msgstr "" msgid "Sort by likes" msgstr "" -#: lib/mindwendel_web/templates/layout/root.html.heex:66 +#: lib/mindwendel_web/templates/layout/app.html.heex:47 #, elixir-autogen, elixir-format msgid "Your brainstormings" msgstr "" @@ -177,7 +177,7 @@ msgstr "" msgid "Export" msgstr "" -#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:50 +#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:49 #, elixir-autogen msgid "Your latest brainstormings" msgstr "" @@ -235,9 +235,9 @@ msgstr "" msgid "yellow" msgstr "" -#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:74 -#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:114 -#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:153 +#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:75 +#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:115 +#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:154 #, elixir-autogen, elixir-format msgid "Your brainstorming was not saved." msgstr "" @@ -252,12 +252,12 @@ msgstr "" msgid "Mindwendel Brainstorming" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:35 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:46 #, elixir-autogen, elixir-format msgid "Share" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:164 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:175 #, elixir-autogen, elixir-format msgid "Share brainstorming" msgstr "" @@ -277,7 +277,7 @@ msgstr "" msgid "Brainstorming delete are you sure" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:131 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:142 #, elixir-autogen, elixir-format msgid "Update idea" msgstr "" @@ -303,7 +303,7 @@ msgstr "" msgid "Brainstorming will be deleted %{days}" msgstr "" -#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:62 +#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:59 #, elixir-autogen, elixir-format msgid "Attention: Brainstormings will be deleted %{available_until} after last access!" msgstr "" @@ -313,7 +313,7 @@ msgstr "" msgid "Allow users to change the order of ideas" msgstr "" -#: lib/mindwendel_web/templates/layout/root.html.heex:29 +#: lib/mindwendel_web/templates/layout/app.html.heex:10 #, elixir-autogen, elixir-format msgid "Back" msgstr "" @@ -384,7 +384,7 @@ msgstr "" msgid "Type the label name" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:171 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:183 #, elixir-autogen, elixir-format msgid "%{name} - New Lane" msgstr "" @@ -399,15 +399,15 @@ msgstr "" msgid "Name" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:26 -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:28 -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:114 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:37 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:39 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:125 #: lib/mindwendel_web/live/lane_live/index_component.html.heex:130 #, elixir-autogen, elixir-format msgid "New lane" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:148 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:159 #, elixir-autogen, elixir-format msgid "Update lane" msgstr "" @@ -540,19 +540,19 @@ msgstr "" msgid "Your comment" msgstr "" -#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:75 -#: lib/mindwendel_web/templates/layout/root.html.heex:86 +#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:71 +#: lib/mindwendel_web/templates/layout/app.html.heex:69 #, elixir-autogen, elixir-format msgid "Legal Disclosure" msgstr "" -#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:76 -#: lib/mindwendel_web/templates/layout/root.html.heex:82 +#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:72 +#: lib/mindwendel_web/templates/layout/app.html.heex:65 #, elixir-autogen, elixir-format msgid "Privacy" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:97 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:108 #, elixir-autogen, elixir-format msgid "Idea details" msgstr "" @@ -562,7 +562,7 @@ msgstr "" msgid "Give moderating permissions" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:45 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:48 #, elixir-autogen, elixir-format msgid "Brainstorming not found" msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index 9312c662..4f842571 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -26,12 +26,12 @@ msgstr "" msgid "Ready?" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:184 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:196 #, elixir-autogen, elixir-format msgid "%{name} - Edit" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:161 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:173 #, elixir-autogen, elixir-format msgid "%{name} - New Idea" msgstr "" @@ -102,12 +102,12 @@ msgstr "" msgid "Idea created successfully" msgstr "" -#: lib/mindwendel_web/templates/layout/root.html.heex:53 +#: lib/mindwendel_web/templates/layout/app.html.heex:34 #, elixir-autogen, elixir-format msgid "New brainstorming" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:80 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:91 #, elixir-autogen, elixir-format msgid "New idea" msgstr "" @@ -148,7 +148,7 @@ msgstr "" msgid "Sort by likes" msgstr "" -#: lib/mindwendel_web/templates/layout/root.html.heex:66 +#: lib/mindwendel_web/templates/layout/app.html.heex:47 #, elixir-autogen, elixir-format msgid "Your brainstormings" msgstr "" @@ -178,7 +178,7 @@ msgstr "" msgid "Export" msgstr "" -#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:50 +#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:49 #, elixir-autogen msgid "Your latest brainstormings" msgstr "" @@ -236,9 +236,9 @@ msgstr "" msgid "yellow" msgstr "" -#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:74 -#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:114 -#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:153 +#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:75 +#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:115 +#: lib/mindwendel_web/live/admin/brainstorming_live/edit.ex:154 #, elixir-autogen, elixir-format msgid "Your brainstorming was not saved." msgstr "Your brainstorming was not saved." @@ -253,12 +253,12 @@ msgstr "Join my brainstorming" msgid "Mindwendel Brainstorming" msgstr "Mindwendel Brainstorming" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:35 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:46 #, elixir-autogen, elixir-format msgid "Share" msgstr "Share" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:164 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:175 #, elixir-autogen, elixir-format msgid "Share brainstorming" msgstr "Share brainstorming" @@ -278,7 +278,7 @@ msgstr "Download as svg" msgid "Brainstorming delete are you sure" msgstr "Are you sure that you want to delete this brainstorming?" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:131 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:142 #, elixir-autogen, elixir-format msgid "Update idea" msgstr "" @@ -304,7 +304,7 @@ msgstr "" msgid "Brainstorming will be deleted %{days}" msgstr "" -#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:62 +#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:59 #, elixir-autogen, elixir-format msgid "Attention: Brainstormings will be deleted %{available_until} after last access!" msgstr "" @@ -314,7 +314,7 @@ msgstr "" msgid "Allow users to change the order of ideas" msgstr "Allow users to change the order of ideas" -#: lib/mindwendel_web/templates/layout/root.html.heex:29 +#: lib/mindwendel_web/templates/layout/app.html.heex:10 #, elixir-autogen, elixir-format msgid "Back" msgstr "" @@ -385,7 +385,7 @@ msgstr "" msgid "Type the label name" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:171 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:183 #, elixir-autogen, elixir-format, fuzzy msgid "%{name} - New Lane" msgstr "" @@ -400,15 +400,15 @@ msgstr "" msgid "Name" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:26 -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:28 -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:114 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:37 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:39 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:125 #: lib/mindwendel_web/live/lane_live/index_component.html.heex:130 #, elixir-autogen, elixir-format msgid "New lane" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:148 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:159 #, elixir-autogen, elixir-format, fuzzy msgid "Update lane" msgstr "" @@ -541,19 +541,19 @@ msgstr "" msgid "Your comment" msgstr "" -#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:75 -#: lib/mindwendel_web/templates/layout/root.html.heex:86 +#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:71 +#: lib/mindwendel_web/templates/layout/app.html.heex:69 #, elixir-autogen, elixir-format msgid "Legal Disclosure" msgstr "" -#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:76 -#: lib/mindwendel_web/templates/layout/root.html.heex:82 +#: lib/mindwendel_web/controllers/static_page_html/home.html.heex:72 +#: lib/mindwendel_web/templates/layout/app.html.heex:65 #, elixir-autogen, elixir-format msgid "Privacy" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:97 +#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:108 #, elixir-autogen, elixir-format msgid "Idea details" msgstr "" @@ -563,7 +563,7 @@ msgstr "" msgid "Give moderating permissions" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:45 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:48 #, elixir-autogen, elixir-format, fuzzy msgid "Brainstorming not found" msgstr "" From 4e2f369a0b5701a5e14e39d08acefb36e3cc08b8 Mon Sep 17 00:00:00 2001 From: Jannik Streek Date: Tue, 17 Dec 2024 17:02:25 +0100 Subject: [PATCH 03/21] fixes --- assets/js/app.js | 2 +- lib/mindwendel_web/components/layouts.ex | 5 +++++ lib/mindwendel_web/templates/layout/app.html.heex | 11 +++++++---- priv/gettext/de/LC_MESSAGES/default.po | 4 ++-- priv/gettext/default.pot | 4 ++-- priv/gettext/en/LC_MESSAGES/default.po | 4 ++-- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 3be1c37b..5eaaf1d1 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -168,7 +168,7 @@ Hooks.StoreRecentBrainstorming = { recentBrainstormings[brainstormingId] = { id: brainstormingId, - admin_url_id: this.el.dataset.adminUrlId, + admin_url_id: this.el.dataset.adminUrlId || recentBrainstormings?.brainstormingId?.admin_url_id, name: this.el.dataset.name, last_accessed_at: this.el.dataset.lastAccessedAt } diff --git a/lib/mindwendel_web/components/layouts.ex b/lib/mindwendel_web/components/layouts.ex index f49e777e..7539a80e 100644 --- a/lib/mindwendel_web/components/layouts.ex +++ b/lib/mindwendel_web/components/layouts.ex @@ -18,6 +18,11 @@ defmodule MindwendelWeb.Layouts do Brainstormings.list_brainstormings_for(user.id, limit) end + def brainstorming_url(id, admin_url_id) do + admin_url_id = admin_url_id || "" + ~p"/brainstormings/#{id}/##{admin_url_id}" + end + def admin_view(current_view) do current_view == MindwendelWeb.Admin.BrainstormingLive.Edit end diff --git a/lib/mindwendel_web/templates/layout/app.html.heex b/lib/mindwendel_web/templates/layout/app.html.heex index d4128ec8..24e05dc9 100644 --- a/lib/mindwendel_web/templates/layout/app.html.heex +++ b/lib/mindwendel_web/templates/layout/app.html.heex @@ -47,11 +47,14 @@ {gettext("Your brainstormings")}
-
+

{gettext("Your latest brainstormings")}

- + <%= for brainstorming <- @brainstormings_stored do %> +
+ <.link href={ + ~p"/brainstormings/#{brainstorming["id"]}/##{brainstorming["admin_url_id"] || ""}" + }> + {brainstorming["name"]} + + + {format_iso8601(brainstorming["last_accessed_at"])} + +
+ <% end %>

{gettext( "Attention: Brainstormings will be deleted %{available_until} after last access!", diff --git a/lib/mindwendel_web/router.ex b/lib/mindwendel_web/router.ex index e0dc7257..f367388c 100644 --- a/lib/mindwendel_web/router.ex +++ b/lib/mindwendel_web/router.ex @@ -38,12 +38,17 @@ defmodule MindwendelWeb.Router do scope "/", MindwendelWeb do pipe_through(:browser) - get("/", StaticPageController, :home) get("/files/:id", FileController, :get_file) get("/legal", StaticPageController, :legal) get("/privacy", StaticPageController, :privacy) + live_session :default, + root_layout: {MindwendelWeb.Layouts, :static_page}, + layout: {MindwendelWeb.Layouts, :app_static} do + live "/", StartLive.Home, :home + end + scope "/admin", Admin, as: :admin do delete("/brainstormings/:id", BrainstormingController, :delete) get("/brainstormings/:id/export", BrainstormingController, :export) diff --git a/lib/mindwendel_web/templates/layout/app_static.html.heex b/lib/mindwendel_web/templates/layout/app_static.html.heex index 6f6d99b0..329efb01 100644 --- a/lib/mindwendel_web/templates/layout/app_static.html.heex +++ b/lib/mindwendel_web/templates/layout/app_static.html.heex @@ -1,4 +1,4 @@ -

+
<%= if Phoenix.Flash.get(@flash, :info) do %>
+
<%= if Phoenix.Flash.get(@flash, :info) do %>

{gettext("Your latest brainstormings")}

- <%= for brainstorming <- @brainstormings_stored do %> -
- <.link href={ - ~p"/brainstormings/#{brainstorming["id"]}/##{brainstorming["admin_url_id"] || ""}" - }> - {brainstorming["name"]} - - - {Timex.from_now(brainstorming["last_accessed_at"])} - -
+ <%= if !Enum.empty?(@brainstormings_stored) do %> +

{gettext("Your latest brainstormings")}

+ <%= for brainstorming <- @brainstormings_stored do %> +
+ <.link href={ + ~p"/brainstormings/#{brainstorming["id"]}/##{brainstorming["admin_url_id"] || ""}" + }> + {brainstorming["name"]} + + + {Timex.from_now(brainstorming["last_accessed_at"])} + +
+ <% end %> +

+ {gettext( + "Attention: Brainstormings will be deleted %{available_until} after last access!", + available_until: brainstormings_available_until() + )} +

<% end %> -

- {gettext( - "Attention: Brainstormings will be deleted %{available_until} after last access!", - available_until: brainstormings_available_until() - )} -

diff --git a/test/mindwendel/local_storage_test.exs b/test/mindwendel/local_storage_test.exs new file mode 100644 index 00000000..46ef3910 --- /dev/null +++ b/test/mindwendel/local_storage_test.exs @@ -0,0 +1,134 @@ +defmodule Mindwendel.LocalStorageTest do + use Mindwendel.DataCase, async: true + alias Mindwendel.Factory + alias Mindwendel.Accounts + + describe "brainstormings_from_local_storage_and_session" do + test "returns empty list when input is nil" do + assert [] == + Mindwendel.LocalStorage.brainstormings_from_local_storage_and_session( + nil, + nil, + nil + ) + end + + test "returns local storage brainstormings" do + local_storage_brainstormings = [ + %{ + "id" => Ecto.UUID.generate(), + "last_accessed_at" => "2024-01-02T00:00:00Z", + "name" => "Brainstorming 2" + }, + %{ + "id" => Ecto.UUID.generate(), + "last_accessed_at" => "2024-01-01T00:00:00Z", + "name" => "Brainstorming 1" + } + ] + + merged_brainstormings = + Mindwendel.LocalStorage.brainstormings_from_local_storage_and_session( + local_storage_brainstormings, + nil, + nil + ) + + assert Enum.map(local_storage_brainstormings, & &1["id"]) == + Enum.map(merged_brainstormings, & &1["id"]) + end + + test "returns session brainstormings without a user" do + session_brainstormings = [ + Factory.insert!(:brainstorming, %{ + last_accessed_at: ~U[2024-12-18 13:10:35Z], + name: "Brainstorming 2" + }), + Factory.insert!(:brainstorming, %{ + last_accessed_at: ~U[2024-12-18 13:10:34Z], + name: "Brainstorming 1" + }) + ] + + merged_brainstormings = + Mindwendel.LocalStorage.brainstormings_from_local_storage_and_session( + nil, + session_brainstormings, + nil + ) + + assert Enum.map(session_brainstormings, & &1.id) == + Enum.map(merged_brainstormings, & &1["id"]) + end + + test "returns session brainstormings without admin_url_id if permission is missing" do + session_brainstormings = [ + Factory.insert!(:brainstorming, %{ + last_accessed_at: ~U[2024-12-18 13:10:35Z], + name: "Brainstorming 2" + }) + ] + + merged_brainstormings = + Mindwendel.LocalStorage.brainstormings_from_local_storage_and_session( + nil, + session_brainstormings, + nil + ) + + assert List.first(merged_brainstormings)["admin_url_id"] == nil + end + + test "returns session brainstormings with admin_url_id" do + moderating_user = Factory.insert!(:user) + brainstorming = Factory.insert!(:brainstorming) + Accounts.add_moderating_user(brainstorming, moderating_user) + + session_brainstormings = [ + brainstorming + ] + + merged_brainstormings = + Mindwendel.LocalStorage.brainstormings_from_local_storage_and_session( + nil, + session_brainstormings, + Accounts.get_user(moderating_user.id) + ) + + refute List.first(merged_brainstormings)["admin_url_id"] == nil + end + + test "returns all brainstormings sorted by last_accessed_at" do + session_brainstormings = [ + Factory.insert!(:brainstorming, %{ + last_accessed_at: ~U[2024-12-18 13:10:35Z], + name: "Brainstorming 2" + }) + ] + + local_storage_brainstormings = [ + %{ + "id" => Ecto.UUID.generate(), + "last_accessed_at" => "2024-01-02T00:00:00Z", + "name" => "Brainstorming 2" + }, + %{ + "id" => Ecto.UUID.generate(), + "last_accessed_at" => "2024-01-01T00:00:00Z", + "name" => "Brainstorming 1" + } + ] + + merged_brainstormings = + Mindwendel.LocalStorage.brainstormings_from_local_storage_and_session( + local_storage_brainstormings, + session_brainstormings, + nil + ) + + assert Enum.map(session_brainstormings, & &1.id) ++ + Enum.map(local_storage_brainstormings, & &1["id"]) == + Enum.map(merged_brainstormings, & &1["id"]) + end + end +end diff --git a/test/mindwendel/permissions_test.exs b/test/mindwendel/permissions_test.exs new file mode 100644 index 00000000..c1360340 --- /dev/null +++ b/test/mindwendel/permissions_test.exs @@ -0,0 +1,25 @@ +defmodule Mindwendel.PermissionsTest do + use Mindwendel.DataCase, async: true + alias Mindwendel.Factory + alias Mindwendel.Accounts + alias Mindwendel.Permissions + + describe "has_moderating_permission" do + test "returns true if user is moderating" do + moderating_user = Factory.insert!(:user) + brainstorming = Factory.insert!(:brainstorming) + Accounts.add_moderating_user(brainstorming, moderating_user) + + assert Permissions.has_moderating_permission( + brainstorming, + Accounts.get_user(moderating_user.id) + ) + end + + test "returns false if user is not moderating" do + user = Factory.insert!(:user) + brainstorming = Factory.insert!(:brainstorming) + refute Permissions.has_moderating_permission(brainstorming, Accounts.get_user(user.id)) + end + end +end diff --git a/test/mindwendel_web/controllers/static_page_controller_test.exs b/test/mindwendel_web/live/start_live_test.exs similarity index 56% rename from test/mindwendel_web/controllers/static_page_controller_test.exs rename to test/mindwendel_web/live/start_live_test.exs index 2a14ec5f..328c59c5 100644 --- a/test/mindwendel_web/controllers/static_page_controller_test.exs +++ b/test/mindwendel_web/live/start_live_test.exs @@ -1,32 +1,28 @@ -defmodule MindwendelWeb.StaticPageControllerTest do +defmodule MindwendelWeb.StartLiveTest do use MindwendelWeb.ConnCase, async: true + import Phoenix.LiveViewTest describe "home without current_user_id in session" do test "contains text", %{conn: conn} do - html = - conn - |> get(~p"/") - |> html_response(200) + {:ok, _show_live, html} = live(conn, ~p"/") assert html =~ "mindwendel" assert html =~ "Brainstorm" end - test "sets current_user_id in session", %{conn: conn} do - conn = get(conn, ~p"/") - refute Mindwendel.Services.SessionService.get_current_user_id(conn) == nil - end - test "shows a form to create a new brainstorming", %{conn: conn} do - html = - conn - |> get(~p"/") - |> html_response(200) + {:ok, _show_live, html} = live(conn, ~p"/") assert html =~ ~r/form.*action="\/brainstormings"/i assert html =~ ~r/ Date: Wed, 18 Dec 2024 14:30:33 +0100 Subject: [PATCH 19/21] another test --- test/mindwendel/local_storage_test.exs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/mindwendel/local_storage_test.exs b/test/mindwendel/local_storage_test.exs index 46ef3910..df37d4dd 100644 --- a/test/mindwendel/local_storage_test.exs +++ b/test/mindwendel/local_storage_test.exs @@ -130,5 +130,31 @@ defmodule Mindwendel.LocalStorageTest do Enum.map(local_storage_brainstormings, & &1["id"]) == Enum.map(merged_brainstormings, & &1["id"]) end + + test "returns no duplicated brainstormings" do + session_brainstormings = [ + Factory.insert!(:brainstorming, %{ + last_accessed_at: ~U[2024-12-18 13:10:35Z], + name: "Brainstorming 2" + }) + ] + + local_storage_brainstormings = [ + %{ + "id" => List.first(session_brainstormings).id, + "last_accessed_at" => "2024-01-02T00:00:00Z", + "name" => "Brainstorming 2" + } + ] + + merged_brainstormings = + Mindwendel.LocalStorage.brainstormings_from_local_storage_and_session( + local_storage_brainstormings, + session_brainstormings, + nil + ) + + assert length(merged_brainstormings) == 1 + end end end From b69eb5c78523fd7e9e695afb71bde0acc1587f6f Mon Sep 17 00:00:00 2001 From: Jannik Streek Date: Wed, 18 Dec 2024 14:31:38 +0100 Subject: [PATCH 20/21] update locals --- priv/gettext/de/LC_MESSAGES/default.po | 8 ++++---- priv/gettext/default.pot | 8 ++++---- priv/gettext/en/LC_MESSAGES/default.po | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/priv/gettext/de/LC_MESSAGES/default.po b/priv/gettext/de/LC_MESSAGES/default.po index 0e55a7ab..41dc2795 100644 --- a/priv/gettext/de/LC_MESSAGES/default.po +++ b/priv/gettext/de/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "Editiere Brainstorming" msgid "Export" msgstr "Export" -#: lib/mindwendel_web/live/start_live/home.html.heex:53 +#: lib/mindwendel_web/live/start_live/home.html.heex:54 #, elixir-autogen msgid "Your latest brainstormings" msgstr "Deine letzten Brainstormings" @@ -304,7 +304,7 @@ msgstr "Leere das Brainstorming" msgid "Brainstorming will be deleted %{days}" msgstr "Brainstorming wird gelöscht %{days}" -#: lib/mindwendel_web/live/start_live/home.html.heex:67 +#: lib/mindwendel_web/live/start_live/home.html.heex:68 #, elixir-autogen, elixir-format msgid "Attention: Brainstormings will be deleted %{available_until} after last access!" msgstr "Achtung: Brainstormings werden %{available_until} nach dem letzten Zugriff gelöscht!" @@ -541,13 +541,13 @@ msgstr "Zeige Idee" msgid "Your comment" msgstr "Kommentar" -#: lib/mindwendel_web/live/start_live/home.html.heex:79 +#: lib/mindwendel_web/live/start_live/home.html.heex:81 #: lib/mindwendel_web/templates/layout/app.html.heex:69 #, elixir-autogen, elixir-format msgid "Legal Disclosure" msgstr "Impressum" -#: lib/mindwendel_web/live/start_live/home.html.heex:80 +#: lib/mindwendel_web/live/start_live/home.html.heex:82 #: lib/mindwendel_web/templates/layout/app.html.heex:65 #, elixir-autogen, elixir-format msgid "Privacy" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 062f9b07..c94c11b4 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -177,7 +177,7 @@ msgstr "" msgid "Export" msgstr "" -#: lib/mindwendel_web/live/start_live/home.html.heex:53 +#: lib/mindwendel_web/live/start_live/home.html.heex:54 #, elixir-autogen msgid "Your latest brainstormings" msgstr "" @@ -303,7 +303,7 @@ msgstr "" msgid "Brainstorming will be deleted %{days}" msgstr "" -#: lib/mindwendel_web/live/start_live/home.html.heex:67 +#: lib/mindwendel_web/live/start_live/home.html.heex:68 #, elixir-autogen, elixir-format msgid "Attention: Brainstormings will be deleted %{available_until} after last access!" msgstr "" @@ -540,13 +540,13 @@ msgstr "" msgid "Your comment" msgstr "" -#: lib/mindwendel_web/live/start_live/home.html.heex:79 +#: lib/mindwendel_web/live/start_live/home.html.heex:81 #: lib/mindwendel_web/templates/layout/app.html.heex:69 #, elixir-autogen, elixir-format msgid "Legal Disclosure" msgstr "" -#: lib/mindwendel_web/live/start_live/home.html.heex:80 +#: lib/mindwendel_web/live/start_live/home.html.heex:82 #: lib/mindwendel_web/templates/layout/app.html.heex:65 #, elixir-autogen, elixir-format msgid "Privacy" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index c2a0b7ff..977877fc 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -178,7 +178,7 @@ msgstr "" msgid "Export" msgstr "" -#: lib/mindwendel_web/live/start_live/home.html.heex:53 +#: lib/mindwendel_web/live/start_live/home.html.heex:54 #, elixir-autogen msgid "Your latest brainstormings" msgstr "" @@ -304,7 +304,7 @@ msgstr "" msgid "Brainstorming will be deleted %{days}" msgstr "" -#: lib/mindwendel_web/live/start_live/home.html.heex:67 +#: lib/mindwendel_web/live/start_live/home.html.heex:68 #, elixir-autogen, elixir-format msgid "Attention: Brainstormings will be deleted %{available_until} after last access!" msgstr "" @@ -541,13 +541,13 @@ msgstr "" msgid "Your comment" msgstr "" -#: lib/mindwendel_web/live/start_live/home.html.heex:79 +#: lib/mindwendel_web/live/start_live/home.html.heex:81 #: lib/mindwendel_web/templates/layout/app.html.heex:69 #, elixir-autogen, elixir-format msgid "Legal Disclosure" msgstr "" -#: lib/mindwendel_web/live/start_live/home.html.heex:80 +#: lib/mindwendel_web/live/start_live/home.html.heex:82 #: lib/mindwendel_web/templates/layout/app.html.heex:65 #, elixir-autogen, elixir-format msgid "Privacy" From 6feb3aaf7f645a271fd66702f2b623e0356e4b0e Mon Sep 17 00:00:00 2001 From: Jannik Streek Date: Wed, 18 Dec 2024 22:30:24 +0100 Subject: [PATCH 21/21] fix last problems when accessing --- lib/mindwendel_web/live/start_live/home.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/mindwendel_web/live/start_live/home.ex b/lib/mindwendel_web/live/start_live/home.ex index ed392cc2..345e08a7 100644 --- a/lib/mindwendel_web/live/start_live/home.ex +++ b/lib/mindwendel_web/live/start_live/home.ex @@ -29,7 +29,9 @@ defmodule MindwendelWeb.StartLive.Home do valid_stored_brainstormings = LocalStorage.brainstormings_from_local_storage_and_session( brainstormings_stored, - Brainstormings.list_brainstormings_for(socket.assigns.current_user.id), + Brainstormings.list_brainstormings_for( + get_in(socket.assigns, [Access.key(:current_user), Access.key(:id)]) + ), socket.assigns.current_user )