mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 05:21:52 +08:00
feat(select): add disabled status in select options
This commit is contained in:

committed by
Adam Bradley

parent
d993a1bfd8
commit
76619cf4d0
@ -26,7 +26,7 @@ import {ViewController} from '../nav/view-controller';
|
|||||||
|
|
||||||
<template ngSwitchCase="radio">
|
<template ngSwitchCase="radio">
|
||||||
<div class="alert-radio-group" role="radiogroup" [attr.aria-labelledby]="hdrId" [attr.aria-activedescendant]="activeId">
|
<div class="alert-radio-group" role="radiogroup" [attr.aria-labelledby]="hdrId" [attr.aria-activedescendant]="activeId">
|
||||||
<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">
|
<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">
|
||||||
<div class="alert-radio-icon"><div class="alert-radio-inner"></div></div>
|
<div class="alert-radio-icon"><div class="alert-radio-inner"></div></div>
|
||||||
<div class="alert-radio-label">
|
<div class="alert-radio-label">
|
||||||
{{i.label}}
|
{{i.label}}
|
||||||
@ -37,7 +37,7 @@ import {ViewController} from '../nav/view-controller';
|
|||||||
|
|
||||||
<template ngSwitchCase="checkbox">
|
<template ngSwitchCase="checkbox">
|
||||||
<div class="alert-checkbox-group">
|
<div class="alert-checkbox-group">
|
||||||
<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">
|
<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">
|
||||||
<div class="alert-checkbox-icon"><div class="alert-checkbox-inner"></div></div>
|
<div class="alert-checkbox-icon"><div class="alert-checkbox-inner"></div></div>
|
||||||
<div class="alert-checkbox-label">
|
<div class="alert-checkbox-label">
|
||||||
{{i.label}}
|
{{i.label}}
|
||||||
@ -142,6 +142,7 @@ export class AlertCmp {
|
|||||||
value: isPresent(input.value) ? input.value : '',
|
value: isPresent(input.value) ? input.value : '',
|
||||||
label: input.label,
|
label: input.label,
|
||||||
checked: !!input.checked,
|
checked: !!input.checked,
|
||||||
|
disabled: !!input.disabled,
|
||||||
id: 'alert-input-' + this.id + '-' + index
|
id: 'alert-input-' + this.id + '-' + index
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -16,5 +16,6 @@ export interface AlertInputOptions {
|
|||||||
value?: string;
|
value?: string;
|
||||||
label?: string;
|
label?: string;
|
||||||
checked?: boolean;
|
checked?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
id?: string;
|
id?: string;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import { isPresent, isTrueProperty } from '../../util/util';
|
|||||||
})
|
})
|
||||||
export class Option {
|
export class Option {
|
||||||
private _checked: any = false;
|
private _checked: any = false;
|
||||||
|
private _disabled: any = false;
|
||||||
private _value: any;
|
private _value: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,6 +51,18 @@ export class Option {
|
|||||||
this._value = val;
|
this._value = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @input {boolean} Whether or not the option is disabled
|
||||||
|
*/
|
||||||
|
@Input()
|
||||||
|
get disabled() {
|
||||||
|
return this._disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
set disabled(val) {
|
||||||
|
this._disabled = isTrueProperty(val);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -290,7 +290,8 @@ export class Select {
|
|||||||
type: (this._multi ? 'checkbox' : 'radio'),
|
type: (this._multi ? 'checkbox' : 'radio'),
|
||||||
label: input.text,
|
label: input.text,
|
||||||
value: input.value,
|
value: input.value,
|
||||||
checked: input.checked
|
checked: input.checked,
|
||||||
|
disabled: input.disabled
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ class E2EPage {
|
|||||||
pets: Array<string>;
|
pets: Array<string>;
|
||||||
petOptions: Array<{text: string, value: string}>;
|
petOptions: Array<{text: string, value: string}>;
|
||||||
authForm: ControlGroup;
|
authForm: ControlGroup;
|
||||||
|
status: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.toppings = ['bacon', 'xcheese'];
|
this.toppings = ['bacon', 'xcheese'];
|
||||||
@ -24,6 +25,7 @@ class E2EPage {
|
|||||||
{ text: 'Honey Badger', value: 'honeybadger' },
|
{ text: 'Honey Badger', value: 'honeybadger' },
|
||||||
{ text: 'Pig', value: 'pig' },
|
{ text: 'Pig', value: 'pig' },
|
||||||
];
|
];
|
||||||
|
this.status = "checked";
|
||||||
|
|
||||||
this.authForm = new ControlGroup({
|
this.authForm = new ControlGroup({
|
||||||
name: new Control(''),
|
name: new Control(''),
|
||||||
|
@ -51,6 +51,15 @@
|
|||||||
</ion-select>
|
</ion-select>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
|
<ion-item>
|
||||||
|
<ion-label>Statuses</ion-label>
|
||||||
|
<ion-select multiple [(ngModel)]="status">
|
||||||
|
<ion-option value="checked" checked="true">Checked</ion-option>
|
||||||
|
<ion-option value="default">Default</ion-option>
|
||||||
|
<ion-option value="disabled" disabled="true">Disabled</ion-option>
|
||||||
|
</ion-select>
|
||||||
|
</ion-item>
|
||||||
|
|
||||||
<p aria-hidden="true" padding>
|
<p aria-hidden="true" padding>
|
||||||
<code>toppings: {{toppings}}</code><br>
|
<code>toppings: {{toppings}}</code><br>
|
||||||
<code>carFeatures: {{carFeatures}}</code><br>
|
<code>carFeatures: {{carFeatures}}</code><br>
|
||||||
|
@ -15,6 +15,7 @@ class E2EPage {
|
|||||||
year: string;
|
year: string;
|
||||||
years: Array<number>;
|
years: Array<number>;
|
||||||
notification: string;
|
notification: string;
|
||||||
|
status: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.gaming = '';
|
this.gaming = '';
|
||||||
@ -23,6 +24,7 @@ class E2EPage {
|
|||||||
this.month = '12';
|
this.month = '12';
|
||||||
this.year = '1994';
|
this.year = '1994';
|
||||||
this.notification = 'enable';
|
this.notification = 'enable';
|
||||||
|
this.status = "checked";
|
||||||
|
|
||||||
this.years = [1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999];
|
this.years = [1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999];
|
||||||
|
|
||||||
|
@ -86,6 +86,15 @@
|
|||||||
</ion-select>
|
</ion-select>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
|
<ion-item>
|
||||||
|
<ion-label>Statuses</ion-label>
|
||||||
|
<ion-select [(ngModel)]="status">
|
||||||
|
<ion-option value="checked" checked="true">Checked</ion-option>
|
||||||
|
<ion-option value="default">Default</ion-option>
|
||||||
|
<ion-option value="disabled" disabled="true">Disabled</ion-option>
|
||||||
|
</ion-select>
|
||||||
|
</ion-item>
|
||||||
|
|
||||||
<button (click)="resetGender()">Reset Gender</button>
|
<button (click)="resetGender()">Reset Gender</button>
|
||||||
|
|
||||||
<p aria-hidden="true" padding>
|
<p aria-hidden="true" padding>
|
||||||
|
Reference in New Issue
Block a user