From bf884b24b457f50e2d3738b398e39533c4fae3d8 Mon Sep 17 00:00:00 2001 From: Matthew Wheatley Date: Mon, 6 Jun 2016 12:24:02 -0500 Subject: [PATCH] fixed merge issues changed navigate method of app.ts --- app/client/app.ts | 44 ++++++++++++++---------------- app/client/lib/meteor-ionic-app.ts | 4 +-- app/package.json | 1 + 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/app/client/app.ts b/app/client/app.ts index b504f30..8631f8c 100644 --- a/app/client/app.ts +++ b/app/client/app.ts @@ -1,6 +1,6 @@ import {MeteorComponent} from 'angular2-meteor'; import {App, IonicApp, Platform} from 'ionic-angular'; -import {Component, NgZone, provide, Type} from '@angular/core'; +import {Component, NgZone, provide, Type, ViewChild} from '@angular/core'; import {Http, HTTP_PROVIDERS} from '@angular/http'; import {TranslateService, TranslatePipe, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate'; import {MeteorIonicApp} from "./lib/meteor-ionic-app"; @@ -33,10 +33,10 @@ declare var device; }) class MyApp extends MeteorComponent { // Set the root (or first) page - private rootPage:Type; - private pages:Array<{icon?: string, title: string, component: Type}>; + private rootPage:Type = HomePage; + private pages:Array<{icon?: string, title: string, component: Type, rootPage:boolean}>; private appName:string; - //private user:Meteor.User; + private user:Meteor.User; @ViewChild('leftMenu') leftMenu:any; @ViewChild('content') nav:any; @@ -51,20 +51,13 @@ class MyApp extends MeteorComponent { ngOnInit():void { this.initializeApp(); - // set the root (or first) page - //if (Meteor.user()) { - this.rootPage = HomePage; - //} else { - // this.rootPage = LoginPage; - //} - // set the nav menu title to the application name from settings.json this.appName = Meteor.settings.public.appName; // set our app's pages // title references a key in the language JSON to be translated by the translate pipe in the HTML this.pages = [ - {icon: "home", title: "home.title", component: HomePage}, + {icon: "home", title: "home.title", component: HomePage, rootPage: true}, ]; Tracker.autorun(() => this.zone.run(() => { @@ -112,14 +105,11 @@ class MyApp extends MeteorComponent { } private openPage(page) { - let setRoot = false; - if (page.component === HomePage) { - setRoot = true; - } - this.navigate({page: page.component, setRoot: setRoot}); + this.navigate({page: page.component, setRoot: page.setRoot}); } private logout():void { + this.user = null; Meteor.logout(); //this.navigate({page: LoginPage, setRoot: true}); } @@ -127,13 +117,19 @@ class MyApp extends MeteorComponent { private navigate(location:{page:any, setRoot:boolean}):void { // close the menu when clicking a link from the menu // getComponent selector is the component id attribute - this.leftMenu.close(); - // navigate to the new page if it is not the current page - if (location.setRoot) { - this.nav.setRoot(location.page); - } else { - this.nav.push(location.page); - } + this.leftMenu.close().then(() => { + if (location.setRoot) { + this.nav.setRoot(location.page); + } else { + if (location.page) { + // navigate to the new page if it is not the current page + let viewCtrl = this.nav.getActive(); + if (viewCtrl.componentType !== location.page) { + this.nav.push(location.page); + } + } + } + }); } private setStyle():void { diff --git a/app/client/lib/meteor-ionic-app.ts b/app/client/lib/meteor-ionic-app.ts index 8421d6f..87a5c2f 100644 --- a/app/client/lib/meteor-ionic-app.ts +++ b/app/client/lib/meteor-ionic-app.ts @@ -1,10 +1,10 @@ +import 'reflect-metadata'; +import 'zone.js/dist/zone'; import {provide, Type, Provider, IterableDiffers, Component, PLATFORM_DIRECTIVES, enableProdMode} from '@angular/core'; import {METEOR_PROVIDERS} from 'angular2-meteor'; import {bootstrap} from 'angular2-meteor-auto-bootstrap'; import {IonicApp, IONIC_DIRECTIVES, ionicProviders, postBootstrap} from 'ionic-angular'; -import { Meteor } from 'meteor/meteor'; - export function MeteorIonicApp(args: any = {}) { return function(cls) { // get annotations diff --git a/app/package.json b/app/package.json index babad96..c37401e 100644 --- a/app/package.json +++ b/app/package.json @@ -13,6 +13,7 @@ "dependencies": { "@angular/core": "2.0.0-rc.1", "@angular/http": "2.0.0-rc.1", + "@angular/router": "2.0.0-rc.1", "angular2-meteor": "0.5.5", "angular2-meteor-auto-bootstrap": "0.5.5", "es6-promise": "3.2.1",