dossier dict version updates
This commit is contained in:
parent
288fad9ff6
commit
bbd4b7984d
@ -22,6 +22,10 @@ export class FileStatusWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
get dossierDictionaryVersion() {
|
||||
return this.fileStatus.dossierDictionaryVersion;
|
||||
}
|
||||
|
||||
get analysisDuration() {
|
||||
return this.fileStatus.analysisDuration;
|
||||
}
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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 : [];
|
||||
|
||||
@ -13,6 +13,7 @@ export class ProjectWrapper {
|
||||
|
||||
allFilesApproved?: boolean;
|
||||
type: Dictionary;
|
||||
dictionaryVersion?: number;
|
||||
|
||||
constructor(public project: Project, files: FileStatusWrapper[]) {
|
||||
this._files = files ? files : [];
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user