-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1001 from HealthCatalyst/dev
Release
- Loading branch information
Showing
40 changed files
with
530 additions
and
190 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
...ects/cashmere-examples/src/lib/checkbox-disabled/checkbox-disabled-example.component.html
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
projects/cashmere-examples/src/lib/checkbox-disabled/checkbox-disabled-example.component.ts
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...ere-examples/src/lib/checkbox-indeterminate/checkbox-indeterminate-example.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,10 @@ | ||
<hc-checkbox [checked]="isChecked()" [indeterminate]="isIndeterminate()" (change)="parentClick()"> | ||
Parent Checkbox (indeterminate) | ||
</hc-checkbox> | ||
|
||
<form [formGroup]="checkboxGroup" class="checkbox-group"> | ||
<div *ngFor="let control of getChecks()"> | ||
<hc-checkbox [formControl]="control">Child Checkbox</hc-checkbox> | ||
</div> | ||
</form> | ||
|
4 changes: 4 additions & 0 deletions
4
...ere-examples/src/lib/checkbox-indeterminate/checkbox-indeterminate-example.component.scss
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,4 @@ | ||
.checkbox-group { | ||
margin-left: 25px; | ||
margin-top: 5px; | ||
} |
51 changes: 51 additions & 0 deletions
51
...hmere-examples/src/lib/checkbox-indeterminate/checkbox-indeterminate-example.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,51 @@ | ||
import {Component} from '@angular/core'; | ||
import {CheckboxChangeEvent} from '@healthcatalyst/cashmere'; | ||
import {FormGroup, FormArray, FormControl, FormBuilder} from '@angular/forms'; | ||
|
||
/** | ||
* @title Indeterminate Checkbox | ||
*/ | ||
@Component({ | ||
selector: 'hc-checkbox-indeterminate-example', | ||
templateUrl: 'checkbox-indeterminate-example.component.html', | ||
styleUrls: ['checkbox-indeterminate-example.component.scss'] | ||
}) | ||
export class CheckboxIndeterminateExampleComponent { | ||
checkboxGroup: FormGroup; | ||
|
||
constructor(_fb: FormBuilder) { | ||
let checkboxArray = new FormArray([new FormControl(false), new FormControl(true), new FormControl(false), new FormControl(true)]); | ||
this.checkboxGroup = _fb.group({ | ||
checkValues: checkboxArray | ||
}); | ||
} | ||
|
||
getChecks() { | ||
const formArray = this.checkboxGroup.get('checkValues') as FormArray; | ||
const controls = formArray.controls as FormControl[]; | ||
return controls; | ||
} | ||
|
||
isChecked() { | ||
const checkedCount = this.checkboxGroup.controls['checkValues'].value.filter(c => c).length; | ||
return checkedCount === this.checkboxGroup.controls['checkValues'].value.length; | ||
} | ||
|
||
isIndeterminate() { | ||
const checkedCount = this.checkboxGroup.controls['checkValues'].value.filter(c => c).length; | ||
return !(checkedCount === 0 || checkedCount === this.checkboxGroup.controls['checkValues'].value.length); | ||
} | ||
|
||
parentClick() { | ||
const checkedCount = this.checkboxGroup.controls['checkValues'].value.filter(c => c).length; | ||
const valueArray = new Array(this.checkboxGroup.controls['checkValues'].value.length); | ||
|
||
if (checkedCount !== this.checkboxGroup.controls['checkValues'].value.length) { | ||
valueArray.fill(true); | ||
} else { | ||
valueArray.fill(false); | ||
} | ||
|
||
this.checkboxGroup.controls['checkValues'].setValue(valueArray); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...ects/cashmere-examples/src/lib/checkbox-standard/checkbox-standard-example.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 +1,3 @@ | ||
<hc-checkbox id="light">Standard Checkbox</hc-checkbox> | ||
|
||
<hc-checkbox id="disabled" disabled="true">Disabled Checkbox</hc-checkbox> |
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
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
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
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
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
Oops, something went wrong.