Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

docs(toh-6/ts): minor edits and enhancements #1686

Merged
merged 2 commits into from
Jun 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions public/_includes/_util-fns.jade
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ mixin makeExcerpt(_filePath, _region, _title, stylePatterns)
- var filePath = adjustments.filePath;
- var title = adjustments.title;
- var region = _region || parenText;
- var excerpt = !region || parenText === '' ? 'excerpt' : region;
- var excerpt = !region || parenText === '' ? 'excerpt' : parenText || region;
- if (title) title = title + ' (' + excerpt + ')';
+makeExample(filePath, region, title, stylePatterns)(format='.')

//- Extract the doc example name from `current`.
//- Get the doc example name either from `_example` if set, or
//- extract the example name from `current`.
- var getExampleName = function() {
- var dir = current.path[current.path.length - 1];
- return dir == 'latest' ? current.source : dir;
- return _example ? _example : dir == 'latest' ? current.source : dir;
- };

mixin makeTabs(filePaths, regions, tabNames, stylePatterns)
Expand Down
4 changes: 1 addition & 3 deletions public/docs/_examples/toh-6/ts/app/app.component.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* #docplaster */
/* #docregion css */
/* #docregion */
h1 {
font-size: 1.2em;
color: #999;
Expand Down Expand Up @@ -28,4 +27,3 @@ nav a:hover {
nav a.router-link-active {
color: #039be5;
}
/* #enddocregion css */
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ <h2>{{hero.name}} details!</h2>
<input [(ngModel)]="hero.name" placeholder="name" />
</div>
<button (click)="goBack()">Back</button>
<!-- #docregion save -->
<button (click)="save()">Save</button>
</div>
<!-- #enddocregion save -->
</div>
4 changes: 2 additions & 2 deletions public/docs/_examples/toh-6/ts/app/hero-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ export class HeroDetailComponent implements OnInit {
.catch(error => this.error = error); // TODO: Display error message
}
// #enddocregion save
// #docregion goback
// #docregion goBack
goBack(savedHero: Hero = null) {
this.close.emit(savedHero);
if (this.navigated) { window.history.back(); }
}
// #enddocregion goback
// #enddocregion goBack
}

22 changes: 11 additions & 11 deletions public/docs/_examples/toh-6/ts/app/hero.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import { Hero } from './hero';
@Injectable()
export class HeroService {

// #docregion getHeroes
private heroesUrl = 'app/heroes'; // URL to web api

constructor(private http: Http) { }

// #docregion get-heroes
getHeroes(): Promise<Hero[]> {
return this.http.get(this.heroesUrl)
// #docregion to-promise
Expand All @@ -29,7 +29,7 @@ export class HeroService {
.catch(this.handleError);
// #enddocregion catch
}
// #enddocregion get-heroes
// #enddocregion getHeroes

getHero(id: number) {
return this.getHeroes()
Expand All @@ -45,7 +45,7 @@ export class HeroService {
}
// #enddocregion save

// #docregion delete-hero
// #docregion delete
delete(hero: Hero) {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
Expand All @@ -57,9 +57,9 @@ export class HeroService {
.toPromise()
.catch(this.handleError);
}
// #enddocregion delete-hero
// #enddocregion delete

// #docregion post-hero
// #docregion post
// Add new Hero
private post(hero: Hero): Promise<Hero> {
let headers = new Headers({
Expand All @@ -71,9 +71,9 @@ export class HeroService {
.then(res => res.json().data)
.catch(this.handleError);
}
// #enddocregion post-hero
// #enddocregion post

// #docregion put-hero
// #docregion put
// Update existing Hero
private put(hero: Hero) {
let headers = new Headers();
Expand All @@ -87,13 +87,13 @@ export class HeroService {
.then(() => hero)
.catch(this.handleError);
}
// #enddocregion put-hero
// #enddocregion put

// #docregion error-handler
// #docregion handleError
private handleError(error: any) {
console.error('An error occurred', error);
return Promise.reject(error.message || error);
}
// #enddocregion error-handler
// #enddocregion handleError
}
// #enddocregion

11 changes: 6 additions & 5 deletions public/docs/_examples/toh-6/ts/app/heroes.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ <h2>My Heroes</h2>
<span class="hero-element">
<span class="badge">{{hero.id}}</span> {{hero.name}}
</span>
<!-- #docregion delete-hero -->
<button class="delete-button" (click)="delete(hero, $event)">Delete</button>
<!-- #enddocregion delete-hero -->
<!-- #docregion delete -->
<button class="delete-button" (click)="deleteHero(hero, $event)">Delete</button>
<!-- #enddocregion delete -->
</li>
</ul>

<!-- #docregion add-hero -->
<!-- #docregion add-and-error -->
<div class="error" *ngIf="error">{{error}}</div>
<button (click)="addHero()">Add New Hero</button>
<div *ngIf="addingHero">
<my-hero-detail (close)="close($event)"></my-hero-detail>
</div>
<!-- #enddocregion add-hero -->
<!-- #enddocregion add-and-error -->

<div *ngIf="selectedHero">
<h2>
Expand Down
16 changes: 9 additions & 7 deletions public/docs/_examples/toh-6/ts/app/heroes.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export class HeroesComponent implements OnInit {
heroes: Hero[];
selectedHero: Hero;
addingHero = false;
// #docregion error
error: any;
// #enddocregion error

constructor(
private router: Router,
Expand All @@ -28,10 +30,10 @@ export class HeroesComponent implements OnInit {
this.heroService
.getHeroes()
.then(heroes => this.heroes = heroes)
.catch(error => this.error = error); // TODO: Display error message
.catch(error => this.error = error);
}

// #docregion add
// #docregion addHero
addHero() {
this.addingHero = true;
this.selectedHero = null;
Expand All @@ -41,20 +43,20 @@ export class HeroesComponent implements OnInit {
this.addingHero = false;
if (savedHero) { this.getHeroes(); }
}
// #enddocregion add
// #enddocregion addHero

// #docregion delete
delete(hero: Hero, event: any) {
// #docregion deleteHero
deleteHero(hero: Hero, event: any) {
event.stopPropagation();
this.heroService
.delete(hero)
.then(res => {
this.heroes = this.heroes.filter(h => h !== hero);
if (this.selectedHero === hero) { this.selectedHero = null; }
})
.catch(error => this.error = error); // TODO: Display error message
.catch(error => this.error = error);
}
// #enddocregion delete
// #enddocregion deleteHero

ngOnInit() {
this.getHeroes();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// #docregion
// #docregion , init
export class InMemoryDataService {
createDb() {
let heroes = [
Expand Down
5 changes: 2 additions & 3 deletions public/docs/_examples/toh-6/ts/sample.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* #docregion */
.error {color:red;}
button.delete-button{
float:right;
background-color: gray !important;
color:white;
}



Loading