Skip to content

Integrations overwriting existing organization data, displayName for organizations#935

Merged
epipav merged 5 commits intomainfrom
bugfix/organizations-overwritten-on-upsert
Jun 5, 2023
Merged

Integrations overwriting existing organization data, displayName for organizations#935
epipav merged 5 commits intomainfrom
bugfix/organizations-overwritten-on-upsert

Conversation

@epipav
Copy link
Copy Markdown
Collaborator

@epipav epipav commented Jun 2, 2023

Changes proposed ✍️

  • memberExists function now also returns existing organizations of a member - This helps with upserting existing & incoming organizations of a member through integrations
  • Organizations new field: displayName - We now use this field to do name updates on an organization via user. This is for ensuring edited organization names to be considered as the same organization. Since we're checking the existence of an organization by name, when user edits the name field, incoming data was creating new organizations - to prevent this now we're using displayName

What

🤖 Generated by Copilot at 1d71d95

This pull request adds a new feature that allows organizations to have a display name that is different from their name. The display name is used in the frontend to show the organization's label. The pull request modifies the organization model, table, repository, service, and test files in the backend, as well as the organization model, component, and page files in the frontend. It also includes migration scripts to add and drop the displayName column in the database.

🤖 Generated by Copilot at 1d71d95

We're changing the name of the orgs, me hearties
We're adding a displayName to the table
We're updating the models and the components
We're heaving away on the count of three

Why

How

🤖 Generated by Copilot at 1d71d95

  • Add displayName column to organizations table and organization model to allow organizations to have a label different from their name (link,link,link)
  • Assign displayName the same value as name by default in organizationRepository.create and organizationService.createOrUpdate methods (link,link)
  • Update organizationRepository.update method to include displayName in the data object (link)
  • Add displayName to the select clause of SQL queries in organizationRepository.findAndCountAll, organizationRepository.findAllAutocomplete, and organizationRepository.findById methods (link,link,link)
  • Add textContains operator for displayName in the where clause of SQL query in organizationRepository.filter method (link)
  • Use displayName instead of name to match the query and populate the label in organizationRepository.findAllAutocomplete method (link,link)
  • Add displayName property to organization objects in test cases for memberRepository, memberService, and organizationRepository (link,link,link,link,link,link,link,link,link)
  • Remove unnecessary deletion of organizations property from member objects in test cases for memberRepository and memberService (link,link,link)
  • Add getOrganizationIds method to memberRepository to query the database for organization ids of a given member (link)
  • Modify memberRepository.findById method to return a plainMember object that includes the organizations property as an array of organization ids (link)
  • Modify organization.name expressions to organization.displayName in frontend components that show the organization label, such as member-organizations, organization-form-details, organization-name, organization-view-header, and organization-form-page (link,link,link,link,link,link,link,link,link)
  • Modify name field to displayName field in organization-model.js in the frontend (link)

Checklist ✅

  • Label appropriately with Feature, Improvement, or Bug.
  • Add screehshots to the PR description for relevant FE changes
  • New backend functionality has been unit-tested.
  • API documentation has been updated (if necessary) (see docs on API documentation).
  • Quality standards are met.

@epipav epipav changed the title organization overwriting bug fixed, displayName for organizations Integrations overwriting existing organization data, displayName for organizations Jun 2, 2023
@epipav epipav self-assigned this Jun 2, 2023
@epipav epipav requested review from joanagmaia and themarolt June 2, 2023 11:10
@epipav epipav marked this pull request as ready for review June 2, 2023 11:10
epipav added 2 commits June 2, 2023 13:16
…om:CrowdDotDev/crowd.dev into bugfix/organizations-overwritten-on-upsert
Copy link
Copy Markdown
Contributor

@joanagmaia joanagmaia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are 2 places still missing to update:

  • In dashboard-organization-item line 31
  • In member-form-details in line 133. This is where in member's form we are adding organizations to the member and if they don't exist, we create a new organization

Another thing that is currently failing and needs update is in organization-form-page. You've updated the forms to read from displayName. But as you mentioned when creating an organization you still need to create it with name.
So in method onSubmit on that file, you should add the property name if you are in the create form. Probably on line 357, below ...formModel.value, you can add name: formModel.value.displayName if isEditPage.value === false and add displayName: formModel.value.displayName if isEditPage.value === true

@epipav epipav requested a review from garrrikkotua June 5, 2023 07:41
@epipav epipav merged commit e93e16d into main Jun 5, 2023
@epipav epipav deleted the bugfix/organizations-overwritten-on-upsert branch June 5, 2023 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants