From 488150f7f5558c05c1ec8a71afcb9f9a37e68a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jovan=20Kruni=C4=87?= Date: Thu, 14 Apr 2022 08:52:31 +0000 Subject: [PATCH] fix: add areaServed to person detail --- .../data/elements/title-card.component.html | 6 + .../person/person-detail-content.component.ts | 57 +++++++- .../types/person/person-detail-content.html | 122 +++++------------- 3 files changed, 91 insertions(+), 94 deletions(-) diff --git a/src/app/modules/data/elements/title-card.component.html b/src/app/modules/data/elements/title-card.component.html index f9c17507..da789dd0 100644 --- a/src/app/modules/data/elements/title-card.component.html +++ b/src/app/modules/data/elements/title-card.component.html @@ -16,7 +16,13 @@

+ {{ + 'honorificPrefix' | thingTranslate: item + }} {{ 'name' | thingTranslate: item }} + {{ + 'honorificSuffix' | thingTranslate: item + }}

diff --git a/src/app/modules/data/types/person/person-detail-content.component.ts b/src/app/modules/data/types/person/person-detail-content.component.ts index 88466af6..5b3ebb3d 100644 --- a/src/app/modules/data/types/person/person-detail-content.component.ts +++ b/src/app/modules/data/types/person/person-detail-content.component.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 StApps + * Copyright (C) 2019-2022 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. @@ -13,7 +13,14 @@ * this program. If not, see . */ import {Component, Input} from '@angular/core'; -import {SCPerson} from '@openstapps/core'; +import { + SCContactPoint, + SCContactPointWithoutReferences, + SCPerson, + SCSearchQuery, + SCUuid, +} from '@openstapps/core'; +import {DataProvider} from '../../data.provider'; /** * TODO @@ -23,8 +30,46 @@ import {SCPerson} from '@openstapps/core'; templateUrl: 'person-detail-content.html', }) export class PersonDetailContentComponent { - /** - * TODO - */ - @Input() item: SCPerson; + private _item: SCPerson; + + contactPoints: SCContactPoint[] | SCContactPointWithoutReferences[]; + + get item(): SCPerson { + return this._item; + } + + @Input() set item(item: SCPerson) { + this._item = item; + if (item.workLocations) { + this.contactPoints = item.workLocations; + this.getContactPoints(item.workLocations).then(contactPoints => { + this.contactPoints = contactPoints; + }); + } + } + + constructor(private readonly dataProvider: DataProvider) {} + + async getContactPoints( + workLocations: SCContactPointWithoutReferences[], + ): Promise { + const query: {[uid in SCUuid]: SCSearchQuery} = {}; + workLocations.map(workLocation => { + query[workLocation.uid] = { + filter: { + arguments: { + field: 'uid', + value: workLocation.uid, + }, + type: 'value', + }, + }; + }); + + const contactPoints: SCContactPoint[] = Object.values( + await this.dataProvider.multiSearch(query), + ).map(result => result.data[0] as SCContactPoint); + + return contactPoints; + } } diff --git a/src/app/modules/data/types/person/person-detail-content.html b/src/app/modules/data/types/person/person-detail-content.html index 714692e6..1c4ffc8a 100644 --- a/src/app/modules/data/types/person/person-detail-content.html +++ b/src/app/modules/data/types/person/person-detail-content.html @@ -1,95 +1,41 @@ - - - {{ 'type' | thingTranslate: item.workLocations[0] | titlecase }} - - - -

- {{ - 'telephone' - | propertyNameTranslate: item.workLocations[0] - | titlecase - }}: - {{ - item.workLocations[0].telephone + + + + {{ i + 1 }}. + {{ 'type' | thingTranslate: contactPoint | titlecase }} + + +

+ {{ 'telephone' | propertyNameTranslate: contactPoint | titlecase }}: + {{ + contactPoint.telephone }}

-

- {{ - 'email' | propertyNameTranslate: item.workLocations[0] | titlecase - }}: - {{ - item.workLocations[0].email +

+ {{ 'email' | propertyNameTranslate: contactPoint | titlecase }}: + {{ contactPoint.email }} +

+

+ {{ 'faxNumber' | propertyNameTranslate: contactPoint | titlecase }}: + {{ contactPoint.faxNumber }} +

+

+ {{ 'officeHours' | propertyNameTranslate: contactPoint | titlecase }}: + {{ contactPoint.officeHours }} +

+

+ {{ 'url' | propertyNameTranslate: contactPoint | titlecase }}: + {{ contactPoint.url }} +

+

+ {{ 'areaServed' | propertyNameTranslate: contactPoint | titlecase }}: + {{ + contactPoint.areaServed.name }}

-

- {{ - 'faxNumber' - | propertyNameTranslate: item.workLocations[0] - | titlecase - }}: {{ item.workLocations[0].faxNumber }} -

-

- {{ 'url' | propertyNameTranslate: item.workLocations[0] | titlecase }}: - {{ - item.workLocations[0].url - }} -

-

- {{ - 'areaServed' - | propertyNameTranslate: item.workLocations[0] - | titlecase - }}: - {{ item.workLocations[0].areaServed.name }} -

-
- - -

- {{ - 'telephone' | propertyNameTranslate: item.workLocation | titlecase - }}: - {{ - workLocation.telephone - }} -

-

- {{ 'email' | propertyNameTranslate: item.workLocation | titlecase }}: - {{ - workLocation.email - }} -

-

- {{ - 'faxNumber' | propertyNameTranslate: item.workLocation | titlecase - }}: {{ workLocation.faxNumber }} -

-

- {{ 'url' | propertyNameTranslate: item.workLocation | titlecase }}: - {{ workLocation.url }} -

-

- {{ - 'areaServed' | propertyNameTranslate: item.workLocation | titlecase - }}: - {{ - workLocation.areaServed.name - }} -

- - -
-
-
-
+ + +