Fixed Permission issues for edit dossier and deleted dossiers
This commit is contained in:
parent
f682303c1a
commit
7a55e12432
@ -50,7 +50,7 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa
|
||||
}
|
||||
|
||||
get disabled(): boolean {
|
||||
return !this._permissionsService.canHardDeleteOrRestore(this.dossier);
|
||||
return !this._permissionsService.isOwner(this.dossier);
|
||||
}
|
||||
|
||||
get valid(): boolean {
|
||||
|
||||
@ -70,7 +70,8 @@ export class TrashService extends GenericService<TrashItem> {
|
||||
new TrashDossier(
|
||||
dossier,
|
||||
this._configService.values.DELETE_RETENTION_HOURS as number,
|
||||
this._permissionsService.canDeleteDossier(dossier),
|
||||
this._permissionsService.canHardDeleteDossier(dossier),
|
||||
this._permissionsService.canRestoreDossier(dossier),
|
||||
),
|
||||
),
|
||||
switchMap(dossiers => this._dossierStatsService.getFor(dossiers.map(d => d.id)).pipe(map(() => dossiers))),
|
||||
|
||||
@ -169,6 +169,14 @@ export class PermissionsService {
|
||||
return dossier.ownerId === this._userService.currentUser.id;
|
||||
}
|
||||
|
||||
canHardDeleteDossier(dossier: IDossier): boolean {
|
||||
return this._userService.currentUser.isManager;
|
||||
}
|
||||
|
||||
canRestoreDossier(dossier: IDossier): boolean {
|
||||
return this._userService.currentUser.isManager;
|
||||
}
|
||||
|
||||
canArchiveDossier(dossier: Dossier): boolean {
|
||||
return (
|
||||
this._featuresService.isEnabled(DOSSIERS_ARCHIVE) && dossier.isActive && dossier.ownerId === this._userService.currentUser.id
|
||||
@ -180,7 +188,7 @@ export class PermissionsService {
|
||||
}
|
||||
|
||||
canEditDossierDictionary(dossier: Dossier, user = this._userService.currentUser): boolean {
|
||||
return dossier.isActive && this.canEditDossier(dossier, user);
|
||||
return dossier.isActive && this.isDossierMember(dossier, user);
|
||||
}
|
||||
|
||||
canEditDossierDictionaryDisplayName(dossier: Dossier, user = this._userService.currentUser): boolean {
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 22434a2627d71f7cddc8bdd7d9adab9762c41e4c
|
||||
Subproject commit 08737703e46fd0a8366bdf0c4241772d7ac8e2bb
|
||||
@ -17,7 +17,12 @@ export class TrashDossier extends TrashItem {
|
||||
readonly ownerId: string;
|
||||
readonly softDeletedTime: string;
|
||||
|
||||
constructor(dossier: IDossier, protected readonly _retentionHours: number, readonly canHardDelete: boolean) {
|
||||
constructor(
|
||||
dossier: IDossier,
|
||||
protected readonly _retentionHours: number,
|
||||
readonly canHardDelete: boolean,
|
||||
protected readonly _hasRestoreRights: boolean,
|
||||
) {
|
||||
super(_retentionHours, dossier.softDeletedTime, canHardDelete);
|
||||
this.dossierId = dossier.dossierId;
|
||||
this.dossierTemplateId = dossier.dossierTemplateId;
|
||||
@ -29,6 +34,7 @@ export class TrashDossier extends TrashItem {
|
||||
|
||||
// Because of migrations, for some this is not set
|
||||
this.softDeletedTime = dossier.softDeletedTime || '-';
|
||||
this.canRestore = this.canRestore && this._hasRestoreRights;
|
||||
}
|
||||
|
||||
get id(): string {
|
||||
|
||||
@ -6,8 +6,8 @@ export abstract class TrashItem {
|
||||
abstract readonly ownerId?: string;
|
||||
abstract readonly dossierId: string;
|
||||
abstract readonly icon: string;
|
||||
readonly canRestore: boolean;
|
||||
readonly restoreDate: string;
|
||||
canRestore: boolean;
|
||||
|
||||
protected constructor(
|
||||
protected readonly _retentionHours: number,
|
||||
@ -34,7 +34,7 @@ export abstract class TrashItem {
|
||||
|
||||
get #canRestore(): boolean {
|
||||
const { daysLeft, hoursLeft, minutesLeft } = getLeftDateTime(this.restoreDate);
|
||||
return daysLeft >= 0 && hoursLeft >= 0 && minutesLeft > 0;
|
||||
return daysLeft >= 0 || hoursLeft >= 0 || minutesLeft > 0;
|
||||
}
|
||||
|
||||
get #restoreDate(): string {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user