use generic service for dossiers
This commit is contained in:
parent
f186f766ec
commit
91efc6fd0e
@ -29,11 +29,7 @@ interface DossierListItem extends IDossier, IListable {
|
||||
templateUrl: './trash-screen.component.html',
|
||||
styleUrls: ['./trash-screen.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
providers: [
|
||||
...DefaultListingServices,
|
||||
DossiersService,
|
||||
{ provide: ListingComponent, useExisting: forwardRef(() => TrashScreenComponent) }
|
||||
]
|
||||
providers: [...DefaultListingServices, { provide: ListingComponent, useExisting: forwardRef(() => TrashScreenComponent) }]
|
||||
})
|
||||
export class TrashScreenComponent extends ListingComponent<DossierListItem> implements OnInit {
|
||||
readonly circleButtonTypes = CircleButtonTypes;
|
||||
|
||||
@ -1,33 +1,45 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { IDossier, DossierControllerService } from '@redaction/red-ui-http';
|
||||
import { Injectable, Injector } from "@angular/core";
|
||||
import { IDossier } from "@redaction/red-ui-http";
|
||||
import { EntitiesService, FilterService, SearchService } from "@iqser/common-ui";
|
||||
import { Dossier } from "@state/model/dossier";
|
||||
|
||||
/**
|
||||
* This should be removed when refactoring is done
|
||||
* @param injector
|
||||
* @constructor
|
||||
*/
|
||||
const TEMPORARY_INJECTOR = injector =>
|
||||
Injector.create({
|
||||
providers: [
|
||||
{ provide: FilterService, useClass: FilterService },
|
||||
{ provide: SearchService, useClass: SearchService }
|
||||
],
|
||||
parent: injector
|
||||
});
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DossiersService {
|
||||
constructor(private readonly _dossierControllerService: DossierControllerService) {}
|
||||
export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
||||
constructor(protected readonly _injector: Injector) {
|
||||
super(TEMPORARY_INJECTOR(_injector), 'dossier');
|
||||
}
|
||||
|
||||
createOrUpdate(dossier: IDossier): Promise<IDossier> {
|
||||
return this._dossierControllerService.createOrUpdateDossier(dossier).toPromise();
|
||||
}
|
||||
|
||||
delete(dossierId: string): Promise<unknown> {
|
||||
return this._dossierControllerService.deleteDossier(dossierId).toPromise();
|
||||
}
|
||||
|
||||
getAll(): Promise<IDossier[]> {
|
||||
return this._dossierControllerService.getDossiers().toPromise();
|
||||
return this.post(dossier).toPromise();
|
||||
}
|
||||
|
||||
getDeleted(): Promise<IDossier[]> {
|
||||
return this._dossierControllerService.getDeletedDossiers().toPromise();
|
||||
return this.getAll<IDossier>('deleted-dossiers').toPromise();
|
||||
}
|
||||
|
||||
restore(dossierIds: Array<string>): Promise<unknown> {
|
||||
return this._dossierControllerService.restoreDossiers(dossierIds).toPromise();
|
||||
const body = dossierIds.map<[string, string]>(id => ['dossierId', id]);
|
||||
return this.post(body, 'deleted-dossiers/restore').toPromise();
|
||||
}
|
||||
|
||||
hardDelete(dossierIds: Array<string>): Promise<unknown> {
|
||||
return this._dossierControllerService.hardDeleteDossiers(dossierIds).toPromise();
|
||||
const body = dossierIds.map<[string, string]>(id => ['dossierId', id]);
|
||||
return this.delete(body, 'deleted-dossiers/hard-delete').toPromise();
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ export class AppStateService {
|
||||
}
|
||||
|
||||
async loadAllDossiers(emitEvents: boolean = true) {
|
||||
const dossiers = await this._dossiersService.getAll();
|
||||
const dossiers = await this._dossiersService.get().toPromise();
|
||||
if (!dossiers) {
|
||||
return;
|
||||
}
|
||||
@ -334,13 +334,16 @@ export class AppStateService {
|
||||
}
|
||||
|
||||
deleteDossier(dossier: Dossier) {
|
||||
return this._dossiersService.delete(dossier.id).then(
|
||||
() => {
|
||||
const index = this.allDossiers.findIndex(p => p.id === dossier.id);
|
||||
this._appState.dossiers.splice(index, 1);
|
||||
},
|
||||
() => this._toaster.error(_('dossier-listing.delete.delete-failed'), { params: dossier })
|
||||
);
|
||||
return this._dossiersService
|
||||
.delete(dossier.id)
|
||||
.toPromise()
|
||||
.then(
|
||||
() => {
|
||||
const index = this.allDossiers.findIndex(p => p.id === dossier.id);
|
||||
this._appState.dossiers.splice(index, 1);
|
||||
},
|
||||
() => this._toaster.error(_('dossier-listing.delete.delete-failed'), { params: dossier })
|
||||
);
|
||||
}
|
||||
|
||||
async createOrUpdateDossier(dossier: IDossier) {
|
||||
|
||||
@ -3,7 +3,6 @@ import { Dictionary, DossierStatus, DownloadFileType, IDossier, List } from '@re
|
||||
import { IListable } from '@iqser/common-ui';
|
||||
|
||||
export class Dossier implements IDossier, IListable {
|
||||
readonly id: string;
|
||||
readonly dossierId: string;
|
||||
readonly ownerId: string;
|
||||
readonly memberIds: List;
|
||||
@ -37,7 +36,6 @@ export class Dossier implements IDossier, IListable {
|
||||
type?: Dictionary;
|
||||
|
||||
constructor(dossier: IDossier, private _files: File[] = []) {
|
||||
this.id = dossier.dossierId;
|
||||
this.dossierId = dossier.dossierId;
|
||||
this.approverIds = dossier.approverIds;
|
||||
this.date = dossier.date;
|
||||
@ -59,6 +57,14 @@ export class Dossier implements IDossier, IListable {
|
||||
this._recomputeFileStatus();
|
||||
}
|
||||
|
||||
get id(): string {
|
||||
return this.dossierId;
|
||||
}
|
||||
|
||||
get routerLink(): string {
|
||||
return `/main/dossiers/${this.dossierId}`;
|
||||
}
|
||||
|
||||
get searchKey(): string {
|
||||
return this.dossierName;
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import { AuditControllerService } from './api/auditController.service';
|
||||
import { DictionaryControllerService } from './api/dictionaryController.service';
|
||||
import { DigitalSignatureControllerService } from './api/digitalSignatureController.service';
|
||||
import { DossierAttributesControllerService } from './api/dossierAttributesController.service';
|
||||
import { DossierControllerService } from './api/dossierController.service';
|
||||
import { DossierTemplateControllerService } from './api/dossierTemplateController.service';
|
||||
import { DownloadControllerService } from './api/downloadController.service';
|
||||
import { FileAttributesControllerService } from './api/fileAttributesController.service';
|
||||
@ -40,7 +39,6 @@ import { NotificationControllerService } from './api/notificationController.serv
|
||||
DictionaryControllerService,
|
||||
DigitalSignatureControllerService,
|
||||
DossierAttributesControllerService,
|
||||
DossierControllerService,
|
||||
DossierTemplateControllerService,
|
||||
DownloadControllerService,
|
||||
FileAttributesControllerService,
|
||||
|
||||
@ -6,7 +6,6 @@ import { InfoControllerService } from './infoController.service';
|
||||
import { LegalBasisMappingControllerService } from './legalBasisMappingController.service';
|
||||
import { LicenseReportControllerService } from './licenseReportController.service';
|
||||
import { ManualRedactionControllerService } from './manualRedactionController.service';
|
||||
import { DossierControllerService } from './dossierController.service';
|
||||
import { ReanalysisControllerService } from './reanalysisController.service';
|
||||
import { RedactionLogControllerService } from './redactionLogController.service';
|
||||
import { DossierTemplateControllerService } from './dossierTemplateController.service';
|
||||
@ -95,7 +94,6 @@ export const APIS = [
|
||||
LegalBasisMappingControllerService,
|
||||
LicenseReportControllerService,
|
||||
ManualRedactionControllerService,
|
||||
DossierControllerService,
|
||||
ReanalysisControllerService,
|
||||
RedactionLogControllerService,
|
||||
DossierTemplateControllerService,
|
||||
|
||||
@ -1,27 +1,27 @@
|
||||
export interface ConfigurationParameters {
|
||||
apiKeys?: { [key: string]: string };
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | (() => string);
|
||||
basePath?: string;
|
||||
withCredentials?: boolean;
|
||||
readonly apiKeys?: { [key: string]: string };
|
||||
readonly username?: string;
|
||||
readonly password?: string;
|
||||
readonly accessToken?: string | (() => string);
|
||||
readonly basePath?: string;
|
||||
readonly withCredentials?: boolean;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
apiKeys?: { [key: string]: string };
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | (() => string);
|
||||
basePath?: string;
|
||||
withCredentials?: boolean;
|
||||
export class Configuration implements ConfigurationParameters {
|
||||
readonly apiKeys?: { [key: string]: string };
|
||||
readonly username?: string;
|
||||
readonly password?: string;
|
||||
readonly accessToken?: string | (() => string);
|
||||
readonly basePath: string;
|
||||
readonly withCredentials: boolean;
|
||||
|
||||
constructor(configurationParameters: ConfigurationParameters = {}) {
|
||||
this.apiKeys = configurationParameters.apiKeys;
|
||||
this.username = configurationParameters.username;
|
||||
this.password = configurationParameters.password;
|
||||
this.accessToken = configurationParameters.accessToken;
|
||||
this.basePath = configurationParameters.basePath;
|
||||
this.withCredentials = configurationParameters.withCredentials;
|
||||
this.basePath = configurationParameters.basePath ?? '';
|
||||
this.withCredentials = !!configurationParameters.withCredentials;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,7 +73,7 @@ export class Configuration {
|
||||
* @return True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
const jsonMime = new RegExp('^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
"lint": "nx workspace-lint && nx lint",
|
||||
"lint-fix": "nx workspace-lint --fix && nx lint --fix",
|
||||
"nx": "nx",
|
||||
"start": "nx serve --hmr",
|
||||
"start": "nx serve",
|
||||
"test": "nx test",
|
||||
"update": "nx migrate latest",
|
||||
"migrate": "nx migrate --run-migrations",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user