diff --git a/lib/membership/custom_field.ex b/lib/membership/custom_field.ex index f155968..d7323ff 100644 --- a/lib/membership/custom_field.ex +++ b/lib/membership/custom_field.ex @@ -86,3 +86,4 @@ defmodule Mv.Membership.CustomField do identity :unique_name, [:name] end end + diff --git a/lib/membership/custom_field_value.ex b/lib/membership/custom_field_value.ex index 6e6c95f..908f331 100644 --- a/lib/membership/custom_field_value.ex +++ b/lib/membership/custom_field_value.ex @@ -81,3 +81,4 @@ defmodule Mv.Membership.CustomFieldValue do identity :unique_custom_field_per_member, [:member_id, :custom_field_id] end end + diff --git a/lib/mv_web/live/custom_field_live/form.ex b/lib/mv_web/live/custom_field_live/form.ex index b1d3f86..1772bf7 100644 --- a/lib/mv_web/live/custom_field_live/form.ex +++ b/lib/mv_web/live/custom_field_live/form.ex @@ -137,3 +137,4 @@ defmodule MvWeb.CustomFieldLive.Form do defp return_path("index", _custom_field), do: ~p"/custom_fields" defp return_path("show", custom_field), do: ~p"/custom_fields/#{custom_field.id}" end + diff --git a/lib/mv_web/live/custom_field_live/index.ex b/lib/mv_web/live/custom_field_live/index.ex index 2870611..f0bb290 100644 --- a/lib/mv_web/live/custom_field_live/index.ex +++ b/lib/mv_web/live/custom_field_live/index.ex @@ -86,3 +86,4 @@ defmodule MvWeb.CustomFieldLive.Index do {:noreply, stream_delete(socket, :custom_fields, custom_field)} end end + diff --git a/lib/mv_web/live/custom_field_live/show.ex b/lib/mv_web/live/custom_field_live/show.ex index 783cb4e..4ec70b7 100644 --- a/lib/mv_web/live/custom_field_live/show.ex +++ b/lib/mv_web/live/custom_field_live/show.ex @@ -64,3 +64,4 @@ defmodule MvWeb.CustomFieldLive.Show do |> assign(:custom_field, Ash.get!(Mv.Membership.CustomField, id))} end end + diff --git a/lib/mv_web/live/custom_field_value_live/form.ex b/lib/mv_web/live/custom_field_value_live/form.ex index 7df4c69..d71539d 100644 --- a/lib/mv_web/live/custom_field_value_live/form.ex +++ b/lib/mv_web/live/custom_field_value_live/form.ex @@ -38,9 +38,7 @@ defmodule MvWeb.CustomFieldValueLive.Form do <.header> {@page_title} - <:subtitle> - {gettext("Use this form to manage custom_field_value records in your database.")} - + <:subtitle>{gettext("Use this form to manage custom_field_value records in your database.")} <.form for={@form} id="custom_field_value-form" phx-change="validate" phx-submit="save"> @@ -237,10 +235,7 @@ defmodule MvWeb.CustomFieldValueLive.Form do socket = socket - |> put_flash( - :info, - gettext("Custom field value %{action} successfully", action: action) - ) + |> put_flash(:info, gettext("Custom field value %{action} successfully", action: action)) |> push_navigate(to: return_path(socket.assigns.return_to, custom_field_value)) {:noreply, socket} @@ -265,23 +260,16 @@ defmodule MvWeb.CustomFieldValueLive.Form do %{} end - AshPhoenix.Form.for_update(custom_field_value, :update, - as: "custom_field_value", - params: params - ) + AshPhoenix.Form.for_update(custom_field_value, :update, as: "custom_field_value", params: params) else - AshPhoenix.Form.for_create(Mv.Membership.CustomFieldValue, :create, - as: "custom_field_value" - ) + AshPhoenix.Form.for_create(Mv.Membership.CustomFieldValue, :create, as: "custom_field_value") end assign(socket, form: to_form(form)) end defp return_path("index", _custom_field_value), do: ~p"/custom_field_values" - - defp return_path("show", custom_field_value), - do: ~p"/custom_field_values/#{custom_field_value.id}" + defp return_path("show", custom_field_value), do: ~p"/custom_field_values/#{custom_field_value.id}" # Helper functions for selection options defp custom_field_options(custom_fields) do @@ -292,3 +280,4 @@ defmodule MvWeb.CustomFieldValueLive.Form do Enum.map(members, &{"#{&1.first_name} #{&1.last_name}", &1.id}) end end + diff --git a/lib/mv_web/live/custom_field_value_live/index.ex b/lib/mv_web/live/custom_field_value_live/index.ex index b52fd96..b7542ea 100644 --- a/lib/mv_web/live/custom_field_value_live/index.ex +++ b/lib/mv_web/live/custom_field_value_live/index.ex @@ -39,11 +39,7 @@ defmodule MvWeb.CustomFieldValueLive.Index do <.table id="custom_field_values" rows={@streams.custom_field_values} - row_click={ - fn {_id, custom_field_value} -> - JS.navigate(~p"/custom_field_values/#{custom_field_value}") - end - } + row_click={fn {_id, custom_field_value} -> JS.navigate(~p"/custom_field_values/#{custom_field_value}") end} > <:col :let={{_id, custom_field_value}} label="Id">{custom_field_value.id} @@ -84,3 +80,4 @@ defmodule MvWeb.CustomFieldValueLive.Index do {:noreply, stream_delete(socket, :custom_field_values, custom_field_value)} end end + diff --git a/lib/mv_web/live/custom_field_value_live/show.ex b/lib/mv_web/live/custom_field_value_live/show.ex index 42e9f43..6538f4e 100644 --- a/lib/mv_web/live/custom_field_value_live/show.ex +++ b/lib/mv_web/live/custom_field_value_live/show.ex @@ -33,10 +33,7 @@ defmodule MvWeb.CustomFieldValueLive.Show do <.button navigate={~p"/custom_field_values"}> <.icon name="hero-arrow-left" /> - <.button - variant="primary" - navigate={~p"/custom_field_values/#{@custom_field_value}/edit?return_to=show"} - > + <.button variant="primary" navigate={~p"/custom_field_values/#{@custom_field_value}/edit?return_to=show"}> <.icon name="hero-pencil-square" /> Edit Custom field value @@ -65,3 +62,4 @@ defmodule MvWeb.CustomFieldValueLive.Show do defp page_title(:show), do: "Show Custom field value" defp page_title(:edit), do: "Edit Custom field value" end + diff --git a/lib/mv_web/live/member_live/form.ex b/lib/mv_web/live/member_live/form.ex index e4c2e7e..98ef08e 100644 --- a/lib/mv_web/live/member_live/form.ex +++ b/lib/mv_web/live/member_live/form.ex @@ -58,8 +58,7 @@ defmodule MvWeb.MemberLive.Form do

{gettext("Custom Field Values")}

<.inputs_for :let={f_custom_field_value} field={@form[:custom_field_values]}> - <% type = - Enum.find(@custom_fields, &(&1.id == f_custom_field_value[:custom_field_id].value)) %> + <% type = Enum.find(@custom_fields, &(&1.id == f_custom_field_value[:custom_field_id].value)) %> <.inputs_for :let={value_form} field={f_custom_field_value[:value]}> <% input_type = cond do @@ -191,8 +190,7 @@ defmodule MvWeb.MemberLive.Form do forms: [auto?: true] ) - missing_custom_field_values = - Enum.filter(socket.assigns[:initial_custom_field_values], is_missing_custom_field_value) + missing_custom_field_values = Enum.filter(socket.assigns[:initial_custom_field_values], is_missing_custom_field_value) Enum.reduce( missing_custom_field_values, diff --git a/priv/repo/migrations/20251113163602_rename_properties_to_custom_fields.exs b/priv/repo/migrations/20251113163602_rename_properties_to_custom_fields.exs index 0517c0b..26a1c13 100644 --- a/priv/repo/migrations/20251113163602_rename_properties_to_custom_fields.exs +++ b/priv/repo/migrations/20251113163602_rename_properties_to_custom_fields.exs @@ -11,14 +11,14 @@ defmodule Mv.Repo.Migrations.RenamePropertiesToCustomFields do # Rename tables rename table("property_types"), to: table("custom_fields") rename table("properties"), to: table("custom_field_values") - + # Rename the foreign key column rename table("custom_field_values"), :property_type_id, to: :custom_field_id - + # Drop old foreign key constraints drop constraint(:custom_field_values, "properties_member_id_fkey") drop constraint(:custom_field_values, "properties_property_type_id_fkey") - + # Add new foreign key constraints with correct names and on_delete behavior alter table(:custom_field_values) do modify :member_id, @@ -38,23 +38,21 @@ defmodule Mv.Repo.Migrations.RenamePropertiesToCustomFields do prefix: "public" ) end - + # Rename indexes execute "ALTER INDEX IF EXISTS property_types_unique_name_index RENAME TO custom_fields_unique_name_index" - execute "ALTER INDEX IF EXISTS properties_unique_property_per_member_index RENAME TO custom_field_values_unique_custom_field_per_member_index" end def down do # Rename indexes back execute "ALTER INDEX IF EXISTS custom_fields_unique_name_index RENAME TO property_types_unique_name_index" - execute "ALTER INDEX IF EXISTS custom_field_values_unique_custom_field_per_member_index RENAME TO properties_unique_property_per_member_index" - + # Drop new foreign key constraints drop constraint(:custom_field_values, "custom_field_values_member_id_fkey") drop constraint(:custom_field_values, "custom_field_values_custom_field_id_fkey") - + # Add back old foreign key constraints alter table(:custom_field_values) do modify :member_id, @@ -73,10 +71,10 @@ defmodule Mv.Repo.Migrations.RenamePropertiesToCustomFields do prefix: "public" ) end - + # Rename the foreign key column back rename table("custom_field_values"), :custom_field_id, to: :property_type_id - + # Rename tables back rename table("custom_fields"), to: table("property_types") rename table("custom_field_values"), to: table("properties")