Merge branch 'dan' into 'master'

DM-414 fix save button not enabled

See merge request redactmanager/red-ui!82
This commit is contained in:
Dan Percic 2023-09-15 13:45:52 +02:00
commit 41d5c7f57e
9 changed files with 28 additions and 28 deletions

View File

@ -5,7 +5,7 @@
<div class="dialog-content redaction">
<div class="iqser-input-group w-450">
<label [translate]="'add-annotation.dialog.content.selected-text'" class="selected-text"></label>
{{ form.get('selectedText').value }}
<span [innerHTML]="form.controls.selectedText.value"></span>
</div>
<div class="iqser-input-group required w-450">

View File

@ -1,10 +1,9 @@
import { Component, inject, OnInit } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { IconButtonTypes, IqserDialogComponent, IqserPermissionsService } from '@iqser/common-ui';
import { IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui';
import { Dictionary, IAddRedactionRequest } from '@red/domain';
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
import { DictionaryService } from '@services/entity-services/dictionary.service';
import { Roles } from '@users/roles';
import { AddAnnotationData, AddAnnotationResult } from '../../../utils/dialog-types';
@Component({
@ -15,17 +14,19 @@ export class AddAnnotationDialogComponent
implements OnInit
{
readonly #dossier = inject(ActiveDossiersService).find(this.data.dossierId);
readonly #isRss = inject(IqserPermissionsService).has(Roles.getRss);
readonly iconButtonTypes = IconButtonTypes;
dictionaries: Dictionary[] = [];
readonly form = this.#getForm();
constructor(private readonly _dictionaryService: DictionaryService, private readonly _formBuilder: FormBuilder) {
constructor(
private readonly _dictionaryService: DictionaryService,
private readonly _formBuilder: FormBuilder,
) {
super();
}
get displayedDictionaryLabel() {
const dictType = this.form.get('dictionary').value;
const dictType = this.form.controls.dictionary.value;
if (dictType) {
return this.dictionaries.find(d => d.type === dictType)?.label ?? null;
}
@ -33,7 +34,7 @@ export class AddAnnotationDialogComponent
}
get disabled() {
return !this.#isRss || !this.form.get('dictionary').value;
return !this.form.controls.dictionary.value;
}
ngOnInit() {
@ -45,7 +46,7 @@ export class AddAnnotationDialogComponent
const redaction = this.data.manualRedactionEntryWrapper.manualRedactionEntry;
this.close({
redaction,
dictionary: this.dictionaries.find(d => d.type === this.form.get('dictionary').value),
dictionary: this.dictionaries.find(d => d.type === this.form.controls.dictionary.value),
});
}
@ -58,16 +59,16 @@ export class AddAnnotationDialogComponent
}
#enhanceManualRedaction(addRedactionRequest: IAddRedactionRequest) {
addRedactionRequest.type = this.form.get('dictionary').value;
addRedactionRequest.type = this.form.controls.dictionary.value;
const selectedType = this.dictionaries.find(d => d.type === addRedactionRequest.type);
addRedactionRequest.addToDictionary = !!selectedType?.hasDictionary;
addRedactionRequest.reason ??= 'Dictionary Request';
const commentValue = this.form.get('comment').value;
const commentValue = this.form.controls.comment.value;
addRedactionRequest.comment = commentValue ? { text: commentValue } : null;
addRedactionRequest.section = null;
addRedactionRequest.value = this.form.get('selectedText').value;
addRedactionRequest.value = this.form.controls.selectedText.value;
addRedactionRequest.addToAllDossiers = addRedactionRequest.addToDictionary || !!this.data.applyToAllDossiers;
}
}

View File

@ -9,6 +9,7 @@ import { ActiveDossiersService } from '@services/dossiers/active-dossiers.servic
import { DictionaryService } from '@services/entity-services/dictionary.service';
import { JustificationsService } from '@services/entity-services/justifications.service';
import { Roles } from '@users/roles';
import { removeHyphensAndSpecialChars } from '@utils/functions';
import { firstValueFrom } from 'rxjs';
import { ManualRedactionService } from '../../services/manual-redaction.service';
@ -185,6 +186,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
addRedactionRequest.value = addRedactionRequest.rectangle
? this.form.get('classification').value
: this.form.get('selectedText').value;
addRedactionRequest.value = removeHyphensAndSpecialChars(addRedactionRequest.value);
}
#selectReason() {

View File

@ -14,7 +14,7 @@
></label>
<div [ngClass]="isEditingSelectedText ? 'flex relative' : 'flex-align-items-center'" class="fixed-height">
<span *ngIf="!isEditingSelectedText" [innerHTML]="form.controls.selectedText.value" class="use-n-as-line-break"></span>
<span *ngIf="!isEditingSelectedText" [innerHTML]="form.controls.selectedText.value"></span>
<textarea
*ngIf="isEditingSelectedText"

View File

@ -43,7 +43,3 @@
textarea {
margin-top: 0;
}
.use-n-as-line-break {
white-space: pre-line !important;
}

View File

@ -52,7 +52,7 @@ import JSZip from 'jszip';
import { NGXLogger } from 'ngx-logger';
import { combineLatest, first, firstValueFrom, of, pairwise } from 'rxjs';
import { catchError, filter, map, startWith, switchMap, tap } from 'rxjs/operators';
import { byId, byPage, download, handleFilterDelta, hasChanges } from '../../utils';
import { byId, byPage, download, handleFilterDelta, hasChanges, removeHyphensAndSpecialChars } from '../../utils';
import { AnnotationDrawService } from '../pdf-viewer/services/annotation-draw.service';
import { REDAnnotationManager } from '../pdf-viewer/services/annotation-manager.service';
import { REDDocumentViewer } from '../pdf-viewer/services/document-viewer.service';
@ -533,6 +533,7 @@ export class FilePreviewScreenComponent
}
const hint = manualRedactionEntryWrapper.type === ManualRedactionEntryTypes.HINT;
result.redaction.value = removeHyphensAndSpecialChars(result.redaction.value);
const add$ = this._manualRedactionService.addAnnotation([result.redaction], this.dossierId, this.fileId, {
hint,
dictionaryLabel: result.dictionary?.label,

View File

@ -266,19 +266,11 @@ export class PdfProxyService {
}
}
entry.value = this.#formatSelectedText(text);
entry.value = text;
entry.rectangle = !text;
return entry;
}
#formatSelectedText(text: string): string {
return text?.replace(
// eslint-disable-next-line no-control-regex,max-len
/([^\s\d-]{2,})[-\u00AD]\u000D|[\u000B\u000C\u000D\u0085\u2028\u2029]/gi,
'$1',
);
}
#deactivateMultiSelect() {
this._logger.info('[PDF] Deactivating multi-select');
this._multiSelectService.deactivate();

View File

@ -1,5 +1,5 @@
import type { List } from '@iqser/common-ui/lib/utils';
import { ITrackable } from '@iqser/common-ui';
import type { List } from '@iqser/common-ui/lib/utils';
import type { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { Dayjs } from 'dayjs';
@ -133,3 +133,11 @@ export function calcTextWidthInPixels(text: string): number {
return width;
}
export function removeHyphensAndSpecialChars(text: string): string {
return text?.replace(
// eslint-disable-next-line no-control-regex,max-len
/([^\s\d-]{2,})[-\u00AD]\u000A\u000D|[\u000A\u000B\u000C\u000D\u0085\u2028\u2029]/gi,
'$1',
);
}

@ -1 +1 @@
Subproject commit d1df30b56ea5abd03b0c8623f68fc96db9fef271
Subproject commit a4132b82f52e92025f2348fb83587680790ca3a8