From 38f8fe760bc9424e129c3e8dfdd14d18ab6cb4ee Mon Sep 17 00:00:00 2001 From: mechtelm <nicht@mehr.fragen> Date: Mon, 22 Nov 2021 21:11:52 +0100 Subject: [PATCH] Implement readonly --- .../spell-correct.component.ts | 16 ++++++++++++++-- projects/common/models/spell-correct-element.ts | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/projects/common/element-components/spell-correct.component.ts b/projects/common/element-components/spell-correct.component.ts index 8f5e2fe98..a8fcfb1c0 100644 --- a/projects/common/element-components/spell-correct.component.ts +++ b/projects/common/element-components/spell-correct.component.ts @@ -1,5 +1,6 @@ -import { Component, ViewChild } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; import { MatInput } from '@angular/material/input'; +import { MatButton } from '@angular/material/button'; import { FormElementComponent } from '../form-element-component.directive'; import { SpellCorrectElement } from '../models/spell-correct-element'; @@ -35,9 +36,20 @@ import { SpellCorrectElement } from '../models/spell-correct-element'; '::ng-deep app-spell-correct .small-input div.mat-form-field-infix {border-top: none; padding: 0.75em 0 0.25em 0;}' ] }) -export class SpellCorrectComponent extends FormElementComponent { +export class SpellCorrectComponent extends FormElementComponent implements OnInit { elementModel!: SpellCorrectElement; @ViewChild(MatInput) inputElement!: MatInput; + @ViewChild(MatButton) buttonElement!: MatButton; + + ngOnInit(): void { + super.ngOnInit(); + if (this.inputElement && this.elementModel.readOnly) { + this.inputElement.readonly = true; + } + if (this.buttonElement && this.elementModel.readOnly) { + this.buttonElement.disabled = true; + } + } strikethrough(): boolean { if (this.inputElement) { diff --git a/projects/common/models/spell-correct-element.ts b/projects/common/models/spell-correct-element.ts index 8f7eaf4da..3324747e3 100644 --- a/projects/common/models/spell-correct-element.ts +++ b/projects/common/models/spell-correct-element.ts @@ -1,6 +1,6 @@ -import {FontElement, SurfaceUIElement} from '../interfaces/UIElementInterfaces'; -import { InputElement, UIElement} from './uI-element'; -import {initFontElement, initSurfaceElement} from '../util/unit-interface-initializer'; +import { FontElement, SurfaceUIElement } from '../interfaces/UIElementInterfaces'; +import { InputElement, UIElement } from './uI-element'; +import { initFontElement, initSurfaceElement } from '../util/unit-interface-initializer'; export class SpellCorrectElement extends InputElement implements FontElement, SurfaceUIElement { bold: boolean = false; -- GitLab