Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove members references from user group form [DHIS2-16766] #1342

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 39 additions & 11 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2023-12-12T13:36:05.060Z\n"
"PO-Revision-Date: 2023-12-12T13:36:05.060Z\n"
"POT-Creation-Date: 2024-02-08T17:31:59.581Z\n"
"PO-Revision-Date: 2024-02-08T17:31:59.581Z\n"

msgid "Yes"
msgstr "Yes"
Expand Down Expand Up @@ -50,15 +50,52 @@ msgstr "There was an error fetching this form."
msgid "Cancel without saving"
msgstr "Cancel without saving"

msgid "Basic information"
msgstr "Basic information"

msgid "Name"
msgstr "Name"

msgid "Code"
msgstr "Code"

msgid "Used in analytics reports."
msgstr "Used in analytics reports."

msgid "Error updating group"
msgstr "Error updating group"

msgid "Error creating group"
msgstr "Error creating group"

msgid "User management"
msgstr "User management"

msgid "Add or remove users from this group."
msgstr "Add or remove users from this group."

msgid ""
"To add a user to this group, go to the User section and edit the user group "
"settings for a specific user."
msgstr ""
"To add a user to this group, go to the User section and edit the user group "
"settings for a specific user."

msgid "Attributes"
msgstr "Attributes"

msgid "User group management"
msgstr "User group management"

msgid "This group can manage other user groups. Add managed user groups below."
msgstr "This group can manage other user groups. Add managed user groups below."

msgid "Available user groups"
msgstr "Available user groups"

msgid "Managed user groups"
msgstr "Managed user groups"

msgid "Name is already taken"
msgstr "Name is already taken"

Expand Down Expand Up @@ -95,12 +132,6 @@ msgstr "Error updating role"
msgid "Error creating role"
msgstr "Error creating role"

msgid "Basic information"
msgstr "Basic information"

msgid "Name"
msgstr "Name"

msgid "Description"
msgstr "Description"

Expand Down Expand Up @@ -481,9 +512,6 @@ msgstr "Available user roles"
msgid "User roles this user is assigned"
msgstr "User roles this user is assigned"

msgid "Available user groups"
msgstr "Available user groups"

msgid "User groups this user is a member of"
msgstr "User groups this user is a member of"

Expand Down
23 changes: 2 additions & 21 deletions src/components/GroupForm/createRequestBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import { getAttributeValues } from '../../attributes.js'
const ATTRIBUTE_VALUES = 'attributeValues'

export const createPostRequestBody = ({ values, attributes }) => {
const { name, code, members, managedGroups } = values
const { name, code, managedGroups } = values

return {
name,
code,
users: members.additions.map(({ id }) => ({ id })),
managedGroups: managedGroups.map(id => ({ id })),
attributeValues: getAttributeValues({ attributes, values }),
}
Expand All @@ -23,7 +22,7 @@ export const createJsonPatchRequestBody = ({
key => dirtyFields[key]
)
const patch = dirtyFieldsArray.reduce((acc, key) => {
if (key !== 'members' && !key.startsWith(ATTRIBUTE_VALUES)) {
if (!key.startsWith(ATTRIBUTE_VALUES)) {
const value =
key === 'managedGroups'
? values[key].map(id => ({ id }))
Expand Down Expand Up @@ -52,23 +51,5 @@ export const createJsonPatchRequestBody = ({
})
}

if (dirtyFields.members) {
const { additions, removals } = values.members
for (const addition of additions) {
patch.push({
op: 'add',
path: '/users/-',
value: { id: addition.id },
})
}
for (const removal of removals) {
patch.push({
op: 'remove-by-id',
path: '/users',
id: removal.id,
})
}
}

return patch
}
Loading