Skip to content

Commit

Permalink
feat(bootstrap): support switch style checkboxes (#2263)
Browse files Browse the repository at this point in the history
  • Loading branch information
aitboudad committed Jun 1, 2020
1 parent aea28e1 commit 5b1a771
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule, ValidationErrors } from '@angular/forms';
import { ReactiveFormsModule, FormControl, ValidationErrors } from '@angular/forms';
import { FormlyModule, FormlyFieldConfig } from '@ngx-formly/core';
import { FormlyBootstrapModule } from '@ngx-formly/bootstrap';
import { FormControl } from '@angular/forms';
import { AppComponent } from './app.component';

export function IpValidator(control: FormControl): ValidationErrors {
Expand Down
8 changes: 5 additions & 3 deletions src/bootstrap/src/lib/types/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { FieldType } from '@ngx-formly/core';
<div [ngClass]="{
'form-check': to.formCheck.indexOf('custom') === -1,
'form-check-inline': to.formCheck === 'inline',
'custom-control custom-checkbox': to.formCheck.indexOf('custom') === 0,
'custom-control-inline': to.formCheck === 'custom-inline'
'custom-control': to.formCheck.indexOf('custom') === 0,
'custom-checkbox': to.formCheck === 'custom' || to.formCheck === 'custom-inline',
'custom-control-inline': to.formCheck === 'custom-inline',
'custom-switch': to.formCheck === 'custom-switch'
}">
<input type="checkbox"
[class.is-invalid]="showError"
Expand All @@ -32,7 +34,7 @@ export class FormlyFieldCheckbox extends FieldType {
templateOptions: {
indeterminate: true,
hideLabel: true,
formCheck: 'custom', // 'custom' | 'stacked' | 'inline' | 'custom-inline'
formCheck: 'custom', // 'custom' | 'custom-inline' | 'custom-switch' | 'stacked' | 'inline'
},
};
}
8 changes: 5 additions & 3 deletions src/bootstrap/src/lib/types/multicheckbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import { FieldType } from '@ngx-formly/core';
[ngClass]="{
'form-check': to.formCheck.indexOf('custom') === -1,
'form-check-inline': to.formCheck === 'inline',
'custom-control custom-checkbox': to.formCheck.indexOf('custom') === 0,
'custom-control-inline': to.formCheck === 'custom-inline'
'custom-control': to.formCheck.indexOf('custom') === 0,
'custom-checkbox': to.formCheck === 'custom' || to.formCheck === 'custom-inline',
'custom-control-inline': to.formCheck === 'custom-inline',
'custom-switch': to.formCheck === 'custom-switch'
}"
>
<input type="checkbox"
Expand All @@ -35,7 +37,7 @@ export class FormlyFieldMultiCheckbox extends FieldType {
defaultOptions = {
templateOptions: {
options: [],
formCheck: 'custom', // 'custom' | 'custom-inline' | 'stacked' | 'inline'
formCheck: 'custom', // 'custom' | 'custom-inline' | 'custom-switch' | 'stacked' | 'inline'
},
};

Expand Down

0 comments on commit 5b1a771

Please sign in to comment.