From c968edec569b8f0f5f887a0fb22e3a9c8222e6f8 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Mon, 5 Jun 2023 10:27:20 -0600 Subject: [PATCH 1/8] 8662-qa-items-in-countries-modal-not-displayed-correctly-for-de-pl-and-tr --- .../modals/modal-country/modal-country.component.html | 2 +- .../modals/modal-country/modal-country.component.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.html b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.html index 8fe78b7285..7404a2c6cf 100644 --- a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.html +++ b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.html @@ -98,7 +98,7 @@ let countryCode of countryCodes | sortBy : 'asc' : 'key' " > - + {{ countryCode.key }} diff --git a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.ts b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.ts index 2eb621d27e..7bec909b17 100644 --- a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.ts +++ b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.ts @@ -101,7 +101,7 @@ export class ModalCountryComponent implements OnInit, OnDestroy { countries.forEach((country) => { group[country.putCode] = new UntypedFormGroup({ - country: new UntypedFormControl(country.countryName), + country: new UntypedFormControl(country.iso2Country.value), visibility: new UntypedFormControl(country.visibility.visibility, {}), }) }) @@ -121,14 +121,15 @@ export class ModalCountryComponent implements OnInit, OnDestroy { // Clear empty inputs .filter((key) => countryForm.getRawValue()[key].country) .forEach((key, i) => { - const countryName = countryForm.getRawValue()[key].country + const countryCode = countryForm.getRawValue()[key].country const visibility = countryForm.getRawValue()[key].visibility if (countryForm.getRawValue()[key]) { countries.addresses.push({ putCode: key.indexOf('new-') === 0 ? null : key, - countryName, + countryName: this.countryCodes.find((x) => x.value === countryCode) + .key, iso2Country: { - value: this.countryCodes.find((x) => x.key === countryName).value, + value: countryCode, }, displayIndex: i + 1, visibility: { From b807976ac02b5bd6e5161f59c35a3fdef4c4a464 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Mon, 5 Jun 2023 10:28:32 -0600 Subject: [PATCH 2/8] 8662-qa-items-in-countries-modal-not-displayed-correctly-for-de-pl-and-tr --- .../side-bar/modals/modal-country/modal-country.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.ts b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.ts index 7bec909b17..7efae07dcd 100644 --- a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.ts +++ b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.ts @@ -127,7 +127,7 @@ export class ModalCountryComponent implements OnInit, OnDestroy { countries.addresses.push({ putCode: key.indexOf('new-') === 0 ? null : key, countryName: this.countryCodes.find((x) => x.value === countryCode) - .key, + ?.key, iso2Country: { value: countryCode, }, From 5a5fa32879edf37415a40eb023968aa51aa3694d Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Mon, 5 Jun 2023 11:13:34 -0600 Subject: [PATCH 3/8] Fix testing --- .../modal-country.component.spec.ts | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.spec.ts b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.spec.ts index 82d6e1fbc0..9ee9b0c96a 100644 --- a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.spec.ts +++ b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.spec.ts @@ -31,6 +31,7 @@ import { ChangeDetectorRef } from '@angular/core' import { MatSelectHarness } from '@angular/material/select/testing' import { MatInputHarness } from '@angular/material/input/testing' import { VisibilitySelectorModule } from 'src/app/cdk/visibility-selector/visibility-selector.module' +import { log } from 'console' describe('ModalCountryComponent', () => { let component: ModalCountryComponent @@ -134,6 +135,7 @@ describe('ModalCountryComponent', () => { const countriesSelects = await loader.getAllHarnesses(MatSelectHarness) const countriesInputs = await loader.getAllHarnesses(MatInputHarness) + console.log(countriesSelects) await countriesSelects[1].open() await countriesSelects[1].clickOptions() //Select the first option @@ -141,12 +143,10 @@ describe('ModalCountryComponent', () => { // countriesSelects.map((select) => select.isDisabled()) // ) - expect(countriesForm.controls[1].value.country).toBe('Albania') - expect(countriesForm.controls[2].getRawValue().country).toBe( - 'United States' - ) - expect(countriesForm.controls[3].getRawValue().country).toBe('Kosovo') - expect(countriesForm.controls['new-0'].value.country).toBe('Afghanistan') + expect(countriesForm.controls[1].value.country).toBe('AL') + expect(countriesForm.controls[2].getRawValue().country).toBe('US') + expect(countriesForm.controls[3].getRawValue().country).toBe('XK') + expect(countriesForm.controls['new-0'].value.country).toBe('AF') expect(countriesInputs.length).toBe(2) expect(countriesSelects.length).toBe(2) }) @@ -159,6 +159,9 @@ function getAddresses(): Address[] { countryName: 'Albania', source: '0000-0000-0000-000X', sourceName: 'Test Record', + iso2Country: { + value: 'AL', + }, visibility: { visibility: 'PUBLIC', }, @@ -168,6 +171,9 @@ function getAddresses(): Address[] { countryName: 'United States', source: '0000-0000-0000-000Z', sourceName: 'ORCID', + iso2Country: { + value: 'US', + }, visibility: { visibility: 'PRIVATE', }, @@ -175,6 +181,9 @@ function getAddresses(): Address[] { { putCode: '3', countryName: 'Kosovo', + iso2Country: { + value: 'XK', + }, source: '0000-0000-0000-000Z', sourceName: 'ORCID', visibility: { From 4209ed20e4c5f3c4380f06c0606808674524cfa7 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Tue, 6 Jun 2023 12:25:50 -0600 Subject: [PATCH 4/8] 8662-qa-items-in-countries-modal-not-displayed-correctly-for-de-pl-and-tr --- .../modal-country.component.html | 5 ++-- .../record-countries.service.ts | 23 +++++++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.html b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.html index 7404a2c6cf..a5b9d9eccb 100644 --- a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.html +++ b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.html @@ -99,7 +99,7 @@ " > - {{ countryCode.key }} + {{ countryCode.key }} here @@ -126,9 +126,8 @@ #descriptionInput [attr.aria-label]="ariaLabelCountryLocationReadOnly" matInput - formControlName="country" - placeholder=" {{ ngOrcidCountry }}" [ngClass]="{ 'website-input': screenDirection === 'rtl' }" + [value]="country.countryName || ''" /> { if (options.publicRecordId) { - return this._recordPublicSidebar - .getPublicRecordSideBar(options) - .pipe(map((value) => value.countries)) + return forkJoin([ + this._recordPublicSidebar.getPublicRecordSideBar(options), + this.getCountryCodes(), + ]).pipe( + map((value) => { + const countries = value[0].countries + const countryCodes = value[1] + countries.addresses.forEach((country) => { + country.countryName = countryCodes[country.iso2Country.value] || '' + }) + return countries + }) + ) } if (!this.$addresses) { From d8b7cce889744c4a31ce2268a916685e06073ca3 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Tue, 6 Jun 2023 12:27:24 -0600 Subject: [PATCH 5/8] Add comments --- src/app/core/record-countries/record-countries.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/core/record-countries/record-countries.service.ts b/src/app/core/record-countries/record-countries.service.ts index 537911ce03..d632f9ba01 100644 --- a/src/app/core/record-countries/record-countries.service.ts +++ b/src/app/core/record-countries/record-countries.service.ts @@ -308,6 +308,7 @@ export class RecordCountriesService { const countries = value[0].countries const countryCodes = value[1] countries.addresses.forEach((country) => { + //Overrride backend country name translations country.countryName = countryCodes[country.iso2Country.value] || '' }) return countries From da634a88d32abc73dc2af028dac48330889c1292 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Tue, 6 Jun 2023 12:28:34 -0600 Subject: [PATCH 6/8] remove logs --- .../modals/modal-country/modal-country.component.spec.ts | 2 -- src/app/core/google-tag-manager/google-tag-manager.service.ts | 1 - 2 files changed, 3 deletions(-) diff --git a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.spec.ts b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.spec.ts index 9ee9b0c96a..dcb906f847 100644 --- a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.spec.ts +++ b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.spec.ts @@ -31,7 +31,6 @@ import { ChangeDetectorRef } from '@angular/core' import { MatSelectHarness } from '@angular/material/select/testing' import { MatInputHarness } from '@angular/material/input/testing' import { VisibilitySelectorModule } from 'src/app/cdk/visibility-selector/visibility-selector.module' -import { log } from 'console' describe('ModalCountryComponent', () => { let component: ModalCountryComponent @@ -135,7 +134,6 @@ describe('ModalCountryComponent', () => { const countriesSelects = await loader.getAllHarnesses(MatSelectHarness) const countriesInputs = await loader.getAllHarnesses(MatInputHarness) - console.log(countriesSelects) await countriesSelects[1].open() await countriesSelects[1].clickOptions() //Select the first option diff --git a/src/app/core/google-tag-manager/google-tag-manager.service.ts b/src/app/core/google-tag-manager/google-tag-manager.service.ts index ae68d0cbe1..5e6472af80 100644 --- a/src/app/core/google-tag-manager/google-tag-manager.service.ts +++ b/src/app/core/google-tag-manager/google-tag-manager.service.ts @@ -13,7 +13,6 @@ import { ItemGTM } from '../../types/item_gtm' import { ERROR_REPORT } from '../../errors' import { ErrorHandlerService } from '../error-handler/error-handler.service' import { WINDOW } from 'src/app/cdk/window' -import { log } from 'console' @Injectable({ providedIn: 'root', From 95af8946e66d305401f0fcff73eee4e3f4154954 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Tue, 6 Jun 2023 12:28:59 -0600 Subject: [PATCH 7/8] Remove testing code --- .../side-bar/modals/modal-country/modal-country.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.html b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.html index a5b9d9eccb..290c382fd9 100644 --- a/src/app/cdk/side-bar/modals/modal-country/modal-country.component.html +++ b/src/app/cdk/side-bar/modals/modal-country/modal-country.component.html @@ -99,7 +99,7 @@ " > - {{ countryCode.key }} here + {{ countryCode.key }} From d01277b1e5ead439af2abdf2cbe2d3a332840631 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Tue, 6 Jun 2023 12:31:54 -0600 Subject: [PATCH 8/8] Fix comment --- src/app/core/record-countries/record-countries.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/core/record-countries/record-countries.service.ts b/src/app/core/record-countries/record-countries.service.ts index d632f9ba01..c278cc9c24 100644 --- a/src/app/core/record-countries/record-countries.service.ts +++ b/src/app/core/record-countries/record-countries.service.ts @@ -308,7 +308,7 @@ export class RecordCountriesService { const countries = value[0].countries const countryCodes = value[1] countries.addresses.forEach((country) => { - //Overrride backend country name translations + //Override backend country name translations country.countryName = countryCodes[country.iso2Country.value] || '' }) return countries