fix(build): clang-format

This commit is contained in:
Alex Eagle 2015-07-08 16:30:43 -07:00
parent 4572157c49
commit df877a7d5b
2 changed files with 34 additions and 58 deletions

View File

@ -1,5 +1,12 @@
import {NgIf, NgFor, EventEmitter, Component, View, Inject, Injectable} from 'angular2/angular2'; import {NgIf, NgFor, EventEmitter, Component, View, Inject, Injectable} from 'angular2/angular2';
import {RouterLink, RouteConfig, Router, RouterOutlet, Location, RouteParams} from 'angular2/router'; import {
RouterLink,
RouteConfig,
Router,
RouterOutlet,
Location,
RouteParams
} from 'angular2/router';
import {Http} from 'angular2/http'; import {Http} from 'angular2/http';
import {ObservableWrapper, PromiseWrapper} from 'angular2/src/facade/async'; import {ObservableWrapper, PromiseWrapper} from 'angular2/src/facade/async';
@ -9,22 +16,19 @@ class DbService {
getData() { getData() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
ObservableWrapper.subscribe(this.http.get('./db.json', { cache: true }), (resp) => { ObservableWrapper.subscribe(this.http.get('./db.json', {cache: true}),
resolve(resp.json()); (resp) => { resolve(resp.json()); });
});
}); });
} }
drafts() { drafts() {
return PromiseWrapper.then(this.getData(), (data) => { return PromiseWrapper.then(this.getData(),
return data.filter(record => record.draft); (data) => { return data.filter(record => record.draft); });
});
} }
emails() { emails() {
return PromiseWrapper.then(this.getData(), (data) => { return PromiseWrapper.then(this.getData(),
return data.filter(record => !record.draft); (data) => { return data.filter(record => !record.draft); });
});
} }
email(id) { email(id) {
@ -39,13 +43,8 @@ class DbService {
} }
} }
@Component({ @Component({selector: 'inbox-detail'})
selector: 'inbox-detail' @View({templateUrl: "inbox-detail.html", directives: [NgFor, RouterLink]})
})
@View({
templateUrl: "inbox-detail.html",
directives: [NgFor, RouterLink]
})
class InboxDetailCmp { class InboxDetailCmp {
id: string; id: string;
subject: string; subject: string;
@ -56,38 +55,29 @@ class InboxDetailCmp {
constructor(db: DbService, params: RouteParams) { constructor(db: DbService, params: RouteParams) {
var id = params.get('id'); var id = params.get('id');
PromiseWrapper.then(db.email(id)).then((data) => { PromiseWrapper.then(db.email(id)).then((data) => { this.setEmailRecord(data); });
this.setEmailRecord(data);
});
} }
get fullName() { get fullName() { return this.firstName + ' ' + this.lastName; }
return this.firstName + ' ' + this.lastName;
}
setEmailRecord(record) { setEmailRecord(record) {
this.id = record['id']; this.id = record['id'];
this.subject = record['subject']; this.subject = record['subject'];
this.content = record['content']; this.content = record['content'];
this.email = record['email']; this.email = record['email'];
this.firstName = record['first-name']; this.firstName = record['first-name'];
this.lastName = record['last-name']; this.lastName = record['last-name'];
this.date = record['date']; this.date = record['date'];
} }
} }
@Component({selector: 'inbox'}) @Component({selector: 'inbox'})
@View({ @View({templateUrl: "inbox.html", directives: [NgFor, RouterLink]})
templateUrl: "inbox.html",
directives: [NgFor, RouterLink]
})
class InboxCmp { class InboxCmp {
q: string; q: string;
items: List = []; items: List = [];
constructor(public router: Router, db: DbService) { constructor(public router: Router, db: DbService) {
PromiseWrapper.then(db.emails(), (emails) => { PromiseWrapper.then(db.emails(), (emails) => { this.items = emails; });
this.items = emails;
});
} }
} }
@ -97,21 +87,13 @@ class InboxCmp {
class DraftsCmp { class DraftsCmp {
items: List = []; items: List = [];
constructor(public router: Router, db: DbService) { constructor(public router: Router, db: DbService) {
PromiseWrapper.then(db.drafts(), (drafts) => { PromiseWrapper.then(db.drafts(), (drafts) => { this.items = drafts; });
this.items = drafts;
});
} }
} }
@Component({ @Component({selector: 'inbox-app', viewInjector: [DbService]})
selector: 'inbox-app', @View({templateUrl: "inbox-app.html", directives: [RouterOutlet, RouterLink]})
viewInjector: [DbService]
})
@View({
templateUrl: "inbox-app.html",
directives: [RouterOutlet, RouterLink]
})
@RouteConfig([ @RouteConfig([
{path: '/', component: InboxCmp, as: 'inbox'}, {path: '/', component: InboxCmp, as: 'inbox'},
{path: '/drafts', component: DraftsCmp, as: 'drafts'}, {path: '/drafts', component: DraftsCmp, as: 'drafts'},
@ -124,10 +106,6 @@ export class InboxApp {
this.router = router; this.router = router;
this.location = location; this.location = location;
} }
inboxPageActive() { inboxPageActive() { return this.location.path() == ''; }
return this.location.path() == ''; draftsPageActive() { return this.location.path() == '/drafts'; }
}
draftsPageActive() {
return this.location.path() == '/drafts';
}
} }

View File

@ -4,9 +4,7 @@ import {routerInjectables, HashLocationStrategy, LocationStrategy} from 'angular
import {httpInjectables} from 'angular2/http'; import {httpInjectables} from 'angular2/http';
export function main() { export function main() {
bootstrap(InboxApp, [ bootstrap(
routerInjectables, InboxApp,
httpInjectables, [routerInjectables, httpInjectables, bind(LocationStrategy).toClass(HashLocationStrategy)]);
bind(LocationStrategy).toClass(HashLocationStrategy)
]);
} }