From 9705fd44287289e4a58c09b8a8a84a08849f0974 Mon Sep 17 00:00:00 2001 From: nwittstruck Date: Thu, 25 Jan 2024 13:15:34 +0100 Subject: [PATCH] chore: upgrade phoenix to 1.7.10 --- .formatter.exs | 12 +- .../admin/brainstorming_live/edit.html.heex | 122 +++++++++++++----- .../share_component.html.heex | 11 +- .../live/brainstorming_live/show.html.heex | 42 ++++-- .../live/idea_live/form_component.html.heex | 27 ++-- .../live/idea_live/index_component.html.heex | 43 ++++-- lib/mindwendel_web/live/modal_component.ex | 30 +++-- .../admin/brainstorming/export.html.heex | 5 +- .../templates/error/error_page.html.heex | 19 ++- .../templates/layout/app.html.heex | 4 +- .../templates/layout/live.html.heex | 12 +- .../templates/layout/root.html.heex | 56 +++++--- .../templates/layout/static_page.html.heex | 19 ++- .../templates/static_page/home.html.heex | 47 ++++--- mix.exs | 6 +- mix.lock | 4 +- 16 files changed, 311 insertions(+), 148 deletions(-) diff --git a/.formatter.exs b/.formatter.exs index d336cda1..ef8840ce 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,10 +1,6 @@ [ - import_deps: [:ecto, :phoenix], - inputs: [ - "*.{ex,exs}", - "priv/repo/data_migrations/*.{ex,exs}", - "priv/*/seeds.exs", - "{config,lib,test}/**/*.{ex,exs}" - ], - subdirectories: ["priv/*/migrations"] + import_deps: [:ecto, :ecto_sql, :phoenix], + subdirectories: ["priv/*/migrations"], + plugins: [Phoenix.LiveView.HTMLFormatter], + inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"] ] diff --git a/lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex b/lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex index cc97c790..001bb3b1 100644 --- a/lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex +++ b/lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex @@ -1,6 +1,8 @@
-

<%= gettext("Administration for brainstorming: %{name}", name: @brainstorming.name) %>

+

+ <%= gettext("Administration for brainstorming: %{name}", name: @brainstorming.name) %> +

<%= gettext("Save this link to update / delete your brainstorming later on:") %>

@@ -12,7 +14,7 @@ id="brainstorming-link-input-readonly" readonly="true" type="text" - value={ URI.to_string(@uri) } + value={URI.to_string(@uri)} />

- <%= link gettext("Proceed to your brainstorming"), to: Routes.brainstorming_show_path(@socket, :show, @brainstorming), class: "fw-bold" %> + <%= link(gettext("Proceed to your brainstorming"), + to: Routes.brainstorming_show_path(@socket, :show, @brainstorming), + class: "fw-bold" + ) %>
-

(<%= gettext("Brainstorming will be deleted ") %> <%= Timex.format!(brainstorming_available_until(@brainstorming), "{relative}", :relative) %>)

+

+ (<%= gettext("Brainstorming will be deleted ") %> <%= Timex.format!( + brainstorming_available_until(@brainstorming), + "{relative}", + :relative + ) %>) +

@@ -50,9 +61,14 @@
<%= form_for @changeset, "#", [phx_submit: :save, phx_change: :save, id: "form-edit-brainstorming"], fn f -> %>
- <%= label f, :name, class: "form-label" %> - <%= text_input f, :name, class: "form-control #{if f.errors[:name], do: "is-invalid"} #{if f.source.changes[:name], do: "is-valid"}", phx_debounce: 500, phx_feedback_for: input_id(f, :name) %> - <%= error_tag_tooltip f, :name %> + <%= label(f, :name, class: "form-label") %> + <%= text_input(f, :name, + class: + "form-control #{if f.errors[:name], do: "is-invalid"} #{if f.source.changes[:name], do: "is-valid"}", + phx_debounce: 500, + phx_feedback_for: input_id(f, :name) + ) %> + <%= error_tag_tooltip(f, :name) %> <%= content_tag(:div, class: "valid-tooltip", phx_feedback_for: input_id(f, :name) @@ -62,15 +78,23 @@
- <%= checkbox f, :option_show_link_to_settings, id: "checkbox-option-show-link-to-settings", class: "form-check-input #{if f.source.changes[:option_show_link_to_settings] != nil, do: "is-valid"}" %> - <%= label f, :option_show_link_to_settings, - gettext("Show brainstorming settings link for all users"), - for: "checkbox-option-show-link-to-settings", - class: "form-check-label" - %> + <%= checkbox(f, :option_show_link_to_settings, + id: "checkbox-option-show-link-to-settings", + class: + "form-check-input #{if f.source.changes[:option_show_link_to_settings] != nil, do: "is-valid"}" + ) %> + <%= label( + f, + :option_show_link_to_settings, + gettext("Show brainstorming settings link for all users"), + for: "checkbox-option-show-link-to-settings", + class: "form-check-label" + ) %>
- <%= gettext("Warning: Please make sure you save the admin link at the top, before hiding the settings link!") %> + <%= gettext( + "Warning: Please make sure you save the admin link at the top, before hiding the settings link!" + ) %> <%= content_tag(:div, class: "valid-tooltip", @@ -93,30 +117,53 @@
<%= inputs_for f, :labels, fn p -> %>
- <%= color_input p, :color, class: "form-control form-control-color #{if p.errors[:color], do: "is-invalid"} #{if p.source.changes[:name] || p.source.changes[:color], do: "border-success"}", style: "max-width: 50px", title: gettext("Choose the label color") %> - <%= text_input p, :name, class: "form-control #{if p.errors[:name] || p.errors[:idea_idea_labels] || f.errors[:labels], do: "is-invalid"} #{if p.source.changes[:name] || p.source.changes[:color], do: "is-valid"}", placeholder: gettext("Type the label name"), phx_debounce: 500 %> - - <%= error_tag_tooltip p, :color %> - <%= error_tag_tooltip p, :name %> + <%= color_input(p, :color, + class: + "form-control form-control-color #{if p.errors[:color], do: "is-invalid"} #{if p.source.changes[:name] || p.source.changes[:color], do: "border-success"}", + style: "max-width: 50px", + title: gettext("Choose the label color") + ) %> + <%= text_input(p, :name, + class: + "form-control #{if p.errors[:name] || p.errors[:idea_idea_labels] || f.errors[:labels], do: "is-invalid"} #{if p.source.changes[:name] || p.source.changes[:color], do: "is-valid"}", + placeholder: gettext("Type the label name"), + phx_debounce: 500 + ) %> + + <%= error_tag_tooltip(p, :color) %> + <%= error_tag_tooltip(p, :name) %> <%= if message = p.errors[:idea_idea_labels] do %> - - <%= translate_error(message) %> + + + <%= translate_error(message) %> + <% end %> <%= if message = f.errors[:labels] do %> - <%= translate_error(message) %> + + <%= translate_error(message) %> + <% end %> <%= content_tag(:span, class: "valid-tooltip", phx_feedback_for: input_id(f, :labels)) do %> <%= gettext("Saved") %> <% end %>
<% end %> - <%= error_tag_tooltip f, :labels %> + <%= error_tag_tooltip(f, :labels) %>
- +
<% end %> @@ -128,8 +175,17 @@

<%= gettext("Export") %>

- <%= link gettext("Export to CSV"), to: Routes.admin_brainstorming_path(@socket, :export, @brainstorming.admin_url_id, _format: "csv"), class: "fw-bold"%>
- <%= link gettext("Export to HTML"), to: Routes.admin_brainstorming_path(@socket, :export, @brainstorming.admin_url_id), class: "fw-bold" %> + <%= link(gettext("Export to CSV"), + to: + Routes.admin_brainstorming_path(@socket, :export, @brainstorming.admin_url_id, + _format: "csv" + ), + class: "fw-bold" + ) %>
+ <%= link(gettext("Export to HTML"), + to: Routes.admin_brainstorming_path(@socket, :export, @brainstorming.admin_url_id), + class: "fw-bold" + ) %>
@@ -141,14 +197,16 @@

- <%= gettext("Attention: This will delete the brainstorming with all belonging ideas and other associated records to it. This cant be undone") %> + <%= gettext( + "Attention: This will delete the brainstorming with all belonging ideas and other associated records to it. This cant be undone" + ) %>

- <%= button gettext("Delete"), + <%= button(gettext("Delete"), "data-confirm": gettext("Brainstorming delete are you sure"), class: "btn btn-danger", method: :delete, to: Routes.admin_brainstorming_path(@socket, :delete, @brainstorming.admin_url_id) - %> + ) %>
diff --git a/lib/mindwendel_web/live/brainstorming_live/share_component.html.heex b/lib/mindwendel_web/live/brainstorming_live/share_component.html.heex index 86564cb4..a7cdfa9d 100644 --- a/lib/mindwendel_web/live/brainstorming_live/share_component.html.heex +++ b/lib/mindwendel_web/live/brainstorming_live/share_component.html.heex @@ -1,4 +1,3 @@ -
@@ -33,15 +32,11 @@
-
+
-
@@ -59,7 +54,6 @@ <%= gettext("Download as svg") %>   - <%= gettext("Download as png") %> -
diff --git a/lib/mindwendel_web/live/brainstorming_live/show.html.heex b/lib/mindwendel_web/live/brainstorming_live/show.html.heex index d99823d7..089ba83f 100644 --- a/lib/mindwendel_web/live/brainstorming_live/show.html.heex +++ b/lib/mindwendel_web/live/brainstorming_live/show.html.heex @@ -5,7 +5,8 @@ <%= if @inspiration do %>

+ +

<%= @inspiration.title %> @@ -21,7 +22,11 @@

- <%= live_patch gettext("New Idea"), to: Routes.brainstorming_show_path(@socket, :new_idea, @brainstorming), class: "btn btn-primary m-1", title: gettext("New idea page (Hotkey: i)") %> + <%= live_patch(gettext("New Idea"), + to: Routes.brainstorming_show_path(@socket, :new_idea, @brainstorming), + class: "btn btn-primary m-1", + title: gettext("New idea page (Hotkey: i)") + ) %> <%= link to: "#", class: "btn btn-primary m-1", phx_click: "sort_by_likes", phx_value_id: @brainstorming.id, title: gettext("Sort by likes") do %> <%= gettext("Sort by likes") %> <% end %> @@ -44,38 +49,41 @@
<%= if @live_action in [:edit] do %> - <%= live_modal MindwendelWeb.BrainstormingLive.FormComponent, + <%= live_modal(MindwendelWeb.BrainstormingLive.FormComponent, id: @brainstorming.id, title: @page_title, action: @live_action, brainstorming: @brainstorming, - return_to: Routes.brainstorming_show_path(@socket, :show, @brainstorming) %> + return_to: Routes.brainstorming_show_path(@socket, :show, @brainstorming) + ) %> <% end %> <%= if @live_action in [:new_idea] do %> - <%= live_modal MindwendelWeb.IdeaLive.FormComponent, + <%= live_modal(MindwendelWeb.IdeaLive.FormComponent, id: :new, title: gettext("New idea"), action: :new, brainstorming: @brainstorming, current_user: @current_user, idea: @idea, - return_to: Routes.brainstorming_show_path(@socket, :show, @brainstorming) %> + return_to: Routes.brainstorming_show_path(@socket, :show, @brainstorming) + ) %> <% end %> <%= if @live_action in [:edit_idea] do %> - <%= live_modal MindwendelWeb.IdeaLive.FormComponent, + <%= live_modal(MindwendelWeb.IdeaLive.FormComponent, id: :update, title: gettext("Update idea"), action: :update, brainstorming: @brainstorming, current_user: @current_user, idea: @idea, - return_to: Routes.brainstorming_show_path(@socket, :show, @brainstorming) %> + return_to: Routes.brainstorming_show_path(@socket, :show, @brainstorming) + ) %> <% end %> <%= if @live_action in [:share] do %> - <%= live_modal MindwendelWeb.BrainstormingLive.ShareComponent, + <%= live_modal(MindwendelWeb.BrainstormingLive.ShareComponent, id: :share, title: gettext("Share brainstorming"), action: :share, @@ -83,14 +91,24 @@ current_user: @current_user, uri: Routes.brainstorming_show_url(@socket, :show, @brainstorming), modal_size: "modal-lg", - return_to: Routes.brainstorming_show_path(@socket, :show, @brainstorming) %> + return_to: Routes.brainstorming_show_path(@socket, :show, @brainstorming) + ) %> <% end %> - <%= live_component MindwendelWeb.IdeaLive.IndexComponent, ideas: @ideas, brainstorming: @brainstorming, id: @brainstorming.id, current_user: @current_user %> + <%= live_component(MindwendelWeb.IdeaLive.IndexComponent, + ideas: @ideas, + brainstorming: @brainstorming, + id: @brainstorming.id, + current_user: @current_user + ) %>
- <%= live_patch gettext("New Idea"), to: Routes.brainstorming_show_path(@socket, :new_idea, @brainstorming), class: "btn btn-primary", title: gettext("Open new idea page (Hotkey: i)") %> + <%= live_patch(gettext("New Idea"), + to: Routes.brainstorming_show_path(@socket, :new_idea, @brainstorming), + class: "btn btn-primary", + title: gettext("Open new idea page (Hotkey: i)") + ) %>
diff --git a/lib/mindwendel_web/live/idea_live/form_component.html.heex b/lib/mindwendel_web/live/idea_live/form_component.html.heex index 4269d9e3..f981d601 100644 --- a/lib/mindwendel_web/live/idea_live/form_component.html.heex +++ b/lib/mindwendel_web/live/idea_live/form_component.html.heex @@ -1,7 +1,6 @@
<%= form_for @changeset, "#", [id: "idea-form", phx_target: @myself, phx_change: "validate", phx_submit: "save"], fn f -> %> - - <%= hidden_input f, :id %> + <%= hidden_input(f, :id) %> <%= if Enum.count(f.errors) > 0 do %>
@@ -10,24 +9,34 @@ <% end %>
- <%= label f, gettext("Username") %> - <%= text_input f, :username, class: "form-control" %> + <%= label(f, gettext("Username")) %> + <%= text_input(f, :username, class: "form-control") %> <%= if message = f.errors[:username] do %> <%= translate_error(message) %> <% end %>
- <%= label f, :body, gettext("Your idea") %> - <%= textarea f, :body, class: "form-control" %> + <%= label(f, :body, gettext("Your idea")) %> + <%= textarea(f, :body, class: "form-control") %> <%= if message = f.errors[:body] do %> <%= translate_error(message) %> <% end %>

- <%= hidden_input f, :brainstorming_id %> + <%= hidden_input(f, :brainstorming_id) %> - <%= live_patch gettext("Close"), to: @return_to, id: "idea-modal-cancel", class: "btn btn-secondary form-cancel me-2", phx_update: "ignore" %> - <%= submit gettext("Save"), to: @return_to, phx_disable_with: gettext("Saving..."), class: "btn btn-primary", disabled: !@changeset.valid? %> + <%= live_patch(gettext("Close"), + to: @return_to, + id: "idea-modal-cancel", + class: "btn btn-secondary form-cancel me-2", + phx_update: "ignore" + ) %> + <%= submit(gettext("Save"), + to: @return_to, + phx_disable_with: gettext("Saving..."), + class: "btn btn-primary", + disabled: !@changeset.valid? + ) %> <% end %>
diff --git a/lib/mindwendel_web/live/idea_live/index_component.html.heex b/lib/mindwendel_web/live/idea_live/index_component.html.heex index 500a6141..6edcf371 100644 --- a/lib/mindwendel_web/live/idea_live/index_component.html.heex +++ b/lib/mindwendel_web/live/idea_live/index_component.html.heex @@ -2,7 +2,10 @@
<%= for idea <- @ideas do %>
-
+
<%= if @current_user.id in [idea.user_id | @brainstorming.moderating_users |> Enum.map(& &1.id)] do %> <%= link to: "#", class: "float-end ms-3 mb-3", phx_click: "delete", phx_target: @myself, phx_value_id: idea.id, title: 'Delete', data: [confirm: gettext("Are you sure you want to delete this idea?")] do %> @@ -14,7 +17,13 @@ <% end %> <%= for idea_label <- Enum.sort_by(idea.idea_labels, &(&1.position_order)) do %> - <%= idea_label.name %> + + <%= idea_label.name %> + <% end %> <%= unless idea.link do %> @@ -28,24 +37,30 @@
- <%= img_tag idea.link.img_preview_url, style: "width: 100px; margin: auto; display: block;" %> + <%= img_tag(idea.link.img_preview_url, + style: "width: 100px; margin: auto; display: block;" + ) %>
- <%= content_tag :p, idea.link.title, class: "fw-bold" %> - <%= content_tag :p, idea.link.description %> + <%= content_tag(:p, idea.link.title, class: "fw-bold") %> + <%= content_tag(:p, idea.link.description) %>
<% end %>