Skip to content
Open
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
17,168 changes: 17,131 additions & 37 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"@angular/cli": "~9.1.1",
"@angular/compiler-cli": "~9.1.1",
"@angular/language-service": "~9.1.1",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
Expand Down
4 changes: 0 additions & 4 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
<app-todo></app-todo>

<app-todo></app-todo>

<app-todo></app-todo>
1 change: 1 addition & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ import { Component } from '@angular/core';
})
export class AppComponent {
title = 'ng-peti';

}
10 changes: 8 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { TodoAppComponent } from './todo-app/todo-app.component';
import { TodoFormComponent } from './todo-form/todo-form.component';
import { TodoListComponent } from './todo-list/todo-list.component';
import { TodoFooterComponent } from './todo-footer/todo-footer.component';
import { FormsModule } from '@angular/forms';

@NgModule({
declarations: [
AppComponent,
TodoAppComponent,
TodoFormComponent
TodoFormComponent,
TodoListComponent,
TodoFooterComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule
BrowserAnimationsModule,
FormsModule
],
providers: [],
bootstrap: [AppComponent]
Expand Down
2 changes: 2 additions & 0 deletions src/app/todo-app/todo-app.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<app-todo-form (add)="onTodoItemCreated($event)"></app-todo-form>

<app-todo-list
[list]="list"
(itemRemoved)="onTodoItemRemoved($event)"
(itemStateChanged)="onItemStateChanged($event)"
>
</app-todo-list>

<app-todo-footer [list]="list"></app-todo-footer>
25 changes: 16 additions & 9 deletions src/app/todo-app/todo-app.component.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import { Component, OnInit } from '@angular/core';
import {TodoItem} from '../model/todo-item';
import { TodoItem } from './../model/todo-item';
import { Component } from '@angular/core';

@Component({
selector: 'app-todo',
templateUrl: './todo-app.component.html',
styleUrls: ['./todo-app.component.scss']
})
export class TodoAppComponent implements OnInit {
export class TodoAppComponent{

list = [];
lastItemId = 0;
constructor() { }

ngOnInit(): void {
}

onItemStateChanged(item: TodoItem) {
onItemStateChanged( item: TodoItem ) {
item.toggleCompleted();
}
};

onTodoItemRemoved( index: number ) {
this.list.splice( index, 1 );
};

onTodoItemCreated( item: TodoItem ) {
this.lastItemId += 1;
item.id = this.lastItemId;
this.list.push( item );
};
}
4 changes: 4 additions & 0 deletions src/app/todo-footer/todo-footer.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<footer>
<p>Tareas completadas: {{ counterCompletedTasks() }}</p>
<p>Tareas pendientes: {{ counterPendingTasks() }}</p>
</footer>
Empty file.
25 changes: 25 additions & 0 deletions src/app/todo-footer/todo-footer.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { TodoFooterComponent } from './todo-footer.component';

describe('TodoFooterComponent', () => {
let component: TodoFooterComponent;
let fixture: ComponentFixture<TodoFooterComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TodoFooterComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(TodoFooterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
20 changes: 20 additions & 0 deletions src/app/todo-footer/todo-footer.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component, Input} from '@angular/core';

@Component({
selector: 'app-todo-footer',
templateUrl: './todo-footer.component.html',
styleUrls: ['./todo-footer.component.scss']
})
export class TodoFooterComponent{

@Input() list;

counterCompletedTasks() {
return this.list.filter( item => item.isCompleted === true ).length;
};

counterPendingTasks() {
return this.list.filter( item => item.isCompleted === false ).length;
};

}
6 changes: 5 additions & 1 deletion src/app/todo-form/todo-form.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<p>todo-form works!</p>
<div>
<label>Ingrese una tarea:</label>
<input type="text" [(ngModel)]="item.description">
<input type="button" value="Agregar +" (click)="addTask()">
</div>
22 changes: 17 additions & 5 deletions src/app/todo-form/todo-form.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import { Component, OnInit, Output, EventEmitter} from '@angular/core';
import { TodoItem } from './../model/todo-item';
import { Component, Output, EventEmitter} from '@angular/core';

@Component({
selector: 'app-todo-form',
templateUrl: './todo-form.component.html',
styleUrls: ['./todo-form.component.scss']
})
export class TodoFormComponent implements OnInit {
export class TodoFormComponent{

@Output() add = new EventEmitter();
constructor() { }

ngOnInit(): void {
}
item: TodoItem;


constructor() {
this.item = new TodoItem();
};

addTask() {
if ( !this.item.description ) {
return;
};
this.add.emit( this.item );
this.item = new TodoItem();
};

}
12 changes: 12 additions & 0 deletions src/app/todo-list/todo-list.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div>
<ul>
<li *ngFor="let item of list; let i = index"
[style.text-decoration]="item.isCompleted ? 'line-through red' : ''">

ID: {{ item.id }} - Tarea: {{ item.description }} - Completada: {{ item.isCompleted }}

<input type="button" value="Eliminar" (click)="deleteTask( i )">
<input type="button" value="Completada" (click)="completedTask( item )">
</li>
</ul>
</div>
Empty file.
25 changes: 25 additions & 0 deletions src/app/todo-list/todo-list.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { TodoListComponent } from './todo-list.component';

describe('TodoListComponent', () => {
let component: TodoListComponent;
let fixture: ComponentFixture<TodoListComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TodoListComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(TodoListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
24 changes: 24 additions & 0 deletions src/app/todo-list/todo-list.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { TodoItem } from './../model/todo-item';
import { Component, Input, Output, EventEmitter } from '@angular/core';

@Component({
selector: 'app-todo-list',
templateUrl: './todo-list.component.html',
styleUrls: ['./todo-list.component.scss']
})
export class TodoListComponent{

@Input() list;

@Output() itemRemoved = new EventEmitter();
@Output() itemStateChanged = new EventEmitter();

deleteTask( index: number ) {
this.itemRemoved.emit( index );
};

completedTask( item: TodoItem ) {
this.itemStateChanged.emit( item );
};

}