Ajustement des permissions
This commit is contained in:
parent
587a846e3e
commit
af7bf65f8d
|
@ -28,7 +28,7 @@
|
|||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button color="primary" routerLink="/color/edit/{{recipeId}}">Retour</button>
|
||||
<button *ngIf="editionMode && canDeleteMix" mat-raised-button color="warn" (click)="deleteConfirmBox.show()">
|
||||
<button *ngIf="editionMode" mat-raised-button color="warn" (click)="deleteConfirmBox.show()">
|
||||
Supprimer
|
||||
</button>
|
||||
<button mat-raised-button color="accent" [disabled]="!form.valid" (click)="submit()">Enregistrer</button>
|
||||
|
|
|
@ -19,7 +19,6 @@ import {MatTable} from '@angular/material/table'
|
|||
import {ActivatedRoute, Router} from '@angular/router'
|
||||
import {ConfirmBoxComponent} from '../../../shared/components/confirm-box/confirm-box.component'
|
||||
import {AccountService} from '../../../accounts/services/account.service'
|
||||
import {Permission} from '../../../shared/model/user'
|
||||
import {ErrorService} from '../../../shared/service/error.service'
|
||||
|
||||
@Component({
|
||||
|
@ -190,10 +189,6 @@ export class MixEditorComponent extends ErrorHandlingComponent {
|
|||
})
|
||||
}
|
||||
|
||||
get canDeleteMix() {
|
||||
return this.accountService.hasPermission(Permission.REMOVE_RECIPES)
|
||||
}
|
||||
|
||||
private generateForm() {
|
||||
this.nameControl = new FormControl(this.mix ? this.mix.mixType.name : null, Validators.required)
|
||||
this.materialTypeControl = new FormControl(this.mix ? this.mix.mixType.material.materialType.id : null, Validators.required)
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
Enregistrer
|
||||
</button>
|
||||
<button
|
||||
*ngIf="hasDeletePermission"
|
||||
mat-raised-button
|
||||
color="warn"
|
||||
(click)="confirmBoxComponent.show()">
|
||||
|
|
|
@ -7,7 +7,6 @@ import {Validators} from '@angular/forms'
|
|||
import {Subject} from 'rxjs'
|
||||
import {UNIT_GALLON, UNIT_LITER, UNIT_MILLILITER} from '../../../shared/units'
|
||||
import {AccountService} from '../../../accounts/services/account.service'
|
||||
import {Permission} from '../../../shared/model/user'
|
||||
import {EntityEditComponent} from '../../../shared/components/entity-edit/entity-edit.component'
|
||||
import {ImagesEditorComponent} from '../../components/images-editor/images-editor.component'
|
||||
import {ErrorHandler, ErrorService} from '../../../shared/service/error.service'
|
||||
|
@ -168,10 +167,6 @@ export class EditComponent extends ErrorHandlingComponent {
|
|||
)
|
||||
}
|
||||
|
||||
get hasDeletePermission(): boolean {
|
||||
return this.accountService.hasPermission(Permission.REMOVE_RECIPES)
|
||||
}
|
||||
|
||||
get loggedInUserGroupId(): number {
|
||||
return this.appState.authenticatedUser.group?.id
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
title="Modifier la bannière {{company.name}}"
|
||||
deleteConfirmMessage="Voulez-vous vraiment supprimer la bannière {{company.name}}?"
|
||||
backButtonLink="/catalog/company/list"
|
||||
deletePermission="REMOVE_COMPANIES"
|
||||
[entity]="company"
|
||||
[formFields]="formFields"
|
||||
(submit)="submit($event)"
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
*ngIf="group"
|
||||
title="Modifier le groupe {{group.name}}"
|
||||
backButtonLink="/admin/group/list"
|
||||
deletePermission="REMOVE_USERS"
|
||||
deleteConfirmMessage="Voulez-vous vraiment supprimer le groupe {{group.name}}?"
|
||||
[entity]="group"
|
||||
[formFields]="formFields"
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
title="Modifier le group {{materialType.name}}"
|
||||
deleteConfirmMessage="Voulez-vous vraiment supprimer le type de produit {{materialType.name}}?"
|
||||
backButtonLink="/catalog/materialtype/list"
|
||||
deletePermission="REMOVE_MATERIAL_TYPES"
|
||||
[entity]="materialType"
|
||||
[formFields]="formFields"
|
||||
(submit)="submit($event)"
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
title="Modifier le produit {{material.name}}"
|
||||
deleteConfirmMessage="Voulez-vous vraiment supprimer le produit {{material.name}}?"
|
||||
backButtonLink="/catalog/material/list"
|
||||
deletePermission="REMOVE_MATERIALS"
|
||||
[entity]="material"
|
||||
[formFields]="formFields"
|
||||
(submit)="submit($event)"
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
</mat-card-content>
|
||||
<mat-card-actions *ngIf="!disableButtons">
|
||||
<button mat-raised-button color="primary" [routerLink]="backButtonLink">Retour</button>
|
||||
<button mat-raised-button color="warn" *ngIf="canDelete" (click)="confirmBoxComponent.show()">Supprimer</button>
|
||||
<button mat-raised-button color="warn" (click)="confirmBoxComponent.show()">Supprimer</button>
|
||||
<button mat-raised-button color="accent" [disabled]="form.invalid" (click)="submitForm()">
|
||||
Enregistrer
|
||||
</button>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import {ChangeDetectorRef, Component, EventEmitter, Input, Output} from '@angular/core'
|
||||
import {Component, EventEmitter, Input, Output} from '@angular/core'
|
||||
import {FormBuilder, FormControl, FormGroup} from '@angular/forms'
|
||||
import {FormField} from '../entity-add/entity-add.component'
|
||||
import {Permission} from '../../model/user'
|
||||
import {AccountService} from '../../../accounts/services/account.service'
|
||||
|
||||
@Component({
|
||||
|
@ -15,7 +14,6 @@ export class EntityEditComponent {
|
|||
@Input() deleteConfirmMessage: string
|
||||
@Input() backButtonLink: string
|
||||
@Input() formFields: FormField[]
|
||||
@Input() deletePermission: Permission
|
||||
@Input() disableButtons: boolean
|
||||
@Input() noTopMargin = false
|
||||
@Output() submit = new EventEmitter<any>()
|
||||
|
@ -55,8 +53,4 @@ export class EntityEditComponent {
|
|||
})
|
||||
return values
|
||||
}
|
||||
|
||||
get canDelete(): boolean {
|
||||
return this.accountService.hasPermission(this.deletePermission)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ export class HeaderComponent extends SubscribingComponent {
|
|||
}
|
||||
|
||||
if (l.route === '/misc') {
|
||||
l.enabled = this.accountService.hasPermission(Permission.GENERATE_TOUCH_UP_KIT)
|
||||
l.enabled = this.accountService.hasPermission(Permission.VIEW_TOUCH_UP_KITS)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ export class PermissionsFieldComponent implements OnInit {
|
|||
ngOnInit(): void {
|
||||
this.mapPermissions('view')
|
||||
this.mapPermissions('edit')
|
||||
this.mapPermissions('remove')
|
||||
this.mapPermissions('other')
|
||||
|
||||
if (this.enabledPermissions) {
|
||||
|
|
|
@ -33,17 +33,12 @@ export enum Permission {
|
|||
EDIT_USERS = 'EDIT_USERS',
|
||||
EDIT_CATALOG = 'EDIT_CATALOG',
|
||||
|
||||
REMOVE_RECIPES = 'REMOVE_RECIPES',
|
||||
REMOVE_MATERIALS = 'REMOVE_MATERIALS',
|
||||
REMOVE_MATERIAL_TYPES = 'REMOVE_MATERIAL_TYPES',
|
||||
REMOVE_COMPANIES = 'REMOVE_COMPANIES',
|
||||
REMOVE_USERS = 'REMOVE_USERS',
|
||||
REMOVE_CATALOG = 'REMOVE_CATALOG',
|
||||
VIEW_TOUCH_UP_KITS = 'VIEW_TOUCH_UP_KITS',
|
||||
EDIT_TOUCH_UP_KITS = 'EDIT_TOUCH_UP_KITS',
|
||||
|
||||
PRINT_MIXES = 'PRINT_MIXES',
|
||||
ADD_TO_INVENTORY = 'ADD_TO_INVENTORY',
|
||||
DEDUCT_FROM_INVENTORY = 'DEDUCT_FROM_INVENTORY',
|
||||
GENERATE_TOUCH_UP_KIT = 'GENERATE_TOUCH_UP_KIT',
|
||||
|
||||
ADMIN = 'ADMIN'
|
||||
}
|
||||
|
@ -53,6 +48,7 @@ export const mapped_permissions = {
|
|||
{permission: Permission.VIEW_RECIPES, description: 'Voir les recettes', impliedPermissions: []},
|
||||
{permission: Permission.VIEW_CATALOG, description: 'Voir le catalogue', impliedPermissions: []},
|
||||
{permission: Permission.VIEW_USERS, description: 'Voir les utilisateurs', impliedPermissions: []},
|
||||
{permission: Permission.VIEW_TOUCH_UP_KITS, description: 'Voir les kits de retouche', impliedPermissions: []}
|
||||
],
|
||||
edit: [{
|
||||
permission: Permission.EDIT_RECIPES_PUBLIC_DATA,
|
||||
|
@ -82,31 +78,10 @@ export const mapped_permissions = {
|
|||
permission: Permission.EDIT_USERS,
|
||||
description: 'Modifier les utilisateurs',
|
||||
impliedPermissions: [Permission.VIEW_USERS]
|
||||
}],
|
||||
remove: [{
|
||||
permission: Permission.REMOVE_RECIPES,
|
||||
description: 'Supprimer des recettes',
|
||||
impliedPermissions: [Permission.EDIT_RECIPES]
|
||||
}, {
|
||||
permission: Permission.REMOVE_MATERIALS,
|
||||
description: 'Supprimer des produits',
|
||||
impliedPermissions: [Permission.EDIT_MATERIALS]
|
||||
}, {
|
||||
permission: Permission.REMOVE_MATERIAL_TYPES,
|
||||
description: 'Supprimer des types de produit',
|
||||
impliedPermissions: [Permission.EDIT_MATERIAL_TYPES]
|
||||
}, {
|
||||
permission: Permission.REMOVE_COMPANIES,
|
||||
description: 'Supprimer des bannières',
|
||||
impliedPermissions: [Permission.EDIT_COMPANIES]
|
||||
}, {
|
||||
permission: Permission.REMOVE_CATALOG,
|
||||
description: 'Supprimer dans le catalogue',
|
||||
impliedPermissions: [Permission.REMOVE_MATERIALS, Permission.REMOVE_MATERIAL_TYPES, Permission.REMOVE_COMPANIES]
|
||||
}, {
|
||||
permission: Permission.REMOVE_USERS,
|
||||
description: 'Supprimer des utilisateurs',
|
||||
impliedPermissions: [Permission.EDIT_USERS]
|
||||
permission: Permission.EDIT_TOUCH_UP_KITS,
|
||||
description: 'Modifier les kits de retouche',
|
||||
impliedPermissions: [Permission.VIEW_TOUCH_UP_KITS]
|
||||
}],
|
||||
other: [{
|
||||
permission: Permission.PRINT_MIXES,
|
||||
|
@ -120,13 +95,9 @@ export const mapped_permissions = {
|
|||
permission: Permission.DEDUCT_FROM_INVENTORY,
|
||||
description: 'Déduire dans l\'inventaire',
|
||||
impliedPermissions: [Permission.VIEW_RECIPES]
|
||||
}, {
|
||||
permission: Permission.GENERATE_TOUCH_UP_KIT,
|
||||
description: 'Générer un PDF de kit de retouche',
|
||||
impliedPermissions: []
|
||||
}, {
|
||||
permission: Permission.ADMIN,
|
||||
description: 'Administrateur',
|
||||
impliedPermissions: [Permission.EDIT_CATALOG, Permission.REMOVE_RECIPES, Permission.REMOVE_USERS, Permission.REMOVE_CATALOG, Permission.PRINT_MIXES, Permission.ADD_TO_INVENTORY, Permission.DEDUCT_FROM_INVENTORY, Permission.GENERATE_TOUCH_UP_KIT]
|
||||
impliedPermissions: [Permission.EDIT_RECIPES, Permission.EDIT_CATALOG, Permission.EDIT_USERS, Permission.EDIT_TOUCH_UP_KITS, Permission.PRINT_MIXES, Permission.ADD_TO_INVENTORY, Permission.DEDUCT_FROM_INVENTORY]
|
||||
}]
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
*ngIf="user"
|
||||
title="Modification de l'utilisateur #{{user.id}}"
|
||||
backButtonLink="/admin/user/list"
|
||||
deletePermission="REMOVE_USERS"
|
||||
deleteConfirmMessage="Voulez-vous vraiment supprimer l'utilisateur #{{user.id}}?"
|
||||
[entity]="user"
|
||||
[formFields]="formFields"
|
||||
|
|
|
@ -10,6 +10,6 @@ import {Permission} from '../../modules/shared/model/user'
|
|||
})
|
||||
export class MiscComponent extends SubMenuComponent{
|
||||
links: NavLink[] = [
|
||||
{route: '/misc/touchupkit', title: 'Kits de retouche', permission: Permission.GENERATE_TOUCH_UP_KIT}
|
||||
{route: '/misc/touchupkit', title: 'Kits de retouche', permission: Permission.VIEW_TOUCH_UP_KITS}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue