Repository navigation
Groups: refresh member list after adding a member - #2936
Conversation
The Member List tile renders the `members` connection itself and only redrew on `dt-post-connection-added` / `dt-post-connection-created`. Nothing has fired those events since the move to web components (DiscipleTools#2650), so members added via Select or Create did not appear until a page reload. Listen for `dt:post:update`, which ComponentService dispatches with the saved record, and redraw when `members` or `leaders` changed. Also guard against a missing `members` field (after removing the last member) and missing `data.milestones` on a member. Fixes DiscipleTools#2935
|
Hey @EthanW96 Thanks! One small issue: the list and the modal can get out of sync Group has members A and B. Click the row × on B. API.update_post deletes B, but the component's value is still [A, B] in the modal. |
Removing a member with the row x saves through jQuery and redraws the list, but left the add-member modal's <dt-connection> holding the old value. Its next save sends that whole value, which silently re-added the removed member. Set the component's value from post.members whenever the list is populated. Setting value directly does not fire change, so this does not trigger a save.
|
Thanks @corsacca, good catch. I reproduced it: the row × removes B through API.update_post, but the modal's still holds [A, B], so the next _select sends B again without a delete flag and B gets re-added. Fixed in 83e10fa. populateMembersList() now also sets the modal component's value from post.members, converted with ComponentService.convertApiValue. Every path that changes the list ends in populateMembersList(): page load, the row ×, the leader toggle, and the new dt:post:update listener. Setting value directly doesn't dispatch change, so it doesn't trigger a save. This is the same approach details.js uses to put the saved value back into dt-multi-text after dt:post:update. Tested with your steps: remove B, then Select C. The list shows A and C, B stays removed after a reload, and B can be found and picked again from the modal's search. Let me know if that doesn't work correctly or there is a better pattern to follow. |
|
thank you @EthanW96! |
Fixes #2935
Problem
Members added to a group from the Member List tile (Select or Create) didn't appear until a page reload. The tile in
dt-groups/groups.jsonly redraws ondt-post-connection-added/dt-post-connection-created, and nothing has triggered those events since the connection fields moved to web components in #2650.Changes
dt-groups/groups.jsonly:dt:post:update.ComponentServicedispatches this after each save, with the saved record. The Member List now redraws when the save touchedmembersorleaders. This covers both Select (the typeahead in the add-member modal) and Create (details.jscalls_select()on the same<dt-connection name="members">aftercreate_post). The new row gets the existing leader toggle and remove button, which already use delegated handlers.post.membersto[]. After the last member is removed, the saved record has nomemberskey, sopopulateMembersList()would throw.member.data.milestonesthe same waymember.data.overall_statusis already checked.I left the old
dt-post-connection-*listeners in place, since a plugin could still trigger them.Testing
On a group record: