From f5ea0293edbec933815139e158dd7d043667e73b Mon Sep 17 00:00:00 2001 From: Timo Date: Thu, 26 Nov 2020 21:53:27 +0200 Subject: [PATCH] Fixed some Humanize issues --- .../file-preview-screen.component.html | 4 ++-- .../screens/file/pdf-viewer/pdf-viewer.component.ts | 8 ++++++++ apps/red-ui/src/app/state/app-state.service.ts | 2 +- apps/red-ui/src/app/utils/functions.ts | 8 ++++++-- apps/red-ui/src/app/utils/humanize.pipe.ts | 4 ++-- apps/red-ui/src/assets/icons/general/rectangle.svg | 10 ++++++++++ 6 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 apps/red-ui/src/assets/icons/general/rectangle.svg diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html index b2e6ce185..b465c26c7 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html @@ -153,7 +153,7 @@ {{ annotation.typeLabel | translate }}
- : {{ annotation.dictionary | humanize }} + : {{ annotation.dictionary | humanize: false }}
: {{ annotation.content }} @@ -180,6 +180,6 @@ - {{ filter.key | humanize }} + {{ filter.key | humanize: false }} diff --git a/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts index 2670a82f8..ec70f31f3 100644 --- a/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/screens/file/pdf-viewer/pdf-viewer.component.ts @@ -12,6 +12,7 @@ import { FileStatusWrapper } from '../model/file-status.wrapper'; import { KeycloakService } from 'keycloak-angular'; import { environment } from '../../../../environments/environment'; import { AnnotationDrawService } from '../service/annotation-draw.service'; +import { keypress } from '../../../utils/functions'; export interface ViewerState { displayMode?: any; @@ -119,6 +120,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { private _disableElements() { this.instance.disableElements([ 'menuButton', + 'selectToolButton', 'textHighlightToolButton', 'textUnderlineToolButton', 'textSquigglyToolButton', @@ -147,6 +149,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { type: 'toolGroupButton', toolGroup: 'rectangleTools', dataElement: 'shapeToolGroupButton', + img: '/assets/icons/general/rectangle.svg', title: 'annotation.rectangle' }); }); @@ -173,6 +176,11 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { const quadsObject = {}; quadsObject[activePage] = [quad]; const mre = this._getManualRedactionEntry(quadsObject, 'Rectangle'); + // cleanup selection and button state + this.instance.annotManager.deselectAllAnnotations(); + this.instance.disableElements(['shapeToolGroupButton']); + this.instance.enableElements(['shapeToolGroupButton']); + // dispatch event this.manualAnnotationRequested.emit(new ManualRedactionEntryWrapper([quad], mre, 'REDACTION', 'RECTANGLE')); } }); diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts index bf310a947..c2f530fd5 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -461,7 +461,7 @@ export class AppStateService { virtual: true }; for (const key of Object.keys(this._dictionaryData)) { - this._dictionaryData[key].label = humanize(key); + this._dictionaryData[key].label = humanize(key, false); } } else { return this._dictionaryData; diff --git a/apps/red-ui/src/app/utils/functions.ts b/apps/red-ui/src/app/utils/functions.ts index e616a656c..7a74a8bb6 100644 --- a/apps/red-ui/src/app/utils/functions.ts +++ b/apps/red-ui/src/app/utils/functions.ts @@ -13,11 +13,11 @@ export function computerize(str: string) { return frags.join('_'); } -export function humanize(str: string) { +export function humanize(str: string, lowercase: boolean = true) { if (!str) { return undefined; } - const frags = str.toLowerCase().split(/[ \-_]+/); + const frags = (lowercase ? str.toLowerCase() : str).split(/[ \-_]+/); for (let i = 0; i < frags.length; i++) { frags[i] = frags[i].charAt(0).toUpperCase() + frags[i].slice(1); } @@ -34,3 +34,7 @@ export function hexToRgb(hex) { } : null; } + +export function keypress(key: string) { + document.dispatchEvent(new KeyboardEvent('keypress', { key: key })); +} diff --git a/apps/red-ui/src/app/utils/humanize.pipe.ts b/apps/red-ui/src/app/utils/humanize.pipe.ts index 38292071d..c06c2fa03 100644 --- a/apps/red-ui/src/app/utils/humanize.pipe.ts +++ b/apps/red-ui/src/app/utils/humanize.pipe.ts @@ -5,7 +5,7 @@ import { humanize } from './functions'; name: 'humanize' }) export class HumanizePipe implements PipeTransform { - transform(item: string): any { - return humanize(item); + transform(item: string, lowercase: boolean = false): any { + return humanize(item, lowercase); } } diff --git a/apps/red-ui/src/assets/icons/general/rectangle.svg b/apps/red-ui/src/assets/icons/general/rectangle.svg new file mode 100644 index 000000000..d07571e19 --- /dev/null +++ b/apps/red-ui/src/assets/icons/general/rectangle.svg @@ -0,0 +1,10 @@ +icon / operation / multi select + + + + + + + +