feat: TUI tags panels (cloud, manage, merge) wired to the shared tags backend (issue #34)
This commit is contained in:
@@ -7,7 +7,6 @@ defmodule BDS.Desktop.ShellLive.TagsEditor do
|
||||
|
||||
alias BDS.{Repo, Tags}
|
||||
alias BDS.Desktop.ShellLive.Notify
|
||||
alias BDS.Posts.Post
|
||||
alias BDS.Tags.Tag
|
||||
alias BDS.Templates.Template
|
||||
use Gettext, backend: BDS.Gettext
|
||||
@@ -16,12 +15,8 @@ defmodule BDS.Desktop.ShellLive.TagsEditor do
|
||||
|
||||
@tags_sections ~w(cloud manage merge)
|
||||
|
||||
@colour_presets ~w(
|
||||
#ef4444 #f97316 #f59e0b #eab308 #84cc16
|
||||
#22c55e #10b981 #14b8a6 #06b6d4 #0ea5e9
|
||||
#3b82f6 #6366f1 #8b5cf6 #a855f7 #d946ef
|
||||
#ec4899 #64748b
|
||||
)
|
||||
# Shared with the TUI tags panel (issue #34) via BDS.UI.TagsPanel.
|
||||
@colour_presets BDS.UI.TagsPanel.colour_presets()
|
||||
|
||||
@spec colour_presets() :: [String.t()]
|
||||
def colour_presets, do: @colour_presets
|
||||
@@ -439,12 +434,7 @@ defmodule BDS.Desktop.ShellLive.TagsEditor do
|
||||
|
||||
defp current_tab_meta(_assigns), do: %{}
|
||||
|
||||
defp tag_counts(project_id) do
|
||||
Repo.all(from post in Post, where: post.project_id == ^project_id, select: post.tags)
|
||||
|> List.flatten()
|
||||
|> Enum.reject(&is_nil/1)
|
||||
|> Enum.reduce(%{}, fn tag, acc -> Map.update(acc, tag, 1, &(&1 + 1)) end)
|
||||
end
|
||||
defp tag_counts(project_id), do: BDS.UI.TagsPanel.tag_counts(project_id)
|
||||
|
||||
defp blank_to_nil(nil), do: nil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user