diff --git a/demos/src/alert/pages/page-one/page-one.ts b/demos/src/alert/pages/page-one/page-one.ts index 4d03164731..b25f5b177c 100644 --- a/demos/src/alert/pages/page-one/page-one.ts +++ b/demos/src/alert/pages/page-one/page-one.ts @@ -58,13 +58,13 @@ export class PageOne { buttons: [ { text: 'Cancel', - handler: (data: any) => { + handler: (data) => { console.log('Cancel clicked'); } }, { text: 'Save', - handler: (data: any) => { + handler: (data) => { console.log('Saved clicked'); } } diff --git a/demos/src/searchbar/pages/page-one/page-one.ts b/demos/src/searchbar/pages/page-one/page-one.ts index b59d9042bb..be9d678779 100644 --- a/demos/src/searchbar/pages/page-one/page-one.ts +++ b/demos/src/searchbar/pages/page-one/page-one.ts @@ -16,7 +16,7 @@ export class PageOne { filterItems(ev: any) { this.setItems(); - let val = ev.target.value; + let val = ev.value; if (val && val.trim() !== '') { this.items = this.items.filter(function(item) { diff --git a/src/components/alert/alert-options.ts b/src/components/alert/alert-options.ts index 39cd2e8030..454b895ca6 100644 --- a/src/components/alert/alert-options.ts +++ b/src/components/alert/alert-options.ts @@ -28,5 +28,5 @@ export interface AlertButton { text?: string; role?: string; cssClass?: string; - handler?: Function; + handler?: (value: any) => boolean|void; }; diff --git a/src/components/checkbox/checkbox.ts b/src/components/checkbox/checkbox.ts index b71bb510ed..3cf847fd7c 100644 --- a/src/components/checkbox/checkbox.ts +++ b/src/components/checkbox/checkbox.ts @@ -1,10 +1,10 @@ -import { AfterContentInit, ChangeDetectorRef, Component, ElementRef, EventEmitter, forwardRef, HostListener, Input, OnDestroy, Optional, Output, Renderer, ViewEncapsulation } from '@angular/core'; -import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, forwardRef, HostListener, Input, OnDestroy, Optional, Renderer, ViewEncapsulation } from '@angular/core'; +import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { Config } from '../../config/config'; -import { Form, IonicTapInput } from '../../util/form'; -import { Ion } from '../ion'; import { isTrueProperty } from '../../util/util'; +import { Form, IonicTapInput } from '../../util/form'; +import { BaseInput } from '../../util/base-input'; import { Item } from '../item/item'; export const CHECKBOX_VALUE_ACCESSOR: any = { @@ -54,14 +54,14 @@ export const CHECKBOX_VALUE_ACCESSOR: any = { @Component({ selector: 'ion-checkbox', template: - '
' + + '
' + '
' + '
' + ' + + + @@ -112,7 +114,7 @@ - + Default diff --git a/src/components/segment/test/basic/pages/home-page/home-page.ts b/src/components/segment/test/basic/pages/home-page/home-page.ts index 6f6728025e..a1f102c2f3 100644 --- a/src/components/segment/test/basic/pages/home-page/home-page.ts +++ b/src/components/segment/test/basic/pages/home-page/home-page.ts @@ -11,7 +11,9 @@ export class HomePage { modelStyle: string = 'B'; appType: string = 'free'; icons: string = 'camera'; - isDisabled: boolean = true; + isDisabledB: boolean = true; + isDisabledS: boolean = false; + myForm: any; constructor(fb: FormBuilder) { @@ -20,8 +22,12 @@ export class HomePage { }); } - toggleDisabled() { - this.isDisabled = !this.isDisabled; + toggleBDisabled() { + this.isDisabledB = !this.isDisabledB; + } + + toggleSDisabled() { + this.isDisabledS = !this.isDisabledS; } onSegmentChanged(segmentButton: SegmentButton) { diff --git a/src/components/segment/test/segment.spec.ts b/src/components/segment/test/segment.spec.ts new file mode 100644 index 0000000000..ee0fbe57ae --- /dev/null +++ b/src/components/segment/test/segment.spec.ts @@ -0,0 +1,31 @@ + +import { QueryList } from '@angular/core'; +import { Segment } from '../segment'; +import { SegmentButton } from '../segment-button'; +import { mockConfig, mockElementRef, mockRenderer } from '../../../util/mock-providers'; +import { commonInputTest } from '../../../util/input-tester'; + +describe('Segment', () => { + + it('should pass common test', () => { + + const config = mockConfig(); + const elementRef = mockElementRef(); + const renderer = mockRenderer(); + const segment = new Segment(config, elementRef, renderer, null); + segment._buttons = new QueryList(); + + commonInputTest(segment, { + defaultValue: null, + corpus: [ + ['option1', 'option1'], + ['option2', 'option2'], + ['option3', 'option3'], + ['option4', 'option4'], + ['', ''], + ] + }); + + }); + +}); diff --git a/src/components/select/select.ts b/src/components/select/select.ts index 718e512551..2e88600d6c 100644 --- a/src/components/select/select.ts +++ b/src/components/select/select.ts @@ -1,13 +1,13 @@ -import { AfterContentInit, Component, ContentChildren, ElementRef, EventEmitter, forwardRef, Input, HostListener, OnDestroy, Optional, Output, Renderer, QueryList, ViewEncapsulation } from '@angular/core'; -import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { AfterViewInit, Component, ContentChildren, ElementRef, EventEmitter, forwardRef, Input, HostListener, OnDestroy, Optional, Output, Renderer, QueryList, ViewEncapsulation } from '@angular/core'; +import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { ActionSheet } from '../action-sheet/action-sheet'; import { Alert } from '../alert/alert'; import { App } from '../app/app'; import { Config } from '../../config/config'; import { Form } from '../../util/form'; -import { Ion } from '../ion'; -import { isBlank, isCheckedProperty, isTrueProperty, deepCopy } from '../../util/util'; +import { BaseInput } from '../../util/base-input'; +import { isCheckedProperty, isTrueProperty, deepCopy, deepEqual } from '../../util/util'; import { Item } from '../item/item'; import { NavController } from '../../navigation/nav-controller'; import { Option } from '../option/option'; @@ -141,21 +141,12 @@ export const SELECT_VALUE_ACCESSOR: any = { providers: [SELECT_VALUE_ACCESSOR], encapsulation: ViewEncapsulation.None, }) -export class Select extends Ion implements AfterContentInit, ControlValueAccessor, OnDestroy { - _disabled: any = false; - _labelId: string; +export class Select extends BaseInput implements AfterViewInit, OnDestroy { + _multi: boolean = false; _options: QueryList