Compare commits
5 Commits
master
...
d2cfa4d0f8
| Author | SHA1 | Date | |
|---|---|---|---|
| d2cfa4d0f8 | |||
| bc5209b60e | |||
| eb453c6852 | |||
| 3c049acd9e | |||
| 9ba0ba5856 |
14
functionalities.md
Normal file
14
functionalities.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Fonctionnalités
|
||||||
|
- Ajouter une tâche
|
||||||
|
- Renommer la tâche
|
||||||
|
- Terminer une tâche
|
||||||
|
- Supprimer une tâche
|
||||||
|
- Saisir la note d'une tâche
|
||||||
|
- Ajouter des sous tâches à une autre
|
||||||
|
- Renommer des sous tâches d'une autre
|
||||||
|
- Terminer des sous tâches d'une autre
|
||||||
|
- Supprimer des sous tâches d'une autre
|
||||||
|
|
||||||
|
- J'aimerai "tagger" une tâche comme "asynchrone/bloquante" (où je dois attendre la fin, genre un build jenkins) et donc être notifié toutes les 5mins d'aller vérifier si la tâche est terminée.
|
||||||
|
- Quand je termine une sous tâche, je veux qu'elle soit archivée pour pouvoir la consulter à postériori
|
||||||
|
- J'aimerai définir un e API sur laquelle je pourrais sauverader mes tâches, à la manière de git
|
||||||
16
package-lock.json
generated
16
package-lock.json
generated
@@ -18,9 +18,11 @@
|
|||||||
"@angular/platform-browser": "~12.2.0",
|
"@angular/platform-browser": "~12.2.0",
|
||||||
"@angular/platform-browser-dynamic": "~12.2.0",
|
"@angular/platform-browser-dynamic": "~12.2.0",
|
||||||
"@angular/router": "~12.2.0",
|
"@angular/router": "~12.2.0",
|
||||||
|
"@types/uuid": "^8.3.4",
|
||||||
"ngx-cookie-service": "^12.0.3",
|
"ngx-cookie-service": "^12.0.3",
|
||||||
"rxjs": "~6.6.0",
|
"rxjs": "~6.6.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
|
"uuid": "^8.3.2",
|
||||||
"zone.js": "~0.11.4"
|
"zone.js": "~0.11.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -2573,6 +2575,11 @@
|
|||||||
"integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==",
|
"integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/uuid": {
|
||||||
|
"version": "8.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz",
|
||||||
|
"integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw=="
|
||||||
|
},
|
||||||
"node_modules/@types/webpack-sources": {
|
"node_modules/@types/webpack-sources": {
|
||||||
"version": "0.1.9",
|
"version": "0.1.9",
|
||||||
"resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-0.1.9.tgz",
|
"resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-0.1.9.tgz",
|
||||||
@@ -14882,7 +14889,6 @@
|
|||||||
"version": "8.3.2",
|
"version": "8.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
"dev": true,
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"uuid": "dist/bin/uuid"
|
"uuid": "dist/bin/uuid"
|
||||||
}
|
}
|
||||||
@@ -17916,6 +17922,11 @@
|
|||||||
"integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==",
|
"integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/uuid": {
|
||||||
|
"version": "8.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz",
|
||||||
|
"integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw=="
|
||||||
|
},
|
||||||
"@types/webpack-sources": {
|
"@types/webpack-sources": {
|
||||||
"version": "0.1.9",
|
"version": "0.1.9",
|
||||||
"resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-0.1.9.tgz",
|
"resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-0.1.9.tgz",
|
||||||
@@ -27377,8 +27388,7 @@
|
|||||||
"uuid": {
|
"uuid": {
|
||||||
"version": "8.3.2",
|
"version": "8.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"validate-npm-package-name": {
|
"validate-npm-package-name": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
|
|||||||
@@ -20,9 +20,11 @@
|
|||||||
"@angular/platform-browser": "~12.2.0",
|
"@angular/platform-browser": "~12.2.0",
|
||||||
"@angular/platform-browser-dynamic": "~12.2.0",
|
"@angular/platform-browser-dynamic": "~12.2.0",
|
||||||
"@angular/router": "~12.2.0",
|
"@angular/router": "~12.2.0",
|
||||||
|
"@types/uuid": "^8.3.4",
|
||||||
"ngx-cookie-service": "^12.0.3",
|
"ngx-cookie-service": "^12.0.3",
|
||||||
"rxjs": "~6.6.0",
|
"rxjs": "~6.6.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
|
"uuid": "^8.3.2",
|
||||||
"zone.js": "~0.11.4"
|
"zone.js": "~0.11.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ const routes: Routes = [
|
|||||||
imports: [RouterModule.forRoot(routes)],
|
imports: [RouterModule.forRoot(routes)],
|
||||||
exports: [RouterModule]
|
exports: [RouterModule]
|
||||||
})
|
})
|
||||||
export class AppRoutingModule { }
|
export class AppRoutingModule {}
|
||||||
|
|||||||
@@ -1,32 +1,52 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { APP_INITIALIZER, NgModule } from '@angular/core';
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { CookieService } from 'ngx-cookie-service';
|
import { CookieService } from 'ngx-cookie-service';
|
||||||
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { MainPageComponent } from './main-page/main-page.component';
|
import { MainPageComponent } from './main-page/main-page.component';
|
||||||
import { AddTaskComponent } from './add-task/add-task.component';
|
import { AddTaskComponent } from './add-task/add-task.component';
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import {MatIconModule} from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import {MatInputModule} from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
|
import { MatDialogModule } from '@angular/material/dialog';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||||
import { DisplayTaskComponent } from './display-task/display-task.component';
|
import { DisplayTaskComponent } from './display-task/display-task.component';
|
||||||
|
import { TaskListsComponent } from './task-lists/task-lists.component';
|
||||||
|
import { AddNewListComponent } from './task-lists/add-new-list/add-new-list.component';
|
||||||
|
import { initTaskListService, TaskListService } from './core/service/task-list.service';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
MainPageComponent,
|
MainPageComponent,
|
||||||
AddTaskComponent,
|
AddTaskComponent,
|
||||||
DisplayTaskComponent
|
DisplayTaskComponent,
|
||||||
|
TaskListsComponent,
|
||||||
|
AddNewListComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
|
FormsModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
MatIconModule,
|
MatIconModule,
|
||||||
MatInputModule
|
MatInputModule,
|
||||||
|
MatDialogModule,
|
||||||
|
MatButtonModule,
|
||||||
|
MatSnackBarModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
CookieService,
|
CookieService,
|
||||||
|
{
|
||||||
|
provide: APP_INITIALIZER,
|
||||||
|
useFactory: initTaskListService,
|
||||||
|
deps: [TaskListService],
|
||||||
|
multi: true
|
||||||
|
}
|
||||||
],
|
],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,4 +2,6 @@ export interface Task {
|
|||||||
title: string;
|
title: string;
|
||||||
creationDate: Date;
|
creationDate: Date;
|
||||||
description: string;
|
description: string;
|
||||||
|
subtasks: Task[];
|
||||||
|
isAsync: boolean;
|
||||||
}
|
}
|
||||||
9
src/app/core/entity/taskList.ts
Normal file
9
src/app/core/entity/taskList.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { Task } from "./task";
|
||||||
|
|
||||||
|
export interface TaskList {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
tasks: Task[],
|
||||||
|
achievedTasks: Task[];
|
||||||
|
abandonnedTasks: Task[];
|
||||||
|
}
|
||||||
16
src/app/core/service/task-list.service.spec.ts
Normal file
16
src/app/core/service/task-list.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { TaskListService } from './task-list.service';
|
||||||
|
|
||||||
|
describe('TaskListService', () => {
|
||||||
|
let service: TaskListService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(TaskListService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
35
src/app/core/service/task-list.service.ts
Normal file
35
src/app/core/service/task-list.service.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
|
import { TaskList } from '../entity/taskList';
|
||||||
|
import { TaskPersistenceService } from './task-persistence.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class TaskListService {
|
||||||
|
private _taskListsSubject: BehaviorSubject<TaskList[]> = new BehaviorSubject<TaskList[]>([]);
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private _taskPersistenceService: TaskPersistenceService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
init(): void {
|
||||||
|
const taskLists = this._taskPersistenceService.getAll();
|
||||||
|
this._taskListsSubject.next(taskLists);
|
||||||
|
}
|
||||||
|
|
||||||
|
add(taskList: TaskList): void {
|
||||||
|
const taskLists = this._taskPersistenceService.getAll();
|
||||||
|
taskLists.push(taskList);
|
||||||
|
this._taskPersistenceService.save(taskLists);
|
||||||
|
this._taskListsSubject.next(taskLists);
|
||||||
|
}
|
||||||
|
|
||||||
|
get taskLists$(): Observable<TaskList[]> {
|
||||||
|
return this._taskListsSubject.asObservable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function initTaskListService(taskListService: TaskListService) {
|
||||||
|
return () => taskListService.init();
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CookieService } from 'ngx-cookie-service';
|
import { CookieService } from 'ngx-cookie-service';
|
||||||
import { Task } from '../entity/task';
|
import { Task } from '../entity/task';
|
||||||
|
import { TaskList } from '../entity/taskList';
|
||||||
|
|
||||||
const COOKIE_NAME = 'todo-data';
|
const COOKIE_NAME = 'todo-data';
|
||||||
|
|
||||||
@@ -12,17 +13,17 @@ export class TaskPersistenceService {
|
|||||||
private _cookieService: CookieService
|
private _cookieService: CookieService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
save(tasks: Task[]): void {
|
save(taskLists: TaskList[]): void {
|
||||||
this._cookieService.set(COOKIE_NAME, JSON.stringify(tasks));
|
this._cookieService.set(COOKIE_NAME, JSON.stringify(taskLists));
|
||||||
}
|
}
|
||||||
|
|
||||||
getAll(): Task[] {
|
getAll(): TaskList[] {
|
||||||
const serializedTasks = this._cookieService.get(COOKIE_NAME);
|
const serializedTaskLists = this._cookieService.get(COOKIE_NAME);
|
||||||
let result: Task[] = [];
|
let result: TaskList[] = [];
|
||||||
try {
|
try {
|
||||||
result = JSON.parse(serializedTasks);
|
result = JSON.parse(serializedTaskLists);
|
||||||
} catch(jsonParseError) {
|
} catch(jsonParseError) {
|
||||||
console.log(`Unable to parse tasks from cookie: ${serializedTasks}`);
|
console.log(`Unable to parse task lists from cookie: ${serializedTaskLists}`);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ export class TaskService {
|
|||||||
constructor(
|
constructor(
|
||||||
private _taskPersistenceService: TaskPersistenceService
|
private _taskPersistenceService: TaskPersistenceService
|
||||||
) {
|
) {
|
||||||
const tasks = this._taskPersistenceService.getAll() || [];
|
const taskLists = this._taskPersistenceService.getAll() || [];
|
||||||
this._tasks.next(tasks);
|
// this._tasks.next(taskLists);
|
||||||
}
|
}
|
||||||
|
|
||||||
get tasks(): Observable<Task[]> {
|
get tasks(): Observable<Task[]> {
|
||||||
@@ -28,11 +28,11 @@ export class TaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _saveTasks(): void {
|
private _saveTasks(): void {
|
||||||
this._taskPersistenceService.save(this._tasks.value);
|
// this._taskPersistenceService.save(this._tasks.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
const tasks = this._taskPersistenceService.getAll();
|
const tasks = this._taskPersistenceService.getAll();
|
||||||
this._tasks.next(tasks);
|
// this._tasks.next(tasks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<div class="component">
|
<!-- <div class="component">
|
||||||
<h1>Todo List</h1>
|
<h1>Todo List</h1>
|
||||||
<app-display-task *ngFor="let task of tasks" [task]="task"></app-display-task>
|
<app-display-task *ngFor="let task of tasks" [task]="task"></app-display-task>
|
||||||
<div id="add-task-btn" *ngIf="!isAddingATask" (click)="createTask()">
|
<div id="add-task-btn" *ngIf="!isAddingATask" (click)="createTask()">
|
||||||
<mat-icon>add</mat-icon>
|
<mat-icon>add</mat-icon>
|
||||||
<span>Ajouter une nouvelle tâche...</span>
|
<span>Ajouter une nouvelle tâche...</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
|
<app-task-lists></app-task-lists>
|
||||||
22
src/app/task-lists/add-new-list/add-new-list.component.html
Normal file
22
src/app/task-lists/add-new-list/add-new-list.component.html
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<h1>Création d'une liste de tâches</h1>
|
||||||
|
<form [formGroup]="taskListForm" (ngSubmit)="onSubmit()" ngNativeValidate>
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>Nom de la liste</mat-label>
|
||||||
|
<input matInput formControlName="name" required>
|
||||||
|
<mat-error *ngIf="!taskListForm.controls.name.valid">
|
||||||
|
Veuillez saisir le nom de la liste.
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
<div class="actions">
|
||||||
|
<button mat-raised-button
|
||||||
|
type="button"
|
||||||
|
(click)="close()">
|
||||||
|
Annuler
|
||||||
|
</button>
|
||||||
|
<button mat-raised-button
|
||||||
|
type="submit"
|
||||||
|
color="primary">
|
||||||
|
Créer une liste
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
16
src/app/task-lists/add-new-list/add-new-list.component.scss
Normal file
16
src/app/task-lists/add-new-list/add-new-list.component.scss
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
form {
|
||||||
|
width: 20rem;
|
||||||
|
|
||||||
|
mat-form-field {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/app/task-lists/add-new-list/add-new-list.component.ts
Normal file
42
src/app/task-lists/add-new-list/add-new-list.component.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
|
import { MatDialogRef } from '@angular/material/dialog';
|
||||||
|
import { TaskList } from 'src/app/core/entity/taskList';
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-add-new-list',
|
||||||
|
templateUrl: './add-new-list.component.html',
|
||||||
|
styleUrls: ['./add-new-list.component.scss']
|
||||||
|
})
|
||||||
|
export class AddNewListComponent {
|
||||||
|
taskListForm: FormGroup;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private _dialogRef: MatDialogRef<AddNewListComponent>,
|
||||||
|
private _formBuilder: FormBuilder
|
||||||
|
) {
|
||||||
|
this.taskListForm = this._formBuilder.group(
|
||||||
|
{
|
||||||
|
name: [undefined, Validators.required]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit(): void {
|
||||||
|
if (this.taskListForm.valid) {
|
||||||
|
const newList = {
|
||||||
|
id: uuidv4(),
|
||||||
|
name: this.taskListForm.controls.name.value,
|
||||||
|
tasks: [],
|
||||||
|
achievedTasks: [],
|
||||||
|
abandonnedTasks: []
|
||||||
|
} as TaskList;
|
||||||
|
this._dialogRef.close(newList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(): void {
|
||||||
|
this._dialogRef.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/app/task-lists/task-lists.component.html
Normal file
14
src/app/task-lists/task-lists.component.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<button mat-raised-button (click)="addNewList()">Nouvelle liste</button>
|
||||||
|
<div class="task-list-container">
|
||||||
|
<div *ngFor="let list of taskLists$ | async" class="task-list">
|
||||||
|
<div class="card">
|
||||||
|
<span *ngIf="list?.tasks?.length">
|
||||||
|
{{list?.tasks?.length}} tâches
|
||||||
|
</span>
|
||||||
|
<span *ngIf="!list?.tasks?.length">
|
||||||
|
Aucune tâche
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<h3>{{list?.name}}</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
23
src/app/task-lists/task-lists.component.scss
Normal file
23
src/app/task-lists/task-lists.component.scss
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
.task-list-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
.task-list {
|
||||||
|
width: 10rem;
|
||||||
|
margin: 1rem;
|
||||||
|
|
||||||
|
.card {
|
||||||
|
height: 10rem;
|
||||||
|
border: 1px solid black;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
border-radius: .3rem;
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/app/task-lists/task-lists.component.ts
Normal file
32
src/app/task-lists/task-lists.component.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { Observable, Subscription } from 'rxjs';
|
||||||
|
import { TaskList } from '../core/entity/taskList';
|
||||||
|
import { TaskListService } from '../core/service/task-list.service';
|
||||||
|
import { AddNewListComponent } from './add-new-list/add-new-list.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-task-lists',
|
||||||
|
templateUrl: './task-lists.component.html',
|
||||||
|
styleUrls: ['./task-lists.component.scss']
|
||||||
|
})
|
||||||
|
export class TaskListsComponent implements OnInit {
|
||||||
|
taskLists$?: Observable<TaskList[]>;
|
||||||
|
private _taskListsSubscription?: Subscription;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private _dialog: MatDialog,
|
||||||
|
private _taskListService: TaskListService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.taskLists$ = this._taskListService.taskLists$;
|
||||||
|
}
|
||||||
|
|
||||||
|
addNewList(): void {
|
||||||
|
const dialogRef = this._dialog.open(AddNewListComponent);
|
||||||
|
dialogRef.afterClosed().subscribe(newList => {
|
||||||
|
this._taskListService.add(newList);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user