Skip to content

Commit 76619cf

Browse files
volivaadamdbradley
authored andcommitted
feat(select): add disabled status in select options
1 parent d993a1b commit 76619cf

File tree

8 files changed

+41
-3
lines changed

8 files changed

+41
-3
lines changed

src/components/alert/alert-component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {ViewController} from '../nav/view-controller';
2626
2727
<template ngSwitchCase="radio">
2828
<div class="alert-radio-group" role="radiogroup" [attr.aria-labelledby]="hdrId" [attr.aria-activedescendant]="activeId">
29-
<button category="alert-radio-button" *ngFor="let i of d.inputs" (click)="rbClick(i)" [attr.aria-checked]="i.checked" [attr.id]="i.id" class="alert-tappable alert-radio" role="radio">
29+
<button category="alert-radio-button" *ngFor="let i of d.inputs" (click)="rbClick(i)" [attr.aria-checked]="i.checked" [disabled]="i.disabled" [attr.id]="i.id" class="alert-tappable alert-radio" role="radio">
3030
<div class="alert-radio-icon"><div class="alert-radio-inner"></div></div>
3131
<div class="alert-radio-label">
3232
{{i.label}}
@@ -37,7 +37,7 @@ import {ViewController} from '../nav/view-controller';
3737
3838
<template ngSwitchCase="checkbox">
3939
<div class="alert-checkbox-group">
40-
<button category="alert-checkbox-button" *ngFor="let i of d.inputs" (click)="cbClick(i)" [attr.aria-checked]="i.checked" class="alert-tappable alert-checkbox" role="checkbox">
40+
<button category="alert-checkbox-button" *ngFor="let i of d.inputs" (click)="cbClick(i)" [attr.aria-checked]="i.checked" [disabled]="i.disabled" class="alert-tappable alert-checkbox" role="checkbox">
4141
<div class="alert-checkbox-icon"><div class="alert-checkbox-inner"></div></div>
4242
<div class="alert-checkbox-label">
4343
{{i.label}}
@@ -142,6 +142,7 @@ export class AlertCmp {
142142
value: isPresent(input.value) ? input.value : '',
143143
label: input.label,
144144
checked: !!input.checked,
145+
disabled: !!input.disabled,
145146
id: 'alert-input-' + this.id + '-' + index
146147
};
147148
});

src/components/alert/alert-options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ export interface AlertInputOptions {
1616
value?: string;
1717
label?: string;
1818
checked?: boolean;
19+
disabled?: boolean;
1920
id?: string;
2021
}

src/components/option/option.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { isPresent, isTrueProperty } from '../../util/util';
1414
})
1515
export class Option {
1616
private _checked: any = false;
17+
private _disabled: any = false;
1718
private _value: any;
1819

1920
/**
@@ -50,6 +51,18 @@ export class Option {
5051
this._value = val;
5152
}
5253

54+
/**
55+
* @input {boolean} Whether or not the option is disabled
56+
*/
57+
@Input()
58+
get disabled() {
59+
return this._disabled;
60+
}
61+
62+
set disabled(val) {
63+
this._disabled = isTrueProperty(val);
64+
}
65+
5366
/**
5467
* @private
5568
*/

src/components/select/select.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ export class Select {
290290
type: (this._multi ? 'checkbox' : 'radio'),
291291
label: input.text,
292292
value: input.value,
293-
checked: input.checked
293+
checked: input.checked,
294+
disabled: input.disabled
294295
};
295296
});
296297

src/components/select/test/multiple-value/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class E2EPage {
1212
pets: Array<string>;
1313
petOptions: Array<{text: string, value: string}>;
1414
authForm: ControlGroup;
15+
status: string;
1516

1617
constructor() {
1718
this.toppings = ['bacon', 'xcheese'];
@@ -24,6 +25,7 @@ class E2EPage {
2425
{ text: 'Honey Badger', value: 'honeybadger' },
2526
{ text: 'Pig', value: 'pig' },
2627
];
28+
this.status = "checked";
2729

2830
this.authForm = new ControlGroup({
2931
name: new Control(''),

src/components/select/test/multiple-value/main.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@
5151
</ion-select>
5252
</ion-item>
5353

54+
<ion-item>
55+
<ion-label>Statuses</ion-label>
56+
<ion-select multiple [(ngModel)]="status">
57+
<ion-option value="checked" checked="true">Checked</ion-option>
58+
<ion-option value="default">Default</ion-option>
59+
<ion-option value="disabled" disabled="true">Disabled</ion-option>
60+
</ion-select>
61+
</ion-item>
62+
5463
<p aria-hidden="true" padding>
5564
<code>toppings: {{toppings}}</code><br>
5665
<code>carFeatures: {{carFeatures}}</code><br>

src/components/select/test/single-value/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class E2EPage {
1515
year: string;
1616
years: Array<number>;
1717
notification: string;
18+
status: string;
1819

1920
constructor() {
2021
this.gaming = '';
@@ -23,6 +24,7 @@ class E2EPage {
2324
this.month = '12';
2425
this.year = '1994';
2526
this.notification = 'enable';
27+
this.status = "checked";
2628

2729
this.years = [1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999];
2830

src/components/select/test/single-value/main.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@
8686
</ion-select>
8787
</ion-item>
8888

89+
<ion-item>
90+
<ion-label>Statuses</ion-label>
91+
<ion-select [(ngModel)]="status">
92+
<ion-option value="checked" checked="true">Checked</ion-option>
93+
<ion-option value="default">Default</ion-option>
94+
<ion-option value="disabled" disabled="true">Disabled</ion-option>
95+
</ion-select>
96+
</ion-item>
97+
8998
<button (click)="resetGender()">Reset Gender</button>
9099

91100
<p aria-hidden="true" padding>

0 commit comments

Comments
 (0)