Implements uneditable type for custom fields closes #198 #433
2 changed files with 28 additions and 16 deletions
|
|
@ -75,9 +75,7 @@ defmodule Mv.Membership.CustomField do
|
|||
|
||||
validate fn changeset, _context ->
|
||||
if Ash.Changeset.changing_attribute?(changeset, :value_type) do
|
||||
{:error,
|
||||
field: :value_type,
|
||||
message: "cannot be changed after creation"}
|
||||
{:error, field: :value_type, message: "cannot be changed after creation"}
|
||||
else
|
||||
:ok
|
||||
end
|
||||
|
|
|
|||
|
|
@ -45,19 +45,33 @@ defmodule MvWeb.CustomFieldLive.FormComponent do
|
|||
<.input field={@form[:name]} type="text" label={gettext("Name")} />
|
||||
|
||||
<%= if @custom_field do %>
|
||||
<%!-- Show value_type as read-only text when editing --%>
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<span class="label-text">{gettext("Value type")}</span>
|
||||
</label>
|
||||
<div class="input input-bordered bg-base-200 text-base-content/70">
|
||||
{MvWeb.Translations.FieldTypes.label(@custom_field.value_type)}
|
||||
</div>
|
||||
<label class="label">
|
||||
<span class="label-text-alt text-base-content/70">
|
||||
{gettext("Value type cannot be changed after creation")}
|
||||
</span>
|
||||
</label>
|
||||
<%!-- Show value_type as read-only input when editing (matches Member Field pattern) --%>
|
||||
<div
|
||||
class="tooltip tooltip-right"
|
||||
data-tip={gettext("Value type cannot be changed after creation")}
|
||||
aria-label={gettext("Value type cannot be changed after creation")}
|
||||
>
|
||||
<fieldset class="mb-2 fieldset">
|
||||
<label>
|
||||
<span class="mb-1 label flex items-center gap-2">
|
||||
{gettext("Value type")}
|
||||
<.icon
|
||||
name="hero-information-circle"
|
||||
class="w-4 h-4 text-base-content/60 cursor-help"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
<input
|
||||
type="text"
|
||||
name={@form[:value_type].name}
|
||||
id={@form[:value_type].id}
|
||||
value={MvWeb.Translations.FieldTypes.label(@custom_field.value_type)}
|
||||
disabled
|
||||
readonly
|
||||
class="w-full input"
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
<% else %>
|
||||
<%!-- Show value_type as select when creating --%>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue