From a77bb2c1d5b558041686866498073f163678aa54 Mon Sep 17 00:00:00 2001 From: Dan Bucholtz Date: Tue, 3 Oct 2017 12:34:07 -0500 Subject: [PATCH] fix(tabs): return promises where appropriate --- package-lock.json | 56 ++++---- src/components/app/test/app.spec.ts | 40 +++--- .../app/app.component.ts | 8 ++ .../app/app.module.ts | 17 +++ .../simple-nav-default-history/app/main.ts | 5 + .../pages/first-page/first-page.html | 10 ++ .../pages/first-page/first-page.module.ts | 13 ++ .../pages/first-page/first-page.ts | 15 +++ .../pages/second-page/second-page.html | 16 +++ .../pages/second-page/second-page.module.ts | 13 ++ .../pages/second-page/second-page.ts | 25 ++++ .../pages/third-page/third-page.html | 13 ++ .../pages/third-page/third-page.module.ts | 13 ++ .../pages/third-page/third-page.ts | 21 +++ .../app/app.component.ts | 8 ++ .../app/app.module.ts | 17 +++ .../app/main.ts | 5 + .../pages/login-page/login-page.module.ts | 13 ++ .../pages/login-page/login-page.ts | 24 ++++ .../pages/tab-one/first-page/first-page.html | 11 ++ .../tab-one/first-page/first-page.module.ts | 13 ++ .../pages/tab-one/first-page/first-page.ts | 15 +++ .../tab-one/second-page/second-page.html | 14 ++ .../tab-one/second-page/second-page.module.ts | 13 ++ .../pages/tab-one/second-page/second-page.ts | 23 ++++ .../pages/tab-one/third-page/third-page.html | 14 ++ .../tab-one/third-page/third-page.module.ts | 13 ++ .../pages/tab-one/third-page/third-page.ts | 20 +++ .../pages/tab-two/fifth-page/fifth-page.html | 15 +++ .../tab-two/fifth-page/fifth-page.module.ts | 13 ++ .../pages/tab-two/fifth-page/fifth-page.ts | 23 ++++ .../tab-two/fourth-page/fourth-page.html | 11 ++ .../tab-two/fourth-page/fourth-page.module.ts | 13 ++ .../pages/tab-two/fourth-page/fourth-page.ts | 15 +++ .../pages/tab-two/sixth-page/sixth-page.html | 14 ++ .../tab-two/sixth-page/sixth-page.module.ts | 13 ++ .../pages/tab-two/sixth-page/sixth-page.ts | 20 +++ .../pages/tabs/tabs-page.module.ts | 13 ++ .../pages/tabs/tabs-page.ts | 16 +++ .../app/app.component.ts | 14 ++ .../app/app.module.ts | 17 +++ .../simple-tabs-default-history/app/main.ts | 5 + .../pages/tab-one/first-page/first-page.html | 11 ++ .../tab-one/first-page/first-page.module.ts | 13 ++ .../pages/tab-one/first-page/first-page.ts | 15 +++ .../tab-one/second-page/second-page.html | 17 +++ .../tab-one/second-page/second-page.module.ts | 13 ++ .../pages/tab-one/second-page/second-page.ts | 28 ++++ .../pages/tab-one/third-page/third-page.html | 14 ++ .../tab-one/third-page/third-page.module.ts | 13 ++ .../pages/tab-one/third-page/third-page.ts | 24 ++++ .../pages/tab-two/fifth-page/fifth-page.html | 17 +++ .../tab-two/fifth-page/fifth-page.module.ts | 13 ++ .../pages/tab-two/fifth-page/fifth-page.ts | 26 ++++ .../tab-two/fourth-page/fourth-page.html | 10 ++ .../tab-two/fourth-page/fourth-page.module.ts | 13 ++ .../pages/tab-two/fourth-page/fourth-page.ts | 17 +++ .../pages/tab-two/sixth-page/sixth-page.html | 14 ++ .../tab-two/sixth-page/sixth-page.module.ts | 13 ++ .../pages/tab-two/sixth-page/sixth-page.ts | 22 +++ src/components/tabs/tab.ts | 46 +++---- src/components/tabs/tabs.ts | 50 +++---- src/components/tabs/test/tab.spec.ts | 99 ++++++++------ src/components/tabs/test/tabs.spec.ts | 127 +++++++++++------- src/navigation/deep-linker.ts | 3 +- src/navigation/nav-interfaces.ts | 5 +- src/navigation/test/deep-linker.spec.ts | 3 +- src/navigation/url-serializer.ts | 2 +- src/util/mock-providers.ts | 5 +- 69 files changed, 1109 insertions(+), 194 deletions(-) create mode 100644 src/components/nav/test/simple-nav-default-history/app/app.component.ts create mode 100644 src/components/nav/test/simple-nav-default-history/app/app.module.ts create mode 100644 src/components/nav/test/simple-nav-default-history/app/main.ts create mode 100644 src/components/nav/test/simple-nav-default-history/pages/first-page/first-page.html create mode 100644 src/components/nav/test/simple-nav-default-history/pages/first-page/first-page.module.ts create mode 100644 src/components/nav/test/simple-nav-default-history/pages/first-page/first-page.ts create mode 100644 src/components/nav/test/simple-nav-default-history/pages/second-page/second-page.html create mode 100644 src/components/nav/test/simple-nav-default-history/pages/second-page/second-page.module.ts create mode 100644 src/components/nav/test/simple-nav-default-history/pages/second-page/second-page.ts create mode 100644 src/components/nav/test/simple-nav-default-history/pages/third-page/third-page.html create mode 100644 src/components/nav/test/simple-nav-default-history/pages/third-page/third-page.module.ts create mode 100644 src/components/nav/test/simple-nav-default-history/pages/third-page/third-page.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/app/app.component.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/app/app.module.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/app/main.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/login-page/login-page.module.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/login-page/login-page.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/first-page/first-page.html create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/first-page/first-page.module.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/first-page/first-page.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/second-page/second-page.html create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/second-page/second-page.module.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/second-page/second-page.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/third-page/third-page.html create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/third-page/third-page.module.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/third-page/third-page.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fifth-page/fifth-page.html create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fifth-page/fifth-page.module.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fifth-page/fifth-page.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fourth-page/fourth-page.html create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fourth-page/fourth-page.module.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fourth-page/fourth-page.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/sixth-page/sixth-page.html create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/sixth-page/sixth-page.module.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/sixth-page/sixth-page.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tabs/tabs-page.module.ts create mode 100644 src/components/nav/test/simple-nav-then-tabs-default-history/pages/tabs/tabs-page.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/app/app.component.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/app/app.module.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/app/main.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-one/first-page/first-page.html create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-one/first-page/first-page.module.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-one/first-page/first-page.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-one/second-page/second-page.html create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-one/second-page/second-page.module.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-one/second-page/second-page.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-one/third-page/third-page.html create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-one/third-page/third-page.module.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-one/third-page/third-page.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-two/fifth-page/fifth-page.html create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-two/fifth-page/fifth-page.module.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-two/fifth-page/fifth-page.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-two/fourth-page/fourth-page.html create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-two/fourth-page/fourth-page.module.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-two/fourth-page/fourth-page.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-two/sixth-page/sixth-page.html create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-two/sixth-page/sixth-page.module.ts create mode 100644 src/components/nav/test/simple-tabs-default-history/pages/tab-two/sixth-page/sixth-page.ts diff --git a/package-lock.json b/package-lock.json index 634d11d8c2c..75cf16a54cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -368,6 +368,16 @@ "@types/node": "6.0.88" } }, + "JSONStream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", + "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -2732,8 +2742,8 @@ "integrity": "sha512-8od6g684Fhi5Vpp4ABRv/RBsW1AY6wSHbJHEK6FGTv+8jvAAnlABniZu/FVmX9TcirkHepaEsa1QGkRvbg0CKw==", "dev": true, "requires": { - "is-text-path": "1.0.1", "JSONStream": "1.3.1", + "is-text-path": "1.0.1", "lodash": "4.17.4", "meow": "3.7.0", "split2": "2.2.0", @@ -5320,14 +5330,6 @@ } } }, - "string_decoder": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, "string-width": { "version": "1.0.2", "bundled": true, @@ -5338,6 +5340,14 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, "stringstream": { "version": "0.0.5", "bundled": true, @@ -8491,16 +8501,6 @@ "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true }, - "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -13210,15 +13210,6 @@ "integrity": "sha1-76/unx4i01ke1949yqlcP1559zw=", "dev": true }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-range": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/string-range/-/string-range-1.2.2.tgz", @@ -13242,6 +13233,15 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringmap": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/stringmap/-/stringmap-0.2.2.tgz", diff --git a/src/components/app/test/app.spec.ts b/src/components/app/test/app.spec.ts index c84afbc404f..2f833578de9 100644 --- a/src/components/app/test/app.spec.ts +++ b/src/components/app/test/app.spec.ts @@ -10,7 +10,7 @@ describe('App', () => { describe('goBack', () => { - it('should not select the previous tab', () => { + it('should not select the previous tab', (done: Function) => { const nav = mockNavController(); app.registerRootNav(nav); @@ -23,24 +23,26 @@ describe('App', () => { nav.registerChildNav(tabs); - tabs.select(tab1); - tabs.select(tab2); - - expect(tabs._selectHistory).toEqual([tab1.id, tab2.id]); - - spyOn(plt, 'exitApp'); - spyOn(tabs, 'select'); - spyOn(tab1, 'pop'); - spyOn(tab2, 'pop'); - spyOn(portal, 'pop'); - - app.goBack(); - - expect(tabs.select).not.toHaveBeenCalled(); - expect(tab1.pop).not.toHaveBeenCalled(); - expect(tab2.pop).not.toHaveBeenCalled(); - expect(portal.pop).not.toHaveBeenCalled(); - expect(plt.exitApp).toHaveBeenCalled(); + tabs.select(tab1).then(() => { + return tabs.select(tab2); + }).then(() => { + expect(tabs._selectHistory).toEqual([tab1.id, tab2.id]); + spyOn(plt, 'exitApp'); + spyOn(tabs, 'select'); + spyOn(tab1, 'pop'); + spyOn(tab2, 'pop'); + spyOn(portal, 'pop'); + return app.goBack(); + }).then(() => { + expect(tabs.select).not.toHaveBeenCalled(); + expect(tab1.pop).not.toHaveBeenCalled(); + expect(tab2.pop).not.toHaveBeenCalled(); + expect(portal.pop).not.toHaveBeenCalled(); + expect(plt.exitApp).toHaveBeenCalled(); + done(); + }).catch((err: Error) => { + done(err); + }); }); it('should pop from the active tab, when tabs is nested is the root nav', () => { diff --git a/src/components/nav/test/simple-nav-default-history/app/app.component.ts b/src/components/nav/test/simple-nav-default-history/app/app.component.ts new file mode 100644 index 00000000000..10cf363ea4c --- /dev/null +++ b/src/components/nav/test/simple-nav-default-history/app/app.component.ts @@ -0,0 +1,8 @@ +import { Component } from '@angular/core'; + +@Component({ + template: `` +}) +export class AppComponent { + root = 'FirstPage'; +} diff --git a/src/components/nav/test/simple-nav-default-history/app/app.module.ts b/src/components/nav/test/simple-nav-default-history/app/app.module.ts new file mode 100644 index 00000000000..55310fa2157 --- /dev/null +++ b/src/components/nav/test/simple-nav-default-history/app/app.module.ts @@ -0,0 +1,17 @@ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { IonicApp, IonicModule } from '../../../../..'; + +import { AppComponent } from './app.component'; + +@NgModule({ + declarations: [ + AppComponent + ], + imports: [ + BrowserModule, + IonicModule.forRoot(AppComponent, { swipeBackEnabled: true, preloadModules: true }), + ], + bootstrap: [IonicApp] +}) +export class AppModule {} diff --git a/src/components/nav/test/simple-nav-default-history/app/main.ts b/src/components/nav/test/simple-nav-default-history/app/main.ts new file mode 100644 index 00000000000..6af7a5b2ae8 --- /dev/null +++ b/src/components/nav/test/simple-nav-default-history/app/main.ts @@ -0,0 +1,5 @@ +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { AppModule } from './app.module'; + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/src/components/nav/test/simple-nav-default-history/pages/first-page/first-page.html b/src/components/nav/test/simple-nav-default-history/pages/first-page/first-page.html new file mode 100644 index 00000000000..0f6c090ee8b --- /dev/null +++ b/src/components/nav/test/simple-nav-default-history/pages/first-page/first-page.html @@ -0,0 +1,10 @@ + + + First Page + + + + Page One + + Using href + \ No newline at end of file diff --git a/src/components/nav/test/simple-nav-default-history/pages/first-page/first-page.module.ts b/src/components/nav/test/simple-nav-default-history/pages/first-page/first-page.module.ts new file mode 100644 index 00000000000..c088e9f2d4c --- /dev/null +++ b/src/components/nav/test/simple-nav-default-history/pages/first-page/first-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../..'; +import { FirstPage } from './first-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(FirstPage) + ], + declarations: [ + FirstPage + ] +}) +export class FirstPageModule { } diff --git a/src/components/nav/test/simple-nav-default-history/pages/first-page/first-page.ts b/src/components/nav/test/simple-nav-default-history/pages/first-page/first-page.ts new file mode 100644 index 00000000000..da3376f1929 --- /dev/null +++ b/src/components/nav/test/simple-nav-default-history/pages/first-page/first-page.ts @@ -0,0 +1,15 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, } from '../../../../../..'; + +@IonicPage() +@Component({ + templateUrl: 'first-page.html' +}) +export class FirstPage { + constructor(public nav: NavController) { + } + + goToPageTwo() { + this.nav.push('SecondPage', { userId: '123', name: 'ted'}); + } +} diff --git a/src/components/nav/test/simple-nav-default-history/pages/second-page/second-page.html b/src/components/nav/test/simple-nav-default-history/pages/second-page/second-page.html new file mode 100644 index 00000000000..acf24b32710 --- /dev/null +++ b/src/components/nav/test/simple-nav-default-history/pages/second-page/second-page.html @@ -0,0 +1,16 @@ + + + Second Page + + + +
+ User ID: {{userId}} +
+
+ Name {{name}} +
+
+ +
+
\ No newline at end of file diff --git a/src/components/nav/test/simple-nav-default-history/pages/second-page/second-page.module.ts b/src/components/nav/test/simple-nav-default-history/pages/second-page/second-page.module.ts new file mode 100644 index 00000000000..08053b890ac --- /dev/null +++ b/src/components/nav/test/simple-nav-default-history/pages/second-page/second-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../..'; +import { SecondPage } from './second-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(SecondPage) + ], + declarations: [ + SecondPage + ] +}) +export class SecondPageModule { } diff --git a/src/components/nav/test/simple-nav-default-history/pages/second-page/second-page.ts b/src/components/nav/test/simple-nav-default-history/pages/second-page/second-page.ts new file mode 100644 index 00000000000..b9de77cf363 --- /dev/null +++ b/src/components/nav/test/simple-nav-default-history/pages/second-page/second-page.ts @@ -0,0 +1,25 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from '../../../../../..'; + +@IonicPage({ + segment: 'user/:userId/name/:name', + defaultHistory: [ + 'FirstPage' + ] +}) +@Component({ + templateUrl: 'second-page.html' +}) +export class SecondPage { + + userId: string; + name: string; + constructor(public nav: NavController, public params: NavParams) { + this.userId = this.params.data.userId; + this.name = this.params.data.name; + } + + goToNextPage() { + this.nav.push('ThirdPage', { paramOne: 'Hello', paramTwo: 'Its me'}); + } +} diff --git a/src/components/nav/test/simple-nav-default-history/pages/third-page/third-page.html b/src/components/nav/test/simple-nav-default-history/pages/third-page/third-page.html new file mode 100644 index 00000000000..1a7d5eccc25 --- /dev/null +++ b/src/components/nav/test/simple-nav-default-history/pages/third-page/third-page.html @@ -0,0 +1,13 @@ + + + Third Page + + + +
+ Param One: {{paramOne}} +
+
+ Param Two: {{paramTwo}} +
+
\ No newline at end of file diff --git a/src/components/nav/test/simple-nav-default-history/pages/third-page/third-page.module.ts b/src/components/nav/test/simple-nav-default-history/pages/third-page/third-page.module.ts new file mode 100644 index 00000000000..3ae80405cc0 --- /dev/null +++ b/src/components/nav/test/simple-nav-default-history/pages/third-page/third-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../..'; +import { ThirdPage } from './third-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(ThirdPage) + ], + declarations: [ + ThirdPage + ] +}) +export class ThirdPageModule { } diff --git a/src/components/nav/test/simple-nav-default-history/pages/third-page/third-page.ts b/src/components/nav/test/simple-nav-default-history/pages/third-page/third-page.ts new file mode 100644 index 00000000000..49a8dbb5f72 --- /dev/null +++ b/src/components/nav/test/simple-nav-default-history/pages/third-page/third-page.ts @@ -0,0 +1,21 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from '../../../../../..'; + +@IonicPage({ + segment: 'paramOne/:paramOne/paramTwo/:paramTwo', + defaultHistory: [ + 'FirstPage' + ] +}) +@Component({ + templateUrl: 'third-page.html' +}) +export class ThirdPage { + + paramOne: string; + paramTwo: string; + constructor(public nav: NavController, public params: NavParams) { + this.paramOne = this.params.data.paramOne; + this.paramTwo = this.params.data.paramTwo; + } +} diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/app/app.component.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/app/app.component.ts new file mode 100644 index 00000000000..3337574380a --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/app/app.component.ts @@ -0,0 +1,8 @@ +import { Component } from '@angular/core'; + +@Component({ + template: `` +}) +export class AppComponent { + root = 'LoginPage'; +} diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/app/app.module.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/app/app.module.ts new file mode 100644 index 00000000000..55310fa2157 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/app/app.module.ts @@ -0,0 +1,17 @@ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { IonicApp, IonicModule } from '../../../../..'; + +import { AppComponent } from './app.component'; + +@NgModule({ + declarations: [ + AppComponent + ], + imports: [ + BrowserModule, + IonicModule.forRoot(AppComponent, { swipeBackEnabled: true, preloadModules: true }), + ], + bootstrap: [IonicApp] +}) +export class AppModule {} diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/app/main.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/app/main.ts new file mode 100644 index 00000000000..6af7a5b2ae8 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/app/main.ts @@ -0,0 +1,5 @@ +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { AppModule } from './app.module'; + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/login-page/login-page.module.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/login-page/login-page.module.ts new file mode 100644 index 00000000000..e3cbf3d9160 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/login-page/login-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../..'; +import { LoginPage } from './login-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(LoginPage) + ], + declarations: [ + LoginPage + ] +}) +export class LoginPageModule { } diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/login-page/login-page.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/login-page/login-page.ts new file mode 100644 index 00000000000..81f07a055c1 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/login-page/login-page.ts @@ -0,0 +1,24 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, } from '../../../../../..'; + +@IonicPage() +@Component({ + template: ` + + + Login + + + + + + ` +}) +export class LoginPage { + constructor(public nav: NavController) { + } + + clickMe() { + this.nav.push('TabsPage'); + } +} diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/first-page/first-page.html b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/first-page/first-page.html new file mode 100644 index 00000000000..e765b809169 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/first-page/first-page.html @@ -0,0 +1,11 @@ + + + First Page + + + + First Page +
+ +
+
\ No newline at end of file diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/first-page/first-page.module.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/first-page/first-page.module.ts new file mode 100644 index 00000000000..c17e0dde59e --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/first-page/first-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../..'; +import { FirstPage } from './first-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(FirstPage) + ], + declarations: [ + FirstPage + ] +}) +export class FirstPageModule { } diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/first-page/first-page.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/first-page/first-page.ts new file mode 100644 index 00000000000..79628e92b20 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/first-page/first-page.ts @@ -0,0 +1,15 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, } from '../../../../../../..'; + +@IonicPage() +@Component({ + templateUrl: 'first-page.html' +}) +export class FirstPage { + constructor(public nav: NavController) { + } + + clickMe() { + this.nav.push('SecondPage', { userId: '123', name: 'Phyllis Vance, Vance Refridgeration'}); + } +} diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/second-page/second-page.html b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/second-page/second-page.html new file mode 100644 index 00000000000..add45e1e846 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/second-page/second-page.html @@ -0,0 +1,14 @@ + + + Second Page + + + +
+ User ID: {{userId}} +
+
+ Name {{name}} +
+ +
\ No newline at end of file diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/second-page/second-page.module.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/second-page/second-page.module.ts new file mode 100644 index 00000000000..ce824037f89 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/second-page/second-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../..'; +import { SecondPage } from './second-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(SecondPage) + ], + declarations: [ + SecondPage + ] +}) +export class SecondPageModule { } diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/second-page/second-page.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/second-page/second-page.ts new file mode 100644 index 00000000000..4e74d06a2c0 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/second-page/second-page.ts @@ -0,0 +1,23 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from '../../../../../../..'; + +@IonicPage({ + segment: 'secondPage/user/:userId/name/:name', + defaultHistory: ['FirstPage'] +}) +@Component({ + templateUrl: 'second-page.html' +}) +export class SecondPage { + + userId: string; + name: string; + constructor(public nav: NavController, public params: NavParams) { + this.userId = this.params.data.userId; + this.name = this.params.data.name; + } + + goToNextPage() { + this.nav.push('ThirdPage', { paramOne: 'Tobey', paramTwo: 'Kevin'}); + } +} diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/third-page/third-page.html b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/third-page/third-page.html new file mode 100644 index 00000000000..314a287d2f2 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/third-page/third-page.html @@ -0,0 +1,14 @@ + + + Third Page + + + +

Third Page

+
+ Param One: {{paramOne}} +
+
+ Param Two: {{paramTwo}} +
+
\ No newline at end of file diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/third-page/third-page.module.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/third-page/third-page.module.ts new file mode 100644 index 00000000000..fab76aa598a --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/third-page/third-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../..'; +import { ThirdPage } from './third-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(ThirdPage) + ], + declarations: [ + ThirdPage + ] +}) +export class ThirdPageModule { } diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/third-page/third-page.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/third-page/third-page.ts new file mode 100644 index 00000000000..2b1323b4f2f --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-one/third-page/third-page.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from '../../../../../../..'; + +@IonicPage({ + segment: 'thirdPage/paramOne/:paramOne/paramTwo/:paramTwo', + defaultHistory: ['FirstPage'] +}) +@Component({ + templateUrl: 'third-page.html' +}) +export class ThirdPage { + + paramOne: string; + paramTwo: string; + + constructor(public nav: NavController, public params: NavParams) { + this.paramOne = this.params.data.paramOne; + this.paramTwo = this.params.data.paramTwo; + } +} diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fifth-page/fifth-page.html b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fifth-page/fifth-page.html new file mode 100644 index 00000000000..5c551e0ba42 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fifth-page/fifth-page.html @@ -0,0 +1,15 @@ + + + Fifth Page + + + + Fifth Page +
+ User ID: {{userId}} +
+
+ Name {{name}} +
+ +
\ No newline at end of file diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fifth-page/fifth-page.module.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fifth-page/fifth-page.module.ts new file mode 100644 index 00000000000..1499d707cf1 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fifth-page/fifth-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../..'; +import { FifthPage } from './fifth-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(FifthPage) + ], + declarations: [ + FifthPage + ] +}) +export class FifthPageModule { } diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fifth-page/fifth-page.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fifth-page/fifth-page.ts new file mode 100644 index 00000000000..14e5a14c243 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fifth-page/fifth-page.ts @@ -0,0 +1,23 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from '../../../../../../..'; + +@IonicPage({ + segment: 'fifthPage/user/:userId/name/:name', + defaultHistory: ['FourthPage'] +}) +@Component({ + templateUrl: 'fifth-page.html' +}) +export class FifthPage { + + userId: string; + name: string; + constructor(public nav: NavController, public params: NavParams) { + this.userId = this.params.data.userId; + this.name = this.params.data.name; + } + + goToNextPage() { + this.nav.push('SixthPage', { paramOne: 'Kelly Kapore', paramTwo: 'Creed Bratton'}); + } +} diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fourth-page/fourth-page.html b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fourth-page/fourth-page.html new file mode 100644 index 00000000000..52ac013fb70 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fourth-page/fourth-page.html @@ -0,0 +1,11 @@ + + + Fourth Page + + + + Fourth Page +
+ +
+
\ No newline at end of file diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fourth-page/fourth-page.module.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fourth-page/fourth-page.module.ts new file mode 100644 index 00000000000..d041e3bcc8b --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fourth-page/fourth-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../..'; +import { FourthPage } from './fourth-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(FourthPage) + ], + declarations: [ + FourthPage + ] +}) +export class FourthPageModule { } diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fourth-page/fourth-page.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fourth-page/fourth-page.ts new file mode 100644 index 00000000000..2dc366e03f7 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/fourth-page/fourth-page.ts @@ -0,0 +1,15 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, } from '../../../../../../..'; + +@IonicPage() +@Component({ + templateUrl: 'fourth-page.html' +}) +export class FourthPage { + constructor(public nav: NavController) { + } + + clickMe() { + this.nav.push('FifthPage', { userId: '456', name: 'Ryan Howard'}); + } +} diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/sixth-page/sixth-page.html b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/sixth-page/sixth-page.html new file mode 100644 index 00000000000..01e2773f33b --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/sixth-page/sixth-page.html @@ -0,0 +1,14 @@ + + + Sixth Page + + + +

Sixth Page

+
+ Param One: {{paramOne}} +
+
+ Param Two: {{paramTwo}} +
+
\ No newline at end of file diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/sixth-page/sixth-page.module.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/sixth-page/sixth-page.module.ts new file mode 100644 index 00000000000..212bd5c889e --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/sixth-page/sixth-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../..'; +import { SixthPage } from './sixth-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(SixthPage) + ], + declarations: [ + SixthPage + ] +}) +export class SixthPageModule { } diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/sixth-page/sixth-page.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/sixth-page/sixth-page.ts new file mode 100644 index 00000000000..ea82a710924 --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tab-two/sixth-page/sixth-page.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from '../../../../../../..'; + +@IonicPage({ + segment: 'sixthPage/paramOne/:paramOne/paramTwo/:paramTwo', + defaultHistory: ['FourthPage'] +}) +@Component({ + templateUrl: 'sixth-page.html' +}) +export class SixthPage { + + paramOne: string; + paramTwo: string; + + constructor(public nav: NavController, public params: NavParams) { + this.paramOne = this.params.data.paramOne; + this.paramTwo = this.params.data.paramTwo; + } +} diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tabs/tabs-page.module.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tabs/tabs-page.module.ts new file mode 100644 index 00000000000..83778955e4b --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tabs/tabs-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../..'; +import { TabsPage } from './tabs-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(TabsPage) + ], + declarations: [ + TabsPage + ] +}) +export class TabsPageModule { } diff --git a/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tabs/tabs-page.ts b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tabs/tabs-page.ts new file mode 100644 index 00000000000..70cca4a5f9a --- /dev/null +++ b/src/components/nav/test/simple-nav-then-tabs-default-history/pages/tabs/tabs-page.ts @@ -0,0 +1,16 @@ +import { Component } from '@angular/core'; +import { IonicPage, } from '../../../../../..'; + +@IonicPage() +@Component({ + template: ` + + + + + ` +}) +export class TabsPage { + tab1 = 'FirstPage'; + tab2 = 'FourthPage'; +} diff --git a/src/components/nav/test/simple-tabs-default-history/app/app.component.ts b/src/components/nav/test/simple-tabs-default-history/app/app.component.ts new file mode 100644 index 00000000000..fc1fdb14daf --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/app/app.component.ts @@ -0,0 +1,14 @@ +import { Component } from '@angular/core'; + +@Component({ + template: ` + + + + + ` +}) +export class AppComponent { + tab1 = 'FirstPage'; + tab2 = 'FourthPage'; +} diff --git a/src/components/nav/test/simple-tabs-default-history/app/app.module.ts b/src/components/nav/test/simple-tabs-default-history/app/app.module.ts new file mode 100644 index 00000000000..55310fa2157 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/app/app.module.ts @@ -0,0 +1,17 @@ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { IonicApp, IonicModule } from '../../../../..'; + +import { AppComponent } from './app.component'; + +@NgModule({ + declarations: [ + AppComponent + ], + imports: [ + BrowserModule, + IonicModule.forRoot(AppComponent, { swipeBackEnabled: true, preloadModules: true }), + ], + bootstrap: [IonicApp] +}) +export class AppModule {} diff --git a/src/components/nav/test/simple-tabs-default-history/app/main.ts b/src/components/nav/test/simple-tabs-default-history/app/main.ts new file mode 100644 index 00000000000..6af7a5b2ae8 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/app/main.ts @@ -0,0 +1,5 @@ +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { AppModule } from './app.module'; + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-one/first-page/first-page.html b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/first-page/first-page.html new file mode 100644 index 00000000000..1f117924968 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/first-page/first-page.html @@ -0,0 +1,11 @@ + + + Page One + + + + Page One +
+ +
+
\ No newline at end of file diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-one/first-page/first-page.module.ts b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/first-page/first-page.module.ts new file mode 100644 index 00000000000..c17e0dde59e --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/first-page/first-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../..'; +import { FirstPage } from './first-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(FirstPage) + ], + declarations: [ + FirstPage + ] +}) +export class FirstPageModule { } diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-one/first-page/first-page.ts b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/first-page/first-page.ts new file mode 100644 index 00000000000..34103f22d1e --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/first-page/first-page.ts @@ -0,0 +1,15 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, } from '../../../../../../..'; + +@IonicPage() +@Component({ + templateUrl: 'first-page.html' +}) +export class FirstPage { + constructor(public nav: NavController) { + } + + clickMe() { + this.nav.push('SecondPage', { userId: '123', name: 'Hans Gruber'}); + } +} diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-one/second-page/second-page.html b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/second-page/second-page.html new file mode 100644 index 00000000000..3b283bfc953 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/second-page/second-page.html @@ -0,0 +1,17 @@ + + + Page Two + + + + Page Two +
+ UserID: {{userId}} +
+
+ Name: {{name}} +
+
+ +
+
\ No newline at end of file diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-one/second-page/second-page.module.ts b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/second-page/second-page.module.ts new file mode 100644 index 00000000000..ce824037f89 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/second-page/second-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../..'; +import { SecondPage } from './second-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(SecondPage) + ], + declarations: [ + SecondPage + ] +}) +export class SecondPageModule { } diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-one/second-page/second-page.ts b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/second-page/second-page.ts new file mode 100644 index 00000000000..4d7fa80669b --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/second-page/second-page.ts @@ -0,0 +1,28 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from '../../../../../../..'; + +@IonicPage({ + segment: 'pageTwo/userId/:userId/name/:name', + defaultHistory: [ + 'FirstPage' + ] +}) +@Component({ + templateUrl: 'second-page.html' +}) +export class SecondPage { + + userId: string; + name: string; + constructor(public nav: NavController, public params: NavParams) { + } + + ionViewWillEnter() { + this.userId = this.params.data.userId; + this.name = this.params.data.name; + } + + goToNextPage() { + this.nav.push('ThirdPage', { paramOne: 'one one one', paramTwo: 'two two two'}); + } +} diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-one/third-page/third-page.html b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/third-page/third-page.html new file mode 100644 index 00000000000..dabe9013a53 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/third-page/third-page.html @@ -0,0 +1,14 @@ + + + Page Three + + + + Page three +
+ Param One {{paramOne}} +
+
+ Param Two {{paramTwo}} +
+
\ No newline at end of file diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-one/third-page/third-page.module.ts b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/third-page/third-page.module.ts new file mode 100644 index 00000000000..fab76aa598a --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/third-page/third-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../..'; +import { ThirdPage } from './third-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(ThirdPage) + ], + declarations: [ + ThirdPage + ] +}) +export class ThirdPageModule { } diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-one/third-page/third-page.ts b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/third-page/third-page.ts new file mode 100644 index 00000000000..9c259b50041 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-one/third-page/third-page.ts @@ -0,0 +1,24 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from '../../../../../../..'; + +@IonicPage({ + segment: 'pageThree/paramOne/:paramOne/paramTwo/:paramTwo', + defaultHistory: [ + 'FirstPage' + ] +}) +@Component({ + templateUrl: 'third-page.html' +}) +export class ThirdPage { + + paramOne: string; + paramTwo: string; + constructor(public nav: NavController, public params: NavParams) { + } + + ionViewWillEnter() { + this.paramOne = this.params.data.paramOne; + this.paramTwo = this.params.data.paramTwo; + } +} diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fifth-page/fifth-page.html b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fifth-page/fifth-page.html new file mode 100644 index 00000000000..210ea4369b5 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fifth-page/fifth-page.html @@ -0,0 +1,17 @@ + + + Page Five + + + + Page Five +
+ UserID: {{userId}} +
+
+ Name: {{name}} +
+
+ +
+
\ No newline at end of file diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fifth-page/fifth-page.module.ts b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fifth-page/fifth-page.module.ts new file mode 100644 index 00000000000..1499d707cf1 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fifth-page/fifth-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../..'; +import { FifthPage } from './fifth-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(FifthPage) + ], + declarations: [ + FifthPage + ] +}) +export class FifthPageModule { } diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fifth-page/fifth-page.ts b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fifth-page/fifth-page.ts new file mode 100644 index 00000000000..2f5cc600e69 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fifth-page/fifth-page.ts @@ -0,0 +1,26 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from '../../../../../../..'; + +@IonicPage({ + segment: 'pageFive/userId/:userId/name/:name', + defaultHistory: ['FourthPage'] +}) +@Component({ + templateUrl: 'fifth-page.html' +}) +export class FifthPage { + + userId: string; + name: string; + constructor(public nav: NavController, public params: NavParams) { + } + + ionViewWillEnter() { + this.userId = this.params.data.userId; + this.name = this.params.data.name; + } + + goToNextPage() { + this.nav.push('SixthPage', { paramOne: 'taco taco taco', paramTwo: 'yum yum yum'}); + } +} diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fourth-page/fourth-page.html b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fourth-page/fourth-page.html new file mode 100644 index 00000000000..22b994132b6 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fourth-page/fourth-page.html @@ -0,0 +1,10 @@ + + + Page Four + + + + Page Four + + + \ No newline at end of file diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fourth-page/fourth-page.module.ts b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fourth-page/fourth-page.module.ts new file mode 100644 index 00000000000..d041e3bcc8b --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fourth-page/fourth-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../..'; +import { FourthPage } from './fourth-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(FourthPage) + ], + declarations: [ + FourthPage + ] +}) +export class FourthPageModule { } diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fourth-page/fourth-page.ts b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fourth-page/fourth-page.ts new file mode 100644 index 00000000000..2efc7c0973d --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/fourth-page/fourth-page.ts @@ -0,0 +1,17 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from '../../../../../../..'; + +@IonicPage({ +}) +@Component({ + templateUrl: 'fourth-page.html' +}) +export class FourthPage { + + constructor(public nav: NavController, public params: NavParams) { + } + + goToNextPage() { + this.nav.push('FifthPage', { userId: '456', name: 'Stanley Hudson'}); + } +} diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-two/sixth-page/sixth-page.html b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/sixth-page/sixth-page.html new file mode 100644 index 00000000000..a150a262df0 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/sixth-page/sixth-page.html @@ -0,0 +1,14 @@ + + + Page Six + + + + Page Six +
+ Param One {{paramOne}} +
+
+ Param Two {{paramTwo}} +
+
\ No newline at end of file diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-two/sixth-page/sixth-page.module.ts b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/sixth-page/sixth-page.module.ts new file mode 100644 index 00000000000..212bd5c889e --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/sixth-page/sixth-page.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from '../../../../../../..'; +import { SixthPage } from './sixth-page'; + +@NgModule({ + imports: [ + IonicPageModule.forChild(SixthPage) + ], + declarations: [ + SixthPage + ] +}) +export class SixthPageModule { } diff --git a/src/components/nav/test/simple-tabs-default-history/pages/tab-two/sixth-page/sixth-page.ts b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/sixth-page/sixth-page.ts new file mode 100644 index 00000000000..1f6d78d1250 --- /dev/null +++ b/src/components/nav/test/simple-tabs-default-history/pages/tab-two/sixth-page/sixth-page.ts @@ -0,0 +1,22 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from '../../../../../../..'; + +@IonicPage({ + segment: 'pageSix/paramOne/:paramOne/paramTwo/:paramTwo', + defaultHistory: ['FourthPage'] +}) +@Component({ + templateUrl: 'sixth-page.html' +}) +export class SixthPage { + + paramOne: string; + paramTwo: string; + constructor(public nav: NavController, public params: NavParams) { + } + + ionViewWillEnter() { + this.paramOne = this.params.data.paramOne; + this.paramTwo = this.params.data.paramTwo; + } +} diff --git a/src/components/tabs/tab.ts b/src/components/tabs/tab.ts index ef5a18516c2..8d955f087c3 100644 --- a/src/components/tabs/tab.ts +++ b/src/components/tabs/tab.ts @@ -8,7 +8,7 @@ import { GestureController } from '../../gestures/gesture-controller'; import { isTrueProperty } from '../../util/util'; import { Tab as ITab } from '../../navigation/nav-interfaces'; import { NavControllerBase } from '../../navigation/nav-controller-base'; -import { NavOptions, TransitionDoneFn } from '../../navigation/nav-util'; +import { NavOptions, NavSegment } from '../../navigation/nav-util'; import { Platform } from '../../platform/platform'; import { TabButton } from './tab-button'; import { Tabs } from './tabs'; @@ -173,15 +173,11 @@ export class Tab extends NavControllerBase implements ITab { */ _tabsHideOnSubPages: boolean; - /** - * @hidden - */ - _lazyRootFromUrl: any; /** * @hidden */ - _lazyRootFromUrlData: any; + _segment: NavSegment; /** * @input {Page} Set the root page for this tab. @@ -304,12 +300,13 @@ export class Tab extends NavControllerBase implements ITab { /** * @hidden */ - load(opts: NavOptions, done?: TransitionDoneFn) { - if (this._lazyRootFromUrl || (!this._loaded && this.root)) { + load(opts: NavOptions): Promise { + const segment = this._segment; + if (segment || (!this._loaded && this.root)) { this.setElementClass('show-tab', true); // okay, first thing we need to do if check if the view already exists - const nameToUse = this._lazyRootFromUrl ? this._lazyRootFromUrl : this.root; - const dataToUse = this._lazyRootFromUrlData ? this._lazyRootFromUrlData : this.rootParams; + const nameToUse = segment && segment.name ? segment.name : this.root; + const dataToUse = segment ? segment.data : this.rootParams; const numViews = this.length() - 1; for (let i = numViews; i >= 0; i--) { const viewController = this.getByIndex(i); @@ -317,27 +314,31 @@ export class Tab extends NavControllerBase implements ITab { if (i === numViews) { // this is the last view in the stack and it's the same // as the segment so there's no change needed - if (done) { - done(false, false); - } - return; + return Promise.resolve(); } else { // it's not the exact view as the end // let's have this nav go back to this exact view return this.popTo(viewController, { animate: false, updateUrl: false, - }, done); + }); } } } - this.push(nameToUse, dataToUse, opts, done); - + let promise: Promise = null; + if (segment && segment.defaultHistory && segment.defaultHistory.length && this._views.length === 0) { + promise = this.linker.initViews(segment).then((views: ViewController[]) => { + return this.setPages(views, null); + }); + } else { + promise = this.push(nameToUse, dataToUse, opts); + } - this._lazyRootFromUrl = null; - this._lazyRootFromUrlData = null; - this._loaded = true; + return promise.then(() => { + this._segment = null; + this._loaded = true; + }); } else { // if this is not the Tab's initial load then we need @@ -346,10 +347,7 @@ export class Tab extends NavControllerBase implements ITab { this._dom.read(() => { this.resize(); }); - if (done) { - done(false, false); - } - return; + return Promise.resolve(); } } diff --git a/src/components/tabs/tabs.ts b/src/components/tabs/tabs.ts index b4ba46f5520..3e9c012c659 100644 --- a/src/components/tabs/tabs.ts +++ b/src/components/tabs/tabs.ts @@ -328,7 +328,7 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs, Navigat /** * @internal */ - initTabs() { + initTabs(): Promise { // get the selected index from the input // otherwise default it to use the first index let selectedIndex = (isBlank(this.selectedIndex) ? 0 : parseInt(this.selectedIndex, 10)); @@ -348,17 +348,17 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs, Navigat selectedTab = this._tabs.find(t => t.enabled && t.show); } + let promise = Promise.resolve(); if (selectedTab) { - if (tabsSegment) { - selectedTab._lazyRootFromUrl = tabsSegment.name; - selectedTab._lazyRootFromUrlData = tabsSegment.data; - } - this.select(selectedTab); + selectedTab._segment = tabsSegment; + promise = this.select(selectedTab); } - // set the initial href attribute values for each tab - this._tabs.forEach(t => { - t.updateHref(t.root, t.rootParams); + return promise.then(() => { + // set the initial href attribute values for each tab + this._tabs.forEach(t => { + t.updateHref(t.root, t.rootParams); + }); }); } @@ -384,10 +384,10 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs, Navigat /** * @param {number|Tab} tabOrIndex Index, or the Tab instance, of the tab to select. */ - select(tabOrIndex: number | Tab, opts: NavOptions = {}, fromUrl: boolean = false) { + select(tabOrIndex: number | Tab, opts: NavOptions = {}, fromUrl: boolean = false): Promise { const selectedTab: Tab = (typeof tabOrIndex === 'number' ? this.getByIndex(tabOrIndex) : tabOrIndex); if (isBlank(selectedTab)) { - return; + return Promise.resolve(); } // If the selected tab is the current selected tab, we do not switch @@ -415,7 +415,8 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs, Navigat // Let's start the transition opts.animate = false; - selectedTab.load(opts, () => { + return selectedTab.load(opts).then(() => { + console.log('selectedTab.load resolved'); this._tabSwitchEnd(selectedTab, selectedPage, currentPage); if (opts.updateUrl !== false) { this._linker.navChange(DIRECTION_SWITCH); @@ -425,6 +426,7 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs, Navigat }); } else { this._fireChangeEvent(selectedTab); + return Promise.resolve(); } } @@ -536,36 +538,38 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs, Navigat * "Touch" the active tab, going back to the root view of the tab * or optionally letting the tab handle the event */ - private _updateCurrentTab(tab: Tab, fromUrl: boolean) { + private _updateCurrentTab(tab: Tab, fromUrl: boolean): Promise { const active = tab.getActive(); if (active) { - if (fromUrl && tab._lazyRootFromUrl) { + if (fromUrl && tab._segment) { // see if the view controller exists - const vc = tab.getViewById(tab._lazyRootFromUrl); + const vc = tab.getViewById(tab._segment.name); if (vc) { // the view is already in the stack - tab.popTo(vc, { + return tab.popTo(vc, { animate: false, updateUrl: false, }); } else { - tab.setRoot(tab._lazyRootFromUrl, tab._lazyRootFromUrlData, { - animate: false, updateUrl: false + return this._linker.initViews(tab._segment).then((views: ViewController[]) => { + return tab.setPages(views, { + animate: false, updateUrl: false + }); + }).then(() => { + tab._segment = null; }); - tab._lazyRootFromUrl = null; - tab._lazyRootFromUrlData = null; } } else if (active._cmp && active._cmp.instance.ionSelected) { // if they have a custom tab selected handler, call it active._cmp.instance.ionSelected(); - + return Promise.resolve(); } else if (tab.length() > 1) { // if we're a few pages deep, pop to root - tab.popToRoot(); + return tab.popToRoot(); } else { - getComponent(this._linker, tab.root).then(viewController => { + return getComponent(this._linker, tab.root).then(viewController => { if (viewController.component !== active.component) { // Otherwise, if the page we're on is not our real root // reset it to our default root type diff --git a/src/components/tabs/test/tab.spec.ts b/src/components/tabs/test/tab.spec.ts index 0c95bd20437..73b86cdd4aa 100644 --- a/src/components/tabs/test/tab.spec.ts +++ b/src/components/tabs/test/tab.spec.ts @@ -2,70 +2,85 @@ import { mockTab, mockTabs, mockView, mockViews } from '../../../util/mock-provi describe('tab', () => { describe('load', () => { - it('should measure and refresh the tabs', () => { + it('should measure and refresh the tabs', (done: Function) => { // TODO - this test is super leaky but I cant come up with a better way short term const tabs = mockTabs(); const tab = mockTab(tabs, false); - const spy = jasmine.createSpy('done'); spyOn(tab, 'push'); spyOn(tab, 'popTo'); - tab.load({}, spy); - - expect(tab.push).not.toHaveBeenCalled(); - expect(tab.popTo).not.toHaveBeenCalled(); - expect(spy).toHaveBeenCalled(); + tab.load({}).then(() => { + expect(tab.push).not.toHaveBeenCalled(); + expect(tab.popTo).not.toHaveBeenCalled(); + done(); + }).catch((err: Error) => { + done(err); + }); }); - it('should reuse the view if its the top view in the stack', () => { + it('should reuse the view if its the top view in the stack', (done: Function) => { const tabs = mockTabs(); const tab = mockTab(tabs, false); - const spy = jasmine.createSpy('done'); const mockViewOne = mockView('one'); const mockViewTwo = mockView('two'); mockViews(tab, [mockViewOne, mockViewTwo]); - tab._lazyRootFromUrl = 'someValue'; - tab._lazyRootFromUrlData = { }; + tab._segment = { + name: 'someValue', + data: {}, + id: 'taco', + type: 'tab', + navId: null, + secondaryId: null + }; - mockViewTwo.id = tab._lazyRootFromUrl; + mockViewTwo.id = tab._segment.name; spyOn(tab, 'push'); spyOn(tab, 'popTo'); - tab.load({}, spy); - - expect(tab.push).not.toHaveBeenCalled(); - expect(tab.popTo).not.toHaveBeenCalled(); - expect(spy).toHaveBeenCalled(); + tab.load({}).then(() => { + expect(tab.push).not.toHaveBeenCalled(); + expect(tab.popTo).not.toHaveBeenCalled(); + done(); + }).catch((err: Error) => { + done(err); + }); }); - it('should pop back to a previous view if ', () => { + it('should pop back to a previous view if the view exists in the stack', (done: Function) => { const tabs = mockTabs(); const tab = mockTab(tabs, false); - const spy = jasmine.createSpy('done'); const mockViewOne = mockView('one'); const mockViewTwo = mockView('two'); mockViews(tab, [mockViewOne, mockViewTwo]); - tab._lazyRootFromUrl = 'someValue'; - tab._lazyRootFromUrlData = { }; + tab._segment = { + name: 'someValue', + data: {}, + id: 'taco', + type: 'tab', + navId: null, + secondaryId: null + }; - mockViewOne.id = tab._lazyRootFromUrl; + mockViewOne.id = tab._segment.name; spyOn(tab, 'push'); - spyOn(tab, 'popTo'); - - tab.load({}, spy); - - expect(tab.push).not.toHaveBeenCalled(); - expect(tab.popTo).toHaveBeenCalled(); - expect(spy).not.toHaveBeenCalled(); + spyOn(tab, 'popTo').and.returnValue(Promise.resolve()); + + tab.load({}).then(() => { + expect(tab.push).not.toHaveBeenCalled(); + expect(tab.popTo).toHaveBeenCalled(); + done(); + }).catch((err: Error) => { + done(err); + }); }); - it('should push the view if it doesnt exist already', () => { + it('should push the view if it doesnt exist already', (done: Function) => { const tabs = mockTabs(); const tab = mockTab(tabs, false); const spy = jasmine.createSpy('done'); @@ -74,17 +89,25 @@ describe('tab', () => { const mockViewTwo = mockView('two'); mockViews(tab, [mockViewOne, mockViewTwo]); - tab._lazyRootFromUrl = 'someValue'; - tab._lazyRootFromUrlData = { }; + tab._segment = { + name: 'someValue', + data: {}, + id: 'taco', + type: 'tab', + navId: null, + secondaryId: null + }; - spyOn(tab, 'push'); + spyOn(tab, 'push').and.returnValue(Promise.resolve()); spyOn(tab, 'popTo'); - tab.load({}, spy); - - expect(tab.push).toHaveBeenCalled(); - expect(tab.popTo).not.toHaveBeenCalled(); - expect(spy).not.toHaveBeenCalled(); + const result = tab.load({}); + result.then(() => { + expect(tab.push).toHaveBeenCalled(); + expect(tab.popTo).not.toHaveBeenCalled(); + expect(spy).not.toHaveBeenCalled(); + done(); + }); }); }); diff --git a/src/components/tabs/test/tabs.spec.ts b/src/components/tabs/test/tabs.spec.ts index d65599128cc..c795809bbb3 100644 --- a/src/components/tabs/test/tabs.spec.ts +++ b/src/components/tabs/test/tabs.spec.ts @@ -6,7 +6,7 @@ describe('Tabs', () => { describe('initTabs', () => { - it('should not select a hidden or disabled tab', () => { + it('should not select a hidden or disabled tab', (done: Function) => { var tabs = mockTabs(); var tab0 = mockTab(tabs); var tab1 = mockTab(tabs); @@ -17,13 +17,16 @@ describe('Tabs', () => { tab1.show = false; tabs.selectedIndex = 1; - tabs.initTabs(); - - expect(tab0.isSelected).toEqual(true); - expect(tab1.isSelected).toEqual(false); + tabs.initTabs().then(() => { + expect(tab0.isSelected).toEqual(true); + expect(tab1.isSelected).toEqual(false); + done(); + }).catch((err: Error) => { + done(err); + }); }); - it('should select the second tab from selectedIndex input', () => { + it('should select the second tab from selectedIndex input', (done: Function) => { var tabs = mockTabs(); var tab0 = mockTab(tabs); var tab1 = mockTab(tabs); @@ -31,30 +34,37 @@ describe('Tabs', () => { tab1.root = SomePage; tabs.selectedIndex = 1; - tabs.initTabs(); - expect(tab0.isSelected).toEqual(false); - expect(tab1.isSelected).toEqual(true); + tabs.initTabs().then(() => { + expect(tab0.isSelected).toEqual(false); + expect(tab1.isSelected).toEqual(true); + done(); + }).catch((err: Error) => { + done(err); + }); }); - it('should select the first tab by default', () => { + it('should select the first tab by default', (done: Function) => { var tabs = mockTabs(); var tab0 = mockTab(tabs); var tab1 = mockTab(tabs); tab0.root = SomePage; tab1.root = SomePage; - tabs.initTabs(); - - expect(tab0.isSelected).toEqual(true); - expect(tab1.isSelected).toEqual(false); + tabs.initTabs().then(() => { + expect(tab0.isSelected).toEqual(true); + expect(tab1.isSelected).toEqual(false); + done(); + }).catch((err: Error) => { + done(err); + }); }); }); describe('previousTab', () => { - it('should find the previous tab when there has been 3 selections', () => { + it('should find the previous tab when there has been 3 selections', (done: Function) => { var tabs = mockTabs(); var tab0 = mockTab(tabs); var tab1 = mockTab(tabs); @@ -63,17 +73,22 @@ describe('Tabs', () => { tab1.root = SomePage; tab2.root = SomePage; - tabs.select(tab0); - tabs.select(tab1); - tabs.select(tab2); - - expect(tabs._selectHistory).toEqual([tab0.id, tab1.id, tab2.id]); - - expect(tabs.previousTab(true)).toEqual(tab1); - expect(tabs._selectHistory).toEqual([tab0.id, tab1.id]); - - expect(tabs.previousTab(true)).toEqual(tab0); - expect(tabs._selectHistory).toEqual([tab0.id]); + tabs.select(tab0).then(() => { + return tabs.select(tab1); + }).then(() => { + return tabs.select(tab2); + }).then(() => { + expect(tabs._selectHistory).toEqual([tab0.id, tab1.id, tab2.id]); + + expect(tabs.previousTab(true)).toEqual(tab1); + expect(tabs._selectHistory).toEqual([tab0.id, tab1.id]); + + expect(tabs.previousTab(true)).toEqual(tab0); + expect(tabs._selectHistory).toEqual([tab0.id]); + done(); + }).catch((err: Error) => { + done(err); + }); }); it('should not find a previous tab when there has only been one selection', () => { @@ -94,7 +109,7 @@ describe('Tabs', () => { expect(tabs.previousTab(true)).toEqual(null); }); - it('should track tab selections', () => { + it('should track tab selections', (done: Function) => { var tabs = mockTabs(); var tab0 = mockTab(tabs); var tab1 = mockTab(tabs); @@ -103,27 +118,31 @@ describe('Tabs', () => { expect(tabs._selectHistory.length).toEqual(0); - tabs.select(tab0); - expect(tabs._selectHistory[0]).toEqual(tab0.id); - expect(tabs._selectHistory.length).toEqual(1); - - tabs.select(tab1); - expect(tabs._selectHistory[0]).toEqual(tab0.id); - expect(tabs._selectHistory[1]).toEqual(tab1.id); - expect(tabs._selectHistory.length).toEqual(2); - - tabs.select(tab0); - expect(tabs._selectHistory[0]).toEqual(tab0.id); - expect(tabs._selectHistory[1]).toEqual(tab1.id); - expect(tabs._selectHistory[2]).toEqual(tab0.id); - expect(tabs._selectHistory.length).toEqual(3); + tabs.select(tab0).then(() => { + expect(tabs._selectHistory[0]).toEqual(tab0.id); + expect(tabs._selectHistory.length).toEqual(1); + return tabs.select(tab1); + }).then(() => { + expect(tabs._selectHistory[0]).toEqual(tab0.id); + expect(tabs._selectHistory[1]).toEqual(tab1.id); + expect(tabs._selectHistory.length).toEqual(2); + return tabs.select(tab0); + }).then(() => { + expect(tabs._selectHistory[0]).toEqual(tab0.id); + expect(tabs._selectHistory[1]).toEqual(tab1.id); + expect(tabs._selectHistory[2]).toEqual(tab0.id); + expect(tabs._selectHistory.length).toEqual(3); + done(); + }).catch((err: Error) => { + done(err); + }); }); }); describe('select', () => { - it('should select tab by tab instance', () => { + it('should select tab by tab instance', (done: Function) => { var tabs = mockTabs(); var tab0 = mockTab(tabs); var tab1 = mockTab(tabs); @@ -131,13 +150,16 @@ describe('Tabs', () => { tab0.root = SomePage; tab1.root = SomePage; - tabs.select(tab1); - - expect(tab0.isSelected).toEqual(false); - expect(tab1.isSelected).toEqual(true); + tabs.select(tab1).then(() => { + expect(tab0.isSelected).toEqual(false); + expect(tab1.isSelected).toEqual(true); + done(); + }).catch((err: Error) => { + done(err); + }); }); - it('should select tab by index', () => { + it('should select tab by index', (done: Function) => { var tabs = mockTabs(); var tab0 = mockTab(tabs); var tab1 = mockTab(tabs); @@ -149,10 +171,13 @@ describe('Tabs', () => { expect(tab0.isSelected).toBeUndefined(); expect(tab1.isSelected).toBeUndefined(); - tabs.select(0); - - expect(tab0.isSelected).toEqual(true); - expect(tab1.isSelected).toEqual(false); + tabs.select(0).then(() => { + expect(tab0.isSelected).toEqual(true); + expect(tab1.isSelected).toEqual(false); + done(); + }).catch((err: Error) => { + done(err); + }); }); }); diff --git a/src/navigation/deep-linker.ts b/src/navigation/deep-linker.ts index 7ffc053519e..6a9e558f7e9 100644 --- a/src/navigation/deep-linker.ts +++ b/src/navigation/deep-linker.ts @@ -389,8 +389,7 @@ export class DeepLinker { const tabs = (isTabs(navContainer) ? navContainer : navContainer.parent); const selectedIndex = tabs._getSelectedTabIndex(segment.secondaryId); const tab = tabs.getByIndex(selectedIndex); - tab._lazyRootFromUrl = segment.name; - tab._lazyRootFromUrlData = segment.data; + tab._segment = segment; tabs.select(tab, { updateUrl: false, animate: false diff --git a/src/navigation/nav-interfaces.ts b/src/navigation/nav-interfaces.ts index 479fa2424fb..e1d959b7157 100644 --- a/src/navigation/nav-interfaces.ts +++ b/src/navigation/nav-interfaces.ts @@ -1,4 +1,4 @@ -import { NavOptions } from './nav-util'; +import { NavOptions, NavSegment } from './nav-util'; import { ViewController } from './view-controller'; export interface Nav { @@ -19,8 +19,7 @@ export interface Tab { tabUrlPath: string; tabTitle: string; index: number; - _lazyRootFromUrl: string; - _lazyRootFromUrlData: string; + _segment: NavSegment; } export interface Content { diff --git a/src/navigation/test/deep-linker.spec.ts b/src/navigation/test/deep-linker.spec.ts index 5f23f4a6334..60d924c9762 100644 --- a/src/navigation/test/deep-linker.spec.ts +++ b/src/navigation/test/deep-linker.spec.ts @@ -550,8 +550,7 @@ describe('DeepLinker', () => { linker._loadViewForSegment(tabs, segment, wrapper.done); expect(selectSpy.calls.first().args[0]).toEqual(tabOne); - expect(selectSpy.calls.first().args[0]._lazyRootFromUrl).toEqual(segment.name); - expect(selectSpy.calls.first().args[0]._lazyRootFromUrlData).toEqual(segment.data); + expect(selectSpy.calls.first().args[0]._segment).toEqual(segment); expect(wrapper.done).toHaveBeenCalled(); }); diff --git a/src/navigation/url-serializer.ts b/src/navigation/url-serializer.ts index d6f1034b067..a5ec6ad26e1 100644 --- a/src/navigation/url-serializer.ts +++ b/src/navigation/url-serializer.ts @@ -2,7 +2,7 @@ import { OpaqueToken } from '@angular/core'; import { App } from '../components/app/app'; import { NavigationContainer } from './navigation-container'; -import { DeepLinkConfig, DehydratedSegment, DehydratedSegmentPair, isNav, isTab, isTabs, NavGroup, NavLink, NavSegment } from './nav-util'; +import { DeepLinkConfig, DehydratedSegment, DehydratedSegmentPair, NavGroup, NavLink, NavSegment, isTabs } from './nav-util'; import { isArray, isBlank, isPresent } from '../util/util'; diff --git a/src/util/mock-providers.ts b/src/util/mock-providers.ts index c45a63877a8..9e7a7ced5db 100644 --- a/src/util/mock-providers.ts +++ b/src/util/mock-providers.ts @@ -11,7 +11,7 @@ import { GestureController } from '../gestures/gesture-controller'; import { Haptic } from '../tap-click/haptic'; import { IonicApp } from '../components/app/app-root'; import { Menu } from '../components/menu/menu'; -import { NavOptions, TransitionDoneFn } from '../navigation/nav-util'; +import { NavOptions } from '../navigation/nav-util'; import { NavControllerBase } from '../navigation/nav-controller-base'; import { OverlayPortal } from '../components/app/overlay-portal'; import { PageTransition } from '../transitions/page-transition'; @@ -501,8 +501,7 @@ export function mockTab(parentTabs: Tabs, overrideLoad: boolean = true): Tab { ); if (overrideLoad) { - tab.load = (_opts: any, cb: TransitionDoneFn) => { - cb(false, false); + tab.load = (_opts: any) => { return Promise.resolve(); }; }