Browse Source

Add support for country codes to entity logo component

pull/7884/head
Thomas Kaul 4 weeks ago
parent
commit
e3c52570d7
  1. 4
      libs/common/src/lib/helper.spec.ts
  2. 8
      libs/common/src/lib/helper.ts
  3. 4
      libs/ui/src/lib/entity-logo/entity-logo.component.ts

4
libs/common/src/lib/helper.spec.ts

@ -134,11 +134,11 @@ describe('Helper', () => {
});
it('Invalid country code', () => {
expect(getEmojiFlag('XX')).toEqual('');
expect(getEmojiFlag('XX')).toEqual(undefined);
});
it('Empty country code', () => {
expect(getEmojiFlag('')).toEqual('');
expect(getEmojiFlag('')).toEqual(undefined);
});
});

8
libs/common/src/lib/helper.ts

@ -444,12 +444,12 @@ export function getEmojiFlag(aCountryCode: string) {
const countryCode = aCountryCode?.toUpperCase();
if (!countryCode || !VALID_COUNTRY_CODES.has(countryCode)) {
return '';
return undefined;
}
return countryCode.replace(/./g, (character) =>
String.fromCodePoint(127397 + character.charCodeAt(0))
);
return countryCode.replace(/./g, (character) => {
return String.fromCodePoint(127397 + character.charCodeAt(0));
});
}
export function getLocale() {

4
libs/ui/src/lib/entity-logo/entity-logo.component.ts

@ -27,7 +27,7 @@ export class GfEntityLogoComponent implements OnChanges {
@Input() tooltip: string;
@Input() url: string;
public emojiFlag = '';
public emojiFlag?: string;
public hasError = false;
public src?: string;
@ -36,7 +36,7 @@ export class GfEntityLogoComponent implements OnChanges {
) {}
public ngOnChanges() {
this.emojiFlag = '';
this.emojiFlag = undefined;
this.hasError = false;
this.src = undefined;

Loading…
Cancel
Save