fix(alert): do not use mutable prop

This commit is contained in:
Adam Bradley
2017-10-25 13:02:32 -05:00
parent 95014fd5ca
commit 8e2fdf1ee5

View File

@ -38,7 +38,7 @@ export class Alert {
@Prop() subTitle: string; @Prop() subTitle: string;
@Prop() message: string; @Prop() message: string;
@Prop() buttons: AlertButton[] = []; @Prop() buttons: AlertButton[] = [];
@Prop({ mutable: true }) inputs: AlertInput[] = []; @Prop() inputs: AlertInput[] = [];
@Prop() enableBackdropDismiss: boolean = true; @Prop() enableBackdropDismiss: boolean = true;
@Prop() enterAnimation: AnimationBuilder; @Prop() enterAnimation: AnimationBuilder;
@ -146,7 +146,6 @@ export class Alert {
rbClick(button: any) { rbClick(button: any) {
this.inputs.forEach(input => { this.inputs.forEach(input => {
input.checked = (button === input); input.checked = (button === input);
return input;
}); });
this.activeId = button.id; this.activeId = button.id;
@ -313,9 +312,9 @@ export class Alert {
// checkboxes and inputs are all accepted, but they cannot be mixed. // checkboxes and inputs are all accepted, but they cannot be mixed.
const inputTypes: string[] = []; const inputTypes: string[] = [];
this.inputs = this.inputs const inputs = this.inputs
.map((i, index) => { .map((i, index) => {
let r: AlertInput = { const r: AlertInput = {
type: i.type || 'text', type: i.type || 'text',
name: i.name ? i.name : index + '', name: i.name ? i.name : index + '',
placeholder: i.placeholder ? i.placeholder : '', placeholder: i.placeholder ? i.placeholder : '',
@ -332,7 +331,7 @@ export class Alert {
}) })
.filter(i => i !== null); .filter(i => i !== null);
this.inputs.forEach(i => { inputs.forEach(i => {
if (inputTypes.indexOf(i.type) < 0) { if (inputTypes.indexOf(i.type) < 0) {
inputTypes.push(i.type); inputTypes.push(i.type);
} }
@ -363,13 +362,13 @@ export class Alert {
{(() => { {(() => {
switch (this.inputType) { switch (this.inputType) {
case 'checkbox': case 'checkbox':
return this.renderCheckbox(this.inputs); return this.renderCheckbox(inputs);
case 'radio': case 'radio':
return this.renderRadio(this.inputs); return this.renderRadio(inputs);
default: default:
return this.renderInput(this.inputs); return this.renderInput(inputs);
} }
})()} })()}