Browse Source

Three state toggle.

pull/342/head
Sebastian 8 years ago
parent
commit
515fc199b0
  1. 2
      src/Squidex/app/framework/angular/forms/toggle.component.html
  2. 14
      src/Squidex/app/framework/angular/forms/toggle.component.ts

2
src/Squidex/app/framework/angular/forms/toggle.component.html

@ -1,4 +1,4 @@
<div class="toggle-container" (click)="changeState()"
<div class="toggle-container" (click)="changeState($event)"
[class.disabled]="isDisabled"
[class.checked]="isChecked === true"
[class.unchecked]="isChecked === false">

14
src/Squidex/app/framework/angular/forms/toggle.component.ts

@ -53,12 +53,22 @@ export class ToggleComponent implements ControlValueAccessor {
this.callTouched = fn;
}
public changeState() {
public changeState(event: MouseEvent) {
if (this.isDisabled) {
return;
}
this.isChecked = !(this.isChecked === true);
if (event.ctrlKey || event.shiftKey) {
if (this.isChecked) {
this.isChecked = null;
} else if (this.isChecked === null) {
this.isChecked = false;
} else {
this.isChecked = true;
}
} else {
this.isChecked = !(this.isChecked === true);
}
this.callChange(this.isChecked);
this.callTouched();

Loading…
Cancel
Save