Form with material design

This commit is contained in:
annampak 2017-12-28 18:32:28 +02:00
parent 4ccafb6b31
commit 391fd20baf
9 changed files with 48 additions and 25 deletions

View File

@ -1,5 +1,7 @@
<div [formGroup]="form"> <div [formGroup]="form">
<mat-radio-button name="{{field.id}}" value="true" label="Yes" formControlName="value"></mat-radio-button> <mat-radio-group formControlName="value">
<br> <mat-radio-button name="{{field.id}}" value="true">Yes</mat-radio-button>
<mat-radio-button name="{{field.id}}" value="false" label="No" formControlName="value"></mat-radio-button> <br>
<mat-radio-button name="{{field.id}}" value="false">No</mat-radio-button>
</mat-radio-group>
</div> </div>

View File

@ -1,5 +1,6 @@
<div [formGroup]="form" class="form-group"> <div [formGroup]="form" class="form-group">
<mat-checkbox [formControl]="form.get('value')" binary="true">{{field.data.label}}</mat-checkbox> <mat-checkbox formControlName="value">{{field.data.label}}</mat-checkbox>
<!-- <input type="checkbox" formControlName="value"> -->
</div> </div>
<!-- label="{{field.data.label}}" --> <!-- label="{{field.data.label}}" formControlName="form.get('value').value"-->

View File

@ -15,4 +15,5 @@ export class DynamicFieldCheckBoxComponent {
@Input() field: Field; @Input() field: Field;
@Input() form: FormGroup; @Input() form: FormGroup;
} }

View File

@ -1,5 +1,8 @@
<div [formGroup]="form"> <div [formGroup]="form">
<select class="form-control" formControlName="value"> <mat-form-field>
<option *ngFor="let opt of field.data.options" [value]="opt.value">{{opt.label}}</option> <mat-select formControlName="value">
</select> <mat-option *ngFor="let opt of field.data.options" [value]="opt.value">{{opt.label}}</mat-option>
</mat-select>
</mat-form-field>
</div> </div>

View File

@ -1,7 +1,9 @@
<div [formGroup]="form"> <div [formGroup]="form">
<div *ngFor="let option of this.field.data.options let index = index"> <mat-radio-group formControlName="value">
<mat-radio-button name="{{field.id}}" [value]="option.value" formControlName="value">{{option.label}}</mat-radio-button> <div *ngFor="let option of this.field.data.options let index = index">
</div> <mat-radio-button [value]="option.value" >{{option.label}}</mat-radio-button>
</div>
</mat-radio-group>
</div> </div>
<!-- label="{{option.label}}" --> <!-- label="{{option.label}}" -->

View File

@ -1,17 +1,18 @@
<mat-form-field [id]="field.id" *ngIf="visibilityRulesService.isElementVisible(pathName,field.id)" [formGroup]="form" <div [id]="field.id" *ngIf="visibilityRulesService.isElementVisible(pathName,field.id)" [formGroup]="form" [ngSwitch]="field.viewStyle.renderStyle">
[ngSwitch]="field.viewStyle.renderStyle">
<h5 *ngIf="field.title">{{field.title}}</h5> <h5 *ngIf="field.title">{{field.title}}</h5>
<div [class.content-left-margin]="field.title"> <div [class.content-left-margin]="field.title">
<h5 *ngIf="field.description">{{field.description}}</h5> <h5 *ngIf="field.description">{{field.description}}</h5>
<h5 *ngIf="field.extendedDescription" class="field-extended-desc"> <h5 *ngIf="field.extendedDescription" class="field-extended-desc">
<i>{{field.extendedDescription}}</i> <i>{{field.extendedDescription}}</i>
</h5> </h5>
<div *ngSwitchCase="'freetext'"> <div *ngSwitchCase="'freetext'">
<input matInput formControlName="value"> <mat-form-field>
<input matInput formControlName="value">
</mat-form-field>
</div> </div>
<div *ngSwitchCase="'combobox'"> <div *ngSwitchCase="'combobox'">
@ -22,6 +23,7 @@
<div *ngIf="this.field.data.type === 'wordlist'"> <div *ngIf="this.field.data.type === 'wordlist'">
<df-dropdown [form]="form" [field]="field"></df-dropdown> <df-dropdown [form]="form" [field]="field"></df-dropdown>
</div> </div>
</div> </div>
<div *ngSwitchCase="'checkBox'" class="checkbox"> <div *ngSwitchCase="'checkBox'" class="checkbox">
@ -29,7 +31,13 @@
</div> </div>
<div *ngSwitchCase="'textarea'"> <div *ngSwitchCase="'textarea'">
<textarea class="form-control" formControlName="value"> </textarea> <mat-form-field>
<textarea matInput formControlName="value" matTextareaAutosize matAutosizeMinRows="2" matAutosizeMaxRows="10"> </textarea>
<button mat-button *ngIf="form.get('value').value" matSuffix mat-icon-button aria-label="Clear" (click)="this.form.patchValue({'value': ''})">
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
</div> </div>
<div *ngSwitchCase="'booleanDecision'"> <div *ngSwitchCase="'booleanDecision'">
@ -50,7 +58,7 @@
</div> </div>
</div> </div>
</mat-form-field> </div>
<!-- <div [formGroup]="form" class="form-group"> <!-- <div [formGroup]="form" class="form-group">

View File

@ -27,10 +27,15 @@ export class DynamicFormFieldComponent {
constructor(private route: ActivatedRoute,private visibilityRulesService:VisibilityRulesService) { } constructor(private route: ActivatedRoute,private visibilityRulesService:VisibilityRulesService) { }
ngOnChanges(changeRecord) { ngOnChanges(changeRecord) {
} }
clearInput(){
debugger;
}
get isValid() { get isValid() {
return this.form.get("value").valid; return this.form.get("value").valid;
} }

View File

@ -22,7 +22,7 @@ export class DynamicFormCompositeFieldComponent implements OnInit {
constructor(private visibilityRulesService: VisibilityRulesService) { } constructor(private visibilityRulesService: VisibilityRulesService) { }
ngOnInit() { ngOnInit() {
console.log(this.form);
} }
addMultipleField(fieldIndex: number) { addMultipleField(fieldIndex: number) {

View File

@ -1,4 +1,5 @@
<div *ngIf="visibilityRulesService.isElementVisible(pathName,section.id)" class="panel-group" style="margin-top:10px;"> <!-- Το αφηνω σχόλιο για τεστινγ για να βλεπω αν μου ξεφευγει κάτι -->
<!-- <div *ngIf="visibilityRulesService.isElementVisible(pathName,section.id)" class="panel-group" style="margin-top:10px;">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading clearfix"> <div class="panel-heading clearfix">
<a data-toggle="collapse" href="#{{section.id}}" class="panel-title pull-left" style="padding-top: 7.5px;">{{path}} {{section.title}}</a> <a data-toggle="collapse" href="#{{section.id}}" class="panel-title pull-left" style="padding-top: 7.5px;">{{path}} {{section.title}}</a>
@ -28,13 +29,13 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div> -->
<!-- <a *ngIf="!form.get('fieldGroups').get(''+i).get('title').value" data-toggle="collapse" href="#{{indexPath + 'g' + i}}" class="panel-title pull-left" <!-- <a *ngIf="!form.get('fieldGroups').get(''+i).get('title').value" data-toggle="collapse" href="#{{indexPath + 'g' + i}}" class="panel-title pull-left"
style="padding-top: 7.5px;">{{i + 1}}. Group {{i + 1}}</a> --> style="padding-top: 7.5px;">{{i + 1}}. Group {{i + 1}}</a> -->
<div *ngIf="visibilityRulesService.isElementVisible(pathName,section.id)" class="panel-group" style="margin-top:10px;"> <div *ngIf="visibilityRulesService.isElementVisible(pathName,section.id)" class="panel-group" style="margin-top:10px;">
<mat-accordion> <mat-accordion>
<mat-expansion-panel> <mat-expansion-panel expanded=true>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> <mat-panel-title>
<a data-toggle="collapse" href="#{{section.id}}" class="panel-title pull-left" style="padding-top: 7.5px;">{{path}} {{section.title}}</a> <a data-toggle="collapse" href="#{{section.id}}" class="panel-title pull-left" style="padding-top: 7.5px;">{{path}} {{section.title}}</a>