diff --git a/db.json b/db.json index 9e27176..89d58c3 100644 --- a/db.json +++ b/db.json @@ -1,13 +1,13 @@ { "tasks": [ { - "title": "Study Angular", + "title": "Study Angular 6", "completed": false, "editing": false, "id": 1 }, { - "title": "Workout ", + "title": "Workout", "completed": false, "editing": false, "id": 2 diff --git a/src/app/Todo-List-App/components/todo-empty/todo-empty.component.css b/src/app/Todo-List-App/components/todo-empty/todo-empty.component.css new file mode 100644 index 0000000..17bd207 --- /dev/null +++ b/src/app/Todo-List-App/components/todo-empty/todo-empty.component.css @@ -0,0 +1,12 @@ +h3{ + font-size: 2em; +} + +.img-div, h3{ + display: flex; + justify-content: center; +} + +.img-div img{ + max-width: 10em; +} \ No newline at end of file diff --git a/src/app/Todo-List-App/components/todo-empty/todo-empty.component.html b/src/app/Todo-List-App/components/todo-empty/todo-empty.component.html new file mode 100644 index 0000000..122690d --- /dev/null +++ b/src/app/Todo-List-App/components/todo-empty/todo-empty.component.html @@ -0,0 +1,6 @@ +
+

Your list is Empty 👻

+
+ to-do +
+
diff --git a/src/app/Todo-List-App/components/todo-empty/todo-empty.component.spec.ts b/src/app/Todo-List-App/components/todo-empty/todo-empty.component.spec.ts new file mode 100644 index 0000000..5ee5a5c --- /dev/null +++ b/src/app/Todo-List-App/components/todo-empty/todo-empty.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TodoEmptyComponent } from './todo-empty.component'; + +describe('TodoEmptyComponent', () => { + let component: TodoEmptyComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ TodoEmptyComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TodoEmptyComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/Todo-List-App/components/todo-empty/todo-empty.component.ts b/src/app/Todo-List-App/components/todo-empty/todo-empty.component.ts new file mode 100644 index 0000000..66530de --- /dev/null +++ b/src/app/Todo-List-App/components/todo-empty/todo-empty.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'todo-empty', + templateUrl: './todo-empty.component.html', + styleUrls: ['./todo-empty.component.css'] +}) +export class TodoEmptyComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/src/app/Todo-List-App/containers/TodoList/todo-list.component.html b/src/app/Todo-List-App/containers/TodoList/todo-list.component.html index 5c0f121..ee5e06d 100644 --- a/src/app/Todo-List-App/containers/TodoList/todo-list.component.html +++ b/src/app/Todo-List-App/containers/TodoList/todo-list.component.html @@ -9,6 +9,9 @@
+
+ +
diff --git a/src/app/Todo-List-App/containers/TodoList/todo-list.component.ts b/src/app/Todo-List-App/containers/TodoList/todo-list.component.ts index 2d9b903..ab3665e 100644 --- a/src/app/Todo-List-App/containers/TodoList/todo-list.component.ts +++ b/src/app/Todo-List-App/containers/TodoList/todo-list.component.ts @@ -70,25 +70,16 @@ export class TodoList{ // this.taskId++; } - //delete function - deleteTask(tasks: Tasks){ - this.tasks = this.tasks.filter(task => task.id !== tasks.id); - - this.todoService.deleteTask(tasks) - .subscribe(data => this.tasks.filter(task => { - return task.id !== data; - })) - } - toggleEdit(event: Tasks){ event.editing = !event.editing; } - editTask(event: Tasks): void{ + editTask(event: Tasks){ this.beforeEditing = event.title; event.editing = !event.editing; this.todoService.editTodo(event) .subscribe(data => this.tasks = this.tasks.map((task: Tasks )=>{ + if (task.title === event.title){ task = Object.assign({}, task, event); } @@ -96,6 +87,10 @@ export class TodoList{ })); } + console(){ + console.log("try function"); + } + doneEditing(task: Tasks):void{ if(task.title.trim().length === 0){ task.title = this.beforeEditing; @@ -105,7 +100,7 @@ export class TodoList{ cancelEditing(task: Tasks){ task.title = this.beforeEditing; - task.editing = false; + // task.editing = false; } remaining(): number{ @@ -115,9 +110,23 @@ export class TodoList{ atleastOneCompleted(): boolean{ return this.tasks.filter(task => task.completed).length > 0; } + //delete function + deleteTask(tasks: Tasks){ + this.tasks = this.tasks.filter(task => task.id !== tasks.id); - clearCompleted(): void{ + this.todoService.deleteTask(tasks) + .subscribe(data => this.tasks.filter(task => { + return task.id !== data; + })) + } + + clearCompleted(tasks: Tasks){ this.tasks = this.tasks.filter(task => !task.completed); + + this.todoService.deleteTask(tasks) + .subscribe(data => this.tasks.filter(task => { + return task == data; + })) } selectAll():void{ diff --git a/src/app/Todo-List-App/services/todo.service.ts b/src/app/Todo-List-App/services/todo.service.ts index f5441bf..1178731 100644 --- a/src/app/Todo-List-App/services/todo.service.ts +++ b/src/app/Todo-List-App/services/todo.service.ts @@ -18,7 +18,6 @@ export class TodoService{ 'Content-Type': 'application/json' }) }) - } editTodo(task: Tasks):Observable{ diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8d05102..184d201 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -7,11 +7,13 @@ import { AppComponent } from './app.component'; import { TodoList } from './Todo-List-App/containers/TodoList/Todo-list.component'; import { TodoService } from './Todo-List-App/services/todo.service'; import { HttpClientModule } from '@angular/common/http'; +import { TodoEmptyComponent } from './Todo-List-App/components/todo-empty/todo-empty.component'; @NgModule({ declarations: [ AppComponent, - TodoList + TodoList, + TodoEmptyComponent ], imports: [ BrowserModule, diff --git a/src/assets/to-do.png b/src/assets/to-do.png new file mode 100644 index 0000000..b55483c Binary files /dev/null and b/src/assets/to-do.png differ