From 226d14ab34a8f2002118746475527211d33c102c Mon Sep 17 00:00:00 2001 From: Im-praveen Date: Thu, 12 Dec 2024 13:34:22 +0530 Subject: [PATCH] fix for #2692 --- .../eperson-form/eperson-form.component.ts | 24 +++++++++++++++++++ src/app/core/eperson/eperson-data.service.ts | 2 +- src/assets/i18n/en.json5 | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts index 8aa7f152501..e0c1a8ff0ee 100644 --- a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts +++ b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts @@ -118,6 +118,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy { firstName: DynamicInputModel; lastName: DynamicInputModel; email: DynamicInputModel; + phone: DynamicInputModel; // booleans canLogIn: DynamicCheckboxModel; requireCertificate: DynamicCheckboxModel; @@ -146,6 +147,11 @@ export class EPersonFormComponent implements OnInit, OnDestroy { host: 'row', }, }, + phone: { + grid: { + host: 'row', + }, + }, canLogIn: { grid: { host: 'col col-sm-6 d-inline-block', @@ -316,6 +322,12 @@ export class EPersonFormComponent implements OnInit, OnDestroy { }, hint: this.translateService.instant(`${this.messagePrefix}.emailHint`), }); + this.phone = new DynamicInputModel({ + id: 'phone', + label: this.translateService.instant(`${this.messagePrefix}.phone`), + name: 'phone', + required: false, + }); this.canLogIn = new DynamicCheckboxModel( { id: 'canLogIn', @@ -334,6 +346,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy { this.firstName, this.lastName, this.email, + this.phone, this.canLogIn, this.requireCertificate, ]; @@ -349,6 +362,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy { firstName: eperson != null ? eperson.firstMetadataValue('eperson.firstname') : '', lastName: eperson != null ? eperson.firstMetadataValue('eperson.lastname') : '', email: eperson != null ? eperson.email : '', + phone: eperson != null ? eperson.firstMetadataValue('eperson.phone') : '', canLogIn: eperson != null ? eperson.canLogIn : true, requireCertificate: eperson != null ? eperson.requireCertificate : false, }); @@ -425,6 +439,11 @@ export class EPersonFormComponent implements OnInit, OnDestroy { value: this.lastName.value, }, ], + 'eperson.phone': [ + { + value: this.phone.value, + }, + ], }, email: this.email.value, canLogIn: this.canLogIn.value, @@ -482,6 +501,11 @@ export class EPersonFormComponent implements OnInit, OnDestroy { value: (this.lastName.value ? this.lastName.value : ePerson.firstMetadataValue('eperson.lastname')), }, ], + 'eperson.phone': [ + { + value: this.phone.value, + }, + ], }, email: (hasValue(values.email) ? values.email : ePerson.email), canLogIn: (hasValue(values.canLogIn) ? values.canLogIn : ePerson.canLogIn), diff --git a/src/app/core/eperson/eperson-data.service.ts b/src/app/core/eperson/eperson-data.service.ts index 0de6de7407e..0c61e918fe9 100644 --- a/src/app/core/eperson/eperson-data.service.ts +++ b/src/app/core/eperson/eperson-data.service.ts @@ -269,7 +269,7 @@ export class EPersonDataService extends IdentifiableDataService impleme * @param newEPerson */ private generateOperations(oldEPerson: EPerson, newEPerson: EPerson): Operation[] { - let operations = this.comparator.diff(oldEPerson, newEPerson).filter((operation: Operation) => operation.op === 'replace'); + let operations = this.comparator.diff(oldEPerson, newEPerson).filter((operation: Operation) => operation.op === 'replace' || operation.op === 'add'); if (hasValue(oldEPerson.email) && oldEPerson.email !== newEPerson.email) { operations = [...operations, { op: 'replace', path: '/email', value: newEPerson.email, diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 532fc849ffc..58700a57747 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -316,6 +316,8 @@ "admin.access-control.epeople.form.email": "Email", + "admin.access-control.epeople.form.phone": "Phone", + "admin.access-control.epeople.form.emailHint": "Must be a valid email address", "admin.access-control.epeople.form.canLogIn": "Can log in",