Skip to content

Commit

Permalink
feature: show deletion date on ideation page #267 (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwittstruck authored Mar 27, 2024
1 parent 2b3b15d commit 5c054aa
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 97 deletions.
6 changes: 5 additions & 1 deletion assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
// We include this here, so esbuild can handle e.g. copying fonts to the /priv/static/assets directory
import "../scss/app.css";

import { Modal } from "bootstrap"
import { Modal, Tooltip } from "bootstrap"

// activate all tooltips:
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new Tooltip(tooltipTriggerEl))

// webpack automatically bundles all modules in your
// entry points. Those entry points can be configured
Expand Down
2 changes: 2 additions & 0 deletions assets/scss/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ $bootstrap-icons-font-dir: "../node_modules/bootstrap-icons/font/fonts/";
@import "../node_modules/bootstrap-icons/font/bootstrap-icons";
@import "live/idea_live/_index_component.scss";

@import "live/brainstorming_live/_show.scss";

.footer {
height: 40px;
}
Expand Down
8 changes: 8 additions & 0 deletions assets/scss/live/brainstorming_live/_show.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.deletion-date-hint-tooltip {
--bs-tooltip-bg: #6c757d;
--bs-tooltip-color: var(--bs-white);
}

.tooltip.show {
opacity: 1.0;
}
14 changes: 14 additions & 0 deletions lib/mindwendel/brainstormings/brainstorming.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,18 @@ defmodule Mindwendel.Brainstormings.Brainstorming do
%IdeaLabel{name: gettext("yellow"), color: "#ffc107", position_order: 4}
]
end

def brainstorming_available_until(brainstorming) do
available_until =
Timex.shift(brainstorming.inserted_at,
days:
Application.fetch_env!(:mindwendel, :options)[:feature_brainstorming_removal_after_days]
)

Timex.format!(
available_until,
"{relative}",
:relative
)
end
end
7 changes: 0 additions & 7 deletions lib/mindwendel_web/live/admin/brainstorming_live/edit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,6 @@ defmodule MindwendelWeb.Admin.BrainstormingLive.Edit do
end
end

def brainstorming_available_until(brainstorming) do
Timex.shift(brainstorming.inserted_at,
days:
Application.fetch_env!(:mindwendel, :options)[:feature_brainstorming_removal_after_days]
)
end

defp cancel_changeset_timer(socket) do
if socket.assigns[:reset_changeset_timer_ref],
do: Process.cancel_timer(socket.assigns.reset_changeset_timer_ref)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@
) %>
<br />
<p>
(<%= gettext("Brainstorming will be deleted ") %> <%= Timex.format!(
brainstorming_available_until(@brainstorming),
"{relative}",
:relative
) %>)
(<%= brainstorming_available_until_full_text(@brainstorming) %>)
</p>
</div>
</div>
Expand Down
10 changes: 10 additions & 0 deletions lib/mindwendel_web/live/brainstorming_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
<i class="bi-gear-fill"></i>
<% end %>
<% end %>

<div
class="deletion-date-hint btn btn-outline-secondary m-1"
data-bs-toggle="tooltip"
data-bs-placement="auto"
data-bs-custom-class="deletion-date-hint-tooltip"
data-bs-title={brainstorming_available_until_full_text(@brainstorming)}
>
<i class="bi-calendar-x"></i> <%= brainstorming_available_until(@brainstorming) %>
</div>
</div>
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions lib/mindwendel_web/live/live_helpers.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
defmodule MindwendelWeb.LiveHelpers do
import Phoenix.LiveView.Helpers
import MindwendelWeb.Gettext

alias Mindwendel.Brainstormings.Brainstorming

@doc """
Renders a component inside the `MindwendelWeb.ModalComponent` component.
Expand All @@ -24,4 +27,14 @@ defmodule MindwendelWeb.LiveHelpers do
def uuid do
Ecto.UUID.generate()
end

def brainstorming_available_until_full_text(brainstorming) do
gettext("Brainstorming will be deleted in %{days}",
days: Brainstorming.brainstorming_available_until(brainstorming)
)
end

def brainstorming_available_until(brainstorming) do
Brainstorming.brainstorming_available_until(brainstorming)
end
end
56 changes: 28 additions & 28 deletions priv/gettext/de/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ msgstr "%{name} - Neue Idee"
msgid "Are you sure you want to delete this idea?"
msgstr "Möchtest du die Idee löschen?"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:199
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:195
#, elixir-autogen, elixir-format
msgid "Attention: This will delete the brainstorming with all belonging ideas and other associated records to it. This cant be undone"
msgstr "Achtung: Hiermit löschst du das Brainstorming und alle dazugehörigen Ideen. Diese Aktion kann nicht rückgängig gemacht werden."
Expand All @@ -67,22 +67,22 @@ msgstr "Erstelle ein Brainstorming."
msgid "Create!"
msgstr "Erstellen!"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:203
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:199
#, elixir-autogen, elixir-format
msgid "Delete"
msgstr "Löschen"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:193
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:189
#, elixir-autogen, elixir-format
msgid "Delete Brainstorming"
msgstr "Lösche Brainstorming"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:177
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:173
#, elixir-autogen, elixir-format
msgid "Export to CSV"
msgstr "Export als CSV"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:184
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:180
#, elixir-autogen, elixir-format
msgid "Export to HTML"
msgstr "Export als HTML"
Expand All @@ -98,7 +98,7 @@ msgid "Idea created successfully"
msgstr "Idee erstellt"

#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:25
#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:107
#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:117
#, elixir-autogen, elixir-format
msgid "New Idea"
msgstr "Neue Idee"
Expand All @@ -108,7 +108,7 @@ msgstr "Neue Idee"
msgid "New brainstorming"
msgstr "Neues Brainstorming"

#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:64
#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:74
#, elixir-autogen, elixir-format
msgid "New idea"
msgstr "Neue Idee"
Expand All @@ -123,7 +123,7 @@ msgstr "Neue Idee (Hotkey: i)"
msgid "No ideas brainstormed"
msgstr "Bisher keine Ideen"

#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:110
#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:120
#, elixir-autogen, elixir-format
msgid "Open new idea page (Hotkey: i)"
msgstr "Öffne neue Ideen Dialog (Hotkey: i)"
Expand Down Expand Up @@ -190,12 +190,12 @@ msgstr "Brainstorming erfolgreich gelöscht"
msgid "Your brainstorming was created successfully! Share the link with other people and start brainstorming."
msgstr "Dein Brainstorming wurde erstellt! Teile den Link mit anderen Personen und legt los."

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:59
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:55
#, elixir-autogen, elixir-format
msgid "Edit Brainstorming"
msgstr "Editiere Brainstorming"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:174
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:170
#, elixir-autogen, elixir-format
msgid "Export"
msgstr "Export"
Expand Down Expand Up @@ -231,37 +231,32 @@ msgstr "Von"
msgid "Administration for brainstorming: %{name}"
msgstr "Administration für: %{name}"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:89
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:85
#, elixir-autogen, elixir-format
msgid "Show brainstorming settings link for all users"
msgstr "Zeige Link zur Administration für alle Nutzer"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:95
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:91
#, elixir-autogen, elixir-format
msgid "Warning: Please make sure you save the admin link at the top, before hiding the settings link!"
msgstr "Achtung: Bitte speichere den Admin-Link oben ab, bevor du den Link zur Administration versteckst."

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:48
#, elixir-autogen, elixir-format
msgid "Brainstorming will be deleted "
msgstr "Brainstorming wird gelöscht in "

#: lib/mindwendel_web/templates/static_page/home.html.heex:34
#, elixir-autogen, elixir-format
msgid "Brainstormings will be deleted after %{days} days."
msgstr "Brainstormings werden nach %{days} Tagen gelöscht."

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:123
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:119
#, elixir-autogen, elixir-format
msgid "Choose the label color"
msgstr "Wähle die Farbe für das Label aus"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:112
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:108
#, elixir-autogen, elixir-format
msgid "Edit Brainstorming Labels"
msgstr "Editiere Brainstorming Labels"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:128
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:124
#, elixir-autogen, elixir-format
msgid "Type the label name"
msgstr "Gebe dem Label einen Namen"
Expand Down Expand Up @@ -291,19 +286,19 @@ msgstr "Rot"
msgid "yellow"
msgstr "Gelb"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:164
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:160
#, elixir-autogen, elixir-format
msgid "Add idea label"
msgstr "Neues Label"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:137
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:133
#, elixir-autogen, elixir-format
msgid "Remove idea label"
msgstr "Löschen"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:76
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:103
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:153
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:72
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:99
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:149
#, elixir-autogen, elixir-format
msgid "Saved"
msgstr "Gespeichert"
Expand Down Expand Up @@ -333,7 +328,7 @@ msgstr "Mindwendel Brainstorming"
msgid "Share"
msgstr "Teilen"

#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:88
#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:98
#, elixir-autogen, elixir-format
msgid "Share brainstorming"
msgstr "Teile Dein Brainstorming"
Expand All @@ -348,7 +343,7 @@ msgstr "Download als PNG"
msgid "Download as svg"
msgstr "Download als SVG"

#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:204
#: lib/mindwendel_web/live/admin/brainstorming_live/edit.html.heex:200
#, elixir-autogen, elixir-format, fuzzy
msgid "Brainstorming delete are you sure"
msgstr "Bist du sicher, dass das Brainstorming gelöscht werden soll?"
Expand All @@ -363,7 +358,12 @@ msgstr ""
msgid "Idea created updated"
msgstr ""

#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:76
#: lib/mindwendel_web/live/brainstorming_live/show.html.heex:86
#, elixir-autogen, elixir-format
msgid "Update idea"
msgstr ""

#: lib/mindwendel_web/live/live_helpers.ex:32
#, elixir-autogen, elixir-format, fuzzy
msgid "Brainstorming will be deleted in %{days}"
msgstr "Brainstorming wird gelöscht in "
Loading

0 comments on commit 5c054aa

Please sign in to comment.