Refactor dossiers dialog service: add dossier

This commit is contained in:
Adina Țeudan 2021-08-09 19:15:30 +03:00
parent 4741eebbc6
commit 4489fc895c
6 changed files with 25 additions and 28 deletions

View File

@ -27,11 +27,9 @@ interface DossierListItem extends Dossier {
})
export class TrashScreenComponent extends BaseListingComponent<DossierListItem> implements OnInit {
readonly itemSize = 80;
protected readonly _primaryKey = 'dossierName';
readonly circleButtonTypes = CircleButtonTypes;
readonly tableHeaderLabel = 'trash.table-header.title';
readonly tableHeaderLabel = _('trash.table-header.title');
readonly canRestoreSelected$ = this._canRestoreSelected$;
private readonly _deleteRetentionHours = this._appConfigService.getConfig(AppConfigKey.DELETE_RETENTION_HOURS);
readonly tableColumnConfigs: TableColumnConfig<DossierListItem>[] = [
{
label: _('trash.table-col-names.name'),
@ -53,6 +51,8 @@ export class TrashScreenComponent extends BaseListingComponent<DossierListItem>
column: 'softDeletedTime'
}
];
protected readonly _primaryKey = 'dossierName';
private readonly _deleteRetentionHours = this._appConfigService.getConfig(AppConfigKey.DELETE_RETENTION_HOURS);
constructor(
readonly permissionsService: PermissionsService,
@ -78,10 +78,6 @@ export class TrashScreenComponent extends BaseListingComponent<DossierListItem>
this._loadingService.stop();
}
private _getRestoreDate(softDeletedTime: string): string {
return moment(softDeletedTime).add(this._deleteRetentionHours, 'hours').toISOString();
}
hardDelete(dossiers = this.entitiesService.selected) {
const data = new ConfirmationDialogInput({
title: dossiers.length > 1 ? _('confirmation-dialog.delete-dossier.title-alt') : _('confirmation-dialog.delete-dossier.title'),
@ -105,6 +101,10 @@ export class TrashScreenComponent extends BaseListingComponent<DossierListItem>
this._loadingService.loadWhile(this._restore(dossiers));
}
private _getRestoreDate(softDeletedTime: string): string {
return moment(softDeletedTime).add(this._deleteRetentionHours, 'hours').toISOString();
}
private async _loadDossiersData(): Promise<void> {
this.entitiesService.setEntities(this._toListItems(await this._dossiersService.getDeleted()));
}

View File

@ -87,7 +87,6 @@ export class DossierDetailsComponent implements OnInit {
const ownerName = this._userService.getNameForId(this.owner.id);
const dossierName = this.appStateService.activeDossier.name;
const msg = 'Successfully assigned ' + ownerName + ' to dossier: ' + dossierName;
this._toaster.info(msg);
this._toaster.info(_('assignment.owner'), { params: { ownerName, dossierName } });
}
}

View File

@ -42,7 +42,6 @@ export class DossierListingScreenComponent
implements OnInit, AfterViewInit, OnDestroy, OnAttach, OnDetach
{
readonly itemSize = 85;
protected readonly _primaryKey = 'dossierName';
readonly currentUser = this._userService.currentUser;
readonly tableHeaderLabel = _('dossier-listing.table-header.title');
readonly buttonConfigs: ButtonConfig[] = [
@ -74,6 +73,7 @@ export class DossierListingScreenComponent
];
dossiersChartData: DoughnutChartConfig[] = [];
documentsChartData: DoughnutChartConfig[] = [];
protected readonly _primaryKey = 'dossierName';
private _lastScrollPosition: number;
@ViewChild('needsWorkTemplate', { read: TemplateRef, static: true })
private readonly _needsWorkTemplate: TemplateRef<any>;
@ -147,7 +147,7 @@ export class DossierListingScreenComponent
}
openAddDossierDialog(): void {
this._dialogService.openAddDossierDialog(async addResponse => {
this._dialogService.openDialog('addDossier', null, null, async addResponse => {
await this._router.navigate([`/main/dossiers/${addResponse.dossier.dossierId}`]);
if (addResponse.addMembers) {
this._dialogService.openDialog('editDossier', null, {

View File

@ -36,6 +36,7 @@ import { TranslateService } from '@ngx-translate/core';
import { AutoUnsubscribeComponent, CircleButtonTypes, NestedFilter, processFilters } from '@iqser/common-ui';
import { fileStatusTranslations } from '../../translations/file-status-translations';
import { handleFilterDelta } from '@shared/components/filters/popup-filter/utils/filter-utils';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
const ALL_HOTKEY_ARRAY = ['Escape', 'F', 'f'];
@ -471,8 +472,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribeComponent impleme
const { dossierId, fileId, filename } = this.fileData.fileStatus;
await this._statusControllerService.setFileReviewer(dossierId, fileId, reviewerId).toPromise();
const msg = `Successfully assigned ${reviewerName} to file: ${filename}`;
this._toaster.info(msg);
this._toaster.info(_('assignment.reviewer'), { params: { reviewerName, filename } });
await this.appStateService.reloadActiveFile();
this._updateCanPerformActions();
this.editingReviewer = false;

View File

@ -30,7 +30,7 @@ const dialogConfig = {
// TODO: Continue refactor
type DialogType = 'confirm' | 'documentInfo' | 'editDossier';
type DialogType = 'confirm' | 'documentInfo' | 'editDossier' | 'addDossier';
type DossiersDialogConfig = {
[key in DialogType]: {
@ -52,6 +52,14 @@ export class DossiersDialogService extends DialogService<DialogType> {
editDossier: {
component: EditDossierDialogComponent,
dialogConfig: { ...largeDialogConfig }
},
addDossier: {
component: AddDossierDialogComponent,
dialogConfig: {
...dialogConfig,
width: '900px',
autoFocus: true
}
}
};
@ -199,18 +207,4 @@ export class DossiersDialogService extends DialogService<DialogType> {
return ref;
}
openAddDossierDialog(cb?: Function): MatDialogRef<AddDossierDialogComponent> {
const ref = this._dialog.open(AddDossierDialogComponent, {
...dialogConfig,
width: '900px',
autoFocus: true
});
ref.afterClosed().subscribe(result => {
if (result && cb) cb(result);
});
return ref;
}
}

View File

@ -266,6 +266,10 @@
"cancel": "Cancel",
"save": "Save"
},
"assignment": {
"owner": "Successfully assigned {ownerName} to dossier: {dossierName}.",
"reviewer": "Successfully assigned {reviewerName} to file: {filename}."
},
"audit": "Audit",
"audit-screen": {
"all-users": "All Users",