Dictionary edit, reanalyse btn

This commit is contained in:
Timo 2020-12-03 20:03:12 +02:00
parent 20c68e790b
commit 9580a2e3b6
5 changed files with 28 additions and 11 deletions

View File

@ -1,9 +1,11 @@
<section class="dialog">
<form (submit)="saveDictionary()" [formGroup]="dictionaryForm">
<div [translate]="dictionary ? 'add-edit-dictionary.title.edit' : 'add-edit-dictionary.title.new'" class="dialog-header heading-l"></div>
<div class="dialog-header heading-l">
{{ (dictionary ? 'add-edit-dictionary.title.edit' : 'add-edit-dictionary.title.new') | translate: { name: dictionary?.type | humanize } }}
</div>
<div class="dialog-content">
<div class="red-input-group required w-300">
<div class="red-input-group required w-300" *ngIf="!dictionary">
<label translate="add-edit-dictionary.form.type"></label>
<input formControlName="type" name="type" type="text" placeholder="{{ 'add-edit-dictionary.form.type-placeholder' | translate }}" />
</div>

View File

@ -4,7 +4,7 @@
<a class="breadcrumb" routerLink="/ui/admin-dictionaries" translate="dictionaries"></a>
<mat-icon svgIcon="red:arrow-right"></mat-icon>
<a class="breadcrumb" [routerLink]="'/ui/dictionary-overview/' + dictionary.type">
{{ dictionary.type }}
{{ dictionary.type | humanize }}
</a>
</div>
@ -98,7 +98,7 @@
<div class="dictionary-header">
<div class="color-box" [style.backgroundColor]="dictionary.hexColor"></div>
<div class="heading-xl">
{{ dictionary.type }}
{{ dictionary.type | humanize }}
</div>
</div>
<div class="small-label stats-subtitle">
@ -123,3 +123,5 @@
</div>
</div>
</section>
<redaction-full-page-loading-indicator [displayed]="processing"></redaction-full-page-loading-indicator>

View File

@ -41,6 +41,8 @@ export class DictionaryOverviewScreenComponent {
aceOptions = { showPrintMargin: false };
searchText = '';
processing: boolean = true;
constructor(
public readonly permissionsService: PermissionsService,
private readonly _notificationService: NotificationService,
@ -64,10 +66,15 @@ export class DictionaryOverviewScreenComponent {
}
private _initialize() {
this._dictionaryControllerService.getDictionaryForType(this.dictionary.type).subscribe((data) => {
this.initialDictionaryEntries = data.entries.sort((str1, str2) => str1.localeCompare(str2, undefined, { sensitivity: 'accent' }));
this.revert();
});
this._dictionaryControllerService.getDictionaryForType(this.dictionary.type).subscribe(
(data) => {
this.initialDictionaryEntries = data.entries.sort((str1, str2) => str1.localeCompare(str2, undefined, { sensitivity: 'accent' }));
this.revert();
},
() => {
this.processing = false;
}
);
}
openEditDictionaryDialog($event: any) {
@ -156,10 +163,14 @@ export class DictionaryOverviewScreenComponent {
}
get hasChanges() {
return this.activeEditMarkers.length > 0 || this.currentDictionaryEntries.length < this.initialDictionaryEntries.length;
return (
this.activeEditMarkers.length > 0 ||
this.currentDictionaryEntries.filter((e) => e && e.trim().length > 0).length < this.initialDictionaryEntries.length
);
}
async saveEntries() {
this.processing = true;
let entriesToAdd = [];
this.currentDictionaryEntries.forEach((currentEntry) => {
entriesToAdd.push(currentEntry);
@ -170,6 +181,7 @@ export class DictionaryOverviewScreenComponent {
if (invalidRowsExist.length === 0) {
// can add at least 1
let obs: Observable<any>;
console.log('entriesToAdd', entriesToAdd, this);
if (entriesToAdd.length > 0) {
obs = this._dictionaryControllerService.addEntry(entriesToAdd, this.dictionary.type, true);
} else {
@ -209,6 +221,7 @@ export class DictionaryOverviewScreenComponent {
this.editorComponent.getEditor().setValue(this.dictionaryEntriesAsText);
this.editorComponent.getEditor().clearSelection();
this.searchChanged('');
this.processing = false;
}
nextSearchMatch() {

View File

@ -20,7 +20,7 @@
*ngIf="canReanalyse"
tooltip="project-overview.bulk.reanalyse"
type="dark-bg"
icon="red:assign"
icon="red:refresh"
></redaction-circle-button>
<redaction-circle-button

View File

@ -477,7 +477,7 @@
},
"add-edit-dictionary": {
"title": {
"edit": "Edit Dictionary",
"edit": "Edit {{name}} Dictionary",
"new": "Create Dictionary"
},
"form": {