From 76c1b59b484e95d193dfc5c1d9144b29be95bd2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 7 Dec 2020 12:29:29 +0200 Subject: [PATCH] Disable dict save button on too short lines --- .../buttons/icon-button/icon-button.component.html | 2 +- .../buttons/icon-button/icon-button.component.ts | 1 + .../dictionary-overview-screen.component.html | 1 + .../dictionary-overview-screen.component.ts | 12 ++++++++---- apps/red-ui/src/assets/i18n/de.json | 2 +- apps/red-ui/src/assets/i18n/en.json | 2 +- apps/red-ui/src/assets/styles/red-editor.scss | 2 +- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/apps/red-ui/src/app/components/buttons/icon-button/icon-button.component.html b/apps/red-ui/src/app/components/buttons/icon-button/icon-button.component.html index 1311e6b8d..dc429e50f 100644 --- a/apps/red-ui/src/app/components/buttons/icon-button/icon-button.component.html +++ b/apps/red-ui/src/app/components/buttons/icon-button/icon-button.component.html @@ -1,4 +1,4 @@ - diff --git a/apps/red-ui/src/app/components/buttons/icon-button/icon-button.component.ts b/apps/red-ui/src/app/components/buttons/icon-button/icon-button.component.ts index ee3e9c006..46598d416 100644 --- a/apps/red-ui/src/app/components/buttons/icon-button/icon-button.component.ts +++ b/apps/red-ui/src/app/components/buttons/icon-button/icon-button.component.ts @@ -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(); constructor() {} diff --git a/apps/red-ui/src/app/screens/admin/dictionary-overview-screen/dictionary-overview-screen.component.html b/apps/red-ui/src/app/screens/admin/dictionary-overview-screen/dictionary-overview-screen.component.html index def455fdf..5e7336c03 100644 --- a/apps/red-ui/src/app/screens/admin/dictionary-overview-screen/dictionary-overview-screen.component.html +++ b/apps/red-ui/src/app/screens/admin/dictionary-overview-screen/dictionary-overview-screen.component.html @@ -84,6 +84,7 @@ (action)="saveEntries()" text="dictionary-overview.save-changes" [primary]="true" + [disabled]="hasErrors" > 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 ); diff --git a/apps/red-ui/src/assets/i18n/de.json b/apps/red-ui/src/assets/i18n/de.json index e85f75fed..bdad58aa4 100644 --- a/apps/red-ui/src/assets/i18n/de.json +++ b/apps/red-ui/src/assets/i18n/de.json @@ -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", diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index aef28b041..b2d14a049 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -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": { diff --git a/apps/red-ui/src/assets/styles/red-editor.scss b/apps/red-ui/src/assets/styles/red-editor.scss index e831d23f2..e5af43737 100644 --- a/apps/red-ui/src/assets/styles/red-editor.scss +++ b/apps/red-ui/src/assets/styles/red-editor.scss @@ -7,7 +7,7 @@ z-index: 20; } -.to-short-marker { +.too-short-marker { position: absolute; background: rgba($primary, 0.5); z-index: 30;