fix: joinrequest field formats
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
15e9a52bc9
commit
0159d5352a
2 changed files with 89 additions and 7 deletions
|
|
@ -156,14 +156,16 @@ defmodule MvWeb.JoinRequestLive.Show do
|
|||
label={gettext("Submitted at")}
|
||||
value={DateFormatter.format_datetime(@join_request.submitted_at, @browser_timezone)}
|
||||
/>
|
||||
<div class="flex gap-2">
|
||||
<span class="text-base-content/60 min-w-32 shrink-0">{gettext("Status")}:</span>
|
||||
<span>
|
||||
<dl class="grid gap-1 md:grid-cols-[14rem_minmax(0,1fr)] md:gap-2">
|
||||
<dt class="m-0 text-base-content/60 whitespace-normal break-words">
|
||||
{gettext("Status")}:
|
||||
</dt>
|
||||
<dd class="m-0 min-w-0">
|
||||
<.badge variant={JoinRequestHelpers.status_badge_variant(@join_request.status)}>
|
||||
{JoinRequestHelpers.format_status(@join_request.status)}
|
||||
</.badge>
|
||||
</span>
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
<%= if @join_request.status in [:approved, :rejected] do %>
|
||||
<%= if @join_request.approved_at do %>
|
||||
<.field_row
|
||||
|
|
@ -285,11 +287,38 @@ defmodule MvWeb.JoinRequestLive.Show do
|
|||
defp format_applicant_value(value) when is_boolean(value),
|
||||
do: if(value, do: gettext("Yes"), else: gettext("No"))
|
||||
|
||||
defp format_applicant_value(value) when is_binary(value) or is_number(value),
|
||||
do: to_string(value)
|
||||
defp format_applicant_value(value) when is_binary(value),
|
||||
do: format_binary_applicant_value(value)
|
||||
|
||||
defp format_applicant_value(value) when is_number(value), do: to_string(value)
|
||||
|
||||
defp format_applicant_value(value), do: to_string(value)
|
||||
|
||||
defp format_binary_applicant_value(value) do
|
||||
trimmed_value = String.trim(value)
|
||||
|
||||
cond do
|
||||
trimmed_value == "" ->
|
||||
nil
|
||||
|
||||
String.downcase(trimmed_value) in ["on", "true", "1"] ->
|
||||
gettext("Yes")
|
||||
|
||||
String.downcase(trimmed_value) in ["off", "false", "0"] ->
|
||||
gettext("No")
|
||||
|
||||
true ->
|
||||
format_iso_date_string(trimmed_value)
|
||||
end
|
||||
end
|
||||
|
||||
defp format_iso_date_string(value) do
|
||||
case Date.from_iso8601(value) do
|
||||
{:ok, date} -> DateFormatter.format_date(date)
|
||||
_ -> value
|
||||
end
|
||||
end
|
||||
|
||||
defp format_applicant_value_from_map(value) do
|
||||
raw = Map.get(value, "_union_value") || Map.get(value, "value")
|
||||
type = Map.get(value, "_union_type") || Map.get(value, "type")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue