Pull request #56: RED-826
Merge in RED/ui from disable-dict to master * commit '76c1b59b484e95d193dfc5c1d9144b29be95bd2c': Disable dict save button on too short lines Disable add to dict button on length < 3
This commit is contained in:
commit
1bb7ca131c
@ -1,4 +1,4 @@
|
||||
<button mat-button [class.overlay]="showDot" [class.primary]="primary" (click)="action.emit($event)" [class.link-button]="linkButton">
|
||||
<button mat-button [class.overlay]="showDot" [class.primary]="primary" (click)="action.emit($event)" [class.link-button]="linkButton" [disabled]="disabled">
|
||||
<mat-icon [svgIcon]="icon" *ngIf="icon"></mat-icon>
|
||||
<span [translate]="text"></span>
|
||||
</button>
|
||||
|
||||
@ -11,6 +11,7 @@ export class IconButtonComponent implements OnInit {
|
||||
@Input() showDot = false;
|
||||
@Input() primary = false;
|
||||
@Input() linkButton = false;
|
||||
@Input() disabled = false;
|
||||
@Output() action = new EventEmitter<any>();
|
||||
|
||||
constructor() {}
|
||||
|
||||
@ -84,6 +84,7 @@
|
||||
(action)="saveEntries()"
|
||||
text="dictionary-overview.save-changes"
|
||||
[primary]="true"
|
||||
[disabled]="hasErrors"
|
||||
></redaction-icon-button>
|
||||
<redaction-icon-button
|
||||
*ngIf="permissionsService.isAdmin()"
|
||||
|
||||
@ -18,7 +18,7 @@ declare var ace;
|
||||
styleUrls: ['./dictionary-overview-screen.component.scss']
|
||||
})
|
||||
export class DictionaryOverviewScreenComponent {
|
||||
static readonly MIN_WORD_LENGTH: number = 2;
|
||||
static readonly MIN_WORD_LENGTH: number = 3;
|
||||
|
||||
@ViewChild('editorComponent')
|
||||
editorComponent: AceEditorComponent;
|
||||
@ -153,8 +153,8 @@ export class DictionaryOverviewScreenComponent {
|
||||
this.activeEditMarkers.push(this.editorComponent.getEditor().getSession().addMarker(new Range(i, 0, i, 1), 'changed-row-marker', 'fullLine'));
|
||||
}
|
||||
if (entry?.trim().length > 0 && entry.trim().length < DictionaryOverviewScreenComponent.MIN_WORD_LENGTH) {
|
||||
// show lines that are to short
|
||||
this.activeEditMarkers.push(this.editorComponent.getEditor().getSession().addMarker(new Range(i, 0, i, 1), 'to-short-marker', 'fullLine'));
|
||||
// show lines that are too short
|
||||
this.activeEditMarkers.push(this.editorComponent.getEditor().getSession().addMarker(new Range(i, 0, i, 1), 'too-short-marker', 'fullLine'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -166,6 +166,10 @@ export class DictionaryOverviewScreenComponent {
|
||||
);
|
||||
}
|
||||
|
||||
get hasErrors(): boolean {
|
||||
return this.currentDictionaryEntries.filter((e) => e.length < DictionaryOverviewScreenComponent.MIN_WORD_LENGTH).length > 0;
|
||||
}
|
||||
|
||||
async saveEntries() {
|
||||
let entriesToAdd = [];
|
||||
this.currentDictionaryEntries.forEach((currentEntry) => {
|
||||
@ -204,7 +208,7 @@ export class DictionaryOverviewScreenComponent {
|
||||
);
|
||||
} else {
|
||||
this._notificationService.showToastNotification(
|
||||
this._translateService.instant('dictionary-overview.error.entries-to-short'),
|
||||
this._translateService.instant('dictionary-overview.error.entries-too-short'),
|
||||
null,
|
||||
NotificationType.ERROR
|
||||
);
|
||||
|
||||
@ -30,6 +30,7 @@ export interface ViewerState {
|
||||
})
|
||||
export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
||||
private _viewerState: ViewerState = null; // no initial state
|
||||
private _selectedText = '';
|
||||
|
||||
@Input() fileData: Blob;
|
||||
@Input() fileStatus: FileStatusWrapper;
|
||||
@ -125,6 +126,15 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
||||
}
|
||||
});
|
||||
|
||||
instance.docViewer.on('textSelected', (quads, selectedText, pageNumber) => {
|
||||
this._selectedText = selectedText;
|
||||
if (selectedText.length > 2 && this.canPerformActions) {
|
||||
this.instance.enableElements(['add-dictionary']);
|
||||
} else {
|
||||
this.instance.disableElements(['add-dictionary']);
|
||||
}
|
||||
});
|
||||
|
||||
this._loadDocument();
|
||||
});
|
||||
}
|
||||
@ -256,7 +266,10 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
||||
|
||||
private _handleCustomActions() {
|
||||
if (this.canPerformActions) {
|
||||
this.instance.enableElements(['add-redaction', 'add-dictionary', 'add-rectangle', 'shapeToolGroupButton']);
|
||||
this.instance.enableElements(['add-redaction', 'add-rectangle', 'shapeToolGroupButton']);
|
||||
if (this._selectedText.length > 2) {
|
||||
this.instance.enableElements(['add-dictionary']);
|
||||
}
|
||||
} else {
|
||||
this.instance.disableElements(['add-redaction', 'add-dictionary', 'add-rectangle', 'shapeToolGroupButton']);
|
||||
}
|
||||
|
||||
@ -500,7 +500,7 @@
|
||||
},
|
||||
"dictionary-overview": {
|
||||
"error": {
|
||||
"entries-to-short": "Einige Einträge des Wörterbuchs liegen unter der Mindestlänge von 2. Diese sind rot hervorgehoben!"
|
||||
"entries-too-short": "Einige Einträge des Wörterbuchs liegen unter der Mindestlänge von 2. Diese sind rot hervorgehoben!"
|
||||
},
|
||||
"search": "Suche...",
|
||||
"save-changes": "Änderungen speichern",
|
||||
|
||||
@ -504,7 +504,7 @@
|
||||
},
|
||||
"dictionary-overview": {
|
||||
"error": {
|
||||
"entries-to-short": "Some entries of the dictionary are below the minimum length of 2. These are highlighted with red!",
|
||||
"entries-too-short": "Some entries of the dictionary are below the minimum length of 2. These are highlighted with red!",
|
||||
"generic": "Something went wrong... Dictionary update failed!"
|
||||
},
|
||||
"success": {
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.to-short-marker {
|
||||
.too-short-marker {
|
||||
position: absolute;
|
||||
background: rgba($primary, 0.5);
|
||||
z-index: 30;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user