Skip to content

Commit

Permalink
Merge branch 'master' into modal-options
Browse files Browse the repository at this point in the history
* master:
  exclude files from api ref build
  NS Angular api ref build script
  fix(location-strategy): crash on going back with router-outlet after closing modal (NativeScript#1748)
  release: cut the 7.2.2 release (NativeScript#1742)
  fix(router): routing services should be provided in forRoot only (NativeScript#1729)
  fix(list-view): Add support for default item template
  fix(list-view): add support for "defailtTemplate"
  docs: cut the 7.2.1 release
  fix: Router tracing does not work with webpack
  chore: bump package version to 7.2.1
  chore: bump package versino tp 7.3.0
  test: Add tests for nested primary outlets
  fix(location-strategy): extend support for nested primary outlets
  • Loading branch information
Marcus Williams committed Mar 16, 2019
2 parents 7c8424b + 06bbcae commit cc8f6a9
Show file tree
Hide file tree
Showing 36 changed files with 625 additions and 144 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
<a name="7.2.2"></a>
## [7.2.2](https://github.com/NativeScript/nativescript-angular/compare/7.2.1...7.2.2) (2019-02-19)


### Bug Fixes

* **list-view:** add support for default item template ([4061cc7](https://github.com/NativeScript/nativescript-angular/commit/4061cc7))



<a name="7.2.1"></a>
## [7.2.1](https://github.com/NativeScript/nativescript-angular/compare/7.2.0...7.2.1) (2019-02-10)


### Bug Fixes

* **location-strategy:** extend support for nested primary outlets ([566896d](https://github.com/NativeScript/nativescript-angular/commit/566896d))
* Router tracing does not work with webpack ([e87ef68](https://github.com/NativeScript/nativescript-angular/commit/e87ef68))



<a name="7.2.0"></a>
# [7.2.0](https://github.com/NativeScript/nativescript-angular/compare/7.1.2...7.2.0) (2019-01-31)

Expand Down
9 changes: 9 additions & 0 deletions build-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set -e

ENV="${ENV:-dev}"
DIST_DIR="nativescript-angular/bin/dist"
APIREF_DIR="$DIST_DIR/ng-api-reference"
rm -rf "$APIREF_DIR"
cd "nativescript-angular"
npm install
npm run typedoc
2 changes: 1 addition & 1 deletion e2e/nested-router-tab-view/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<page-router-outlet></page-router-outlet>
<page-router-outlet tag="rootPRO"></page-router-outlet>
4 changes: 4 additions & 0 deletions e2e/nested-router-tab-view/app/app.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const routes: Routes = [
path: "home-lazy",
loadChildren: "./home-lazy/home-lazy.module#HomeLazyModule",
},
{
path: "custom-tabs",
loadChildren: "./custom-tabs/custom-tabs.module#CustomTabsModule",
},
{
path: "tabs", component: TabsComponent, children: [
{ path: "players", component: PlayerComponent, outlet: "playerTab" },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<ActionBar title="Custom Tabs Component" class="action-bar">
<NavigationButton text="Root Back"></NavigationButton>

<StackLayout orientation="horizontal">
<Button horizontalAlignment="left" android:visibility="visible" ios:visibility="collapse" text="Root Back" (tap)="onRootBack()"></Button>
<Label horizontalAlignment="center" text="Custom Tabs Component"></Label>
</StackLayout>
</ActionBar>

<GridLayout rows="50,*, auto">
<!-- <Button row="0" text="CanGoBack(ParentRoute)" automationText="CanGoBack(ParentRoute)" col="3" (tap)="canGoBackParentRoute()"></Button> -->
<GridLayout row="1">
<page-router-outlet tag="customTabsPRO"></page-router-outlet>
</GridLayout>
<GridLayout row="2" columns="*, *">
<Button col="0" text="Players Tab" [nsRouterLink]="['../tabs/players']"></Button>
<Button col="1" text="Teams Tab" [nsRouterLink]="['../tabs/teams']"></Button>
</GridLayout>
</GridLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Component, OnInit } from '@angular/core';
import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs";
import { RouterExtensions } from "nativescript-angular/router";
import { ActivatedRoute } from "@angular/router";
import { confirm } from "tns-core-modules/ui/dialogs";
import { Page } from 'tns-core-modules/ui/page/page';

@Component({
moduleId: module.id,
selector: 'custom-tabs',
templateUrl: './custom-tabs.component.html'
})
export class CustomTabsComponent implements OnInit {

constructor(
private activeRoute: ActivatedRoute,
private routerExtension: RouterExtensions,
private page: Page) { }

ngOnInit() {
}

canGoBackParentRoute() {
const canGoBackParentRoute = this.routerExtension.canGoBack({ relativeTo: this.activeRoute });
const title = "CanGoBack(ParentRoute)";
this.onShowDialog(title, title + ` ${canGoBackParentRoute}`);
}

onRootBack() {
this.page.frame.goBack();
}

onShowDialog(title: string, result: string) {
let options: any = {
title: title,
message: result,
okButtonText: "Ok"
}

confirm(options).then((result: boolean) => {
console.log(result);
})
}
}
38 changes: 38 additions & 0 deletions e2e/nested-router-tab-view/app/custom-tabs/custom-tabs.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
import { NativeScriptCommonModule } from 'nativescript-angular/common';
import { NativeScriptRouterModule } from 'nativescript-angular/router';

import { CustomTabsComponent } from './custom-tabs.component';
import { PlayerComponent } from "../player/players.component";
import { PlayerDetailComponent } from "../player/player-detail.component";
import { TeamsComponent } from "../team/teams.component";
import { TeamDetailComponent } from "../team/team-detail.component";
import { Route } from "@angular/router";
import { SharedModule } from "../shared.module";

const routes: Route[] = [
{
path: 'tabs',
component: CustomTabsComponent,
children: [
{ path: "players", component: PlayerComponent },
{ path: "player/:id", component: PlayerDetailComponent },

{ path: "teams", component: TeamsComponent },
{ path: "team/:id", component: TeamDetailComponent },
]
},
];

@NgModule({
declarations: [CustomTabsComponent
],
imports: [
NativeScriptCommonModule,
NativeScriptRouterModule,
NativeScriptRouterModule.forChild(routes),
SharedModule
],
schemas: [NO_ERRORS_SCHEMA]
})
export class CustomTabsModule { }
2 changes: 1 addition & 1 deletion e2e/nested-router-tab-view/app/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</ActionBar>

<StackLayout>
<!-- <Button text="Go To Home Page" [nsRouterLink]="['/home', { outlets: { playerTab: ['players'], teamTab: ['teams'] } }]"></Button> -->
<Button text="Go To Home Page" [nsRouterLink]="['../home', { outlets: { playerTab: ['players'], teamTab: ['teams'] } }]"></Button>
<Button text="Go To Lazy Home Page" [nsRouterLink]="['../home-lazy/home', { outlets: { playerTab: ['players'], teamTab: ['teams'] } }]"></Button>
<Button text="Go To Lazy Custom Tabs" [nsRouterLink]="['../custom-tabs/tabs/players']"></Button>
</StackLayout>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<ActionBar title="Player Details" class="action-bar"></ActionBar>
<ActionBar title="Player Details" class="action-bar">
<!-- <NavigationButton visibility="hidden"></NavigationButton> -->
</ActionBar>
<StackLayout flexDirection="column" class="page" class="m-15">
<Label [text]="item.id"></Label>
<Label [text]="item.name + ' Details'"></Label>
Expand Down
12 changes: 6 additions & 6 deletions e2e/nested-router-tab-view/app/player/players.component.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<ActionBar title="Player List" class="action-bar"></ActionBar>
<ActionBar title="Player List" class="action-bar">
<!-- <NavigationButton visibility="hidden"></NavigationButton> -->
</ActionBar>

<GridLayout>
<!-- <Button text="Open Named Modal" (tap)="onModalFrame()"></Button> -->
<ListView [items]="items" class="list-group">
<GridLayout rows="auto,*">
<ListView row="1" [items]="items" class="list-group">
<ng-template let-item="item">
<Label [nsRouterLink]="['../player', item.id]" [text]="item.name"
class="list-group-item"></Label>
<Label [nsRouterLink]="['../player', item.id]" [text]="item.name" class="list-group-item"></Label>
</ng-template>
</ListView>
</GridLayout>
6 changes: 4 additions & 2 deletions e2e/nested-router-tab-view/app/player/players.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, OnInit, ViewContainerRef } from "@angular/core";
import { DataService, DataItem } from "../data.service";
import { RouterExtensions } from "nativescript-angular/router";

import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs";
import { ModalRouterComponent } from "../modal/modal-router/modal-router.component";
Expand All @@ -12,7 +11,10 @@ import { ModalRouterComponent } from "../modal/modal-router/modal-router.compone
export class PlayerComponent implements OnInit {
items: DataItem[];

constructor(private modal: ModalDialogService, private itemService: DataService, private router: RouterExtensions, private vcRef: ViewContainerRef, ) { }
constructor(
private modal: ModalDialogService,
private itemService: DataService,
private vcRef: ViewContainerRef, ) { }

ngOnInit(): void {
this.items = this.itemService.getPlayers();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<ActionBar title="Team Details" class="action-bar"></ActionBar>
<ActionBar title="Team Details" class="action-bar">
<!-- <NavigationButton visibility="hidden"></NavigationButton> -->
</ActionBar>
<StackLayout flexDirection="column" class="page" class="m-15">
<Label [text]="item.id"></Label>
<Label [text]="item.name + ' Details'"></Label>
Expand Down
4 changes: 3 additions & 1 deletion e2e/nested-router-tab-view/app/team/teams.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<ActionBar title="Team List" class="action-bar"></ActionBar>
<ActionBar title="Team List" class="action-bar">
<!-- <NavigationButton visibility="hidden"></NavigationButton> -->
</ActionBar>

<GridLayout>
<ListView [items]="items" class="list-group">
Expand Down
72 changes: 72 additions & 0 deletions e2e/nested-router-tab-view/e2e/custom-tabs.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { AppiumDriver, createDriver } from "nativescript-dev-appium";
import { Screen } from "./screen"
import {
testPlayerNavigated,
testTeamNavigated,
testPlayerNextNavigated,
testTeamNextNavigated,
} from "./shared.e2e-spec"

describe("custom-tabs:", () => {
let driver: AppiumDriver;
let screen: Screen;

before(async () => {
driver = await createDriver();
screen = new Screen(driver);
});

after(async () => {
await driver.quit();
console.log("Quit driver!");
});

afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logTestArtifacts(this.currentTest.title);
}
});

it("loaded custom tab component and tabs", async () => {
await screen.navigateCustomTabsPage();
await screen.loadedCustomTabsPage();
await screen.loadedPlayersList();
await gotoTeamsTab(driver);
await screen.loadedTeamList();
});

it("navigate back to login and again to custom tabs", async () => {
await backRoot(driver);
await screen.loadedLogin();
await screen.navigateCustomTabsPage();
await screen.loadedCustomTabsPage();
await screen.loadedPlayersList();
await gotoTeamsTab(driver);
await screen.loadedTeamList();
});

it("navigate back to login and again to custom tabs", async () => {
await gotoPlayersTab(driver);
await testPlayerNavigated(screen, screen.playerOne);
await gotoTeamsTab(driver);
await screen.loadedTeamList();
await testTeamNavigated(screen, screen.teamOne);
await backRoot(driver);
await screen.loadedLogin();
});
});

async function backRoot(driver: AppiumDriver) {
const btnBackRoot = await driver.findElementByAutomationText("Root Back");
await btnBackRoot.tap();
}

async function gotoPlayersTab(driver: AppiumDriver) {
const btnTabTeams = await driver.findElementByAutomationText("Players Tab");
await btnTabTeams.tap();
}

async function gotoTeamsTab(driver: AppiumDriver) {
const btnTabTeams = await driver.findElementByAutomationText("Teams Tab");
await btnTabTeams.tap();
}
13 changes: 13 additions & 0 deletions e2e/nested-router-tab-view/e2e/screen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AppiumDriver, SearchOptions } from "nativescript-dev-appium";
import { assert } from "chai";

const customTabs = "Custom Tabs Component";
const home = "Home Component";
const about = "About Component";
const aboutNested = "Nested About Component";
Expand All @@ -18,6 +19,7 @@ const gotoNextTeam = "next team";
const gotoTeams = "teams";

const gotoHomePage = "Go To Home Page";
const gotoCustomTabPage = "Go To Lazy Custom Tabs";
const gotoAboutPage = "Go To About Page";
const gotoTabsPage = "Go To Tabs Page";
const confirmDialog = "Ok";
Expand Down Expand Up @@ -68,6 +70,12 @@ export class Screen {
console.log(home + " loaded!");
}

loadedCustomTabsPage= async () => {
const lblCustomTabs = await this._driver.findElementByAutomationText(customTabs);
assert.isTrue(await lblCustomTabs.isDisplayed());
console.log(home + " loaded!");
}

loadedAbout= async () => {
const lblAbout = await this._driver.findElementByAutomationText(about);
assert.isTrue(await lblAbout.isDisplayed());
Expand Down Expand Up @@ -128,6 +136,11 @@ export class Screen {
await btnNavToHomePage.tap();
}

navigateCustomTabsPage = async () => {
const btnNavToHomePage = await this._driver.findElementByAutomationText(gotoCustomTabPage);
await btnNavToHomePage.tap();
}

navigateToAboutPage = async () => {
const btnNavToAboutPage = await this._driver.findElementByAutomationText(gotoAboutPage);
await btnNavToAboutPage.tap();
Expand Down
2 changes: 1 addition & 1 deletion e2e/single-page/app/app.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.title {
font-size: 30;
font-size: 15;
margin: 16;
}

Expand Down
5 changes: 5 additions & 0 deletions e2e/single-page/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ import { AppComponent } from "./app.component";

import { rendererTraceCategory, viewUtilCategory, routeReuseStrategyTraceCategory, routerTraceCategory } from "nativescript-angular/trace";
import { setCategories, enable } from "tns-core-modules/trace";
import { ModalComponent } from "./second/modal/modal.component";
setCategories(routerTraceCategory + "," + routeReuseStrategyTraceCategory);
enable();

@NgModule({
declarations: [
AppComponent,
ModalComponent,
...navigatableComponents,
],
entryComponents:[
ModalComponent
],
bootstrap: [AppComponent],
providers: [
{ provide: NgModuleFactoryLoader, useClass: NSModuleFactoryLoader }
Expand Down
4 changes: 4 additions & 0 deletions e2e/single-page/app/second/modal/modal.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<StackLayout>
<Label text="Welcome to modal"></Label>
<Button text="Close Modal" (tap)="close()"></Button>
</StackLayout>
19 changes: 19 additions & 0 deletions e2e/single-page/app/second/modal/modal.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component } from '@angular/core';
import { ModalDialogParams } from "nativescript-angular/modal-dialog";

@Component({
moduleId: module.id,
selector: 'modal',
templateUrl: './modal.component.html'
})

export class ModalComponent {

constructor(private params: ModalDialogParams) {
}

public close() {
this.params.closeCallback();
}

}
Loading

0 comments on commit cc8f6a9

Please sign in to comment.