mirror of https://github.com/Squidex/squidex.git
11 changed files with 180 additions and 7 deletions
@ -0,0 +1,41 @@ |
|||
<div [formGroup]="editForm"> |
|||
<div class="form-group row"> |
|||
<label for="field-placeholder" class="col-xs-3 col-form-label">Placeholder</label> |
|||
|
|||
<div class="col-xs-6"> |
|||
<div class="errors-box" *ngIf="editForm.controls.placeholder.invalid && editForm.controls.placeholder.touched" [@fade]> |
|||
<div class="errors"> |
|||
<span *ngIf="editForm.controls.placeholder.hasError('maxlength')"> |
|||
Placeholder can not have more than 100 characters. |
|||
</span> |
|||
</div> |
|||
</div> |
|||
|
|||
<input type="text" class="form-control" id="field-placeholder" maxlength="100" formControlName="placeholder" /> |
|||
|
|||
<span class="form-hint"> |
|||
Define the placeholder for the input control. |
|||
</span> |
|||
</div> |
|||
</div> |
|||
<div class="form-group row"> |
|||
<label for="field-editor" class="col-xs-3 col-form-label">Editor</label> |
|||
|
|||
<div class="col-xs-9"> |
|||
<label class="btn btn-radio" [class.active]="editForm.controls.editor.value === 'Checkbox'"> |
|||
<input type="radio" class="radio-input" formControlName="editor" value="Checkbox" /> |
|||
|
|||
<i class="icon-control-checkbox"></i> |
|||
|
|||
<span class="radio-label">Checkbox</span> |
|||
</label> |
|||
<label class="btn btn-radio" [class.active]="editForm.controls.editor.value === 'Toggle'"> |
|||
<input type="radio" class="radio-input" formControlName="editor" value="Toggle" /> |
|||
|
|||
<i class="icon-control-toggle"></i> |
|||
|
|||
<span class="radio-label" clas>Toggle</span> |
|||
</label> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
@ -0,0 +1,2 @@ |
|||
@import '_vars'; |
|||
@import '_mixins'; |
|||
@ -0,0 +1,47 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Sebastian Stehle. All rights reserved |
|||
*/ |
|||
|
|||
import { Component, Input, OnInit } from '@angular/core'; |
|||
import { FormControl, FormGroup, Validators } from '@angular/forms'; |
|||
import { Observable } from 'rxjs'; |
|||
|
|||
import { |
|||
fadeAnimation, |
|||
FloatConverter, |
|||
BooleanFieldPropertiesDto |
|||
} from 'shared'; |
|||
|
|||
@Component({ |
|||
selector: 'sqx-boolean-ui', |
|||
styleUrls: ['boolean-ui.component.scss'], |
|||
templateUrl: 'boolean-ui.component.html', |
|||
animations: [ |
|||
fadeAnimation |
|||
] |
|||
}) |
|||
export class BooleanUIComponent implements OnInit { |
|||
@Input() |
|||
public editForm: FormGroup; |
|||
|
|||
@Input() |
|||
public properties: BooleanFieldPropertiesDto; |
|||
|
|||
public converter = new FloatConverter(); |
|||
|
|||
public hideAllowedValues: Observable<boolean>; |
|||
|
|||
public ngOnInit() { |
|||
this.editForm.addControl('editor', |
|||
new FormControl(this.properties.editor, [ |
|||
Validators.required |
|||
])); |
|||
this.editForm.addControl('placeholder', |
|||
new FormControl(this.properties.placeholder, [ |
|||
Validators.maxLength(100) |
|||
])); |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
<div [formGroup]="editForm"> |
|||
<div class="form-group row"> |
|||
<label class="col-xs-3 col-form-checkbox-label" for="field-required">Required</label> |
|||
|
|||
<div class="col-xs-6"> |
|||
<input type="checkbox" class="form-check-input" id="field-required" formControlName="isRequired" /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group row" [class.hide]="(hideDefaultValue | async)"> |
|||
<label class="col-xs-3 col-form-label" for="field-default-value">Default Value</label> |
|||
|
|||
<div class="col-xs-6"> |
|||
<input type="number" class="form-control" id="field-default-value" formControlName="defaultValue" /> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
@ -0,0 +1,16 @@ |
|||
@import '_vars'; |
|||
@import '_mixins'; |
|||
|
|||
.minlength { |
|||
&-col { |
|||
position: relative; |
|||
} |
|||
|
|||
&-label { |
|||
@include absolute(0, -4px, auto, auto); |
|||
} |
|||
} |
|||
|
|||
.form-check-input { |
|||
margin: 0; |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
/* |
|||
* Squidex Headless CMS |
|||
* |
|||
* @license |
|||
* Copyright (c) Sebastian Stehle. All rights reserved |
|||
*/ |
|||
|
|||
import { Component, Input, OnInit } from '@angular/core'; |
|||
import { FormControl, FormGroup } from '@angular/forms'; |
|||
import { Observable } from 'rxjs'; |
|||
|
|||
import { BooleanFieldPropertiesDto } from 'shared'; |
|||
|
|||
@Component({ |
|||
selector: 'sqx-boolean-validation', |
|||
styleUrls: ['boolean-validation.component.scss'], |
|||
templateUrl: 'boolean-validation.component.html' |
|||
}) |
|||
export class BooleanValidationComponent implements OnInit { |
|||
@Input() |
|||
public editForm: FormGroup; |
|||
|
|||
@Input() |
|||
public properties: BooleanFieldPropertiesDto; |
|||
|
|||
public hideDefaultValue: Observable<boolean>; |
|||
|
|||
public ngOnInit() { |
|||
this.editForm.addControl('defaultValue', |
|||
new FormControl(this.properties.defaultValue)); |
|||
|
|||
this.hideDefaultValue = |
|||
Observable.of(this.properties.isRequired) |
|||
.merge(this.editForm.get('isRequired').valueChanges) |
|||
.map(x => !!x); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue