add class for dossier attributes & rename interface
This commit is contained in:
parent
680ff4e855
commit
d1cc15ec23
@ -21,7 +21,6 @@ export class DownloadsListScreenComponent extends ListingComponent<DownloadStatu
|
||||
@ViewChild('sizeTemplate', { static: true }) sizeTemplate: TemplateRef<never>;
|
||||
@ViewChild('creationDateTemplate', { static: true }) creationDateTemplate: TemplateRef<never>;
|
||||
@ViewChild('statusTemplate', { static: true }) statusTemplate: TemplateRef<never>;
|
||||
protected readonly _primaryKey = 'storageId';
|
||||
|
||||
constructor(
|
||||
protected readonly _injector: Injector,
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
import { DossierAttributeConfig } from '@redaction/red-ui-http';
|
||||
import { IDossierAttributeConfig } from '@redaction/red-ui-http';
|
||||
|
||||
export type DossierAttributeWithValue = DossierAttributeConfig & { value: any };
|
||||
export type DossierAttributeWithValue = IDossierAttributeConfig & { value: any };
|
||||
|
||||
@ -84,7 +84,7 @@ export class FileStatusWrapper implements FileStatus, IListable {
|
||||
readonly isWorkable = !this.isProcessing && this.canBeOpened;
|
||||
readonly canBeOCRed = !this.excluded && !this.lastOCRTime && ['UNASSIGNED', 'UNDER_REVIEW', 'UNDER_APPROVAL'].includes(this.status);
|
||||
|
||||
get id() {
|
||||
get id(): string {
|
||||
return this.fileId;
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import { Component, Inject, OnDestroy } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { DossierAttributeConfig, FileAttributeConfig } from '@redaction/red-ui-http';
|
||||
import { DossierAttributeConfigTypes, FileAttributeConfig, IDossierAttributeConfig } from '@redaction/red-ui-http';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { AutoUnsubscribe, LoadingService } from '@iqser/common-ui';
|
||||
import { AutoUnsubscribe, LoadingService, Toaster } from '@iqser/common-ui';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service';
|
||||
import { dossierAttributeTypesTranslations } from '../../translations/dossier-attribute-types-translations';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
@ -15,14 +14,9 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
})
|
||||
export class AddEditDossierAttributeDialogComponent extends AutoUnsubscribe implements OnDestroy {
|
||||
dossierAttributeForm: FormGroup;
|
||||
dossierAttribute: DossierAttributeConfig;
|
||||
dossierAttribute: IDossierAttributeConfig;
|
||||
readonly translations = dossierAttributeTypesTranslations;
|
||||
readonly typeOptions = [
|
||||
DossierAttributeConfig.TypeEnum.TEXT,
|
||||
DossierAttributeConfig.TypeEnum.NUMBER,
|
||||
DossierAttributeConfig.TypeEnum.DATE,
|
||||
DossierAttributeConfig.TypeEnum.IMAGE
|
||||
];
|
||||
readonly typeOptions = Object.keys(DossierAttributeConfigTypes);
|
||||
|
||||
constructor(
|
||||
private readonly _formBuilder: FormBuilder,
|
||||
@ -31,7 +25,7 @@ export class AddEditDossierAttributeDialogComponent extends AutoUnsubscribe impl
|
||||
private readonly _toaster: Toaster,
|
||||
readonly dialogRef: MatDialogRef<AddEditDossierAttributeDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA)
|
||||
readonly data: { readonly dossierAttribute: DossierAttributeConfig }
|
||||
readonly data: { readonly dossierAttribute: IDossierAttributeConfig }
|
||||
) {
|
||||
super();
|
||||
this.dossierAttribute = data.dossierAttribute;
|
||||
@ -65,7 +59,7 @@ export class AddEditDossierAttributeDialogComponent extends AutoUnsubscribe impl
|
||||
saveFileAttribute() {
|
||||
this._loadingService.start();
|
||||
|
||||
const attribute: DossierAttributeConfig = {
|
||||
const attribute: IDossierAttributeConfig = {
|
||||
id: this.dossierAttribute?.id,
|
||||
editable: true,
|
||||
...this.dossierAttributeForm.getRawValue()
|
||||
|
||||
@ -7,7 +7,7 @@ import {
|
||||
LoadingService,
|
||||
TableColumnConfig
|
||||
} from '@iqser/common-ui';
|
||||
import { DossierAttributeConfig } from '@redaction/red-ui-http';
|
||||
import { IDossierAttributeConfig } from '@redaction/red-ui-http';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { AdminDialogService } from '../../services/admin-dialog.service';
|
||||
@ -15,6 +15,7 @@ import { DossierAttributesService } from '@shared/services/controller-wrappers/d
|
||||
import { dossierAttributeTypesTranslations } from '../../translations/dossier-attribute-types-translations';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { DossierAttributeConfig } from '@state/model/dossier-attribute-config';
|
||||
|
||||
@Component({
|
||||
templateUrl: './dossier-attributes-listing-screen.component.html',
|
||||
@ -34,7 +35,6 @@ export class DossierAttributesListingScreenComponent extends ListingComponent<Do
|
||||
@ViewChild('labelTemplate', { static: true }) labelTemplate: TemplateRef<never>;
|
||||
@ViewChild('placeholderTemplate', { static: true }) placeholderTemplate: TemplateRef<never>;
|
||||
@ViewChild('typeTemplate', { static: true }) typeTemplate: TemplateRef<never>;
|
||||
protected readonly _primaryKey = 'label';
|
||||
|
||||
constructor(
|
||||
protected readonly _injector: Injector,
|
||||
@ -54,7 +54,7 @@ export class DossierAttributesListingScreenComponent extends ListingComponent<Do
|
||||
await this._loadData();
|
||||
}
|
||||
|
||||
openConfirmDeleteAttributeDialog($event: MouseEvent, dossierAttribute?: DossierAttributeConfig) {
|
||||
openConfirmDeleteAttributeDialog($event: MouseEvent, dossierAttribute?: IDossierAttributeConfig) {
|
||||
this._dialogService.openDialog('confirm', $event, null, async () => {
|
||||
this._loadingService.start();
|
||||
const ids = dossierAttribute ? [dossierAttribute.id] : this.entitiesService.selected.map(item => item.id);
|
||||
@ -64,7 +64,7 @@ export class DossierAttributesListingScreenComponent extends ListingComponent<Do
|
||||
});
|
||||
}
|
||||
|
||||
openAddEditAttributeDialog($event: MouseEvent, dossierAttribute?: DossierAttributeConfig) {
|
||||
openAddEditAttributeDialog($event: MouseEvent, dossierAttribute?: IDossierAttributeConfig) {
|
||||
const dossierTemplateId = this._appStateService.activeDossierTemplateId;
|
||||
|
||||
this._dialogService.openDialog(
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { DossierAttributeConfig } from '@redaction/red-ui-http';
|
||||
import { DossierAttributeConfigType } from '@redaction/red-ui-http';
|
||||
|
||||
export const dossierAttributeTypesTranslations: { [key in DossierAttributeConfig.TypeEnum]: string } = {
|
||||
export const dossierAttributeTypesTranslations: { [key in DossierAttributeConfigType]: string } = {
|
||||
TEXT: _('dossier-attribute-types.text'),
|
||||
NUMBER: _('dossier-attribute-types.number'),
|
||||
DATE: _('dossier-attribute-types.date'),
|
||||
|
||||
@ -21,9 +21,9 @@ export class DossierDetailsComponent implements OnInit {
|
||||
owner: UserWrapper;
|
||||
editingOwner = false;
|
||||
@Input() dossierAttributes: DossierAttributeWithValue[];
|
||||
@Output() openAssignDossierMembersDialog = new EventEmitter();
|
||||
@Output() openDossierDictionaryDialog = new EventEmitter();
|
||||
@Output() toggleCollapse = new EventEmitter();
|
||||
@Output() readonly openAssignDossierMembersDialog = new EventEmitter();
|
||||
@Output() readonly openDossierDictionaryDialog = new EventEmitter();
|
||||
@Output() readonly toggleCollapse = new EventEmitter();
|
||||
collapseTooltip = _('dossier-details.collapse');
|
||||
expandTooltip = _('dossier-details.expand');
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import { UserService } from '@services/user.service';
|
||||
import { DoughnutChartConfig } from '@shared/components/simple-doughnut-chart/simple-doughnut-chart.component';
|
||||
import { groupBy } from '@utils/functions';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Dossier } from '../../../../state/model/dossier';
|
||||
import { Dossier } from '@state/model/dossier';
|
||||
import { timer } from 'rxjs';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { TranslateChartService } from '@services/translate-chart.service';
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
DossierAttributeConfig,
|
||||
DossierAttributeReq,
|
||||
DossierAttributesControllerService,
|
||||
DossierAttributesRes
|
||||
DossierAttributesRes,
|
||||
IDossierAttributeConfig
|
||||
} from '@redaction/red-ui-http';
|
||||
import { Dossier } from '@state/model/dossier';
|
||||
import { DossierAttributeWithValue } from '@models/dossier-attributes.model';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { DossierAttributeConfig } from '@state/model/dossier-attribute-config';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -40,16 +41,15 @@ export class DossierAttributesService {
|
||||
}
|
||||
|
||||
async getConfig(dossierTemplateId = this._appStateService.activeDossierTemplateId): Promise<DossierAttributeConfig[]> {
|
||||
return (
|
||||
(await this._dossierAttributesControllerService.getDossierAttributesConfig(dossierTemplateId).toPromise())
|
||||
?.dossierAttributeConfigs || []
|
||||
);
|
||||
const config$ = this._dossierAttributesControllerService.getDossierAttributesConfig(dossierTemplateId);
|
||||
const result = (await config$.toPromise())?.dossierAttributeConfigs || [];
|
||||
return result.map(item => new DossierAttributeConfig(item));
|
||||
}
|
||||
|
||||
addOrUpdateConfig(
|
||||
attribute: DossierAttributeConfig,
|
||||
attribute: IDossierAttributeConfig,
|
||||
dossierTemplateId = this._appStateService.activeDossierTemplateId
|
||||
): Observable<DossierAttributeConfig> {
|
||||
): Observable<IDossierAttributeConfig> {
|
||||
return this._dossierAttributesControllerService.addOrUpdateDossierAttributesConfig(attribute, dossierTemplateId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,11 @@ export class DownloadStatusWrapper implements IListable {
|
||||
constructor(private _downloadStatus: DownloadStatus) {}
|
||||
|
||||
get id() {
|
||||
return this._downloadStatus.storageId;
|
||||
return this.storageId;
|
||||
}
|
||||
|
||||
get searchKey(): string {
|
||||
return this.storageId;
|
||||
}
|
||||
|
||||
get size() {
|
||||
|
||||
@ -221,9 +221,7 @@ export class AppStateService {
|
||||
return;
|
||||
}
|
||||
|
||||
const mappedDossiers = dossiers.map(
|
||||
p => new Dossier(p, this.getDossierTemplateById(p.dossierTemplateId).name, this._getExistingFiles(p.dossierId))
|
||||
);
|
||||
const mappedDossiers = dossiers.map(p => new Dossier(p, this._getExistingFiles(p.dossierId)));
|
||||
const fileData = await this._statusControllerService.getFileStatusForDossiers(mappedDossiers.map(p => p.id)).toPromise();
|
||||
|
||||
for (const dossierId of Object.keys(fileData)) {
|
||||
@ -353,13 +351,9 @@ export class AppStateService {
|
||||
let foundDossier = this.allDossiers.find(p => p.id === updatedDossier.dossierId);
|
||||
if (foundDossier) {
|
||||
this._appState.dossiers.splice(this._appState.dossiers.indexOf(foundDossier), 1);
|
||||
foundDossier = new Dossier(
|
||||
updatedDossier,
|
||||
this.getDossierTemplateById(updatedDossier.dossierTemplateId).name,
|
||||
foundDossier.files
|
||||
);
|
||||
foundDossier = new Dossier(updatedDossier, foundDossier.files);
|
||||
} else {
|
||||
foundDossier = new Dossier(updatedDossier, this.getDossierTemplateById(updatedDossier.dossierTemplateId).name, []);
|
||||
foundDossier = new Dossier(updatedDossier, []);
|
||||
}
|
||||
|
||||
this._appState.dossiers.push(foundDossier);
|
||||
|
||||
22
apps/red-ui/src/app/state/model/dossier-attribute-config.ts
Normal file
22
apps/red-ui/src/app/state/model/dossier-attribute-config.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { DossierAttributeConfigType, IDossierAttributeConfig } from '@redaction/red-ui-http';
|
||||
import { IListable } from '@iqser/common-ui';
|
||||
|
||||
export class DossierAttributeConfig implements IDossierAttributeConfig, IListable {
|
||||
readonly id: string;
|
||||
readonly editable: boolean;
|
||||
readonly label?: string;
|
||||
readonly placeholder?: string;
|
||||
readonly type?: DossierAttributeConfigType;
|
||||
|
||||
constructor(dossierAttributeConfig: IDossierAttributeConfig) {
|
||||
this.id = dossierAttributeConfig.id;
|
||||
this.editable = !!dossierAttributeConfig.editable;
|
||||
this.label = dossierAttributeConfig.label;
|
||||
this.placeholder = dossierAttributeConfig.placeholder;
|
||||
this.type = dossierAttributeConfig.type;
|
||||
}
|
||||
|
||||
get searchKey(): string {
|
||||
return this.label;
|
||||
}
|
||||
}
|
||||
@ -35,7 +35,7 @@ export class Dossier implements IDossier, IListable {
|
||||
allFilesApproved?: boolean;
|
||||
type?: Dictionary;
|
||||
|
||||
constructor(dossier: IDossier, readonly dossierTemplateName: string, private _files: FileStatusWrapper[] = []) {
|
||||
constructor(dossier: IDossier, private _files: FileStatusWrapper[] = []) {
|
||||
this.id = dossier.dossierId;
|
||||
this.approverIds = dossier.approverIds;
|
||||
this.date = dossier.date;
|
||||
@ -57,6 +57,10 @@ export class Dossier implements IDossier, IListable {
|
||||
this._recomputeFileStatus();
|
||||
}
|
||||
|
||||
get searchKey(): string {
|
||||
return this.dossierName;
|
||||
}
|
||||
|
||||
get files() {
|
||||
return this._files;
|
||||
}
|
||||
|
||||
@ -10,20 +10,20 @@
|
||||
* Do not edit the class manually.
|
||||
*/ /* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { HttpClient, HttpEvent, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
|
||||
import { Inject, Injectable, Optional } from "@angular/core";
|
||||
import { HttpClient, HttpEvent, HttpHeaders, HttpParams, HttpResponse } from "@angular/common/http";
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
import { DossierAttributeConfig } from '../model/dossierAttributeConfig';
|
||||
import { DossierAttributeReq } from '../model/dossierAttributeReq';
|
||||
import { DossierAttributesConfig } from '../model/dossierAttributesConfig';
|
||||
import { DossierAttributesReq } from '../model/dossierAttributesReq';
|
||||
import { DossierAttributesRes } from '../model/dossierAttributesRes';
|
||||
import { IDossierAttributeConfig } from "../model/dossierAttributeConfig";
|
||||
import { DossierAttributeReq } from "../model/dossierAttributeReq";
|
||||
import { DossierAttributesConfig } from "../model/dossierAttributesConfig";
|
||||
import { DossierAttributesReq } from "../model/dossierAttributesReq";
|
||||
import { DossierAttributesRes } from "../model/dossierAttributesRes";
|
||||
|
||||
import { BASE_PATH } from '../variables';
|
||||
import { Configuration } from '../configuration';
|
||||
import { CustomHttpUrlEncodingCodec } from '../encoder';
|
||||
import { BASE_PATH } from "../variables";
|
||||
import { Configuration } from "../configuration";
|
||||
import { CustomHttpUrlEncodingCodec } from "../encoder";
|
||||
|
||||
@Injectable()
|
||||
export class DossierAttributesControllerService {
|
||||
@ -133,28 +133,28 @@ export class DossierAttributesControllerService {
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public addOrUpdateDossierAttributesConfig(
|
||||
body: DossierAttributeConfig,
|
||||
body: IDossierAttributeConfig,
|
||||
dossierTemplateId: string,
|
||||
observe?: 'body',
|
||||
reportProgress?: boolean
|
||||
): Observable<DossierAttributeConfig>;
|
||||
): Observable<IDossierAttributeConfig>;
|
||||
|
||||
public addOrUpdateDossierAttributesConfig(
|
||||
body: DossierAttributeConfig,
|
||||
body: IDossierAttributeConfig,
|
||||
dossierTemplateId: string,
|
||||
observe?: 'response',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpResponse<DossierAttributeConfig>>;
|
||||
): Observable<HttpResponse<IDossierAttributeConfig>>;
|
||||
|
||||
public addOrUpdateDossierAttributesConfig(
|
||||
body: DossierAttributeConfig,
|
||||
body: IDossierAttributeConfig,
|
||||
dossierTemplateId: string,
|
||||
observe?: 'events',
|
||||
reportProgress?: boolean
|
||||
): Observable<HttpEvent<DossierAttributeConfig>>;
|
||||
): Observable<HttpEvent<IDossierAttributeConfig>>;
|
||||
|
||||
public addOrUpdateDossierAttributesConfig(
|
||||
body: DossierAttributeConfig,
|
||||
body: IDossierAttributeConfig,
|
||||
dossierTemplateId: string,
|
||||
observe: any = 'body',
|
||||
reportProgress: boolean = false
|
||||
@ -190,7 +190,7 @@ export class DossierAttributesControllerService {
|
||||
headers = headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
return this.httpClient.request<DossierAttributeConfig>(
|
||||
return this.httpClient.request<IDossierAttributeConfig>(
|
||||
'post',
|
||||
`${this.basePath}/dossier-attributes/config/${encodeURIComponent(String(dossierTemplateId))}`,
|
||||
{
|
||||
|
||||
@ -10,20 +10,18 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
export interface DossierAttributeConfig {
|
||||
id: string;
|
||||
editable?: boolean;
|
||||
label?: string;
|
||||
placeholder?: string;
|
||||
type?: DossierAttributeConfig.TypeEnum;
|
||||
export interface IDossierAttributeConfig {
|
||||
readonly id: string;
|
||||
readonly editable?: boolean;
|
||||
readonly label?: string;
|
||||
readonly placeholder?: string;
|
||||
readonly type?: DossierAttributeConfigType;
|
||||
}
|
||||
|
||||
export namespace DossierAttributeConfig {
|
||||
export type TypeEnum = 'DATE' | 'IMAGE' | 'NUMBER' | 'TEXT';
|
||||
export const TypeEnum = {
|
||||
DATE: 'DATE' as TypeEnum,
|
||||
IMAGE: 'IMAGE' as TypeEnum,
|
||||
NUMBER: 'NUMBER' as TypeEnum,
|
||||
TEXT: 'TEXT' as TypeEnum
|
||||
};
|
||||
}
|
||||
export const DossierAttributeConfigTypes = {
|
||||
DATE: 'DATE',
|
||||
IMAGE: 'IMAGE',
|
||||
NUMBER: 'NUMBER',
|
||||
TEXT: 'TEXT'
|
||||
} as const;
|
||||
export type DossierAttributeConfigType = keyof typeof DossierAttributeConfigTypes;
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { DossierAttributeConfig } from './dossierAttributeConfig';
|
||||
import { IDossierAttributeConfig } from './dossierAttributeConfig';
|
||||
|
||||
export interface DossierAttributesConfig {
|
||||
dossierAttributeConfigs?: Array<DossierAttributeConfig>;
|
||||
dossierAttributeConfigs?: Array<IDossierAttributeConfig>;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user