dossier dict version updates

This commit is contained in:
Timo 2021-05-11 20:19:28 +03:00
parent 288fad9ff6
commit bbd4b7984d
6 changed files with 43 additions and 10 deletions

View File

@ -22,6 +22,10 @@ export class FileStatusWrapper {
}
}
get dossierDictionaryVersion() {
return this.fileStatus.dossierDictionaryVersion;
}
get analysisDuration() {
return this.fileStatus.analysisDuration;
}

View File

@ -29,7 +29,8 @@ export class DossierDictionaryDialogComponent {
'dossier_redaction',
this.project.projectId
)
.subscribe(() => {
.subscribe(async () => {
await this._appStateService.updateProjectDictionaryVersion(this.project);
this._appStateService.updateProjectDictionary(this.project.ruleSetId, this.project.projectId);
this.dialogRef.close();
});

View File

@ -43,12 +43,9 @@ export class PermissionsService {
if (!fileStatus) {
return false;
}
const project = this._appStateService.getProjectById(fileStatus.projectId);
return (
((fileStatus.status === 'UNASSIGNED' || fileStatus.status === 'UNDER_REVIEW' || fileStatus.status === 'UNDER_APPROVAL') &&
(fileStatus.dictionaryVersion !== this._appStateService.dictionaryVersion(project.ruleSetId) ||
fileStatus.rulesVersion !== this._appStateService.rulesVersion(project.ruleSetId) ||
fileStatus.hasUnappliedSuggestions)) ||
(!this._appStateService.fileIsUpToDateWithLatestVersions(fileStatus) || fileStatus.hasUnappliedSuggestions)) ||
fileStatus.isError
);
}
@ -137,7 +134,7 @@ export class PermissionsService {
if (!fileStatus) {
return false;
}
return !fileStatus.hasRequests && !fileStatus.hasUnappliedSuggestions && this._appStateService.isFileUpToDateWithDictionaryAndRules(fileStatus);
return !fileStatus.hasRequests && !fileStatus.hasUnappliedSuggestions && this._appStateService.fileIsUpToDateWithLatestVersions(fileStatus);
}
canSetUnderApproval(fileStatus?: FileStatusWrapper) {

View File

@ -177,24 +177,33 @@ export class AppStateService {
if (this.activeProject?.hasPendingOrProcessing) {
await this.reloadActiveProjectFiles();
await this.updateDictionaryVersion();
await this.updateProjectDictionaryVersion(this.activeProject);
}
}
isFileUpToDateWithDictionaryAndRules(fileStatus?: FileStatusWrapper) {
fileIsUpToDateWithLatestVersions(fileStatus?: FileStatusWrapper) {
if (!fileStatus) {
fileStatus = this.activeFile;
}
return fileStatus.dictionaryVersion === this.dictionaryVersion() && fileStatus.rulesVersion === this.rulesVersion();
const project = this.getProjectById(fileStatus.projectId);
const ruleSetId = project.ruleSetId;
return (
fileStatus.dictionaryVersion === this._dictionaryVersion(ruleSetId) &&
fileStatus.rulesVersion === this._rulesVersion(ruleSetId) &&
(!project.dictionaryVersion || fileStatus.dossierDictionaryVersion === project.dictionaryVersion)
);
}
dictionaryVersion(ruleSetId?: string) {
private _dictionaryVersion(ruleSetId?: string) {
if (!ruleSetId) {
ruleSetId = this.activeProject.ruleSetId;
}
return this._appState.versions[ruleSetId].dictionaryVersion;
}
rulesVersion(ruleSetId?: string) {
private _rulesVersion(ruleSetId?: string) {
if (!ruleSetId) {
ruleSetId = this.activeProject.ruleSetId;
}
@ -270,6 +279,8 @@ export class AppStateService {
this._appState.projects = mappedProjects;
this._computeStats();
this.updateProjectDictionaryVersions();
}
}
@ -611,6 +622,18 @@ export class AppStateService {
this._appState.versions = await this._versionsControllerService.getVersions(ruleSetIds).toPromise();
}
updateProjectDictionaryVersions() {
debugger;
for (const project of this.allProjects) {
// don't wait / block
this.updateProjectDictionaryVersion(project);
}
}
async updateProjectDictionaryVersion(project: ProjectWrapper) {
project.dictionaryVersion = await this._versionsControllerService.getDossierDictionaryVersion(project.projectId, project.ruleSetId).toPromise();
}
private _getExistingFiles(projectId: string) {
const found = this._appState.projects.find((p) => p.project.projectId === projectId);
return found ? found.files : [];

View File

@ -13,6 +13,7 @@ export class ProjectWrapper {
allFilesApproved?: boolean;
type: Dictionary;
dictionaryVersion?: number;
constructor(public project: Project, files: FileStatusWrapper[]) {
this._files = files ? files : [];

View File

@ -39,6 +39,13 @@ export interface FileStatus {
* Shows which dictionary versions was used during the analysis.
*/
dictionaryVersion?: number;
/**
* dossier dictionary version
*/
dossierDictionaryVersion?: number;
/**
* File Attributes;
*/
fileAttributes?: FileAttributes;
/**
* The ID of the file.