mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
retrieve active eperson at component construct for checkboxes
This commit is contained in:
@@ -178,7 +178,7 @@
|
|||||||
|
|
||||||
"admin.access-control.epeople.search.scope.name": "Name",
|
"admin.access-control.epeople.search.scope.name": "Name",
|
||||||
|
|
||||||
"admin.access-control.epeople.search.scope.email": "E-mail",
|
"admin.access-control.epeople.search.scope.email": "E-mail (exact)",
|
||||||
|
|
||||||
"admin.access-control.epeople.search.scope.metadata": "Metadata",
|
"admin.access-control.epeople.search.scope.metadata": "Metadata",
|
||||||
|
|
||||||
|
@@ -9,6 +9,9 @@ import { EPeopleRegistryComponent } from './epeople-registry/epeople-registry.co
|
|||||||
])
|
])
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
/**
|
||||||
|
* Routing module for the AccessControl section of the admin sidebar
|
||||||
|
*/
|
||||||
export class AdminAccessControlRoutingModule {
|
export class AdminAccessControlRoutingModule {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,9 @@ import { EPersonFormComponent } from './epeople-registry/eperson-form/eperson-fo
|
|||||||
],
|
],
|
||||||
entryComponents: []
|
entryComponents: []
|
||||||
})
|
})
|
||||||
|
/**
|
||||||
|
* This module handles all components related to the access control pages
|
||||||
|
*/
|
||||||
export class AdminAccessControlModule {
|
export class AdminAccessControlModule {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -106,10 +106,18 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
subs: Subscription[] = [];
|
subs: Subscription[] = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to retrieve initial active eperson, to fill in checkboxes at component creation
|
||||||
|
*/
|
||||||
|
epersonInitial: EPerson;
|
||||||
|
|
||||||
constructor(public epersonService: EPersonDataService,
|
constructor(public epersonService: EPersonDataService,
|
||||||
private formBuilderService: FormBuilderService,
|
private formBuilderService: FormBuilderService,
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
private notificationsService: NotificationsService,) {
|
private notificationsService: NotificationsService,) {
|
||||||
|
this.subs.push(this.epersonService.getActiveEPerson().subscribe((eperson: EPerson) => {
|
||||||
|
this.epersonInitial = eperson;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -155,12 +163,14 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
id: 'canLogIn',
|
id: 'canLogIn',
|
||||||
label: canLogIn,
|
label: canLogIn,
|
||||||
name: 'canLogIn',
|
name: 'canLogIn',
|
||||||
|
value: (this.epersonInitial != null ? this.epersonInitial.canLogIn : true)
|
||||||
});
|
});
|
||||||
this.requireCertificate = new DynamicCheckboxModel(
|
this.requireCertificate = new DynamicCheckboxModel(
|
||||||
{
|
{
|
||||||
id: 'requireCertificate',
|
id: 'requireCertificate',
|
||||||
label: requireCertificate,
|
label: requireCertificate,
|
||||||
name: 'requireCertificate',
|
name: 'requireCertificate',
|
||||||
|
value: (this.epersonInitial != null ? this.epersonInitial.requireCertificate : false)
|
||||||
});
|
});
|
||||||
this.formModel = [
|
this.formModel = [
|
||||||
this.firstName,
|
this.firstName,
|
||||||
@@ -175,10 +185,9 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
firstName: eperson != null ? eperson.firstMetadataValue('eperson.firstname') : '',
|
firstName: eperson != null ? eperson.firstMetadataValue('eperson.firstname') : '',
|
||||||
lastName: eperson != null ? eperson.firstMetadataValue('eperson.lastname') : '',
|
lastName: eperson != null ? eperson.firstMetadataValue('eperson.lastname') : '',
|
||||||
email: eperson != null ? eperson.email : '',
|
email: eperson != null ? eperson.email : '',
|
||||||
canLogIn: eperson != null ? eperson.canLogIn : true,
|
|
||||||
requireCertificate: eperson != null ? eperson.requireCertificate : false,
|
|
||||||
selfRegistered: false,
|
|
||||||
});
|
});
|
||||||
|
this.formGroup.get('canLogIn').patchValue((eperson != null ? eperson.canLogIn : true));
|
||||||
|
this.formGroup.get('requireCertificate').patchValue((eperson != null ? eperson.requireCertificate : false));
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -216,14 +225,12 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
email: this.email.value,
|
email: this.email.value,
|
||||||
canLogIn: this.canLogIn.value,
|
canLogIn: this.canLogIn.value,
|
||||||
requireCertificate: this.requireCertificate.value,
|
requireCertificate: this.requireCertificate.value,
|
||||||
selfRegistered: false,
|
|
||||||
};
|
};
|
||||||
if (ePerson == null) {
|
if (ePerson == null) {
|
||||||
this.createNewEPerson(values);
|
this.createNewEPerson(values);
|
||||||
} else {
|
} else {
|
||||||
this.editEPerson(ePerson, values);
|
this.editEPerson(ePerson, values);
|
||||||
}
|
}
|
||||||
this.clearFields();
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -270,7 +277,6 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
email: (hasValue(values.email) ? values.email : ePerson.email),
|
email: (hasValue(values.email) ? values.email : ePerson.email),
|
||||||
canLogIn: (hasValue(values.canLogIn) ? values.canLogIn : ePerson.canLogIn),
|
canLogIn: (hasValue(values.canLogIn) ? values.canLogIn : ePerson.canLogIn),
|
||||||
requireCertificate: (hasValue(values.requireCertificate) ? values.requireCertificate : ePerson.requireCertificate),
|
requireCertificate: (hasValue(values.requireCertificate) ? values.requireCertificate : ePerson.requireCertificate),
|
||||||
selfRegistered: false,
|
|
||||||
_links: ePerson._links,
|
_links: ePerson._links,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -320,7 +326,8 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
firstName: '',
|
firstName: '',
|
||||||
lastName: '',
|
lastName: '',
|
||||||
email: '',
|
email: '',
|
||||||
canLogin: '',
|
canLogin: true,
|
||||||
|
requireCertificate: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user