Updated common, fixed admin removing own admin role
This commit is contained in:
parent
b2ba59077f
commit
400afa4133
@ -64,6 +64,21 @@ export class UserDetailsComponent implements OnInit {
|
||||
}, []);
|
||||
}
|
||||
|
||||
shouldBeDisabled(role: string): boolean {
|
||||
if (!this.user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isCurrentAdminUser = this.user.isAdmin && this.user.id === this._userService.currentUser.id;
|
||||
return (
|
||||
(role === 'RED_ADMIN' && isCurrentAdminUser) ||
|
||||
Object.keys(this._ROLE_REQUIREMENTS).reduce(
|
||||
(value, key) => value || (role === this._ROLE_REQUIREMENTS[key] && this.user.roles.includes(key)),
|
||||
false,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
const rolesControls = this.ROLES.reduce(
|
||||
(prev, role) => ({
|
||||
@ -71,12 +86,7 @@ export class UserDetailsComponent implements OnInit {
|
||||
[role]: [
|
||||
{
|
||||
value: this.user && this.user.roles.indexOf(role) !== -1,
|
||||
disabled:
|
||||
this.user &&
|
||||
Object.keys(this._ROLE_REQUIREMENTS).reduce(
|
||||
(value, key) => value || (role === this._ROLE_REQUIREMENTS[key] && this.user.roles.indexOf(key) !== -1),
|
||||
false,
|
||||
),
|
||||
disabled: this.shouldBeDisabled(role),
|
||||
},
|
||||
],
|
||||
}),
|
||||
|
||||
@ -76,7 +76,7 @@ export class TrashScreenComponent extends ListingComponent<DossierListItem> impl
|
||||
hardDelete(dossiers = this.listingService.selected): void {
|
||||
const data = new ConfirmationDialogInput({
|
||||
title: _('confirmation-dialog.delete-dossier.title'),
|
||||
titleColor: TitleColors.PRIMARY,
|
||||
titleColor: TitleColors.WARN,
|
||||
question: _('confirmation-dialog.delete-dossier.question'),
|
||||
// details: _('confirmation-dialog.delete-dossier.details'),
|
||||
confirmationText: _('confirmation-dialog.delete-dossier.confirmation-text'),
|
||||
|
||||
@ -75,7 +75,7 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent<FileL
|
||||
hardDelete(files = this.listingService.selected) {
|
||||
const data = new ConfirmationDialogInput({
|
||||
title: _('confirmation-dialog.permanently-delete-file.title'),
|
||||
titleColor: TitleColors.PRIMARY,
|
||||
titleColor: TitleColors.WARN,
|
||||
question: _('confirmation-dialog.permanently-delete-file.question'),
|
||||
confirmationText: _('confirmation-dialog.permanently-delete-file.confirmation-text'),
|
||||
requireInput: true,
|
||||
|
||||
@ -109,7 +109,7 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
||||
deleteDossier() {
|
||||
const data = new ConfirmationDialogInput({
|
||||
title: _('confirmation-dialog.delete-dossier.title'),
|
||||
titleColor: TitleColors.PRIMARY,
|
||||
titleColor: TitleColors.WARN,
|
||||
question: _('confirmation-dialog.delete-dossier.question'),
|
||||
// details: _('confirmation-dialog.delete-dossier.details'),
|
||||
confirmationText: _('confirmation-dialog.delete-dossier.confirmation-text'),
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 26c117e8d1e0c33fd999fc2e2fc8ddaeacc46bec
|
||||
Subproject commit 6adb38a61db759028e5e18d9b05c8e1b8f85e371
|
||||
Loading…
x
Reference in New Issue
Block a user