Skip to content
Snippets Groups Projects
Commit 4f89bcc6 authored by rhenck's avatar rhenck
Browse files

Add 'readonly' setting for all InputElements and likert

For elements which don't have this functionality the workaround is to 
use pointer events and make the elements unclickable.
parent 578a050d
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ import { CheckboxElement } from '../models/checkbox-element'; ...@@ -11,6 +11,7 @@ import { CheckboxElement } from '../models/checkbox-element';
[style.height.%]="100" [style.height.%]="100"
[style.background-color]="elementModel.backgroundColor"> [style.background-color]="elementModel.backgroundColor">
<mat-checkbox #checkbox class="example-margin" <mat-checkbox #checkbox class="example-margin"
(click)="elementModel.readOnly ? $event.preventDefault() : null"
[formControl]="elementFormControl" [formControl]="elementFormControl"
[style.color]="elementModel.fontColor" [style.color]="elementModel.fontColor"
[style.font-family]="elementModel.font" [style.font-family]="elementModel.font"
......
...@@ -17,6 +17,7 @@ import { LikertElementRow } from '../../models/compound-elements/likert-element- ...@@ -17,6 +17,7 @@ import { LikertElementRow } from '../../models/compound-elements/likert-element-
</div> </div>
<mat-radio-button *ngFor="let answer of [].constructor(elementModel.columnCount); let j = index" <mat-radio-button *ngFor="let answer of [].constructor(elementModel.columnCount); let j = index"
[style.pointer-events]="elementModel.readOnly ? 'none' : 'unset'"
[value]="j" [value]="j"
[style.grid-column-start]="2 + j" [style.grid-column-start]="2 + j"
[style.grid-column-end]="3 + j" [style.grid-column-end]="3 + j"
......
...@@ -18,8 +18,11 @@ import { DropdownElement } from '../models/dropdown-element'; ...@@ -18,8 +18,11 @@ import { DropdownElement } from '../models/dropdown-element';
{{$any(elementModel).label}} {{$any(elementModel).label}}
</mat-label> </mat-label>
<mat-select [formControl]="elementFormControl"> <mat-select [formControl]="elementFormControl">
<mat-option *ngIf="elementModel.allowUnset" value=""></mat-option> <mat-option *ngIf="elementModel.allowUnset" value="" (click)="$event.preventDefault()"
<mat-option *ngFor="let option of elementModel.options; let i = index" [value]="i"> [style.pointer-events]="elementModel.readOnly ? 'none' : 'unset'">
</mat-option>
<mat-option *ngFor="let option of elementModel.options; let i = index" [value]="i"
[style.pointer-events]="elementModel.readOnly ? 'none' : 'unset'">
{{option}} {{option}}
</mat-option> </mat-option>
</mat-select> </mat-select>
......
...@@ -26,6 +26,7 @@ import { RadioButtonGroupElement } from '../models/radio-button-group-element'; ...@@ -26,6 +26,7 @@ import { RadioButtonGroupElement } from '../models/radio-button-group-element';
[formControl]="elementFormControl"> [formControl]="elementFormControl">
<mat-radio-button *ngFor="let option of elementModel.options; let i = index" <mat-radio-button *ngFor="let option of elementModel.options; let i = index"
[value]="i" [value]="i"
[style.pointer-events]="elementModel.readOnly ? 'none' : 'unset'"
[style.line-height.%]="elementModel.lineHeight"> [style.line-height.%]="elementModel.lineHeight">
{{option}} {{option}}
</mat-radio-button> </mat-radio-button>
......
...@@ -17,6 +17,7 @@ import { TextAreaElement } from '../models/text-area-element'; ...@@ -17,6 +17,7 @@ import { TextAreaElement } from '../models/text-area-element';
[appearance]="$any(elementModel.appearance)"> [appearance]="$any(elementModel.appearance)">
<textarea matInput [formControl]="elementFormControl" #input <textarea matInput [formControl]="elementFormControl" #input
rows="{{elementModel.rows}}" rows="{{elementModel.rows}}"
[readonly]="elementModel.readOnly"
(focus)="onFocus.emit(input)" (focus)="onFocus.emit(input)"
(blur)="onBlur.emit(input)" (blur)="onBlur.emit(input)"
autocomplete="off" autocomplete="off"
......
...@@ -19,6 +19,7 @@ import { TextFieldElement } from '../models/text-field-element'; ...@@ -19,6 +19,7 @@ import { TextFieldElement } from '../models/text-field-element';
[appearance]="$any(elementModel.appearance)"> [appearance]="$any(elementModel.appearance)">
<mat-label>{{elementModel.label}}</mat-label> <mat-label>{{elementModel.label}}</mat-label>
<input matInput type="text" [pattern]="elementModel.pattern" #input <input matInput type="text" [pattern]="elementModel.pattern" #input
[readonly]="elementModel.readOnly"
(focus)="onFocus.emit(input)" (focus)="onFocus.emit(input)"
(blur)="onBlur.emit(input)" (blur)="onBlur.emit(input)"
autocomplete="off" autocomplete="off"
...@@ -43,6 +44,7 @@ import { TextFieldElement } from '../models/text-field-element'; ...@@ -43,6 +44,7 @@ import { TextFieldElement } from '../models/text-field-element';
appInputBackgroundColor [backgroundColor]="elementModel.backgroundColor" appInputBackgroundColor [backgroundColor]="elementModel.backgroundColor"
[appearance]="$any(elementModel.appearance)"> [appearance]="$any(elementModel.appearance)">
<input matInput type="text" #input <input matInput type="text" #input
[readonly]="elementModel.readOnly"
[pattern]="elementModel.pattern" [pattern]="elementModel.pattern"
(focus)="onFocus.emit(input)" (focus)="onFocus.emit(input)"
(blur)="onBlur.emit(input)" (blur)="onBlur.emit(input)"
......
...@@ -7,6 +7,7 @@ export class LikertElement extends UIElement implements FontElement, SurfaceUIEl ...@@ -7,6 +7,7 @@ export class LikertElement extends UIElement implements FontElement, SurfaceUIEl
questions: LikertElementRow[] = []; questions: LikertElementRow[] = [];
answers: AnswerOption[] = []; answers: AnswerOption[] = [];
lineColoring: boolean = true; lineColoring: boolean = true;
readOnly: boolean = false;
fontColor: string = 'black'; fontColor: string = 'black';
font: string = 'Roboto'; font: string = 'Roboto';
...@@ -36,5 +37,10 @@ export class LikertElement extends UIElement implements FontElement, SurfaceUIEl ...@@ -36,5 +37,10 @@ export class LikertElement extends UIElement implements FontElement, SurfaceUIEl
question.columnCount = this.answers.length; question.columnCount = this.answers.length;
}); });
} }
if (property === 'readOnly') {
this.questions.forEach(question => {
question.readOnly = this.readOnly;
});
}
} }
} }
...@@ -50,6 +50,7 @@ export abstract class InputElement extends UIElement { ...@@ -50,6 +50,7 @@ export abstract class InputElement extends UIElement {
value: InputElementValue; value: InputElementValue;
required: boolean; required: boolean;
requiredWarnMessage: string; requiredWarnMessage: string;
readOnly: boolean = false;
protected constructor(serializedElement: UIElement) { protected constructor(serializedElement: UIElement) {
super(serializedElement); super(serializedElement);
...@@ -57,5 +58,6 @@ export abstract class InputElement extends UIElement { ...@@ -57,5 +58,6 @@ export abstract class InputElement extends UIElement {
this.value = serializedElement.value as string | number | boolean | null || null; this.value = serializedElement.value as string | number | boolean | null || null;
this.required = serializedElement.required as boolean || false; this.required = serializedElement.required as boolean || false;
this.requiredWarnMessage = serializedElement.requiredWarnMessage as string || 'Eingabe erforderlich'; this.requiredWarnMessage = serializedElement.requiredWarnMessage as string || 'Eingabe erforderlich';
this.readOnly = serializedElement.readOnly as boolean || false;
} }
} }
...@@ -49,6 +49,11 @@ ...@@ -49,6 +49,11 @@
Deselektion erlauben Deselektion erlauben
</mat-checkbox> </mat-checkbox>
<mat-checkbox *ngIf="combinedProperties.readOnly !== undefined"
[checked]="$any(combinedProperties.readOnly)"
(change)="updateModel('readOnly', $event.checked)">
Schreibgeschützt
</mat-checkbox>
<mat-checkbox *ngIf="combinedProperties.required !== undefined" <mat-checkbox *ngIf="combinedProperties.required !== undefined"
[checked]="$any(combinedProperties.required)" [checked]="$any(combinedProperties.required)"
(change)="updateModel('required', $event.checked)"> (change)="updateModel('required', $event.checked)">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment