feat(clients): add/edit/delete data in single row datatables

- add checkbox-base.ts 
- update clients.service.ts file
- add delete feature in multi-row and single datatables

fixes: #460
This commit is contained in:
Jivjyot Singh
2019-12-01 23:20:51 +03:00
committed by Abhay Chawla
parent b6110a9c8a
commit 5436c10a90
8 changed files with 280 additions and 54 deletions
@@ -1,25 +1,35 @@
<div [formGroup]="form" fxFlexFill>
<mat-form-field fxFlexFill>
<div>
<mat-label>{{ formfield.label }}</mat-label>
<div *ngIf="formfield.controlType==='input'||formfield.controlType==='select'">
<mat-form-field fxFlexFill>
<div [ngSwitch]="formfield.controlType">
<mat-label>{{ formfield.label }}</mat-label>
<input *ngSwitchCase="'input'" [type]="formfield.type" matInput [formControlName]="formfield.controlName" [required]="formfield.required">
<input *ngIf="formfield.controlType==='input'" [type]="formfield.type" matInput
[formControlName]="formfield.controlName" [required]="formfield.required">
<mat-select *ngSwitchCase="'select'" [formControlName]="formfield.controlName" [required]="formfield.required">
<mat-option *ngFor="let option of formfield.options.data" [value]="option[formfield.options.value]">
{{ option[formfield.options.label] }}
</mat-option>
</mat-select>
<mat-select *ngIf="formfield.controlType==='select'" [formControlName]="formfield.controlName"
[required]="formfield.required">
<mat-option *ngFor="let option of formfield.options.data" [value]="option[formfield.options.value]">
{{ option[formfield.options.label] }}
</mat-option>
</mat-select>
<mat-error *ngIf="form.controls[formfield.controlName].hasError('required')">
{{ formfield.label }} is <strong>required</strong>
</mat-error>
</mat-form-field>
</div>
<mat-error *ngIf="form.controls[formfield.controlName].hasError('required')">
{{ formfield.label }} is <strong>required</strong>
</mat-error>
<mat-checkbox *ngIf="formfield.controlType==='checkbox'" labelPosition="before" [checked]="formfield.value"
[formControlName]="formfield.controlName" [required]="formfield.required">
{{ formfield.label }}
</mat-checkbox>
</mat-form-field>
</div>
</div>
</div>
@@ -0,0 +1,10 @@
import { FormfieldBase } from './formfield-base';
export class CheckboxBase extends FormfieldBase {
controlType = 'checkbox';
constructor(options: any) {
super(options);
}
}