Replace exact blank_to_nil helpers

This commit is contained in:
2026-06-21 14:31:29 +02:00
parent d3c21247e0
commit 67a1f8a5f0
5 changed files with 14 additions and 22 deletions

View File

@@ -327,7 +327,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do
|> assign(:taxonomy_edit, %{
type: type,
name: name,
value: mapped_to |> to_string() |> blank_to_nil()
value: mapped_to |> to_string() |> BDS.MapUtils.blank_to_nil()
})
|> build_data()
@@ -1451,6 +1451,4 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do
defp present?(value), do: value not in [nil, ""]
defp blank?(value), do: value in [nil, ""]
defp blank_to_nil(""), do: nil
defp blank_to_nil(value), do: value
end

View File

@@ -17,7 +17,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do
Map.put(socket.assigns.import_editor_taxonomy_edits, definition_id, %{
type: type,
name: name,
value: mapped_to |> to_string() |> blank_to_nil()
value: mapped_to |> to_string() |> BDS.MapUtils.blank_to_nil()
})
)
|> reload.(socket.assigns.workbench)
@@ -150,7 +150,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do
@spec update_taxonomy_mapping(term(), term(), term(), term()) :: term()
def update_taxonomy_mapping(report, type, name, mapped_to) do
bucket_key = if(type == "categories", do: :categories, else: :tags)
normalized_value = mapped_to |> to_string() |> String.trim() |> blank_to_nil()
normalized_value = mapped_to |> to_string() |> String.trim() |> BDS.MapUtils.blank_to_nil()
updated_report =
update_in(report, [:items, bucket_key], fn items ->
@@ -229,7 +229,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do
@spec normalize_taxonomy_mapping_value(term(), term(), term()) :: term()
def normalize_taxonomy_mapping_value(project_id, type, mapped_to) do
normalized_value = mapped_to |> to_string() |> String.trim() |> blank_to_nil()
normalized_value = mapped_to |> to_string() |> String.trim() |> BDS.MapUtils.blank_to_nil()
case normalized_value do
nil ->
@@ -285,6 +285,4 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do
def maybe_put_option(opts, key, value), do: Keyword.put(opts, key, value)
defp present?(value), do: value not in [nil, ""]
defp blank_to_nil(""), do: nil
defp blank_to_nil(value), do: value
end