This repository has been archived by the owner on Dec 20, 2023. It is now read-only.
forked from tastejs/todomvc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:tastejs/todomvc
- Loading branch information
Showing
142 changed files
with
11,119 additions
and
93,849 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Michał Gołębiowski-Owczarek <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
npm-debug.log | ||
*.js.map | ||
|
||
!node_modules/todomvc-app-css/index.css | ||
!node_modules/todomvc-common/base.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
import template from './app.template.html'; | ||
|
||
@Component({ | ||
selector: 'todo-app', | ||
template: template | ||
}) | ||
export class AppComponent {} |
5 changes: 5 additions & 0 deletions
5
examples/angular2_es2015/app/components/app/app.template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<router-outlet></router-outlet> | ||
<footer class="info"> | ||
<p>Double-click to edit a todo</p> | ||
<p>Written by <a href="https://github.com/blacksonic">Soós Gábor</a></p> | ||
</footer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './app/app.component'; | ||
export * from './todo-footer/todo-footer.component'; | ||
export * from './todo-header/todo-header.component'; | ||
export * from './todo-item/todo-item.component'; | ||
export * from './todo-list/todo-list.component'; |
41 changes: 41 additions & 0 deletions
41
examples/angular2_es2015/app/components/todo-footer/todo-footer.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Component } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
import { TodoStoreService } from '../../services/todo-store.service'; | ||
import template from './todo-footer.template.html'; | ||
|
||
@Component({ | ||
selector: 'todo-footer', | ||
template: template | ||
}) | ||
export class TodoFooterComponent { | ||
constructor(todoStore:TodoStoreService, route:ActivatedRoute) { | ||
this._todoStore = todoStore; | ||
this._route = route; | ||
this.currentStatus = ''; | ||
} | ||
|
||
ngOnInit() { | ||
this._route.params | ||
.map(params => params.status) | ||
.subscribe((status) => { | ||
this.currentStatus = status || ''; | ||
}); | ||
} | ||
|
||
removeCompleted() { | ||
this._todoStore.removeCompleted(); | ||
} | ||
|
||
getCount() { | ||
return this._todoStore.todos.length; | ||
} | ||
|
||
getRemainingCount() { | ||
return this._todoStore.getRemaining().length; | ||
} | ||
|
||
hasCompleted() { | ||
return this._todoStore.getCompleted().length > 0; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
examples/angular2_es2015/app/components/todo-footer/todo-footer.template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<footer class="footer" *ngIf="getCount()"> | ||
<span class="todo-count"><strong>{{ getRemainingCount() }}</strong> {{ getRemainingCount() == 1 ? 'item' : 'items' }} left</span> | ||
<ul class="filters"> | ||
<li> | ||
<a [routerLink]="['']" [class.selected]="currentStatus == ''">All</a> | ||
</li> | ||
<li> | ||
<a [routerLink]="['', 'active']" [class.selected]="currentStatus == 'active'">Active</a> | ||
</li> | ||
<li> | ||
<a [routerLink]="['', 'completed']" [class.selected]="currentStatus == 'completed'">Completed</a> | ||
</li> | ||
</ul> | ||
<button class="clear-completed" *ngIf="hasCompleted()" (click)="removeCompleted()">Clear completed</button> | ||
</footer> |
23 changes: 23 additions & 0 deletions
23
examples/angular2_es2015/app/components/todo-header/todo-header.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
import { TodoStoreService } from '../../services/todo-store.service'; | ||
import template from './todo-header.template.html'; | ||
|
||
@Component({ | ||
selector: 'todo-header', | ||
template: template | ||
}) | ||
export class TodoHeaderComponent { | ||
newTodo = ''; | ||
|
||
constructor(todoStore:TodoStoreService) { | ||
this._todoStore = todoStore; | ||
} | ||
|
||
addTodo() { | ||
if (this.newTodo.trim().length) { | ||
this._todoStore.add(this.newTodo); | ||
this.newTodo = ''; | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
examples/angular2_es2015/app/components/todo-header/todo-header.template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<header class="header"> | ||
<h1>Todos</h1> | ||
<input class="new-todo" placeholder="What needs to be done?" [(ngModel)]="newTodo" autofocus="" (keyup.enter)="addTodo()"> | ||
</header> |
49 changes: 49 additions & 0 deletions
49
examples/angular2_es2015/app/components/todo-item/todo-item.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Component, EventEmitter, Output, Input } from '@angular/core'; | ||
|
||
import template from './todo-item.template.html'; | ||
|
||
@Component({ | ||
selector: 'todo-item', | ||
template: template | ||
}) | ||
export class TodoItemComponent { | ||
@Input() todo; | ||
|
||
@Output() itemModified = new EventEmitter(); | ||
|
||
@Output() itemRemoved = new EventEmitter(); | ||
|
||
editing = false; | ||
|
||
cancelEditing() { | ||
this.editing = false; | ||
} | ||
|
||
stopEditing(editedTitle) { | ||
this.todo.setTitle(editedTitle.value); | ||
this.editing = false; | ||
|
||
if (this.todo.title.length === 0) { | ||
this.remove(); | ||
} else { | ||
this.update(); | ||
} | ||
} | ||
|
||
edit() { | ||
this.editing = true; | ||
} | ||
|
||
toggleCompletion() { | ||
this.todo.completed = !this.todo.completed; | ||
this.update(); | ||
} | ||
|
||
remove() { | ||
this.itemRemoved.next(this.todo.uid); | ||
} | ||
|
||
update() { | ||
this.itemModified.next(this.todo.uid); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
examples/angular2_es2015/app/components/todo-item/todo-item.template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<li [class.completed]="todo.completed" [class.editing]="editing"> | ||
<div class="view"> | ||
<input class="toggle" type="checkbox" (click)="toggleCompletion()" [checked]="todo.completed"> | ||
<label (dblclick)="edit(todo)">{{ todo.title | trim }}</label> | ||
<button class="destroy" (click)="remove()"></button> | ||
</div> | ||
<input class="edit" *ngIf="editing" [value]="todo.title" #editedtodo (blur)="stopEditing(editedtodo)" (keyup.enter)="stopEditing(editedtodo)" (keyup.escape)="cancelEditing()"> | ||
</li> |
51 changes: 51 additions & 0 deletions
51
examples/angular2_es2015/app/components/todo-list/todo-list.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Component } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
import { TodoStoreService } from '../../services/todo-store.service'; | ||
import template from './todo-list.template.html'; | ||
|
||
@Component({ | ||
selector: 'todo-list', | ||
template: template | ||
}) | ||
export class TodoListComponent { | ||
constructor(todoStore: TodoStoreService, route: ActivatedRoute) { | ||
this._todoStore = todoStore; | ||
this._route = route; | ||
this._currentStatus = ''; | ||
} | ||
|
||
ngOnInit() { | ||
this._route.params | ||
.map(params => params.status) | ||
.subscribe((status) => { | ||
this._currentStatus = status; | ||
}); | ||
} | ||
|
||
remove(uid) { | ||
this._todoStore.remove(uid); | ||
} | ||
|
||
update() { | ||
this._todoStore.persist(); | ||
} | ||
|
||
getTodos() { | ||
if (this._currentStatus == 'completed') { | ||
return this._todoStore.getCompleted(); | ||
} else if (this._currentStatus == 'active') { | ||
return this._todoStore.getRemaining(); | ||
} else { | ||
return this._todoStore.todos; | ||
} | ||
} | ||
|
||
allCompleted() { | ||
return this._todoStore.allCompleted(); | ||
} | ||
|
||
setAllTo(toggleAll) { | ||
this._todoStore.setAllTo(toggleAll.checked); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
examples/angular2_es2015/app/components/todo-list/todo-list.template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<section class="todoapp"> | ||
<todo-header></todo-header> | ||
<section class="main" *ngIf="getTodos().length"> | ||
<input class="toggle-all" type="checkbox" #toggleall [checked]="allCompleted()" (click)="setAllTo(toggleall)"> | ||
<ul class="todo-list"> | ||
<todo-item *ngFor="let todo of getTodos()" [todo]="todo" (itemRemoved)="remove($event)" (itemModified)="update($event)"></todo-item> | ||
</ul> | ||
</section> | ||
<todo-footer></todo-footer> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'core-js/client/shim'; | ||
import 'zone.js/dist/zone'; | ||
import 'zone.js/dist/long-stack-trace-zone'; | ||
import 'node-uuid'; | ||
import 'localStorage'; | ||
import 'rxjs'; | ||
|
||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
|
||
import { MainModule } from './main.module'; | ||
|
||
platformBrowserDynamic().bootstrapModule(MainModule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { HttpModule } from '@angular/http'; | ||
import { RouterModule } from '@angular/router'; | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { TodoStoreService } from './services/todo-store.service'; | ||
import { | ||
AppComponent, | ||
TodoListComponent, | ||
TodoFooterComponent, | ||
TodoHeaderComponent, | ||
TodoItemComponent | ||
} from './components'; | ||
import { TrimPipe } from './pipes'; | ||
import { routes } from './routes'; | ||
|
||
@NgModule({ | ||
bootstrap: [AppComponent], | ||
declarations: [ | ||
AppComponent, | ||
TodoListComponent, | ||
TodoFooterComponent, | ||
TodoHeaderComponent, | ||
TodoItemComponent, | ||
TrimPipe | ||
], | ||
imports: [ | ||
BrowserModule, | ||
FormsModule, | ||
HttpModule, | ||
RouterModule.forRoot(routes, { | ||
useHash: true | ||
}) | ||
], | ||
providers: [ | ||
TodoStoreService | ||
] | ||
}) | ||
export class MainModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as uuid from 'node-uuid'; | ||
|
||
export class TodoModel { | ||
completed; | ||
title; | ||
uid; | ||
|
||
setTitle(title) { | ||
this.title = title.trim(); | ||
} | ||
|
||
constructor(title) { | ||
this.uid = uuid.v4(); | ||
this.completed = false; | ||
this.title = title.trim(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './trim/trim.pipe'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
|
||
@Pipe({ name: 'trim' }) | ||
export class TrimPipe implements PipeTransform { | ||
transform(value, args) { | ||
return value.trim(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { TodoListComponent } from './components/todo-list/todo-list.component'; | ||
|
||
export let routes = [ | ||
{ path: '', component: TodoListComponent, pathMatch: 'full' }, | ||
{ path: ':status', component: TodoListComponent } | ||
]; |
Oops, something went wrong.