Skip to content
Snippets Groups Projects
Commit c10b2868 authored by jojohoch's avatar jojohoch
Browse files

[player] Prevent form validation when clicking buttons

parent 63ea2a25
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ import { ButtonElement } from '../models/button-element'; ...@@ -10,6 +10,7 @@ import { ButtonElement } from '../models/button-element';
[style.height.%]="100"> [style.height.%]="100">
<button *ngIf="!elementModel.imageSrc" mat-button <button *ngIf="!elementModel.imageSrc" mat-button
(focusin)="onFocusin.emit()" (focusin)="onFocusin.emit()"
(click)="onClick($event)"
[style.width.%]="100" [style.width.%]="100"
[style.height.%]="100" [style.height.%]="100"
[style.background-color]="elementModel.backgroundColor" [style.background-color]="elementModel.backgroundColor"
...@@ -23,6 +24,8 @@ import { ButtonElement } from '../models/button-element'; ...@@ -23,6 +24,8 @@ import { ButtonElement } from '../models/button-element';
{{elementModel.label}} {{elementModel.label}}
</button> </button>
<input *ngIf="elementModel.imageSrc" type="image" <input *ngIf="elementModel.imageSrc" type="image"
(focusin)="onFocusin.emit()"
(click)="onClick($event)"
[src]="elementModel.imageSrc | safeResourceUrl" [src]="elementModel.imageSrc | safeResourceUrl"
[class]="elementModel.dynamicPositioning? 'dynamic-image' : 'static-image'" [class]="elementModel.dynamicPositioning? 'dynamic-image' : 'static-image'"
[alt]="'imageNotFound' | translate"> [alt]="'imageNotFound' | translate">
...@@ -36,4 +39,9 @@ import { ButtonElement } from '../models/button-element'; ...@@ -36,4 +39,9 @@ import { ButtonElement } from '../models/button-element';
export class ButtonComponent extends ElementComponent { export class ButtonComponent extends ElementComponent {
@Output() onFocusin = new EventEmitter(); @Output() onFocusin = new EventEmitter();
elementModel!: ButtonElement; elementModel!: ButtonElement;
onClick = (event: MouseEvent): void => {
event.stopPropagation();
event.preventDefault();
};
} }
...@@ -24,7 +24,7 @@ import { TextFieldElement } from '../models/text-field-element'; ...@@ -24,7 +24,7 @@ import { TextFieldElement } from '../models/text-field-element';
[formControl]="elementFormControl" [formControl]="elementFormControl"
placeholder="{{elementModel.label}}"> placeholder="{{elementModel.label}}">
<button *ngIf="elementModel.clearable" matSuffix mat-icon-button aria-label="Clear" <button *ngIf="elementModel.clearable" matSuffix mat-icon-button aria-label="Clear"
(click)="elementFormControl.setValue('')"> (click)="onClick($event)">
<mat-icon>close</mat-icon> <mat-icon>close</mat-icon>
</button> </button>
<mat-error *ngIf="elementFormControl.errors"> <mat-error *ngIf="elementFormControl.errors">
...@@ -39,6 +39,12 @@ export class TextFieldComponent extends FormElementComponent { ...@@ -39,6 +39,12 @@ export class TextFieldComponent extends FormElementComponent {
@Output() onBlur = new EventEmitter<HTMLElement>(); @Output() onBlur = new EventEmitter<HTMLElement>();
elementModel!: TextFieldElement; elementModel!: TextFieldElement;
onClick(event: MouseEvent) : void {
this.elementFormControl.setValue('');
event.preventDefault();
event.stopPropagation();
}
get validators(): ValidatorFn[] { get validators(): ValidatorFn[] {
const validators: ValidatorFn[] = []; const validators: ValidatorFn[] = [];
if (this.elementModel.required) { if (this.elementModel.required) {
......
...@@ -13,19 +13,19 @@ import { TextElement } from '../models/text-element'; ...@@ -13,19 +13,19 @@ import { TextElement } from '../models/text-element';
<div *ngIf="elementModel.highlightable" <div *ngIf="elementModel.highlightable"
class="marking-bar"> class="marking-bar">
<button class="marking-button" mat-mini-fab [style.background-color]="'yellow'" <button class="marking-button" mat-mini-fab [style.background-color]="'yellow'"
(click)="applySelection.emit({color:'yellow', element: container, clear: false})"> (click)="onClick($event, {color:'yellow', element: container, clear: false})">
<mat-icon>border_color</mat-icon> <mat-icon>border_color</mat-icon>
</button> </button>
<button class="marking-button" mat-mini-fab [style.background-color]="'turquoise'" <button class="marking-button" mat-mini-fab [style.background-color]="'turquoise'"
(click)="applySelection.emit({color: 'turquoise', element: container, clear: false})"> (click)="onClick($event, {color: 'turquoise', element: container, clear: false})">
<mat-icon>border_color</mat-icon> <mat-icon>border_color</mat-icon>
</button> </button>
<button class="marking-button" mat-mini-fab [style.background-color]="'orange'" <button class="marking-button" mat-mini-fab [style.background-color]="'orange'"
(click)="applySelection.emit({color: 'orange', element: container, clear: false})"> (click)="onClick($event, {color: 'orange', element: container, clear: false})">
<mat-icon>border_color</mat-icon> <mat-icon>border_color</mat-icon>
</button> </button>
<button class="marking-button" [style.background-color]="'lightgrey'" mat-mini-fab <button class="marking-button" [style.background-color]="'lightgrey'" mat-mini-fab
(click)="applySelection.emit({color: 'none', element: container, clear: true})"> (click)="onClick($event, {color: 'none', element: container, clear: true})">
<mat-icon>clear</mat-icon> <mat-icon>clear</mat-icon>
</button> </button>
</div> </div>
...@@ -53,4 +53,10 @@ export class TextComponent extends ElementComponent { ...@@ -53,4 +53,10 @@ export class TextComponent extends ElementComponent {
constructor(public sanitizer: DomSanitizer) { constructor(public sanitizer: DomSanitizer) {
super(); super();
} }
onClick(event: MouseEvent, markingValues: { color: string; element: HTMLElement; clear: boolean }) : void {
this.applySelection.emit(markingValues);
event.preventDefault();
event.stopPropagation();
}
} }
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