This repository has been archived by the owner on Aug 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): #PPC-50 #PPC-51 add radio and checkbox buttons
- Loading branch information
Showing
26 changed files
with
220 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/app/components/form-checkbox/form-checkbox.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="form-group row" [formGroup]="group" *ngIf="isShow()"> | ||
<label class="col-md-2 font-weight-bold col-form-label">{{field.label}}</label> | ||
<div class="col-md-10 container"> | ||
<label class="row" *ngFor="let item of field.options"> | ||
<input type="checkbox" [formControlName]="field.name">{{item.value}} | ||
</label> | ||
</div> | ||
</div> |
20 changes: 20 additions & 0 deletions
20
src/app/components/form-checkbox/form-checkbox.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Component } from "@angular/core" | ||
import { Field } from "../../models/field.interface"; | ||
import { FormGroup } from '@angular/forms'; | ||
import { FieldConfig } from '../../models/field-config.interface'; | ||
|
||
@Component({ | ||
selector: 'form-checkbox', | ||
templateUrl: './form-checkbox.component.html' | ||
}) | ||
|
||
export class FormCheckboxComponent implements Field{ | ||
field : FieldConfig; | ||
group: FormGroup; | ||
fields: FieldConfig[]; | ||
|
||
|
||
isShow () { | ||
return !this.field.hidden; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<ng-container [formGroup]="group"> | ||
<input type="hidden" class="form-control" [formControlName]="config.name"> | ||
</ng-container> | ||
<input type="hidden" class="form-control" [formControlName]="field.name"> | ||
</ng-container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<div class="form-group row" [formGroup]="group"> | ||
<label class="col-md-2 font-weight-bold col-form-label">{{config.label}} | ||
<span [hidden]="!config.required">*</span> | ||
<div class="form-group row" [formGroup]="group" *ngIf="isShow()"> | ||
<label class="col-md-2 font-weight-bold col-form-label">{{field.label}} | ||
<span [hidden]="!field.required">*</span> | ||
</label> | ||
<div class="col-md-10"> | ||
<input type="text" class="form-control" [attr.placeholder]="config.placeholder" [formControlName]="config.name"> | ||
<input type="text" class="form-control" [attr.placeholder]="field.placeholder" [formControlName]="field.name"> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="form-group row" [formGroup]="group" *ngIf="isShow()"> | ||
<label class="col-md-2 font-weight-bold col-form-label">{{field.label}}</label> | ||
<div class="col-md-10"> | ||
<label *ngFor="let item of field.options"> | ||
<input type="radio" [value]="item.value" [formControlName]="field.name" (change)=onSelectionChange(item.ref)>{{item.value}} | ||
</label> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Component } from "@angular/core" | ||
import {Field} from "../../models/field.interface"; | ||
import { FormGroup } from '@angular/forms'; | ||
import { FieldConfig } from '../../models/field-config.interface'; | ||
import * as _ from 'lodash'; | ||
|
||
|
||
|
||
@Component({ | ||
selector: 'form-radio', | ||
templateUrl: './form-radio.component.html' | ||
}) | ||
|
||
export class FormRadioComponent implements Field{ | ||
field: FieldConfig; | ||
group: FormGroup; | ||
fields: FieldConfig[]; | ||
|
||
/** | ||
* { | ||
* radioName1: refName1, | ||
* radioName2: refName2 | ||
* } | ||
* @type {{}} | ||
*/ | ||
private radioMap = {}; | ||
|
||
|
||
isShow () { | ||
return !this.field.hidden; | ||
} | ||
|
||
/** | ||
* @description change the ref component disabled status when radio button changes | ||
* @param refName | ||
*/ | ||
onSelectionChange(refName) { | ||
let radioName = this.field.name; | ||
let isDisabled = false; | ||
if (!refName) { | ||
refName = this.radioMap[radioName]; | ||
isDisabled = true; | ||
} | ||
|
||
this.fields.forEach(field => { | ||
if (field.name === refName) { | ||
field.hidden = isDisabled; | ||
this.radioMap[radioName] = refName; | ||
} | ||
}); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<div class="form-group row" [formGroup]="group"> | ||
<label class="col-md-2 font-weight-bold col-form-label" for="group">{{config.label}} | ||
<span [hidden]="!config.required">*</span> | ||
<div class="form-group row" [formGroup]="group" *ngIf="isShow()"> | ||
<label class="col-md-2 font-weight-bold col-form-label" for="group">{{field.label}} | ||
<span [hidden]="!field.required">*</span> | ||
</label> | ||
<div class="col-md-10"> | ||
<select [formControlName]="config.name" class="form-control"> | ||
<option *ngFor="let option of config.options" [ngValue]="option">{{option}}</option> | ||
<select [formControlName]="field.name" class="form-control"> | ||
<option *ngFor="let option of field.options" [ngValue]="option">{{option}}</option> | ||
</select> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
src/app/components/form-text-editor/form-text-editor.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<div class="form-group row" [formGroup]="group"> | ||
<label class="col-md-2 font-weight-bold col-form-label" for="group" required>{{config.label}} | ||
<span [hidden]="!config.required">*</span> | ||
<div class="form-group row" [formGroup]="group" *ngIf="isShow()"> | ||
<label class="col-md-2 font-weight-bold col-form-label" for="group" required>{{field.label}} | ||
<span [hidden]="!field.required">*</span> | ||
</label> | ||
<div class="col-md-10 editor-container"> | ||
<quill-editor [modules]="quillToolbar" [formControlName]="config.name"></quill-editor> | ||
<quill-editor [modules]="quillToolbar" [formControlName]="field.name"></quill-editor> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
src/app/components/form-textarea/form-textarea.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<div class="form-group row" [formGroup]="group"> | ||
<label class="col-md-2 font-weight-bold col-form-label">{{config.label}} | ||
<span [hidden]="!config.required">*</span> | ||
<div class="form-group row" [formGroup]="group" *ngIf="isShow()"> | ||
<label class="col-md-2 font-weight-bold col-form-label">{{field.label}} | ||
<span [hidden]="!field.required">*</span> | ||
</label> | ||
<div class="col-md-10"> | ||
<textarea class="form-control" rows="3" [attr.placeholder]="config.placeholder" [formControlName]="config.name"></textarea> | ||
<textarea class="form-control" rows="3" [attr.placeholder]="config.placeholder" [formControlName]="field.name"></textarea> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.