Skip to content

Commit

Permalink
Fixed #7432 - Add required property to p-checkBox and p-tableCheckbox
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Mar 27, 2020
1 parent 35d7bab commit 897866b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/app/components/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const CHECKBOX_VALUE_ACCESSOR: any = {
template: `
<div [ngStyle]="style" [ngClass]="{'ui-chkbox ui-widget': true,'ui-chkbox-readonly': readonly}" [class]="styleClass">
<div class="ui-helper-hidden-accessible">
<input #cb type="checkbox" [attr.id]="inputId" [name]="name" [readonly]="readonly" [value]="value" [checked]="checked" (focus)="onFocus($event)" (blur)="onBlur($event)"
[ngClass]="{'ui-state-focus':focused}" (change)="handleChange($event)" [disabled]="disabled" [attr.tabindex]="tabindex" [attr.aria-labelledby]="ariaLabelledBy">
<input #cb type="checkbox" [attr.id]="inputId" [attr.name]="name" [readonly]="readonly" [value]="value" [checked]="checked" (focus)="onFocus($event)" (blur)="onBlur($event)"
[ngClass]="{'ui-state-focus':focused}" (change)="handleChange($event)" [disabled]="disabled" [attr.tabindex]="tabindex" [attr.aria-labelledby]="ariaLabelledBy" [attr.required]="required">
</div>
<div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default" (click)="onClick($event,cb,true)"
[ngClass]="{'ui-state-active':checked,'ui-state-disabled':disabled,'ui-state-focus':focused}" role="checkbox" [attr.aria-checked]="checked">
Expand Down Expand Up @@ -57,6 +57,8 @@ export class Checkbox implements ControlValueAccessor {

@Input() readonly: boolean;

@Input() required: boolean;

@ViewChild('cb') inputViewChild: ElementRef;

@Output() onChange: EventEmitter<any> = new EventEmitter();
Expand Down
5 changes: 4 additions & 1 deletion src/app/components/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3462,7 +3462,8 @@ export class TableRadioButton {
template: `
<div class="ui-chkbox ui-widget" (click)="onClick($event)">
<div class="ui-helper-hidden-accessible">
<input type="checkbox" [attr.id]="inputId" [attr.name]="name" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()" [disabled]="disabled">
<input type="checkbox" [attr.id]="inputId" [attr.name]="name" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()" [disabled]="disabled"
[attr.required]="required">
</div>
<div #box [ngClass]="{'ui-chkbox-box ui-widget ui-state-default':true,
'ui-state-active':checked, 'ui-state-disabled':disabled}" role="checkbox" [attr.aria-checked]="checked">
Expand All @@ -3483,6 +3484,8 @@ export class TableCheckbox {

@Input() name: string;

@Input() required: boolean;

@ViewChild('box') boxViewChild: ElementRef;

checked: boolean;
Expand Down
6 changes: 6 additions & 0 deletions src/app/showcase/components/checkbox/checkboxdemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ <h3>Properties</h3>
<td>false</td>
<td>When present, it specifies that the component cannot be edited.</td>
</tr>
<tr>
<td>required</td>
<td>boolean</td>
<td>false</td>
<td>When present, it specifies that checkbox must be checked before submitting the form.</td>
</tr>
</tbody>
</table>
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/app/showcase/components/table/tabledemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,12 @@ <h3>TableCheckbox Properties</h3>
<td>null</td>
<td>Name of the checkbox.</td>
</tr>
<tr>
<td>required</td>
<td>boolean</td>
<td>false</td>
<td>When present, it specifies that checkbox must be checked before submitting the form.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 897866b

Please sign in to comment.