diff --git a/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.html b/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.html
index 362a168ef..2d2e5c915 100644
--- a/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.html
+++ b/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.html
@@ -83,7 +83,6 @@
[diffEditorText]="diffEditorText"
[initialEntries]="initialEntries"
[showDiffEditor]="compare && showDiffEditor"
- (enableSaveButton)="onEnableSaveButton($event)"
>
@@ -97,7 +96,6 @@
(action)="saveDictionary.emit()"
[label]="'dictionary-overview.save-changes' | translate"
[type]="iconButtonTypes.primary"
- [disabled]="!(saveButtonEnabled$ | async)"
icon="iqser:check"
>
diff --git a/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.ts b/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.ts
index 4dc5c27dd..400505810 100644
--- a/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.ts
+++ b/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.ts
@@ -1,6 +1,6 @@
import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild } from '@angular/core';
import { Debounce, IconButtonTypes, List, LoadingService } from '@iqser/common-ui';
-import { BehaviorSubject, firstValueFrom, Observable, of } from 'rxjs';
+import { firstValueFrom, Observable, of } from 'rxjs';
import { catchError, map, take, tap } from 'rxjs/operators';
import { Dictionary, DICTIONARY_TYPE_KEY_MAP, DictionaryType, Dossier, DossierTemplate } from '@red/domain';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@@ -27,7 +27,6 @@ const HELP_MODE_KEYS = {
})
export class DictionaryManagerComponent implements OnChanges {
readonly iconButtonTypes = IconButtonTypes;
- readonly saveButtonEnabled$ = new BehaviorSubject(true);
@Input() type: DictionaryType = 'dictionary';
@Input() entityType?: string;
@@ -212,10 +211,6 @@ export class DictionaryManagerComponent implements OnChanges {
}
}
- onEnableSaveButton(value: boolean) {
- this.saveButtonEnabled$.next(value);
- }
-
private _applySearchDecorations() {
this._searchDecorations = this.editor.codeEditor?.deltaDecorations(this._searchDecorations, []) || [];
diff --git a/apps/red-ui/src/app/modules/shared/components/editor/editor.component.ts b/apps/red-ui/src/app/modules/shared/components/editor/editor.component.ts
index ad0c13928..614474f8c 100644
--- a/apps/red-ui/src/app/modules/shared/components/editor/editor.component.ts
+++ b/apps/red-ui/src/app/modules/shared/components/editor/editor.component.ts
@@ -1,4 +1,4 @@
-import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
+import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { Debounce, List, LoadingService, OnChange } from '@iqser/common-ui';
import { EditorThemeService } from '@services/editor-theme.service';
import IStandaloneEditorConstructionOptions = monaco.editor.IStandaloneEditorConstructionOptions;
@@ -30,7 +30,6 @@ export class EditorComponent implements OnInit, OnChanges {
@Input() diffEditorText: string;
@Input() @OnChange
('revert') initialEntries: List;
@Input() canEdit = false;
- @Output() enableSaveButton = new EventEmitter();
/**
* Used as [modified] input on diff editor
@@ -94,11 +93,27 @@ export class EditorComponent implements OnInit, OnChanges {
@Debounce()
codeEditorTextChanged() {
- const newDecorations = this.currentEntries.filter(entry => this._isNew(entry)).map(entry => this._getDecoration(entry));
+ const newDecorations = this._getDecorations();
this._decorations = this.codeEditor.deltaDecorations(this._decorations, newDecorations);
this.diffValue = this.value;
this._loadingService.stop();
- this.enableSaveButton.emit(true);
+ }
+
+ _getDecorations() {
+ const currentEntries = this.currentEntries;
+ const newDecorations: IModelDeltaDecoration[] = [];
+
+ for (let index = 0; index < currentEntries.length; ++index) {
+ const entry = currentEntries.at(index);
+ if (!this._isNew(entry)) {
+ continue;
+ }
+
+ const line = index + 1;
+ newDecorations.push(this._getDecoration(entry, line));
+ }
+
+ return newDecorations;
}
revert() {
@@ -109,7 +124,6 @@ export class EditorComponent implements OnInit, OnChanges {
onPaste() {
this._loadingService.start();
- this.enableSaveButton.emit(false);
}
private _defineThemes(): void {
@@ -168,8 +182,7 @@ export class EditorComponent implements OnInit, OnChanges {
return this.initialEntries.indexOf(entry) < 0 && entry?.trim().length > 0;
}
- private _getDecoration(entry: string): IModelDeltaDecoration {
- const line = this.currentEntries.indexOf(entry) + 1;
+ private _getDecoration(entry: string, line: number): IModelDeltaDecoration {
const cssClass = entry.length < MIN_WORD_LENGTH ? 'too-short-marker' : 'changed-row-marker';
const range = new monaco.Range(line, 1, line, 1);