diff --git a/lib/membership/custom_field.ex b/lib/membership/custom_field.ex index d7323ff..f155968 100644 --- a/lib/membership/custom_field.ex +++ b/lib/membership/custom_field.ex @@ -86,4 +86,3 @@ 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 908f331..6e6c95f 100644 --- a/lib/membership/custom_field_value.ex +++ b/lib/membership/custom_field_value.ex @@ -81,4 +81,3 @@ 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 1772bf7..b1d3f86 100644 --- a/lib/mv_web/live/custom_field_live/form.ex +++ b/lib/mv_web/live/custom_field_live/form.ex @@ -137,4 +137,3 @@ 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 f0bb290..2870611 100644 --- a/lib/mv_web/live/custom_field_live/index.ex +++ b/lib/mv_web/live/custom_field_live/index.ex @@ -86,4 +86,3 @@ 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 4ec70b7..783cb4e 100644 --- a/lib/mv_web/live/custom_field_live/show.ex +++ b/lib/mv_web/live/custom_field_live/show.ex @@ -64,4 +64,3 @@ 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 d71539d..7df4c69 100644 --- a/lib/mv_web/live/custom_field_value_live/form.ex +++ b/lib/mv_web/live/custom_field_value_live/form.ex @@ -38,7 +38,9 @@ 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"> @@ -235,7 +237,10 @@ 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} @@ -260,16 +265,23 @@ 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 @@ -280,4 +292,3 @@ 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 b7542ea..b52fd96 100644 --- a/lib/mv_web/live/custom_field_value_live/index.ex +++ b/lib/mv_web/live/custom_field_value_live/index.ex @@ -39,7 +39,11 @@ 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} @@ -80,4 +84,3 @@ 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 6538f4e..42e9f43 100644 --- a/lib/mv_web/live/custom_field_value_live/show.ex +++ b/lib/mv_web/live/custom_field_value_live/show.ex @@ -33,7 +33,10 @@ 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 @@ -62,4 +65,3 @@ 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 98ef08e..e4c2e7e 100644 --- a/lib/mv_web/live/member_live/form.ex +++ b/lib/mv_web/live/member_live/form.ex @@ -58,7 +58,8 @@ 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 @@ -190,7 +191,8 @@ 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 26a1c13..0517c0b 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,21 +38,23 @@ 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, @@ -71,10 +73,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")