+
{{ attr.label }}:
{{ (file.fileAttributes?.attributeIdToValue)[attr.id] || '-' }}
diff --git a/apps/red-ui/src/app/modules/projects/components/document-info/document-info.component.ts b/apps/red-ui/src/app/modules/projects/components/document-info/document-info.component.ts
index 0bb39dc03..8c330fa8d 100644
--- a/apps/red-ui/src/app/modules/projects/components/document-info/document-info.component.ts
+++ b/apps/red-ui/src/app/modules/projects/components/document-info/document-info.component.ts
@@ -1,5 +1,5 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
-import { FileAttributeConfig, FileStatus } from '@redaction/red-ui-http';
+import { FileAttributesConfig, FileStatus } from '@redaction/red-ui-http';
import { AppStateService } from '../../../../state/app-state.service';
import { ProjectsDialogService } from '../../services/projects-dialog.service';
@@ -12,10 +12,10 @@ export class DocumentInfoComponent implements OnInit {
@Input() file: FileStatus;
@Output() closeDocumentInfoView = new EventEmitter();
- public fileAttributesConfig: FileAttributeConfig[];
+ public fileAttributesConfig: FileAttributesConfig;
constructor(private readonly _appStateService: AppStateService, private readonly _dialogService: ProjectsDialogService) {
- this.fileAttributesConfig = this._appStateService.fileAttributesConfig;
+ this.fileAttributesConfig = this._appStateService.activeFileAttributesConfig;
}
ngOnInit(): void {}
diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts
index ef71d7536..71aa97227 100644
--- a/apps/red-ui/src/app/state/app-state.service.ts
+++ b/apps/red-ui/src/app/state/app-state.service.ts
@@ -30,7 +30,7 @@ export interface AppState {
activeProjectId: string;
activeFileId: string;
activeRuleSetId: string;
- activeFileAttributesConfig: FileAttributeConfig[];
+ fileAttributesConfig: { [key: string]: FileAttributesConfig };
activeDictionaryType: string;
totalAnalysedPages?: number;
totalDocuments?: number;
@@ -63,10 +63,10 @@ export class AppStateService {
this._appState = {
projects: [],
ruleSets: [],
+ fileAttributesConfig: {},
activeProjectId: null,
activeFileId: null,
activeRuleSetId: null,
- activeFileAttributesConfig: [],
activeDictionaryType: null,
versions: {}
};
@@ -171,8 +171,10 @@ export class AppStateService {
return this.ruleSets.find((rs) => rs.ruleSetId === id);
}
- public get fileAttributesConfig(): FileAttributeConfig[] {
- return this._appState.activeFileAttributesConfig;
+ public get activeFileAttributesConfig(): FileAttributesConfig {
+ if (this.activeProject) {
+ return this._appState.fileAttributesConfig[this.activeProject.ruleSetId];
+ }
}
get activeDictionaryType(): string {
@@ -247,14 +249,7 @@ export class AppStateService {
for (const projectId of Object.keys(fileData)) {
const project = mappedProjects.find((p) => p.projectId === projectId);
- const fileAttributesConfig = await this._fileAttributesService
- .getFileAttributesConfiguration(project.ruleSetId)
- .pipe(catchError(() => of({})))
- .toPromise();
-
- console.log(fileAttributesConfig);
-
- this._processFiles(project, fileData[projectId], emitEvents, fileAttributesConfig);
+ this._processFiles(project, fileData[projectId], emitEvents);
}
this._appState.projects = mappedProjects;
@@ -268,14 +263,17 @@ export class AppStateService {
}
async reloadActiveFile() {
- if (!this.activeFile) return null;
+ if (!this.activeFile) {
+ return null;
+ }
const oldProcessedDate = this.activeFile.lastProcessed;
const activeFile = await this._statusControllerService.getFileStatus(this.activeProjectId, this.activeFileId).toPromise();
const activeFileWrapper = new FileStatusWrapper(
activeFile,
this._userService.getNameForId(activeFile.currentReviewer),
- this._appState.activeFileAttributesConfig
+ this.activeProject.ruleSetId,
+ this._appState.fileAttributesConfig[this.activeProject.ruleSetId]
);
this.activeProject.files = this.activeProject.files.map((file) => (file.fileId === activeFileWrapper.fileId ? activeFileWrapper : file));
@@ -294,15 +292,10 @@ export class AppStateService {
}
const files = await this._statusControllerService.getProjectStatus(project.projectId).toPromise();
- const fileAttributesConfig = await this._fileAttributesService
- .getFileAttributesConfiguration(project.ruleSetId)
- .pipe(catchError(() => of({})))
- .toPromise();
-
- return this._processFiles(project, files, emitEvents, fileAttributesConfig);
+ return this._processFiles(project, files, emitEvents);
}
- private _processFiles(project: ProjectWrapper, files: FileStatus[], emitEvents: boolean = true, fileAttributesConfig: FileAttributesConfig) {
+ private _processFiles(project: ProjectWrapper, files: FileStatus[], emitEvents: boolean = true) {
const oldFiles = [...project.files];
const fileStatusChangedEvent = [];
@@ -316,7 +309,8 @@ export class AppStateService {
const fileStatusWrapper = new FileStatusWrapper(
file,
this._userService.getNameForId(file.currentReviewer),
- fileAttributesConfig?.fileAttributeConfigs
+ project.ruleSetId,
+ this._appState.fileAttributesConfig[project.ruleSetId]
);
if (JSON.stringify(oldFile) !== JSON.stringify(fileStatusWrapper)) {
fileStatusChangedEvent.push(fileStatusWrapper);
@@ -330,13 +324,24 @@ export class AppStateService {
}
// emit for new file
if (!found) {
- const fsw = new FileStatusWrapper(file, this._userService.getNameForId(file.currentReviewer), fileAttributesConfig?.fileAttributeConfigs);
+ const fsw = new FileStatusWrapper(
+ file,
+ this._userService.getNameForId(file.currentReviewer),
+ project.ruleSetId,
+ this._appState.fileAttributesConfig[project.ruleSetId]
+ );
fileStatusChangedEvent.push(fsw);
}
}
project.files = files.map(
- (f) => new FileStatusWrapper(f, this._userService.getNameForId(f.currentReviewer), fileAttributesConfig?.fileAttributeConfigs)
+ (f) =>
+ new FileStatusWrapper(
+ f,
+ this._userService.getNameForId(f.currentReviewer),
+ project.ruleSetId,
+ this._appState.fileAttributesConfig[project.ruleSetId]
+ )
);
this._computeStats();
@@ -360,7 +365,6 @@ export class AppStateService {
this._appState.activeProjectId = projectId;
if (!this.activeProject) {
this._appState.activeProjectId = null;
- this._appState.activeFileAttributesConfig = [];
this._router.navigate(['/main/projects']);
return;
}
@@ -482,6 +486,13 @@ export class AppStateService {
async loadAllRuleSets() {
this._appState.ruleSets = await this._ruleSetControllerService.getAllRuleSets1().toPromise();
+ this._appState.fileAttributesConfig = {};
+ for (const ruleSet of this._appState.ruleSets) {
+ this._appState.fileAttributesConfig[ruleSet.ruleSetId] = await this._fileAttributesService
+ .getFileAttributesConfiguration(ruleSet.ruleSetId)
+ .pipe(catchError(() => of({})))
+ .toPromise();
+ }
}
async loadRuleSetsIfNecessary() {