RED-3950: File & dossier delete/restore permissions
This commit is contained in:
parent
f0d9bc0899
commit
2caa66a3d3
@ -9,12 +9,11 @@ import { DownloadsListScreenComponent } from '@components/downloads-list-screen/
|
|||||||
import { DossiersGuard } from '@guards/dossiers.guard';
|
import { DossiersGuard } from '@guards/dossiers.guard';
|
||||||
import { ACTIVE_DOSSIERS_SERVICE, ARCHIVED_DOSSIERS_SERVICE } from './tokens';
|
import { ACTIVE_DOSSIERS_SERVICE, ARCHIVED_DOSSIERS_SERVICE } from './tokens';
|
||||||
import { FeaturesGuard } from '@guards/features-guard.service';
|
import { FeaturesGuard } from '@guards/features-guard.service';
|
||||||
import { ARCHIVE_ROUTE, DOSSIER_TEMPLATE_ID, DOSSIERS_ARCHIVE, DOSSIERS_ROUTE } from '@red/domain';
|
|
||||||
import { DossierTemplatesGuard } from '@guards/dossier-templates.guard';
|
import { DossierTemplatesGuard } from '@guards/dossier-templates.guard';
|
||||||
import { DossierTemplateExistsGuard } from '@guards/dossier-template-exists.guard';
|
import { DossierTemplateExistsGuard } from '@guards/dossier-template-exists.guard';
|
||||||
import { DashboardGuard } from '@guards/dashboard-guard.service';
|
import { DashboardGuard } from '@guards/dashboard-guard.service';
|
||||||
import { ARCHIVE_ROUTE, DOSSIERS_ARCHIVE, DOSSIERS_ROUTE } from '@red/domain';
|
|
||||||
import { TrashGuard } from '@guards/trash.guard';
|
import { TrashGuard } from '@guards/trash.guard';
|
||||||
|
import { ARCHIVE_ROUTE, DOSSIER_TEMPLATE_ID, DOSSIERS_ARCHIVE, DOSSIERS_ROUTE } from '@red/domain';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -69,6 +69,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<iqser-icon-button
|
<iqser-icon-button
|
||||||
(action)="newDossier()"
|
(action)="newDossier()"
|
||||||
|
*ngIf="permissionsService.canCreateDossier()"
|
||||||
[label]="'dashboard.empty-template.new-dossier' | translate"
|
[label]="'dashboard.empty-template.new-dossier' | translate"
|
||||||
[type]="iconButtonTypes.primary"
|
[type]="iconButtonTypes.primary"
|
||||||
icon="iqser:plus"
|
icon="iqser:plus"
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { IconButtonTypes } from '@iqser/common-ui';
|
|||||||
import { DossiersDialogService } from '../../../dossier/shared/services/dossiers-dialog.service';
|
import { DossiersDialogService } from '../../../dossier/shared/services/dossiers-dialog.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { TranslateChartService } from '@services/translate-chart.service';
|
import { TranslateChartService } from '@services/translate-chart.service';
|
||||||
|
import { PermissionsService } from '@services/permissions.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'redaction-template-stats [stats]',
|
selector: 'redaction-template-stats [stats]',
|
||||||
@ -20,6 +21,7 @@ export class TemplateStatsComponent {
|
|||||||
private readonly _dialogService: DossiersDialogService,
|
private readonly _dialogService: DossiersDialogService,
|
||||||
private readonly _translateService: TranslateService,
|
private readonly _translateService: TranslateService,
|
||||||
readonly translateChartService: TranslateChartService,
|
readonly translateChartService: TranslateChartService,
|
||||||
|
readonly permissionsService: PermissionsService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
newDossier(): void {
|
newDossier(): void {
|
||||||
|
|||||||
@ -183,7 +183,7 @@ export class DossierOverviewBulkActionsComponent implements OnChanges {
|
|||||||
);
|
);
|
||||||
this.#canAssignToSelf = this.#canMoveToSameState && this._permissionsService.canAssignToSelf(this.selectedFiles, this.dossier);
|
this.#canAssignToSelf = this.#canMoveToSameState && this._permissionsService.canAssignToSelf(this.selectedFiles, this.dossier);
|
||||||
|
|
||||||
this.#canDelete = this._permissionsService.canDeleteFile(this.selectedFiles, this.dossier);
|
this.#canDelete = this._permissionsService.canSoftDeleteFile(this.selectedFiles, this.dossier);
|
||||||
|
|
||||||
this.#canReanalyse = this._permissionsService.canReanalyseFile(this.selectedFiles, this.dossier);
|
this.#canReanalyse = this._permissionsService.canReanalyseFile(this.selectedFiles, this.dossier);
|
||||||
|
|
||||||
|
|||||||
@ -78,23 +78,23 @@
|
|||||||
<div class="dialog-actions">
|
<div class="dialog-actions">
|
||||||
<iqser-icon-button
|
<iqser-icon-button
|
||||||
(action)="deleteDossier()"
|
(action)="deleteDossier()"
|
||||||
*ngIf="permissionsService.canDeleteDossier(dossier)"
|
*ngIf="permissionsService.canSoftDeleteDossier(dossier)"
|
||||||
|
[dialogElement]="true"
|
||||||
[label]="'dossier-listing.delete.action' | translate"
|
[label]="'dossier-listing.delete.action' | translate"
|
||||||
[type]="iconButtonTypes.dark"
|
[type]="iconButtonTypes.dark"
|
||||||
icon="iqser:trash"
|
icon="iqser:trash"
|
||||||
id="deleteDossier"
|
id="deleteDossier"
|
||||||
iqserHelpMode="edit_dossier_delete_dossier"
|
iqserHelpMode="edit_dossier_delete_dossier"
|
||||||
[dialogElement]="true"
|
|
||||||
></iqser-icon-button>
|
></iqser-icon-button>
|
||||||
|
|
||||||
<iqser-icon-button
|
<iqser-icon-button
|
||||||
(action)="archiveDossier()"
|
(action)="archiveDossier()"
|
||||||
*ngIf="permissionsService.canArchiveDossier(dossier)"
|
*ngIf="permissionsService.canArchiveDossier(dossier)"
|
||||||
|
[dialogElement]="true"
|
||||||
[label]="'dossier-listing.archive.action' | translate"
|
[label]="'dossier-listing.archive.action' | translate"
|
||||||
[type]="iconButtonTypes.dark"
|
[type]="iconButtonTypes.dark"
|
||||||
icon="red:archive"
|
icon="red:archive"
|
||||||
iqserHelpMode="edit_dossier_archive_dossier"
|
iqserHelpMode="edit_dossier_archive_dossier"
|
||||||
[dialogElement]="true"
|
|
||||||
></iqser-icon-button>
|
></iqser-icon-button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@ -398,7 +398,7 @@ export class FileActionsComponent implements OnChanges {
|
|||||||
|
|
||||||
this.canToggleAnalysis = this._permissionsService.canToggleAnalysis(this.file, this.dossier);
|
this.canToggleAnalysis = this._permissionsService.canToggleAnalysis(this.file, this.dossier);
|
||||||
this.showToggleAnalysis = this._permissionsService.showToggleAnalysis(this.dossier);
|
this.showToggleAnalysis = this._permissionsService.showToggleAnalysis(this.dossier);
|
||||||
this.showDelete = this._permissionsService.canDeleteFile(this.file, this.dossier);
|
this.showDelete = this._permissionsService.canSoftDeleteFile(this.file, this.dossier);
|
||||||
this.showOCR = this._permissionsService.canOcrFile(this.file, this.dossier);
|
this.showOCR = this._permissionsService.canOcrFile(this.file, this.dossier);
|
||||||
this.canReanalyse = this._permissionsService.canReanalyseFile(this.file, this.dossier);
|
this.canReanalyse = this._permissionsService.canReanalyseFile(this.file, this.dossier);
|
||||||
this.canDisableAutoAnalysis = this._permissionsService.canDisableAutoAnalysis([this.file], this.dossier);
|
this.canDisableAutoAnalysis = this._permissionsService.canDisableAutoAnalysis([this.file], this.dossier);
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import { workloadTranslations } from '../dossier/translations/workload-translati
|
|||||||
import { DossierStatsService } from '@services/dossiers/dossier-stats.service';
|
import { DossierStatsService } from '@services/dossiers/dossier-stats.service';
|
||||||
import { DossierStatesMapService } from '@services/entity-services/dossier-states-map.service';
|
import { DossierStatesMapService } from '@services/entity-services/dossier-states-map.service';
|
||||||
import { DossiersDialogService } from '../dossier/shared/services/dossiers-dialog.service';
|
import { DossiersDialogService } from '../dossier/shared/services/dossiers-dialog.service';
|
||||||
|
import { PermissionsService } from '@services/permissions.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ConfigService {
|
export class ConfigService {
|
||||||
@ -21,6 +22,7 @@ export class ConfigService {
|
|||||||
private readonly _dossierStatsService: DossierStatsService,
|
private readonly _dossierStatsService: DossierStatsService,
|
||||||
private readonly _dossierStatesMapService: DossierStatesMapService,
|
private readonly _dossierStatesMapService: DossierStatesMapService,
|
||||||
private readonly _dialogService: DossiersDialogService,
|
private readonly _dialogService: DossiersDialogService,
|
||||||
|
private readonly _permissionsService: PermissionsService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
get tableConfig(): TableColumnConfig<Dossier>[] {
|
get tableConfig(): TableColumnConfig<Dossier>[] {
|
||||||
@ -43,7 +45,7 @@ export class ConfigService {
|
|||||||
{
|
{
|
||||||
label: _('dossier-listing.add-new'),
|
label: _('dossier-listing.add-new'),
|
||||||
action: () => this._openAddDossierDialog(dossierTemplateId),
|
action: () => this._openAddDossierDialog(dossierTemplateId),
|
||||||
hide: !this._currentUser.isManager,
|
hide: !this._permissionsService.canCreateDossier(),
|
||||||
icon: 'iqser:plus',
|
icon: 'iqser:plus',
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
helpModeKey: 'new_dossier_button',
|
helpModeKey: 'new_dossier_button',
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
[noDataButtonLabel]="'dossier-listing.no-data.action' | translate"
|
[noDataButtonLabel]="'dossier-listing.no-data.action' | translate"
|
||||||
[noDataText]="'dossier-listing.no-data.title' | translate"
|
[noDataText]="'dossier-listing.no-data.title' | translate"
|
||||||
[noMatchText]="'dossier-listing.no-match.title' | translate"
|
[noMatchText]="'dossier-listing.no-match.title' | translate"
|
||||||
[showNoDataButton]="currentUser.isManager"
|
[showNoDataButton]="permissionsService.canCreateDossier()"
|
||||||
[tableColumnConfigs]="tableColumnConfigs"
|
[tableColumnConfigs]="tableColumnConfigs"
|
||||||
noDataIcon="red:folder"
|
noDataIcon="red:folder"
|
||||||
></iqser-table>
|
></iqser-table>
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { ChangeDetectionStrategy, Component, forwardRef, Injector, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, forwardRef, Injector, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
||||||
import { Dossier, DOSSIER_TEMPLATE_ID } from '@red/domain';
|
import { Dossier, DOSSIER_TEMPLATE_ID } from '@red/domain';
|
||||||
import { UserService } from '@services/user.service';
|
|
||||||
import { PermissionsService } from '@services/permissions.service';
|
import { PermissionsService } from '@services/permissions.service';
|
||||||
import { ButtonConfig, DefaultListingServices, ListingComponent, OnAttach, TableComponent } from '@iqser/common-ui';
|
import { ButtonConfig, DefaultListingServices, ListingComponent, OnAttach, TableComponent } from '@iqser/common-ui';
|
||||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||||
@ -18,7 +17,6 @@ import { UserPreferenceService } from '@services/user-preference.service';
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class DossiersListingScreenComponent extends ListingComponent<Dossier> implements OnInit, OnAttach {
|
export class DossiersListingScreenComponent extends ListingComponent<Dossier> implements OnInit, OnAttach {
|
||||||
readonly currentUser = this._userService.currentUser;
|
|
||||||
readonly tableColumnConfigs = this._configService.tableConfig;
|
readonly tableColumnConfigs = this._configService.tableConfig;
|
||||||
readonly tableHeaderLabel = _('dossier-listing.table-header.title');
|
readonly tableHeaderLabel = _('dossier-listing.table-header.title');
|
||||||
readonly buttonConfigs: ButtonConfig[];
|
readonly buttonConfigs: ButtonConfig[];
|
||||||
@ -33,7 +31,6 @@ export class DossiersListingScreenComponent extends ListingComponent<Dossier> im
|
|||||||
constructor(
|
constructor(
|
||||||
router: Router,
|
router: Router,
|
||||||
protected readonly _injector: Injector,
|
protected readonly _injector: Injector,
|
||||||
private readonly _userService: UserService,
|
|
||||||
private readonly _configService: ConfigService,
|
private readonly _configService: ConfigService,
|
||||||
readonly permissionsService: PermissionsService,
|
readonly permissionsService: PermissionsService,
|
||||||
private readonly _dialogService: DossiersDialogService,
|
private readonly _dialogService: DossiersDialogService,
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||||
import { Dossier, DossierStats } from '@red/domain';
|
import { DossierStats, IDossier } from '@red/domain';
|
||||||
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
|
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
|
||||||
import { List } from '@iqser/common-ui';
|
import { List } from '@iqser/common-ui';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
const DUE_DATE_WARN_DAYS = 14;
|
const DUE_DATE_WARN_DAYS = 14;
|
||||||
|
|
||||||
interface PartialDossier extends Partial<Dossier> {
|
interface PartialDossier extends Partial<IDossier> {
|
||||||
readonly dossierName: string;
|
readonly dossierName: string;
|
||||||
readonly dossierTemplateId: string;
|
readonly dossierTemplateId: string;
|
||||||
readonly dueDate?: string;
|
readonly dueDate?: string;
|
||||||
|
|||||||
@ -63,14 +63,14 @@ export class TrashScreenComponent extends ListingComponent<TrashItem> {
|
|||||||
|
|
||||||
private get _canRestoreSelected$(): Observable<boolean> {
|
private get _canRestoreSelected$(): Observable<boolean> {
|
||||||
return this.listingService.selectedEntities$.pipe(
|
return this.listingService.selectedEntities$.pipe(
|
||||||
map(entities => entities.length && !entities.find(dossier => !dossier.canRestore)),
|
map(entities => entities.length && !entities.find(dossier => !(dossier.canRestore && dossier.hasRestoreRights))),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private get _canHardDeleteSelected$(): Observable<boolean> {
|
private get _canHardDeleteSelected$(): Observable<boolean> {
|
||||||
return this.listingService.selectedEntities$.pipe(
|
return this.listingService.selectedEntities$.pipe(
|
||||||
map(entities => entities.length && !entities.find(dossier => !dossier.canHardDelete)),
|
map(entities => entities.length && !entities.find(dossier => !dossier.hasHardDeleteRights)),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
<div class="action-buttons">
|
<div class="action-buttons">
|
||||||
<iqser-circle-button
|
<iqser-circle-button
|
||||||
(action)="restore.emit([item])"
|
(action)="restore.emit([item])"
|
||||||
*ngIf="item.canRestore"
|
*ngIf="item.canRestore && item.hasRestoreRights"
|
||||||
[tooltip]="'trash.action.restore' | translate"
|
[tooltip]="'trash.action.restore' | translate"
|
||||||
[type]="circleButtonTypes.dark"
|
[type]="circleButtonTypes.dark"
|
||||||
icon="red:put-back"
|
icon="red:put-back"
|
||||||
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
<iqser-circle-button
|
<iqser-circle-button
|
||||||
(action)="hardDelete.emit([item])"
|
(action)="hardDelete.emit([item])"
|
||||||
*ngIf="item.canHardDelete"
|
*ngIf="item.hasHardDeleteRights"
|
||||||
[tooltip]="'trash.action.delete' | translate"
|
[tooltip]="'trash.action.delete' | translate"
|
||||||
[type]="circleButtonTypes.dark"
|
[type]="circleButtonTypes.dark"
|
||||||
icon="iqser:trash"
|
icon="iqser:trash"
|
||||||
|
|||||||
@ -65,8 +65,8 @@ export class TrashService extends EntitiesService<TrashItem> {
|
|||||||
new TrashDossier(
|
new TrashDossier(
|
||||||
dossier,
|
dossier,
|
||||||
this._configService.values.DELETE_RETENTION_HOURS as number,
|
this._configService.values.DELETE_RETENTION_HOURS as number,
|
||||||
this._permissionsService.canHardDeleteDossier(dossier),
|
|
||||||
this._permissionsService.canRestoreDossier(dossier),
|
this._permissionsService.canRestoreDossier(dossier),
|
||||||
|
this._permissionsService.canHardDeleteDossier(dossier),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
switchMap(dossiers => this._dossierStatsService.getFor(dossiers.map(d => d.id)).pipe(map(() => dossiers))),
|
switchMap(dossiers => this._dossierStatsService.getFor(dossiers.map(d => d.id)).pipe(map(() => dossiers))),
|
||||||
@ -83,7 +83,8 @@ export class TrashService extends EntitiesService<TrashItem> {
|
|||||||
file,
|
file,
|
||||||
dossier.dossierTemplateId,
|
dossier.dossierTemplateId,
|
||||||
this._configService.values.DELETE_RETENTION_HOURS as number,
|
this._configService.values.DELETE_RETENTION_HOURS as number,
|
||||||
this._permissionsService.canDeleteFile(file, dossier),
|
this._permissionsService.canRestoreFile(file, dossier),
|
||||||
|
this._permissionsService.canHardDeleteFile(file, dossier),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -79,13 +79,19 @@ export class PermissionsService {
|
|||||||
return file.assignee === this.#userId;
|
return file.assignee === this.#userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
canDeleteFile(file: File | File[], dossier: Dossier): boolean {
|
canSoftDeleteFile(file: File | File[], dossier: Dossier): boolean {
|
||||||
const files = file instanceof File ? [file] : file;
|
const files = file instanceof File ? [file] : file;
|
||||||
return files.reduce((acc, _file) => this._canDeleteFile(_file, dossier) && acc, true);
|
return files.reduce((acc, _file) => this._canSoftDeleteFile(_file, dossier) && acc, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
canHardDeleteOrRestore(dossier: Dossier): boolean {
|
canRestoreFile(file: File | File[], dossier: Dossier): boolean {
|
||||||
return dossier.isActive;
|
const files = file instanceof File ? [file] : file;
|
||||||
|
return files.reduce((acc, _file) => this._canRestoreFile(_file, dossier) && acc, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
canHardDeleteFile(file: File | File[], dossier: Dossier): boolean {
|
||||||
|
const files = file instanceof File ? [file] : file;
|
||||||
|
return files.reduce((acc, _file) => this._canHardDeleteFile(_file, dossier) && acc, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
canOcrFile(file: File | File[], dossier: Dossier): boolean {
|
canOcrFile(file: File | File[], dossier: Dossier): boolean {
|
||||||
@ -140,7 +146,7 @@ export class PermissionsService {
|
|||||||
return dossier.approverIds.indexOf(this.#userId) >= 0;
|
return dossier.approverIds.indexOf(this.#userId) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
isDossierMember(dossier: Dossier): boolean {
|
isDossierMember(dossier: IDossier): boolean {
|
||||||
return dossier.memberIds.includes(this.#userId);
|
return dossier.memberIds.includes(this.#userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,8 +179,8 @@ export class PermissionsService {
|
|||||||
return this.isApprover(dossier) && files.reduce((prev, file) => prev && file.isApproved, true);
|
return this.isApprover(dossier) && files.reduce((prev, file) => prev && file.isApproved, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
canDeleteDossier(dossier: IDossier): boolean {
|
canSoftDeleteDossier(dossier: IDossier): boolean {
|
||||||
return this.isOwner(dossier);
|
return this.isOwner(dossier) || (this.isManager() && this.isDossierMember(dossier));
|
||||||
}
|
}
|
||||||
|
|
||||||
canHardDeleteDossier(dossier: IDossier): boolean {
|
canHardDeleteDossier(dossier: IDossier): boolean {
|
||||||
@ -182,6 +188,10 @@ export class PermissionsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canRestoreDossier(dossier: IDossier): boolean {
|
canRestoreDossier(dossier: IDossier): boolean {
|
||||||
|
return this.isOwner(dossier) || (this.isManager() && this.isDossierMember(dossier));
|
||||||
|
}
|
||||||
|
|
||||||
|
canCreateDossier(): boolean {
|
||||||
return this.isManager();
|
return this.isManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,17 +259,20 @@ export class PermissionsService {
|
|||||||
return dossier.isActive && this.isFileAssignee(file) && (file.isNew || file.isUnderReview || file.isUnderApproval);
|
return dossier.isActive && this.isFileAssignee(file) && (file.isNew || file.isUnderReview || file.isUnderApproval);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://jira.iqser.com/browse/RED-2787
|
private _canSoftDeleteFile(file: File, dossier: Dossier): boolean {
|
||||||
private _canDeleteFile(file: File, dossier: Dossier): boolean {
|
|
||||||
return (
|
return (
|
||||||
dossier.isActive &&
|
dossier.isActive && (this.isApprover(dossier) || this.isFileAssignee(file) || (!file.assignee && this.isDossierMember(dossier)))
|
||||||
(file.isNew ||
|
|
||||||
(file.isUnderReview && !file.assignee && this.isDossierMember(dossier)) ||
|
|
||||||
(file.isUnderApproval && !file.assignee && this.isApprover(dossier)) ||
|
|
||||||
(file.assignee && !file.isApproved && (this.isFileAssignee(file) || this.isOwner(dossier))))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _canRestoreFile(file: File, dossier: Dossier): boolean {
|
||||||
|
return this.isApprover(dossier) || this.isFileAssignee(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _canHardDeleteFile(file: File, dossier: Dossier): boolean {
|
||||||
|
return this.isApprover(dossier) || this.isFileAssignee(file) || (!file.assignee && this.isDossierMember(dossier));
|
||||||
|
}
|
||||||
|
|
||||||
private _canReanalyseFile(file: File, dossier: Dossier): boolean {
|
private _canReanalyseFile(file: File, dossier: Dossier): boolean {
|
||||||
return dossier.isActive && this.isReviewerOrApprover(file, dossier) && file.analysisRequired;
|
return dossier.isActive && this.isReviewerOrApprover(file, dossier) && file.analysisRequired;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { List } from '@iqser/common-ui';
|
|||||||
import { IDossier } from '../dossiers';
|
import { IDossier } from '../dossiers';
|
||||||
import { TrashItem } from './trash.item';
|
import { TrashItem } from './trash.item';
|
||||||
|
|
||||||
export class TrashDossier extends TrashItem {
|
export class TrashDossier extends TrashItem implements Partial<IDossier> {
|
||||||
readonly type = 'dossier';
|
readonly type = 'dossier';
|
||||||
readonly icon = 'red:folder';
|
readonly icon = 'red:folder';
|
||||||
|
|
||||||
@ -21,10 +21,10 @@ export class TrashDossier extends TrashItem {
|
|||||||
constructor(
|
constructor(
|
||||||
dossier: IDossier,
|
dossier: IDossier,
|
||||||
protected readonly _retentionHours: number,
|
protected readonly _retentionHours: number,
|
||||||
readonly canHardDelete: boolean,
|
readonly hasRestoreRights: boolean,
|
||||||
protected readonly _hasRestoreRights: boolean,
|
readonly hasHardDeleteRights: boolean,
|
||||||
) {
|
) {
|
||||||
super(_retentionHours, dossier.softDeletedTime, canHardDelete);
|
super(_retentionHours, dossier.softDeletedTime, hasRestoreRights, hasHardDeleteRights);
|
||||||
this.dossierId = dossier.dossierId;
|
this.dossierId = dossier.dossierId;
|
||||||
this.dossierTemplateId = dossier.dossierTemplateId;
|
this.dossierTemplateId = dossier.dossierTemplateId;
|
||||||
this.date = dossier.date;
|
this.date = dossier.date;
|
||||||
@ -35,7 +35,6 @@ export class TrashDossier extends TrashItem {
|
|||||||
|
|
||||||
// Because of migrations, for some this is not set
|
// Because of migrations, for some this is not set
|
||||||
this.softDeletedTime = dossier.softDeletedTime || '-';
|
this.softDeletedTime = dossier.softDeletedTime || '-';
|
||||||
this.canRestore = this.canRestore && this._hasRestoreRights;
|
|
||||||
|
|
||||||
this.id = this.dossierId;
|
this.id = this.dossierId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,9 +23,10 @@ export class TrashFile extends TrashItem implements Partial<IFile> {
|
|||||||
file: File,
|
file: File,
|
||||||
readonly dossierTemplateId: string,
|
readonly dossierTemplateId: string,
|
||||||
protected readonly _retentionHours: number,
|
protected readonly _retentionHours: number,
|
||||||
readonly canHardDelete: boolean,
|
readonly hasRestoreRights: boolean,
|
||||||
|
readonly hasHardDeleteRights: boolean,
|
||||||
) {
|
) {
|
||||||
super(_retentionHours, file.softDeletedTime, canHardDelete);
|
super(_retentionHours, file.softDeletedTime, hasRestoreRights, hasHardDeleteRights);
|
||||||
this.fileId = file.fileId;
|
this.fileId = file.fileId;
|
||||||
this.dossierId = file.dossierId;
|
this.dossierId = file.dossierId;
|
||||||
this.filename = file.filename;
|
this.filename = file.filename;
|
||||||
|
|||||||
@ -7,12 +7,13 @@ export abstract class TrashItem {
|
|||||||
abstract readonly dossierId: string;
|
abstract readonly dossierId: string;
|
||||||
abstract readonly icon: string;
|
abstract readonly icon: string;
|
||||||
readonly restoreDate: string;
|
readonly restoreDate: string;
|
||||||
canRestore: boolean;
|
readonly canRestore: boolean;
|
||||||
|
|
||||||
protected constructor(
|
protected constructor(
|
||||||
protected readonly _retentionHours: number,
|
protected readonly _retentionHours: number,
|
||||||
readonly softDeletedTime: string | undefined,
|
readonly softDeletedTime: string | undefined,
|
||||||
readonly canHardDelete: boolean,
|
readonly hasRestoreRights: boolean,
|
||||||
|
readonly hasHardDeleteRights: boolean,
|
||||||
) {
|
) {
|
||||||
this.restoreDate = this.#restoreDate;
|
this.restoreDate = this.#restoreDate;
|
||||||
this.canRestore = this.#canRestore;
|
this.canRestore = this.#canRestore;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user