WIP: feature/119_user_as_member #124

Closed
moritz wants to merge 2 commits from feature/119_user_as_member into main
Owner

It's still wip, but maybe someone can have a look. I have some trouble debugging the nested forms for editing existing users, that have related members.

It's still wip, but maybe someone can have a look. I have some trouble debugging the nested forms for editing existing users, that have related members.
moritz added this to the Accounts & Logins milestone 2025-07-25 01:57:45 +02:00
moritz self-assigned this 2025-07-25 01:57:45 +02:00
moritz added 4 commits 2025-07-25 01:57:47 +02:00
moritz added this to the Sprint 4 - 09.07 - 30.07 project 2025-07-25 01:57:48 +02:00
requested reviews from simon, carla, rafael 2025-07-25 01:57:57 +02:00
carla requested changes 2025-07-28 12:24:12 +02:00
@ -16,0 +82,4 @@
<%= if @member_form do %>
<div class="ml-6 mt-4 p-4 bg-gray-50 rounded-lg">
<.form for={@member_form} id="member-form" phx-change="validate_member" phx-submit="save_member">
<.member_form form={@member_form} property_types={@property_types} />
Owner

It only worked for me, if you use here inputs_for as above. Only one submit button for the form is working. So save_member would never be triggered. You can remove the "Save member" button here and adjust the "Save" event to handle both - saving user and member. That worked for me.

It only worked for me, if you use here `inputs_for` as above. Only one submit button for the form is working. So save_member would never be triggered. You can remove the "Save member" button here and adjust the "Save" event to handle both - saving user and member. That worked for me.
@ -136,0 +317,4 @@
def handle_event("validate", %{"user" => user_params, "member" => member_params}, socket) do
member_form = AshPhoenix.Form.validate(socket.assigns.member_form.source, member_params) |> to_form()
user_form = AshPhoenix.Form.validate(socket.assigns.form.source, user_params)
Owner

I had to change this to:
user_form = AshPhoenix.Form.validate(socket.assigns.form.source, user_params) |> to_form()
to make it work

I had to change this to: `user_form = AshPhoenix.Form.validate(socket.assigns.form.source, user_params) |> to_form()` to make it work
carla modified the project from Sprint 4 - 09.07 - 30.07 to Sprint 5 - 31.07. - 11.09. 2025-07-31 14:24:35 +02:00
rafael reviewed 2025-07-31 14:53:05 +02:00
@ -22,0 +27,4 @@
This creates a user and the notifier will automatically create a member.
"""
def register_with_password(params) do
# Use AshAuthentication's standard register_with_password action
Collaborator

We defined this action ourselves, what does "standard action" mean in this context?

We defined this action ourselves, what does "standard action" mean in this context?
@ -67,1 +68,3 @@
accept [:email]
accept [:email, :member_id]
argument :member, :map
change manage_relationship(:member, type: :create)
Collaborator

Does this mean that users will always have an associated member? I don't really remember what our plan was in this regard.

Also, I'm not sure how this interacts with the new MemberCreationNotifier that also creates members for users. Do we need both ways to create new members?

Does this mean that users will always have an associated member? I don't really remember what our plan was in this regard. Also, I'm not sure how this interacts with the new `MemberCreationNotifier` that also creates members for users. Do we need both ways to create new members?
@ -121,2 +139,3 @@
validations do
# Password strength policy: minimum 8 characters for all password-related actions
# Password strength policy: minimum 8 characters
# Note: register_with_password has built-in AshAuthentication validation, but admin_set_password doesn't
Collaborator

I don't see the validation in the action itself, is it defined in one of the two ash authentication changes?

      change AshAuthentication.Strategy.Password.HashPasswordChange
      change AshAuthentication.GenerateTokenChange
I don't see the validation in the action itself, is it defined in one of the two ash authentication changes? ```ex change AshAuthentication.Strategy.Password.HashPasswordChange change AshAuthentication.GenerateTokenChange ```
@ -0,0 +1,50 @@
defmodule MvWeb.MemberFormComponent do
Collaborator

This is pretty similar to the MemberLive.Form liveview, can we extract some common code here?

This is pretty similar to the `MemberLive.Form` liveview, can we extract some common code here?
@ -112,0 +203,4 @@
available_member_options =
available_members_with_user
|> Enum.filter(fn member -> is_nil(member.user) end)
Collaborator

You can make this a bit faster by using something like this (relevant ash docs)

Mv.Membership.list_members([query: [filter: [member: nil]]])

this way, the database will use the foreign key index to filter the members for you.

You can make this a bit faster by using something like this ([relevant ash docs](https://hexdocs.pm/ash/read-actions.html#query-options-via-code-interfaces)) ```ex Mv.Membership.list_members([query: [filter: [member: nil]]]) ``` this way, the database will use the foreign key index to filter the members for you.
@ -112,0 +209,4 @@
end)
# Load PropertyTypes for MemberForm
{:ok, property_types} = Mv.Membership.list_property_types()
Collaborator

We could convert the MemberForm into a LiveComponent. This way, it gets its own mount function which we can move some of this logic into, making the user form page a bit smaller and easier to read.

We could convert the `MemberForm` into a LiveComponent. This way, it gets its own `mount` function which we can move some of this logic into, making the user form page a bit smaller and easier to read.
moritz force-pushed feature/119_user_as_member from 71e6308646 to e74e7cbd31 2025-08-04 19:23:48 +02:00 Compare
carla modified the project from Sprint 5 - 31.07. - 11.09. to Sprint 6 - 11.09 - 02.10. 2025-09-11 10:13:23 +02:00
moritz closed this pull request 2025-09-26 20:38:36 +02:00
Some checks failed
continuous-integration/drone/push Build is failing

Pull request closed

Sign in to join this conversation.
No description provided.