new rule on file preview

This commit is contained in:
Timo Bejan 2020-11-03 23:39:25 +02:00
parent 0a2f8df11d
commit 382f590afb
7 changed files with 64 additions and 21 deletions

View File

@ -7,7 +7,12 @@
</div>
<div class="flex-1 filename page-title">
{{ appStateService.activeFile.filename }}
<span
*ngIf="appStateService.fileNotUpToDateWithDictionary()"
class="pill"
translate="project-overview.new-rule.label"
></span
>&nbsp;<span>{{ appStateService.activeFile.filename }}</span>
</div>
<div class="flex-1 actions-container">

View File

@ -30,6 +30,8 @@ import { AnnotationDrawService } from '../service/annotation-draw.service';
import { AnnotationProcessingService } from '../service/annotation-processing.service';
import { FilterModel } from '../../../common/filter/model/filter.model';
import { tap } from 'rxjs/operators';
import { NotificationService, NotificationType } from '../../../notification/notification.service';
import { TranslateService } from '@ngx-translate/core';
const KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'];
@ -46,6 +48,8 @@ export class FilePreviewScreenComponent implements OnInit {
private readonly _activatedRoute: ActivatedRoute,
private readonly _dialogService: DialogService,
private readonly _router: Router,
private readonly _notificationService: NotificationService,
private readonly _translateService: TranslateService,
private readonly _annotationProcessingService: AnnotationProcessingService,
private readonly _annotationDrawService: AnnotationDrawService,
private readonly _fileActionService: FileActionService,
@ -107,7 +111,9 @@ export class FilePreviewScreenComponent implements OnInit {
loadingMessage: string;
public ngOnInit(): void {
this._loadFileData().subscribe(() => {});
this._loadFileData().subscribe(() => {
this._displayNewRuleToast();
});
this.appStateService.fileStatusChanged.subscribe((fileStatus: FileStatus) => {
if (fileStatus.fileId === this.fileId) {
this._loadFileData().subscribe(() => {
@ -155,8 +161,8 @@ export class FilePreviewScreenComponent implements OnInit {
);
}
public reanalyseFile($event: MouseEvent) {
$event.stopPropagation();
public reanalyseFile($event?: MouseEvent) {
$event?.stopPropagation();
this.viewReady = false;
this.loadingMessage = 'file-preview.reanalyse-file';
this._reanalysisControllerService
@ -510,4 +516,31 @@ export class FilePreviewScreenComponent implements OnInit {
this._fileActionService.setApproved(this.appStateService.activeFile);
}
}
private _displayNewRuleToast() {
if (this.appStateService.fileNotUpToDateWithDictionary()) {
this._notificationService.showToastNotification(
`${this._translateService.instant('project-overview.new-rule.toast.message-file')}`,
null,
NotificationType.WARNING,
{
disableTimeOut: true,
positionClass: 'toast-top-left',
actions: [
{
title: this._translateService.instant(
'project-overview.new-rule.toast.actions.reanalyse-file'
),
action: () => this.reanalyseFile()
},
{
title: this._translateService.instant(
'project-overview.new-rule.toast.actions.later'
)
}
]
}
);
}
}
}

View File

@ -215,7 +215,7 @@
<redaction-simple-doughnut-chart
[config]="projectsChartData"
[strokeWidth]="15"
[subtitle]="'project-listing.stats.charts.projects.label'"
[subtitle]="'project-listing.stats.charts.projects'"
></redaction-simple-doughnut-chart>
<div class="project-stats-container">
@ -240,7 +240,7 @@
<redaction-simple-doughnut-chart
[config]="documentsChartData"
[strokeWidth]="15"
[subtitle]="'project-listing.stats.charts.total-documents.label'"
[subtitle]="'project-listing.stats.charts.total-documents'"
></redaction-simple-doughnut-chart>
</div>
</div>

View File

@ -171,7 +171,7 @@
{{ fileStatus.filename }}
</div>
<span
*ngIf="fileNotUpToDateWithDictionary(fileStatus)"
*ngIf="appStateService.fileNotUpToDateWithDictionary(fileStatus)"
class="pill"
translate="project-overview.new-rule.label"
></span>
@ -248,7 +248,7 @@
*ngIf="
userService.isManager(user) || appStateService.isActiveProjectOwner
"
[matTooltip]="'project-overview.delete.action.label' | translate"
[matTooltip]="'project-overview.delete.action' | translate"
[matTooltipPosition]="'above'"
color="accent"
mat-icon-button
@ -257,7 +257,7 @@
</button>
<button
(click)="downloadFileRedactionReport($event, fileStatus)"
[matTooltip]="'project-overview.report.action.label' | translate"
[matTooltip]="'project-overview.report.action' | translate"
[matTooltipPosition]="'above'"
color="accent"
mat-icon-button
@ -270,7 +270,7 @@
appStateService.isActiveProjectMember &&
!isApprovedOrUnderApproval(fileStatus)
"
[matTooltip]="'project-overview.assign.action.label' | translate"
[matTooltip]="'project-overview.assign.action' | translate"
[matTooltipPosition]="'above'"
color="accent"
mat-icon-button
@ -280,7 +280,7 @@
<button
(click)="reanalyseFile($event, fileStatus)"
*ngIf="!isApprovedOrUnderApproval(fileStatus)"
[matTooltip]="'project-overview.reanalyse.action.label' | translate"
[matTooltip]="'project-overview.reanalyse.action' | translate"
[matTooltipPosition]="'above'"
color="accent"
mat-icon-button

View File

@ -107,7 +107,7 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy {
// @ts-ignore
if (
!this.appStateService.activeProject.files.filter((file) =>
this.fileNotUpToDateWithDictionary(file)
this.appStateService.fileNotUpToDateWithDictionary(file)
).length
) {
return;
@ -115,7 +115,7 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy {
this._notificationService.showToastNotification(
`${this._translateService.instant(
'project-overview.new-rule.toast.message'
'project-overview.new-rule.toast.message-project'
)} <span class="pill">${this._translateService.instant(
'project-overview.new-rule.label'
)}</span>`,
@ -348,13 +348,6 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy {
return filterMatched;
}
fileNotUpToDateWithDictionary(fileStatus: FileStatus) {
return (
(fileStatus.status === 'UNASSIGNED' || fileStatus.status === 'UNDER_REVIEW') &&
fileStatus.dictionaryVersion !== this.appStateService.dictionaryVersion
);
}
requestApprovalOrApproveFile($event: MouseEvent, fileStatus: FileStatus) {
$event.stopPropagation();

View File

@ -480,4 +480,14 @@ export class AppStateService {
this.isActiveProjectOwnerAndManager
);
}
fileNotUpToDateWithDictionary(fileStatus?: FileStatus) {
if (!fileStatus) {
fileStatus = this.activeFile;
}
return (
(fileStatus.status === 'UNASSIGNED' || fileStatus.status === 'UNDER_REVIEW') &&
fileStatus.dictionaryVersion !== this.dictionaryVersion
);
}
}

View File

@ -169,9 +169,11 @@
"new-rule": {
"label": "New Rule",
"toast": {
"message": "Some documents were not processed with the latest rule/dictionary set. They are marked with:\n\n",
"message-project": "Some documents were not processed with the latest rule/dictionary set. They are marked with:\n\n",
"message-file": "This documents was not processed with the latest rule/dictionary set.\n\n",
"actions": {
"reanalyse-all": "Reanalyse all",
"reanalyse-file": "Reanalyse this file",
"later": "Later"
}
}