Fix small UI issues closes #220 #259
3 changed files with 48 additions and 22 deletions
|
|
@ -44,7 +44,7 @@ defmodule MvWeb.Components.PaymentFilterComponent do
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class={[
|
class={[
|
||||||
"btn btn-ghost gap-2",
|
"btn gap-2",
|
||||||
@paid_filter && "btn-active"
|
@paid_filter && "btn-active"
|
||||||
]}
|
]}
|
||||||
phx-click="toggle_dropdown"
|
phx-click="toggle_dropdown"
|
||||||
|
|
|
||||||
|
|
@ -14,20 +14,19 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
|
assigns = assign(assigns, :field_type_label, &MvWeb.Translations.FieldTypes.label/1)
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<div id={@id}>
|
<div id={@id}>
|
||||||
<.header>
|
<.form_section title={gettext("Custom Fields")}>
|
||||||
{gettext("Custom Fields")}
|
<div class="flex">
|
||||||
<:subtitle>
|
<p class="text-sm text-base-content/70">{gettext("These will appear in addition to other data when adding new members.")}</p>
|
||||||
{gettext("These will appear in addition to other data when adding new members.")}
|
<div class="ml-auto">
|
||||||
</:subtitle>
|
<.button class="ml-auto" variant="primary" phx-click="new_custom_field" phx-target={@myself}>
|
||||||
<:actions>
|
|
||||||
<.button variant="primary" phx-click="new_custom_field" phx-target={@myself}>
|
|
||||||
<.icon name="hero-plus" /> {gettext("New Custom field")}
|
<.icon name="hero-plus" /> {gettext("New Custom field")}
|
||||||
</.button>
|
</.button>
|
||||||
</:actions>
|
</div>
|
||||||
</.header>
|
</div>
|
||||||
|
|
||||||
<%!-- Show form when creating or editing --%>
|
<%!-- Show form when creating or editing --%>
|
||||||
<div :if={@show_form} class="mb-8">
|
<div :if={@show_form} class="mb-8">
|
||||||
<.live_component
|
<.live_component
|
||||||
|
|
@ -55,14 +54,14 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
||||||
<:col :let={{_id, custom_field}} label={gettext("Name")}>{custom_field.name}</:col>
|
<:col :let={{_id, custom_field}} label={gettext("Name")}>{custom_field.name}</:col>
|
||||||
|
|
||||||
<:col :let={{_id, custom_field}} label={gettext("Value Type")}>
|
<:col :let={{_id, custom_field}} label={gettext("Value Type")}>
|
||||||
{custom_field.value_type}
|
{@field_type_label.(custom_field.value_type)}
|
||||||
</:col>
|
</:col>
|
||||||
|
|
||||||
<:col :let={{_id, custom_field}} label={gettext("Description")}>
|
<:col :let={{_id, custom_field}} label={gettext("Description")}>
|
||||||
{custom_field.description}
|
{custom_field.description}
|
||||||
</:col>
|
</:col>
|
||||||
|
|
||||||
<:col :let={{_id, custom_field}} label={gettext("Show in Overview")}>
|
<:col :let={{_id, custom_field}} label={gettext("Show in overview")} class="max-w-[9.375rem] text-center">
|
||||||
<span :if={custom_field.show_in_overview} class="badge badge-success">
|
<span :if={custom_field.show_in_overview} class="badge badge-success">
|
||||||
{gettext("Yes")}
|
{gettext("Yes")}
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -72,17 +71,22 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
||||||
</:col>
|
</:col>
|
||||||
|
|
||||||
<:action :let={{_id, custom_field}}>
|
<:action :let={{_id, custom_field}}>
|
||||||
<.link phx-click={
|
<.icon_button
|
||||||
JS.push("edit_custom_field", value: %{id: custom_field.id}, target: @myself)
|
icon="hero-pencil"
|
||||||
}>
|
label={gettext("Edit custom field")}
|
||||||
{gettext("Edit")}
|
size="sm"
|
||||||
</.link>
|
phx-click={JS.push("edit_custom_field", value: %{id: custom_field.id}, target: @myself)}
|
||||||
|
/>
|
||||||
</:action>
|
</:action>
|
||||||
|
|
||||||
<:action :let={{_id, custom_field}}>
|
<:action :let={{_id, custom_field}}>
|
||||||
<.link phx-click={JS.push("prepare_delete", value: %{id: custom_field.id}, target: @myself)}>
|
<.icon_button
|
||||||
{gettext("Delete")}
|
icon="hero-trash"
|
||||||
</.link>
|
label={gettext("Delete custom field")}
|
||||||
|
size="sm"
|
||||||
|
class="btn-error"
|
||||||
|
phx-click={JS.push("prepare_delete", value: %{id: custom_field.id}, target: @myself)}
|
||||||
|
/>
|
||||||
</:action>
|
</:action>
|
||||||
</.table>
|
</.table>
|
||||||
|
|
||||||
|
|
@ -150,6 +154,7 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
</.form_section>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
|
||||||
21
lib/mv_web/translations/field_types.ex
Normal file
21
lib/mv_web/translations/field_types.ex
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
defmodule MvWeb.Translations.FieldTypes do
|
||||||
|
@moduledoc """
|
||||||
|
Helper module to dynamically translate field types.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- Can be used in templates to dynamically translate technical field type words to human friendly text
|
||||||
|
|
||||||
|
## Example
|
||||||
|
assigns = assign(assigns, :field_type_label, &MvWeb.Translations.FieldTypes.label/1)
|
||||||
|
In template:
|
||||||
|
<%= @field_type_label.(custom_field.value_type) %>
|
||||||
|
"""
|
||||||
|
use Gettext, backend: MvWeb.Gettext
|
||||||
|
|
||||||
|
@spec label(atom()) :: String.t()
|
||||||
|
def label(:string), do: gettext("Text")
|
||||||
|
def label(:integer), do: gettext("Number")
|
||||||
|
def label(:boolean), do: gettext("Yes/No-Selection")
|
||||||
|
def label(:date), do: gettext("Date")
|
||||||
|
def label(:email), do: gettext("E-Mail")
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue