Skip to content

Commit

Permalink
Merge pull request #1 from Im-praveen/feature#2692
Browse files Browse the repository at this point in the history
fix for #2692
  • Loading branch information
Im-praveen authored Dec 12, 2024
2 parents ac00f88 + 226d14a commit be408f4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
firstName: DynamicInputModel;
lastName: DynamicInputModel;
email: DynamicInputModel;
phone: DynamicInputModel;
// booleans
canLogIn: DynamicCheckboxModel;
requireCertificate: DynamicCheckboxModel;
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -334,6 +346,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
this.firstName,
this.lastName,
this.email,
this.phone,
this.canLogIn,
this.requireCertificate,
];
Expand All @@ -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,
});
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/eperson/eperson-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export class EPersonDataService extends IdentifiableDataService<EPerson> 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,
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit be408f4

Please sign in to comment.