Browse Source

Selective three states.

pull/342/head
Sebastian 7 years ago
parent
commit
f7667e7314
  1. 2
      src/Squidex/app/features/content/shared/field-editor.component.html
  2. 7
      src/Squidex/app/framework/angular/forms/toggle.component.ts

2
src/Squidex/app/features/content/shared/field-editor.component.html

@ -84,7 +84,7 @@
<ng-container *ngSwitchCase="'Boolean'">
<ng-container [ngSwitch]="field.properties['editor']">
<ng-container *ngSwitchCase="'Toggle'">
<sqx-toggle [formControl]="control"></sqx-toggle>
<sqx-toggle [formControl]="control" [threeStates]="!field.properties.isRequired"></sqx-toggle>
</ng-container>
<ng-container *ngSwitchCase="'Checkbox'">
<input type="checkbox" [formControl]="control" class="form-check" sqxIndeterminateValue />

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

@ -5,7 +5,7 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, forwardRef } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, forwardRef, Input } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { Types } from '@app/framework/internal';
@ -25,6 +25,9 @@ export class ToggleComponent implements ControlValueAccessor {
private callChange = (v: any) => { /* NOOP */ };
private callTouched = () => { /* NOOP */ };
@Input()
public threeStates = false;
public isChecked: boolean | null = null;
public isDisabled = false;
@ -58,7 +61,7 @@ export class ToggleComponent implements ControlValueAccessor {
return;
}
if (event.ctrlKey || event.shiftKey) {
if (this.threeStates && (event.ctrlKey || event.shiftKey)) {
if (this.isChecked) {
this.isChecked = null;
} else if (this.isChecked === null) {

Loading…
Cancel
Save