From 365de7ab7efafdbb55bea35af4558153420baa78 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Tue, 12 Mar 2024 22:57:47 +0200 Subject: [PATCH] Add type to emails and identifiers --- .../autocomplete/cm-autocomplete-people.js | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/app/webroot/js/comanage/components/autocomplete/cm-autocomplete-people.js b/app/webroot/js/comanage/components/autocomplete/cm-autocomplete-people.js index 48445f106..609079fbc 100644 --- a/app/webroot/js/comanage/components/autocomplete/cm-autocomplete-people.js +++ b/app/webroot/js/comanage/components/autocomplete/cm-autocomplete-people.js @@ -64,10 +64,27 @@ export default { const type = types.filter((item) => ppadr_id == item.id) return { - 'value': type[0].value, - 'desplay_name': type[0].display_name + 'id': type?.[0]?.id, + 'value': type?.[0]?.value, + 'display_name': type?.[0]?.display_name } }, + constructEmailCsv(emailList) { + const emailWithType = emailList.map( (mail) => { + return mail.mail + " (" + this.app.types?.find((t) => t.id == mail.type_id)?.display_name + ")" + } + ) + + return emailWithType.join(",") + }, + constructIdentifierCsv(identifierList) { + const emailWithType = identifierList.map( (ident) => { + return ident.identifier + " (" + this.app.types?.find((t) => t.id == ident.type_id)?.display_name + ")" + } + ) + + return emailWithType.join(",") + }, async searchPeople(event) { this.loading = true; this.error = null; @@ -79,8 +96,6 @@ export default { `identifier=${event.query}` + `&mail=${event.query}` + `&name=${event.query}` + - `&identype=${this.identifierType.value}` + - `&mailtype=${this.emailType.value}` + `&limit=10` // todo: The backend need to verify the settings. Else through bad request exception @@ -121,15 +136,16 @@ export default { // todo: Add fetch more data at the end of the options list return data?.People?.map((item) => { + debugger return { "value": item.id, "label": `${item?.primary_name?.given} ${item?.primary_name?.family}`, - "email": item?.email_addresses?.map((ma) => ma.mail)?.join(","), - "emailPretty": this.shortenString(item?.email_addresses?.map((ma) => ma.mail)?.join(",")), + "email": this.constructEmailCsv(item?.email_addresses), + "emailPretty": this.shortenString(this.constructEmailCsv(item?.email_addresses)), "emailLabel": "Email: ", - "identifier": item?.identifiers?.[0].identifier, - "identifierPretty": this.shortenString(item?.identifiers?.[0].identifier), - "identifierLabel": `Identifier: ` + "identifier": this.constructIdentifierCsv(item?.identifiers), + "identifierPretty": this.shortenString(this.constructIdentifierCsv(item?.identifiers)), + "identifierLabel": "Identifier: " } }) }, @@ -152,6 +168,7 @@ export default { :placeholder="this.txt['autocomplete.people.placeholder']" :loading="loading" :delay="500" + forceSelection @item-select="setPerson">