refactor: DRY - use Mv.Constants.custom_field_prefix() instead of string literals
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
fabfe64468
commit
cf6a108049
4 changed files with 28 additions and 8 deletions
|
|
@ -131,17 +131,21 @@ defmodule MvWeb.Components.FieldVisibilityDropdownComponent do
|
|||
defp extract_member_field_keys(nil), do: []
|
||||
|
||||
defp extract_member_field_keys(fields) do
|
||||
prefix = Mv.Constants.custom_field_prefix()
|
||||
|
||||
Enum.filter(fields, fn field ->
|
||||
is_atom(field) ||
|
||||
(is_binary(field) && not String.starts_with?(field, "custom_field_"))
|
||||
(is_binary(field) && not String.starts_with?(field, prefix))
|
||||
end)
|
||||
end
|
||||
|
||||
defp extract_custom_field_keys(nil), do: []
|
||||
|
||||
defp extract_custom_field_keys(fields) do
|
||||
prefix = Mv.Constants.custom_field_prefix()
|
||||
|
||||
Enum.filter(fields, fn field ->
|
||||
is_binary(field) && String.starts_with?(field, "custom_field_")
|
||||
is_binary(field) && String.starts_with?(field, prefix)
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
@ -157,7 +161,7 @@ defmodule MvWeb.Components.FieldVisibilityDropdownComponent do
|
|||
end
|
||||
|
||||
defp format_custom_field_label(field_string, custom_fields) do
|
||||
id = String.trim_leading(field_string, "custom_field_")
|
||||
id = String.trim_leading(field_string, Mv.Constants.custom_field_prefix())
|
||||
find_custom_field_name(id, field_string, custom_fields)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue