diff --git a/src/app/record/components/affiliation-stacks-groups/modals/modal-affiliations/modal-affiliations.component.html b/src/app/record/components/affiliation-stacks-groups/modals/modal-affiliations/modal-affiliations.component.html index a14186696..81138218a 100644 --- a/src/app/record/components/affiliation-stacks-groups/modals/modal-affiliations/modal-affiliations.component.html +++ b/src/app/record/components/affiliation-stacks-groups/modals/modal-affiliations/modal-affiliations.component.html @@ -172,19 +172,28 @@ id="cy-org-dd" > - +
- Use this organization name + Use this organization name
- You will need to add location information manually + You will need to add location information + manually
- +
- Organizations with identifiers + Organizations with identifiers
{ - return this.affiliationForm - .get('organization') - .valueChanges.pipe( - tap((organization: string | Organization) => { - // Auto fill form when the user select an organization from the autocomplete list - if ( - typeof organization === 'object' && - organization.disambiguatedAffiliationIdentifier - ) { - this.selectedOrganizationFromDatabase = organization - this.requireOrganizationDisambiguatedDataOnRefresh = true - this.displayOrganizationHint = true - this.fillForm(organization) - } - if (!organization) { - if (this.selectedOrganizationFromDatabase) { - this.affiliationForm.patchValue({ - city: '', - region: '', - country: '', - }) - } - this.selectedOrganizationFromDatabase = undefined - this.requireOrganizationDisambiguatedDataOnRefresh = true - this.displayOrganizationHint = false - } - }), - switchMap((organization: string | Organization) => { - if ( - typeof organization === 'string' && - !this.selectedOrganizationFromDatabase - ) { - // Display matching organization based on the user string input - this.displayOrganizationOption = false - return this._filter((organization as string) || '').pipe( - tap((organizationList) => { - if (organizationList.length > 0) { - this.displayOrganizationOption = true - } - - this.displayOrganizationHint = true - }) - ) - } else { - // Do not display options once the user has selected an Organization - return of([]) + return this.affiliationForm.get('organization').valueChanges.pipe( + tap((organization: string | Organization) => { + // Auto fill form when the user select an organization from the autocomplete list + if ( + typeof organization === 'object' && + organization.disambiguatedAffiliationIdentifier + ) { + this.selectedOrganizationFromDatabase = organization + this.requireOrganizationDisambiguatedDataOnRefresh = true + this.displayOrganizationHint = true + this.fillForm(organization) + } + if (!organization) { + if (this.selectedOrganizationFromDatabase) { + this.affiliationForm.patchValue({ + city: '', + region: '', + country: '', + }) } - }) - ) + this.selectedOrganizationFromDatabase = undefined + this.requireOrganizationDisambiguatedDataOnRefresh = true + this.displayOrganizationHint = false + } + }), + switchMap((organization: string | Organization) => { + if ( + typeof organization === 'string' && + !this.selectedOrganizationFromDatabase + ) { + // Display matching organization based on the user string input + this.displayOrganizationOption = false + return this._filter((organization as string) || '').pipe( + tap((organizationList) => { + if (organizationList.length > 0) { + this.displayOrganizationOption = true + } + this.displayOrganizationHint = true + }) + ) + } else { + // Do not display options once the user has selected an Organization + return of([]) + } + }) + ) } fillForm(organization: Organization) { @@ -517,9 +514,9 @@ export class ModalAffiliationsComponent implements OnInit, OnDestroy { country: this.countryCodes.find((x) => x.value === organization.country) .key, }) - this.affiliationForm.get('organization').disable(); + this.affiliationForm.get('organization').disable() this.disable(organization?.city, 'city') - this.affiliationForm.get('region').disable(); + this.affiliationForm.get('region').disable() this.disable(organization?.country, 'country') } @@ -528,7 +525,7 @@ export class ModalAffiliationsComponent implements OnInit, OnDestroy { organization: '', city: '', region: '', - country: '' + country: '', }) this.enable('organization') this.enable('city') @@ -597,12 +594,12 @@ export class ModalAffiliationsComponent implements OnInit, OnDestroy { private disable(value: string, element: string): void { if (value) { - this.affiliationForm.get(element).disable(); + this.affiliationForm.get(element).disable() } } private enable(element: string): void { - this.affiliationForm.get(element).enable(); + this.affiliationForm.get(element).enable() } closeEvent() { diff --git a/src/app/record/components/funding-stacks-groups/modals/modal-funding/modal-funding.component.html b/src/app/record/components/funding-stacks-groups/modals/modal-funding/modal-funding.component.html index 3fff4544f..9fcf1ea11 100644 --- a/src/app/record/components/funding-stacks-groups/modals/modal-funding/modal-funding.component.html +++ b/src/app/record/components/funding-stacks-groups/modals/modal-funding/modal-funding.component.html @@ -690,19 +690,28 @@

Funding agency

#auto="matAutocomplete" [displayWith]="autoCompleteDisplayOrganization" > - +
- Use this organization name + Use this organization name
- You will need to add location information manually + You will need to add location information + manually
- +
- Organizations with identifiers + Organizations with identifiers
x.value === organization.country) .key, }) - this.fundingForm.get('agencyName').disable(); + this.fundingForm.get('agencyName').disable() this.disable(organization?.city, 'city') - this.fundingForm.get('region').disable(); + this.fundingForm.get('region').disable() this.disable(organization?.country, 'country') this.disambiguatedFundingSourceId = organization.sourceId this.disambiguatedFundingSource = organization.sourceType @@ -672,12 +672,12 @@ export class ModalFundingComponent implements OnInit, OnDestroy { private disable(value: string, element: string): void { if (value) { - this.fundingForm.get(element).disable(); + this.fundingForm.get(element).disable() } } private enable(element: string): void { - this.fundingForm.get(element).enable(); + this.fundingForm.get(element).enable() } private checkGrantsChanges(index: number) {