RED-6774 - fixed comments

This commit is contained in:
Valentin Mihai 2023-06-28 18:30:52 +03:00
parent a39eb1fa65
commit 403d3e849f
13 changed files with 43 additions and 83 deletions

View File

@ -10,7 +10,6 @@ import { HelpModeService, IqserPermissionsService } from '@iqser/common-ui';
import { ViewModeService } from '../../services/view-mode.service';
import { REDAnnotationManager } from '../../../pdf-viewer/services/annotation-manager.service';
import { Roles } from '@users/roles';
import { RemoveRedactionPermissions } from '../../dialogs/remove-redaction-dialog/remove-redaction-dialog.component';
export const AnnotationButtonTypes = {
dark: 'dark',

View File

@ -58,7 +58,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
}
get title() {
return this._manualRedactionService.getTitle(this.data.manualRedactionEntryWrapper.type, this._dossier);
return this._manualRedactionService.getTitle(this.data.manualRedactionEntryWrapper.type);
}
get isRectangle() {

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { DetailsRadioOption, IconButtonTypes, IqserPermissionsService } from '@iqser/common-ui';
import { Dictionary, Dossier, DossierTemplate, File, IAddRedactionRequest, IManualRedactionEntry, SuperTypes } from '@red/domain';
import { Dictionary, Dossier, File, IAddRedactionRequest, IManualRedactionEntry, SuperTypes } from '@red/domain';
import { FormBuilder, UntypedFormGroup } from '@angular/forms';
import { Roles } from '@users/roles';
import { firstValueFrom } from 'rxjs';
@ -19,7 +19,6 @@ import { RedactTextOption, RedactTextOptions } from './redact-text-options';
import { tap } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { IqserDialogComponent } from '../../../../../../../../libs/common-ui/src/lib/dialog/iqser-dialog-component.directive';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
const PIN_ICON = 'red:push-pin';
const FOLDER_ICON = 'red:folder';
@ -28,6 +27,7 @@ interface RedactTextData {
manualRedactionEntryWrapper: ManualRedactionEntryWrapper;
dossierId: string;
file: File;
applyToAllDossiers: boolean;
}
interface DialogResult {
@ -54,7 +54,7 @@ export class RedactTextDialogComponent
form!: UntypedFormGroup;
#manualRedactionTypeExists = true;
#applyToAllDossiers = true;
#applyToAllDossiers: boolean;
readonly #translations = redactTextTranslations;
readonly #dossier: Dossier;
@ -65,13 +65,13 @@ export class RedactTextDialogComponent
private readonly _activeDossiersService: ActiveDossiersService,
private readonly _dictionaryService: DictionaryService,
private readonly _iqserPermissionsService: IqserPermissionsService,
private readonly _dossierTemplatesService: DossierTemplatesService,
private readonly _formBuilder: FormBuilder,
) {
super();
this.#dossier = _activeDossiersService.find(this.data.dossierId);
this.type = this.data.manualRedactionEntryWrapper.type;
this.#hint = this.type === ManualRedactionEntryTypes.HINT;
this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true;
this.#manualRedactionTypeExists = this._dictionaryService.hasManualType(this.#dossier.dossierTemplateId);
this.options = this.#options();
@ -205,7 +205,7 @@ export class RedactTextDialogComponent
value: RedactTextOptions.IN_DOSSIER,
extraOption: {
label: this.#translations[this.type].inDossier.extraOptionLabel,
checked: true,
checked: this.data.applyToAllDossiers ?? true,
},
});
}
@ -213,8 +213,8 @@ export class RedactTextDialogComponent
}
#resetValues() {
this.#applyToAllDossiers = true;
this.options[1].extraOption.checked = true;
this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true;
this.options[1].extraOption.checked = this.#applyToAllDossiers;
if (this.dictionaryRequest) {
this.form.get('reason').setValue(null);
this.form.get('dictionary').setValue(null);

View File

@ -39,7 +39,7 @@ import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { AnnotationDrawService } from '../pdf-viewer/services/annotation-draw.service';
import { AnnotationProcessingService } from './services/annotation-processing.service';
import { Dictionary, File, IManualRedactionEntry, ViewModes } from '@red/domain';
import { Dictionary, File, ViewModes } from '@red/domain';
import { PermissionsService } from '@services/permissions.service';
import { combineLatest, firstValueFrom, of, pairwise } from 'rxjs';
import { PreferencesKeys, UserPreferenceService } from '@users/user-preference.service';
@ -78,7 +78,7 @@ import { IqserDialog } from '../../../../../../libs/common-ui/src/lib/dialog/iqs
import { RedactTextDialogComponent } from './dialogs/redact-text-dialog/redact-text-dialog.component';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
const textActions = [TextPopups.ADD_DICTIONARY, TextPopups.ADD_FALSE_POSITIVE];
const textActions = [TextPopups.REDACT_TEXT, TextPopups.ADD_HINT, TextPopups.ADD_FALSE_POSITIVE];
@Component({
templateUrl: './file-preview-screen.component.html',
@ -373,9 +373,15 @@ export class FilePreviewScreenComponent
async openRedactTextDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) {
const file = this.state.file();
const dossierTemplate = this._dossierTemplatesService.find(this.state.dossierTemplateId);
const result = await this._iqserDialog
.openDefault(RedactTextDialogComponent, {
data: { manualRedactionEntryWrapper, dossierId: this.dossierId, file },
data: {
manualRedactionEntryWrapper,
dossierId: this.dossierId,
file,
applyToAllDossiers: dossierTemplate.applyDictionaryUpdatesToAllDossiersByDefault,
},
})
.result();
@ -388,7 +394,6 @@ export class FilePreviewScreenComponent
);
if (result.applyToAllDossiers !== null) {
const dossierTemplate = this._dossierTemplatesService.find(this.state.dossierTemplateId);
const { ...body } = dossierTemplate;
body.applyDictionaryUpdatesToAllDossiersByDefault = result.applyToAllDossiers;
await this._dossierTemplatesService.createOrUpdate(body);

View File

@ -156,25 +156,12 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
);
}
getTitle(type: ManualRedactionEntryType, dossier: Dossier) {
if (this._permissionsService.isApprover(dossier)) {
switch (type) {
case 'DICTIONARY':
return _('manual-annotation.dialog.header.dictionary');
case 'FALSE_POSITIVE':
return _('manual-annotation.dialog.header.false-positive');
case 'REDACTION':
return _('manual-annotation.dialog.header.redaction');
}
}
getTitle(type: ManualRedactionEntryType) {
switch (type) {
case 'DICTIONARY':
return _('manual-annotation.dialog.header.request-dictionary');
case 'FALSE_POSITIVE':
return _('manual-annotation.dialog.header.request-false-positive');
case 'REDACTION':
return _('manual-annotation.dialog.header.request-redaction');
case 'REDACT':
return _('manual-annotation.dialog.header.redact');
case 'HINT':
return _('manual-annotation.dialog.header.hint');
}
}

View File

@ -1,5 +1,5 @@
import { computed, effect, inject, Injectable, NgZone } from '@angular/core';
import { IHeaderElement, IManualRedactionEntry } from '@red/domain';
import { IHeaderElement, IManualRedactionEntry, User } from '@red/domain';
import { Core } from '@pdftron/webviewer';
import { TranslateService } from '@ngx-translate/core';
import {
@ -9,7 +9,7 @@ import {
} from '@models/file/manual-redaction-entry.wrapper';
import { AnnotationDrawService } from '../../pdf-viewer/services/annotation-draw.service';
import { UserPreferenceService } from '@users/user-preference.service';
import { BASE_HREF_FN, IqserPermissionsService, isJustOne, shareDistinctLast } from '@iqser/common-ui';
import { BASE_HREF_FN, getCurrentUser, IqserPermissionsService, isJustOne, shareDistinctLast } from '@iqser/common-ui';
import { toPosition } from '../utils/pdf-calculation.utils';
import { MultiSelectService } from './multi-select.service';
import { FilePreviewStateService } from './file-preview-state.service';
@ -43,6 +43,7 @@ export class PdfProxyService {
readonly annotationSelected$ = this.#annotationSelected$;
readonly manualAnnotationRequested$ = new Subject<ManualRedactionEntryWrapper>();
readonly redactTextRequested$ = new Subject<ManualRedactionEntryWrapper>();
readonly currentUser = getCurrentUser<User>();
readonly pageChanged$ = this._pdf.pageChanged$.pipe(
tap(() => this.#handleCustomActions()),
tap(() => this._pdf.resetAnnotationActions()),
@ -157,37 +158,22 @@ export class PdfProxyService {
});
}
if (this._iqserPermissionsService.has(Roles.redactions.write) || this._iqserPermissionsService.has(Roles.redactions.request)) {
const isApprover = this._permissionsService.isApprover(this._state.dossier());
if (this._iqserPermissionsService.has(Roles.redactions.write) && isApprover) {
popups.push({
type: 'actionButton',
dataElement: TextPopups.REDACT_TEXT,
img: this.#addRedactionIcon,
title: this.#getTitle(ManualRedactionEntryTypes.REDACT),
onClick: () => this._ngZone.run(() => this.#redactText(ManualRedactionEntryTypes.REDACT)),
});
popups.push({
type: 'actionButton',
dataElement: TextPopups.ADD_HINT,
img: this.#addHintIcon,
title: this.#getTitle(ManualRedactionEntryTypes.HINT),
onClick: () => this._ngZone.run(() => this.#redactText(ManualRedactionEntryTypes.HINT)),
});
// popups.push({
// type: 'actionButton',
// dataElement: TextPopups.ADD_REDACTION,
// img: this.#addRedactionIcon,
// title: this.#getTitle(ManualRedactionEntryTypes.REDACTION),
// onClick: () => this._ngZone.run(() => this._addManualRedactionOfType(ManualRedactionEntryTypes.REDACTION)),
// });
//
// if (!this._iqserPermissionsService.has(Roles.getRss)) {
// popups.push({
// type: 'actionButton',
// dataElement: TextPopups.ADD_DICTIONARY,
// img: this.#addDictIcon,
// title: this.#getTitle(ManualRedactionEntryTypes.DICTIONARY),
// onClick: () => this._ngZone.run(() => this._addManualRedactionOfType(ManualRedactionEntryTypes.DICTIONARY)),
// });
// }
}
}
@ -254,7 +240,7 @@ export class PdfProxyService {
this._viewerHeaderService.enable(HEADER_ITEMS_TO_TOGGLE);
if (this._documentViewer.selectedText().length > 2) {
this._pdf.enable([TextPopups.ADD_DICTIONARY, TextPopups.ADD_FALSE_POSITIVE]);
this._pdf.enable([TextPopups.REDACT_TEXT, TextPopups.ADD_HINT, TextPopups.ADD_FALSE_POSITIVE]);
}
}
@ -394,6 +380,6 @@ export class PdfProxyService {
}
#getTitle(type: ManualRedactionEntryType) {
return this._translateService.instant(this._manualRedactionService.getTitle(type, this._state.dossier()));
return this._translateService.instant(this._manualRedactionService.getTitle(type));
}
}

View File

@ -31,8 +31,6 @@ export type HeaderElementType = ValuesOf<typeof HeaderElements>;
export const TextPopups = {
REDACT_TEXT: 'redact-text',
ADD_HINT: 'add-hint',
ADD_REDACTION: 'add-redaction',
ADD_DICTIONARY: 'add-dictionary',
ADD_RECTANGLE: 'add-rectangle',
ADD_FALSE_POSITIVE: 'add-false-positive',
} as const;

View File

@ -5,13 +5,14 @@ import { HeaderElements, TextPopups } from '../../file-preview/utils/constants';
export const ROTATION_BUTTONS = [HeaderElements.ROTATE_LEFT_BUTTON, HeaderElements.ROTATE_RIGHT_BUTTON];
export const ROTATION_ACTION_BUTTONS = [HeaderElements.APPLY_ROTATION, HeaderElements.DISCARD_ROTATION];
export const TEXT_POPUPS_TO_TOGGLE = [TextPopups.ADD_REDACTION, TextPopups.ADD_RECTANGLE, TextPopups.ADD_FALSE_POSITIVE];
export const TEXT_POPUPS_TO_TOGGLE = [TextPopups.REDACT_TEXT, TextPopups.ADD_HINT, TextPopups.ADD_RECTANGLE, TextPopups.ADD_FALSE_POSITIVE];
export const HEADER_ITEMS_TO_TOGGLE = [HeaderElements.SHAPE_TOOL_GROUP_BUTTON];
export const ALLOWED_ACTIONS_WHEN_PAGE_EXCLUDED: string[] = [
TextPopups.ADD_RECTANGLE,
TextPopups.ADD_REDACTION,
TextPopups.REDACT_TEXT,
TextPopups.ADD_HINT,
HeaderElements.SHAPE_TOOL_GROUP_BUTTON,
];

View File

@ -150,7 +150,7 @@ export class DictionaryService extends EntitiesService<IDictionary, Dictionary>
this._dictionariesMapService.get(dossierTemplateId).forEach((d: Dictionary) => {
if (!hintTypes) {
if (!d.hint) {
if (!d.virtual && !d.hint && !d.systemManaged) {
possibleDictionaries.push(d);
}
} else if (d.hint) {

View File

@ -1716,14 +1716,10 @@
},
"error": "",
"header": {
"dictionary": "Zum Wörterbuch hinzufügen",
"false-positive": "Als Falsch-Positiv definieren",
"force-hint": "Hinweis erzwingen",
"force-redaction": "Schwärzung erzwingen",
"redaction": "Schwärzung",
"request-dictionary": "Neuen Wörterbucheintrag vorschlagen",
"request-false-positive": "Als Falsch-Positiv vorschlagen",
"request-redaction": "Schwärzung vorschlagen"
"hint": "",
"redact": ""
}
}
},

View File

@ -1716,14 +1716,10 @@
},
"error": "Error! Invalid page selection",
"header": {
"dictionary": "Add to dictionary",
"false-positive": "Set false positive",
"force-hint": "Force Hint",
"force-redaction": "Force Redaction",
"redaction": "Redaction",
"request-dictionary": "Request add to dictionary",
"request-false-positive": "Request false positive",
"request-redaction": "Request Redaction"
"hint": "Add hint",
"redact": "Redact"
}
}
},

View File

@ -1716,14 +1716,10 @@
},
"error": "",
"header": {
"dictionary": "Zum Wörterbuch hinzufügen",
"false-positive": "Als Falsch-Positiv definieren",
"force-hint": "Hinweis erzwingen",
"force-redaction": "Schwärzung erzwingen",
"redaction": "Schwärzung",
"request-dictionary": "Neuen Wörterbucheintrag vorschlagen",
"request-false-positive": "Als Falsch-Positiv vorschlagen",
"request-redaction": "Schwärzung vorschlagen"
"hint": "",
"redact": ""
}
}
},

View File

@ -1716,14 +1716,10 @@
},
"error": "Error! Invalid page selection",
"header": {
"dictionary": "Add to dictionary",
"false-positive": "Set false positive",
"force-hint": "Force Hint",
"force-redaction": "Force Component",
"redaction": "Component",
"request-dictionary": "Request add to dictionary",
"request-false-positive": "Request false positive",
"request-redaction": "Request Component"
"hint": "Add hint",
"redact": "Redact"
}
}
},