Compare commits
13 Commits
1037d74620
...
feature/ta
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ebb1560ae | |||
| e845bfb27f | |||
| 863caeccf3 | |||
| 9b56dddab9 | |||
| ba11f17531 | |||
| a08f92c84c | |||
| c027357cfe | |||
| 0fbc8b1392 | |||
| 54108bc7e5 | |||
| 6de8a4f0fa | |||
| 7283e4f1aa | |||
| 8d3b7fa1c4 | |||
| b8e4d34456 |
@@ -24,7 +24,7 @@
|
|||||||
padding: 0 3rem;
|
padding: 0 3rem;
|
||||||
border-radius: .1rem;
|
border-radius: .1rem;
|
||||||
border-style: none;
|
border-style: none;
|
||||||
background-color: #444;
|
background-color: var(--secondary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<button class="raised" matRipple matTooltip="Définir une alerte dans X minutes">
|
<button class="stroked secondary" [disabled]="true" matRipple matTooltip="Définir une alerte dans X minutes">
|
||||||
<mat-icon>update</mat-icon>
|
<mat-icon>update</mat-icon>
|
||||||
Rappel
|
Rappel
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<button class="raised alert" [disabled]="!task" (click)="delete()">
|
<button class="stroked alert" [disabled]="!task" (click)="delete()">
|
||||||
<mat-icon>delete</mat-icon>
|
<mat-icon>delete</mat-icon>
|
||||||
Supprimer
|
Supprimer
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: .5rem;
|
margin-bottom: .5rem;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background-color: #444;
|
background-color: var(--secondary);
|
||||||
|
border-radius: .2rem;
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
border-radius: .1rem;
|
|
||||||
height: 2.5rem;
|
height: 2.5rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -21,10 +21,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mat-checkbox {
|
|
||||||
// padding: 0 .5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-container {
|
.input-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
@@ -34,7 +30,7 @@
|
|||||||
height: 1.8rem;
|
height: 1.8rem;
|
||||||
padding: 0 .8rem;
|
padding: 0 .8rem;
|
||||||
margin: 0 .8rem;
|
margin: 0 .8rem;
|
||||||
background-color: #444;
|
background-color: inherit;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-width: .1rem;
|
border-width: .1rem;
|
||||||
border-color: rgba(0,0,0, 0);
|
border-color: rgba(0,0,0, 0);
|
||||||
@@ -46,7 +42,7 @@
|
|||||||
border-color .2s ease-out;
|
border-color .2s ease-out;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
border-color: rgb(53, 53, 53);
|
border-color: var(--secondary-border);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,6 +57,7 @@
|
|||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
transition: height .1s ease-in-out;
|
transition: height .1s ease-in-out;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
border-top: .1rem solid var(--primary-border);
|
||||||
|
|
||||||
&.expanded {
|
&.expanded {
|
||||||
height: 20rem;
|
height: 20rem;
|
||||||
@@ -82,10 +79,11 @@
|
|||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
border: 1px solid #444;
|
border: 1px solid var(--secondary-border);
|
||||||
border-radius: .2rem;
|
border-radius: .2rem;
|
||||||
background-color: #4a4a4a;
|
background-color: #ddd;
|
||||||
resize: none;
|
resize: none;
|
||||||
|
padding: .5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,28 +92,27 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
max-width: 20%;
|
max-width: 20%;
|
||||||
|
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
padding: .5rem 1rem;
|
padding: .5rem 0 .5rem 1rem;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
justify-content: left;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
|
||||||
|
mat-icon {
|
||||||
|
margin-right: .5rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
input, textarea, mat-icon, check-box {
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
|
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
|
||||||
import { FormControl } from '@angular/forms';
|
import { FormControl } from '@angular/forms';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
|
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
|
||||||
|
import { ConfirmDialogComponent, ConfirmDialogModel } from 'src/app/core/components/confirm-dialog/confirm-dialog.component';
|
||||||
import { Task } from 'src/app/core/entity/task';
|
import { Task } from 'src/app/core/entity/task';
|
||||||
import { TaskListService } from 'src/app/core/service/task-list.service';
|
import { TaskListService } from 'src/app/core/service/task-list.service';
|
||||||
|
|
||||||
@@ -21,6 +23,7 @@ export class TaskDisplayComponent implements AfterViewInit, OnDestroy {
|
|||||||
private _subscriptions: Subscription[] = [];
|
private _subscriptions: Subscription[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private _dialog: MatDialog,
|
||||||
private _taskListService: TaskListService
|
private _taskListService: TaskListService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@@ -74,7 +77,27 @@ export class TaskDisplayComponent implements AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
delete(): void {
|
delete(): void {
|
||||||
if (this.task) {
|
if (this.task) {
|
||||||
this._taskListService.delete(this.task);
|
const confirmData = {
|
||||||
|
title: `Supprimer la tâche ${this.task.title} ?`,
|
||||||
|
description: 'Une fois supprimé, sa description sera perdue définitivement.',
|
||||||
|
confirmButtonLabel: 'Supprimer la tâche',
|
||||||
|
confirmButtonType: 'alert'
|
||||||
|
} as ConfirmDialogModel;
|
||||||
|
|
||||||
|
const dialogRef = this._dialog.open(
|
||||||
|
ConfirmDialogComponent,
|
||||||
|
{
|
||||||
|
width: '30rem',
|
||||||
|
data: confirmData
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const afterDialogCloseSubscription = dialogRef.afterClosed().subscribe(result => {
|
||||||
|
if (result && this.task) {
|
||||||
|
this._taskListService.delete(this.task);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this._subscriptions.push(afterDialogCloseSubscription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import { TaskListService } from './core/service/task-list.service';
|
|||||||
import { StorePersistenceService } from './core/service/store-persistence.service';
|
import { StorePersistenceService } from './core/service/store-persistence.service';
|
||||||
import {MatTooltipModule} from '@angular/material/tooltip';
|
import {MatTooltipModule} from '@angular/material/tooltip';
|
||||||
import {MatRippleModule} from '@angular/material/core';
|
import {MatRippleModule} from '@angular/material/core';
|
||||||
|
import { RenameTaskListComponent } from './task-lists/rename-task-list/rename-task-list.component';
|
||||||
|
import { ConfirmDialogComponent } from './core/components/confirm-dialog/confirm-dialog.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@@ -35,7 +37,9 @@ import {MatRippleModule} from '@angular/material/core';
|
|||||||
AddTaskListComponent,
|
AddTaskListComponent,
|
||||||
HeaderComponent,
|
HeaderComponent,
|
||||||
ActiveListTasksComponent,
|
ActiveListTasksComponent,
|
||||||
TaskDisplayComponent
|
TaskDisplayComponent,
|
||||||
|
RenameTaskListComponent,
|
||||||
|
ConfirmDialogComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<div class="container">
|
||||||
|
<div class="body">
|
||||||
|
<mat-icon>help_outline</mat-icon>
|
||||||
|
<div class="message">
|
||||||
|
<div class="title">{{data.title}}</div>
|
||||||
|
<div class="description">{{data.description}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="dialog-actions">
|
||||||
|
<button class="stroked" (click)="cancel()">Annuler</button>
|
||||||
|
<button class="stroked"
|
||||||
|
(click)="confirm()"
|
||||||
|
[ngClass]="data.confirmButtonType">
|
||||||
|
{{data.confirmButtonLabel}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
.container {
|
||||||
|
.body {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-grow: 1;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
mat-icon {
|
||||||
|
$iconSize: 4rem;
|
||||||
|
font-size: $iconSize;
|
||||||
|
width: $iconSize;
|
||||||
|
height: $iconSize;
|
||||||
|
margin: 0 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message {
|
||||||
|
.title {
|
||||||
|
display: flex;
|
||||||
|
flex-grow: 1;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
display: flex;
|
||||||
|
flex-grow: 1;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { TaskDisplayComponent } from './task-display.component';
|
import { ConfirmDialogComponent } from './confirm-dialog.component';
|
||||||
|
|
||||||
describe('TaskDisplayComponent', () => {
|
describe('ConfirmDialogComponent', () => {
|
||||||
let component: TaskDisplayComponent;
|
let component: ConfirmDialogComponent;
|
||||||
let fixture: ComponentFixture<TaskDisplayComponent>;
|
let fixture: ComponentFixture<ConfirmDialogComponent>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ TaskDisplayComponent ]
|
declarations: [ ConfirmDialogComponent ]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(TaskDisplayComponent);
|
fixture = TestBed.createComponent(ConfirmDialogComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { Component, Inject } from '@angular/core';
|
||||||
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
|
|
||||||
|
export interface ConfirmDialogModel {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
confirmButtonLabel: string;
|
||||||
|
confirmButtonType: '' | 'alert';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-confirm-dialog',
|
||||||
|
templateUrl: './confirm-dialog.component.html',
|
||||||
|
styleUrls: ['./confirm-dialog.component.scss']
|
||||||
|
})
|
||||||
|
export class ConfirmDialogComponent {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogModel,
|
||||||
|
private _dialogRef: MatDialogRef<ConfirmDialogModel>
|
||||||
|
) {}
|
||||||
|
|
||||||
|
cancel(): void {
|
||||||
|
this._dialogRef.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
confirm(): void {
|
||||||
|
this._dialogRef.close(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,24 +1,35 @@
|
|||||||
<nav *ngIf="!selectionMode">
|
<nav *ngIf="!selectionMode">
|
||||||
<span class="title">
|
<div class="left">
|
||||||
<img src="../../assets/images/to-do.png" />
|
<span class="title">
|
||||||
To Do
|
<img src="../../assets/images/to-do.png" />
|
||||||
</span>
|
To Do
|
||||||
<button *ngIf="!activeTaskList"
|
</span>
|
||||||
(click)="openNewListForm()"
|
<button *ngIf="!activeTaskList"
|
||||||
class="raised"
|
(click)="openNewListForm()"
|
||||||
matRipple>
|
class="stroked primary"
|
||||||
Nouvelle liste
|
matRipple>
|
||||||
</button>
|
Nouvelle liste
|
||||||
<button *ngIf="activeTaskList"
|
</button>
|
||||||
(click)="goTaskListsPane()"
|
<button *ngIf="activeTaskList"
|
||||||
class="icon raised"
|
(click)="goTaskListsPane()"
|
||||||
matRipple
|
class="icon stroked primary"
|
||||||
matTooltip="Retourner aux task-lists">
|
matRipple
|
||||||
<mat-icon>chevron_left</mat-icon>
|
matTooltip="Retourner aux task-lists">
|
||||||
</button>
|
<mat-icon>chevron_left</mat-icon>
|
||||||
<!-- <div *ngIf="activeTaskList">
|
</button>
|
||||||
Liste active : {{activeTaskList.name}}
|
</div>
|
||||||
</div> -->
|
<div class="middle" *ngIf="activeTaskList">
|
||||||
|
{{activeTaskList.name}}
|
||||||
|
</div>
|
||||||
|
<div class="right">
|
||||||
|
<button class="icon stroked primary"
|
||||||
|
(click)="enableSelectionMode()"
|
||||||
|
[disabled]="isNoAnyTaskList()"
|
||||||
|
matTooltip="Activer la sélection des task-lists"
|
||||||
|
matTooltipPosition="left">
|
||||||
|
<mat-icon>checklist_rtl</mat-icon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<nav *ngIf="selectionMode" class="selectionMode">
|
<nav *ngIf="selectionMode" class="selectionMode">
|
||||||
<div></div>
|
<div></div>
|
||||||
@@ -26,6 +37,6 @@
|
|||||||
Cliquez sur une liste pour la sélectionner
|
Cliquez sur une liste pour la sélectionner
|
||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button mat-raised-button (click)="disableSelectionMode()">Annuler</button>
|
<button class="stroked primary" (click)="disableSelectionMode()">Annuler</button>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -6,11 +6,36 @@ nav {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 3.2rem;
|
height: 3.2rem;
|
||||||
background-color: #666;
|
background-color: #eee;
|
||||||
|
|
||||||
|
.left {
|
||||||
|
position: absolute;
|
||||||
|
left: 1rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-right: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.middle {
|
||||||
|
display: flex;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
position: absolute;
|
||||||
|
right: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
&.selectionMode {
|
&.selectionMode {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
background-color: #185eb4;
|
background-color: var(--selection);
|
||||||
color: white;
|
color: white;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -21,11 +46,4 @@ nav {
|
|||||||
margin: 0 1rem;
|
margin: 0 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
margin: 0 1rem;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -13,18 +13,15 @@ import { TaskListService } from '../../service/task-list.service';
|
|||||||
})
|
})
|
||||||
export class HeaderComponent implements OnInit, OnDestroy {
|
export class HeaderComponent implements OnInit, OnDestroy {
|
||||||
private _storeSubscription?: Subscription;
|
private _storeSubscription?: Subscription;
|
||||||
activeTaskList?: TaskList;
|
|
||||||
selectionMode = false;
|
selectionMode = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _dialog: MatDialog,
|
private _dialog: MatDialog,
|
||||||
private _router: Router,
|
|
||||||
private _taskListService: TaskListService
|
private _taskListService: TaskListService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this._storeSubscription = this._taskListService.store$.subscribe(store => {
|
this._storeSubscription = this._taskListService.store$.subscribe(store => {
|
||||||
this.activeTaskList = store.taskLists.find(taskList => store.activeTaskListId === taskList.id);
|
|
||||||
this.selectionMode = store.selectionMode;
|
this.selectionMode = store.selectionMode;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -34,14 +31,31 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openNewListForm(): void {
|
openNewListForm(): void {
|
||||||
this._dialog.open(AddTaskListComponent);
|
this._dialog.open(
|
||||||
|
AddTaskListComponent,
|
||||||
|
{
|
||||||
|
width: '20rem'
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
goTaskListsPane(): void {
|
goTaskListsPane(): void {
|
||||||
this._taskListService.removeActiveTaskList();
|
this._taskListService.removeActiveTaskList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enableSelectionMode(): void {
|
||||||
|
this._taskListService.enableSelectionMode();
|
||||||
|
}
|
||||||
|
|
||||||
disableSelectionMode(): void {
|
disableSelectionMode(): void {
|
||||||
this._taskListService.disableSelectionMode();
|
this._taskListService.disableSelectionMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isNoAnyTaskList(): boolean {
|
||||||
|
return this._taskListService.isNoAnyTaskList();
|
||||||
|
}
|
||||||
|
|
||||||
|
get activeTaskList(): TaskList | undefined {
|
||||||
|
return this._taskListService.activeTaskList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,172 +7,217 @@ import { v4 as uuidv4 } from 'uuid';
|
|||||||
import { filter } from 'rxjs/operators';
|
import { filter } from 'rxjs/operators';
|
||||||
import { Store } from "../entity/store";
|
import { Store } from "../entity/store";
|
||||||
import { Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
|
import { MatSnackBar } from "@angular/material/snack-bar";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class TaskListService {
|
export class TaskListService {
|
||||||
private _store: BehaviorSubject<Store> = new BehaviorSubject<Store>(undefined as unknown as Store);
|
private _store: BehaviorSubject<Store> = new BehaviorSubject<Store>(undefined as unknown as Store);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _router: Router,
|
private _router: Router,
|
||||||
private _storePersistenceService: StorePersistenceService
|
private _snackBar: MatSnackBar,
|
||||||
) {
|
private _storePersistenceService: StorePersistenceService
|
||||||
this.store$.subscribe(store => {
|
) {
|
||||||
this.saveStore(store, true);
|
this.store$.subscribe(store => {
|
||||||
});
|
this.saveStore(store, true);
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
get store$(): Observable<Store> {
|
get store$(): Observable<Store> {
|
||||||
return this._store.asObservable()
|
return this._store.asObservable()
|
||||||
.pipe(filter(store => !!store));
|
.pipe(filter(store => !!store));
|
||||||
}
|
}
|
||||||
|
|
||||||
private get store(): Store {
|
private get store(): Store {
|
||||||
return this._storePersistenceService.load();
|
let result = this._store.value;
|
||||||
}
|
|
||||||
|
|
||||||
private saveStore(store: Store, silent: boolean = false): void {
|
if (!result) {
|
||||||
if (silent) {
|
result = this._storePersistenceService.load();
|
||||||
this._storePersistenceService.save(store);
|
}
|
||||||
} else {
|
return result;
|
||||||
// We send the store into the subject because there is an observable on in, that saves the store at every single value.
|
}
|
||||||
this._store.next(store);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addTask(taskTitle: string): void {
|
private saveStore(store: Store, silent: boolean = false): void {
|
||||||
const store = this.store;
|
if (silent) {
|
||||||
const activeTaskList = store.taskLists.find(taskList => taskList.id === store.activeTaskListId);
|
this._storePersistenceService.save(store);
|
||||||
if (!activeTaskList) {
|
} else {
|
||||||
throw new Error("No active tasklist");
|
// We send the store into the subject because there is an observable on in, that saves the store at every single value.
|
||||||
}
|
this._store.next(store);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!activeTaskList.tasks) {
|
addTask(taskTitle: string): void {
|
||||||
activeTaskList.tasks = [];
|
const store = this.store;
|
||||||
}
|
const activeTaskList = store.taskLists.find(taskList => taskList.id === store.activeTaskListId);
|
||||||
|
if (!activeTaskList) {
|
||||||
|
throw new Error("No active tasklist");
|
||||||
|
}
|
||||||
|
|
||||||
const newTask = {
|
if (!activeTaskList.tasks) {
|
||||||
id: uuidv4(),
|
activeTaskList.tasks = [];
|
||||||
title: taskTitle,
|
}
|
||||||
creationDate: new Date(),
|
|
||||||
description: undefined as unknown as string
|
const newTask = {
|
||||||
} as Task;
|
id: uuidv4(),
|
||||||
|
title: taskTitle,
|
||||||
|
creationDate: new Date(),
|
||||||
|
description: undefined as unknown as string
|
||||||
|
} as Task;
|
||||||
|
|
||||||
|
|
||||||
activeTaskList?.tasks.push(newTask);
|
activeTaskList?.tasks.push(newTask);
|
||||||
this.saveStore(store);
|
this.saveStore(store);
|
||||||
}
|
this._snackBar.open('Tâche ajoutée.', 'Fermer', {duration: 2000});
|
||||||
|
}
|
||||||
|
|
||||||
updateTask(taskToUpdate: Task) {
|
updateTask(taskToUpdate: Task) {
|
||||||
const store = this.store;
|
const store = this.store;
|
||||||
const activeTaskList = store.taskLists.find(taskList => taskList.id === store.activeTaskListId);
|
const activeTaskList = store.taskLists.find(taskList => taskList.id === store.activeTaskListId);
|
||||||
if (!activeTaskList) {
|
if (!activeTaskList) {
|
||||||
throw new Error("No active tasklist");
|
throw new Error("No active tasklist");
|
||||||
}
|
}
|
||||||
|
|
||||||
const task = activeTaskList?.tasks.find(task => task.id === taskToUpdate.id);
|
const task = activeTaskList?.tasks.find(task => task.id === taskToUpdate.id);
|
||||||
if (!task) {
|
if (!task) {
|
||||||
throw new Error('Unknown task to update');
|
throw new Error('Unknown task to update');
|
||||||
}
|
}
|
||||||
|
|
||||||
task.title = taskToUpdate.title;
|
task.title = taskToUpdate.title;
|
||||||
task.description = taskToUpdate.description;
|
task.description = taskToUpdate.description;
|
||||||
|
|
||||||
// If the store is saved loudly, all views will be refreshed and the user will lose the focus of its input,
|
// If the store is saved loudly, all views will be refreshed and the user will lose the focus of its input,
|
||||||
// so we save the store silently here.
|
// so we save the store silently here.
|
||||||
this.saveStore(store, true);
|
this.saveStore(store, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(taskToDelete: Task) {
|
delete(taskToDelete: Task) {
|
||||||
const store = this.store;
|
const store = this.store;
|
||||||
const activeTaskList = store.taskLists.find(taskList => taskList.id === store.activeTaskListId);
|
const activeTaskList = store.taskLists.find(taskList => taskList.id === store.activeTaskListId);
|
||||||
if (!activeTaskList) {
|
if (!activeTaskList) {
|
||||||
throw new Error("No active tasklist");
|
throw new Error("No active tasklist");
|
||||||
}
|
}
|
||||||
|
|
||||||
const taskIndex = activeTaskList?.tasks.findIndex(task => task.id === taskToDelete.id);
|
const taskIndex = activeTaskList?.tasks.findIndex(task => task.id === taskToDelete.id);
|
||||||
if (!taskIndex && taskIndex !== 0) {
|
if (!taskIndex && taskIndex !== 0) {
|
||||||
throw new Error('Unknown task to delete');
|
throw new Error('Unknown task to delete');
|
||||||
}
|
}
|
||||||
|
|
||||||
activeTaskList?.tasks.splice(taskIndex, 1);
|
activeTaskList?.tasks.splice(taskIndex, 1);
|
||||||
this.saveStore(store);
|
this.saveStore(store);
|
||||||
}
|
this._snackBar.open('Tâche supprimée.', 'Fermer', {duration: 2000});
|
||||||
|
}
|
||||||
|
|
||||||
createTaskList(taskListName: string): void {
|
createTaskList(taskListName: string): void {
|
||||||
const newTaskList = {
|
const newTaskList = {
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
name: taskListName,
|
name: taskListName,
|
||||||
tasks: []
|
tasks: []
|
||||||
} as TaskList;
|
} as TaskList;
|
||||||
|
|
||||||
const store = this.store;
|
const store = this.store;
|
||||||
store.taskLists.push(newTaskList);
|
store.taskLists.push(newTaskList);
|
||||||
this.saveStore(store);
|
this.saveStore(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAll(): TaskList[] {
|
updateTaskListName(taskListToUpdate: TaskList): void {
|
||||||
return this.store.taskLists ?? [];
|
const store = this.store;
|
||||||
}
|
const matchingTaskList = store.taskLists.find(taskList => taskList.id === taskListToUpdate.id);
|
||||||
|
if (matchingTaskList) {
|
||||||
|
matchingTaskList.name = taskListToUpdate.name;
|
||||||
|
this.saveStore(store);
|
||||||
|
this.disableSelectionMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setActive(taskList: TaskList): void {
|
deleteSelectedTaskLists(): void {
|
||||||
const store = this.store;
|
const store = this.store;
|
||||||
store.activeTaskListId = taskList.id;
|
const nonSelectedTaskLists = store.taskLists.filter(taskList => !store.selectedTaskLists.some(selectedTaskList => selectedTaskList.id === taskList.id));
|
||||||
this.saveStore(store);
|
store.taskLists = nonSelectedTaskLists;
|
||||||
this._router.navigate(['/task-lists/active']);
|
this.saveStore(store);
|
||||||
}
|
this.disableSelectionMode();
|
||||||
|
}
|
||||||
|
|
||||||
removeActiveTaskList(): void {
|
getAll(): TaskList[] {
|
||||||
const store = this.store;
|
return this.store.taskLists ?? [];
|
||||||
delete store.activeTaskListId;
|
}
|
||||||
this.saveStore(store);
|
|
||||||
this._router.navigate(['/']);
|
|
||||||
}
|
|
||||||
|
|
||||||
selectTaskList(taskList: TaskList): void {
|
setActive(taskList: TaskList): void {
|
||||||
this.enableSelectionMode();
|
const store = this.store;
|
||||||
|
store.activeTaskListId = taskList.id;
|
||||||
|
this.saveStore(store);
|
||||||
|
this._router.navigate(['/task-lists/active']);
|
||||||
|
}
|
||||||
|
|
||||||
const store = this.store;
|
removeActiveTaskList(): void {
|
||||||
|
const store = this.store;
|
||||||
|
delete store.activeTaskListId;
|
||||||
|
this.saveStore(store);
|
||||||
|
this._router.navigate(['/']);
|
||||||
|
}
|
||||||
|
|
||||||
if (!store.selectedTaskLists) {
|
selectTaskList(taskList: TaskList): void {
|
||||||
store.selectedTaskLists = [];
|
this.enableSelectionMode();
|
||||||
}
|
|
||||||
|
|
||||||
if (store.selectedTaskLists.some(tl => tl.id === taskList.id)) {
|
const store = this.store;
|
||||||
const selectedTaskListIndex = store.selectedTaskLists.findIndex(tl => tl.id === taskList.id);
|
|
||||||
store.selectedTaskLists.splice(selectedTaskListIndex, 1);
|
|
||||||
|
|
||||||
if (!store.selectedTaskLists.length) {
|
if (!store.selectedTaskLists) {
|
||||||
store.selectionMode = false;
|
store.selectedTaskLists = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.saveStore(store);
|
if (store.selectedTaskLists.some(tl => tl.id === taskList.id)) {
|
||||||
} else {
|
const selectedTaskListIndex = store.selectedTaskLists.findIndex(tl => tl.id === taskList.id);
|
||||||
store.selectedTaskLists.push(taskList);
|
store.selectedTaskLists.splice(selectedTaskListIndex, 1);
|
||||||
this.saveStore(store);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isSelected(taskList: TaskList): boolean {
|
if (!store.selectedTaskLists.length) {
|
||||||
const store = this.store;
|
store.selectionMode = false;
|
||||||
return store.selectedTaskLists && store.selectedTaskLists.some(tl => tl.id === taskList.id);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
isSelectionModeEnabled(): boolean {
|
this.saveStore(store);
|
||||||
return this.store.selectionMode;
|
} else {
|
||||||
}
|
store.selectedTaskLists.push(taskList);
|
||||||
|
this.saveStore(store);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enableSelectionMode(): void {
|
isSelected(taskList: TaskList): boolean {
|
||||||
const store = this.store;
|
const store = this.store;
|
||||||
store.selectionMode = true;
|
return store.selectedTaskLists && store.selectedTaskLists.some(tl => tl.id === taskList.id);
|
||||||
this.saveStore(store);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
disableSelectionMode(): void {
|
isSelectionModeEnabled(): boolean {
|
||||||
const store = this.store;
|
return this.store.selectionMode;
|
||||||
store.selectionMode = false;
|
}
|
||||||
store.selectedTaskLists = [];
|
|
||||||
this.saveStore(store);
|
enableSelectionMode(): void {
|
||||||
}
|
const store = this.store;
|
||||||
|
store.selectionMode = true;
|
||||||
|
this.saveStore(store);
|
||||||
|
}
|
||||||
|
|
||||||
|
disableSelectionMode(): void {
|
||||||
|
const store = this.store;
|
||||||
|
store.selectionMode = false;
|
||||||
|
store.selectedTaskLists = [];
|
||||||
|
this.saveStore(store);
|
||||||
|
}
|
||||||
|
|
||||||
|
isThereMultipleTaskListsSelected(): boolean {
|
||||||
|
const store = this.store;
|
||||||
|
return (store.selectedTaskLists?.length ?? 0) > 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
get selectedTaskList(): TaskList {
|
||||||
|
return this._store.value?.selectedTaskLists[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
isNoAnyTaskList(): boolean {
|
||||||
|
return !this.store?.taskLists?.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
get activeTaskList(): TaskList | undefined {
|
||||||
|
const store = this.store;
|
||||||
|
return store.taskLists.find(taskList => taskList.id === store.activeTaskListId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<h2>Création d'une task-list</h2>
|
||||||
<form [formGroup]="addTaskListFormGroup" (submit)="onSubmit()" ngNativeValidate>
|
<form [formGroup]="addTaskListFormGroup" (submit)="onSubmit()" ngNativeValidate>
|
||||||
<p>
|
<p>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
@@ -8,8 +9,8 @@
|
|||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</p>
|
</p>
|
||||||
<div>
|
<div class="dialog-actions">
|
||||||
<button mat-raised-button type="button" (click)="close()">Annuler</button>
|
<button class="stroked primary" type="button" (click)="close()">Annuler</button>
|
||||||
<button mat-raised-button type="submit">Créer une liste</button>
|
<button class="stroked primary" type="submit">Créer une liste</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
form {
|
||||||
|
p {
|
||||||
|
mat-form-field {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<h2>Renommage d'une task-list</h2>
|
||||||
|
<form [formGroup]="renameTaskListFormGroup" (submit)="onSubmit()" ngNativeValidate>
|
||||||
|
<p>
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>Nom de la liste</mat-label>
|
||||||
|
<input matInput autofocus id="task-name-input" name="task-name-input" formControlName="name" />
|
||||||
|
<mat-error *ngIf="form.name.invalid">
|
||||||
|
Veuillez saisir le nom de la task-list.
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</p>
|
||||||
|
<div class="dialog-actions">
|
||||||
|
<button class="stroked" type="button" (click)="close()">Annuler</button>
|
||||||
|
<button class="stroked" type="submit">Renommer la liste</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
form {
|
||||||
|
p {
|
||||||
|
mat-form-field {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
|
import { MatDialogRef } from '@angular/material/dialog';
|
||||||
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
|
import { TaskList } from 'src/app/core/entity/task-list';
|
||||||
|
import { TaskListService } from 'src/app/core/service/task-list.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-rename-task-list',
|
||||||
|
templateUrl: './rename-task-list.component.html',
|
||||||
|
styleUrls: ['./rename-task-list.component.scss']
|
||||||
|
})
|
||||||
|
export class RenameTaskListComponent implements OnInit {
|
||||||
|
renameTaskListFormGroup: FormGroup = this._formBuilder.group({
|
||||||
|
name: [undefined, Validators.required]
|
||||||
|
});
|
||||||
|
|
||||||
|
selectedTaskList?: TaskList;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private _dialogRef: MatDialogRef<RenameTaskListComponent>,
|
||||||
|
private _formBuilder: FormBuilder,
|
||||||
|
private _snackBar: MatSnackBar,
|
||||||
|
private _taskListService: TaskListService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.selectedTaskList = this._taskListService.selectedTaskList;
|
||||||
|
|
||||||
|
if (this.selectedTaskList) {
|
||||||
|
this.renameTaskListFormGroup.controls.name.setValue(this.selectedTaskList.name);
|
||||||
|
} else {
|
||||||
|
this._snackBar.open('Impossible de renommer la task-list : aucune task-list n\'est sélectionnée.', 'Fermer', {duration: 5000});
|
||||||
|
this._dialogRef.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get form(): any {
|
||||||
|
return this.renameTaskListFormGroup.controls;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit(): void {
|
||||||
|
if (this.selectedTaskList) {
|
||||||
|
if (this.renameTaskListFormGroup.valid) {
|
||||||
|
this.selectedTaskList.name = this.renameTaskListFormGroup.controls.name.value;
|
||||||
|
this._taskListService.updateTaskListName(this.selectedTaskList);
|
||||||
|
this._snackBar.open('La task-list a été renommée.', 'Fermer', {duration: 5000});
|
||||||
|
this.close();
|
||||||
|
} else {
|
||||||
|
this._snackBar.open('Veuillez vérifier les informations saisies.', 'Fermer', {duration: 5000});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(): void {
|
||||||
|
this._dialogRef.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
<div class="task-lists">
|
<div class="task-lists">
|
||||||
|
<div *ngIf="!taskLists?.length" class="no-task-list">
|
||||||
|
Aucune task-list.
|
||||||
|
</div>
|
||||||
<div *ngFor="let taskList of taskLists" class="task-list-container">
|
<div *ngFor="let taskList of taskLists" class="task-list-container">
|
||||||
<div class="task-list shadowed"
|
<div class="task-list shadowed"
|
||||||
(click)="selectActiveTaskList(taskList)"
|
(click)="selectActiveTaskList(taskList)"
|
||||||
@@ -15,10 +18,18 @@
|
|||||||
{{taskList.tasks?.length}} tâches
|
{{taskList.tasks?.length}} tâches
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
<mat-icon *ngIf="isSelectionModeEnabled() && isSelected(taskList)" class="selection-icon">done</mat-icon>
|
||||||
</div>
|
</div>
|
||||||
{{taskList.name}}
|
{{taskList.name}}
|
||||||
<ng-container *ngIf="isSelectionModeEnabled() && isSelected(taskList)">
|
|
||||||
SELECTED
|
|
||||||
</ng-container>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="selection-actions" *ngIf="isSelectionModeEnabled()">
|
||||||
|
<button class="stroked"
|
||||||
|
[disabled]="isThereMultipleTaskListsSelected()"
|
||||||
|
(click)="renameSelectedTaskList()">
|
||||||
|
Renommer
|
||||||
|
</button>
|
||||||
|
<button class="stroked alert"
|
||||||
|
(click)="deleteSelectedTaskLists()">Supprimer</button>
|
||||||
|
</div>
|
||||||
@@ -1,3 +1,10 @@
|
|||||||
|
.no-task-list {
|
||||||
|
display: flex;
|
||||||
|
margin: auto;
|
||||||
|
margin-top: 3rem;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.task-lists {
|
.task-lists {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@@ -21,6 +28,28 @@
|
|||||||
border-radius: .5rem;
|
border-radius: .5rem;
|
||||||
background-color: aliceblue;
|
background-color: aliceblue;
|
||||||
margin-bottom: .5rem;
|
margin-bottom: .5rem;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.selection-icon {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
font-size: 3rem;
|
||||||
|
width: 3rem;
|
||||||
|
height: 3rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.selection-actions {
|
||||||
|
padding: .5rem;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-grow: 1;
|
||||||
|
justify-content: space-between;
|
||||||
|
border-top: 1px solid #444;
|
||||||
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
import { Component, NgZone, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
import { ConfirmDialogComponent, ConfirmDialogModel } from '../core/components/confirm-dialog/confirm-dialog.component';
|
||||||
import { TaskList } from '../core/entity/task-list';
|
import { TaskList } from '../core/entity/task-list';
|
||||||
import { TaskListService } from '../core/service/task-list.service';
|
import { TaskListService } from '../core/service/task-list.service';
|
||||||
import { AddTaskListComponent } from './add-task-list/add-task-list.component';
|
import { AddTaskListComponent } from './add-task-list/add-task-list.component';
|
||||||
|
import { RenameTaskListComponent } from './rename-task-list/rename-task-list.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-task-lists',
|
selector: 'app-task-lists',
|
||||||
@@ -13,25 +15,23 @@ import { AddTaskListComponent } from './add-task-list/add-task-list.component';
|
|||||||
export class TaskListsComponent implements OnInit, OnDestroy {
|
export class TaskListsComponent implements OnInit, OnDestroy {
|
||||||
taskLists: TaskList[] = [];
|
taskLists: TaskList[] = [];
|
||||||
private _storeSubscription?: Subscription;
|
private _storeSubscription?: Subscription;
|
||||||
|
private _subscriptions: Subscription[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _dialog: MatDialog,
|
private _dialog: MatDialog,
|
||||||
private _taskListService: TaskListService,
|
private _taskListService: TaskListService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.taskLists = this._taskListService.getAll();
|
this.taskLists = this._taskListService.getAll();
|
||||||
this._storeSubscription = this._taskListService.store$.subscribe(store => {
|
const storeSubscription = this._taskListService.store$.subscribe(store => {
|
||||||
this.taskLists = store.taskLists;
|
this.taskLists = store.taskLists;
|
||||||
});
|
});
|
||||||
|
this._subscriptions.push(storeSubscription);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this._storeSubscription?.unsubscribe();
|
this._subscriptions.forEach(subscription => subscription.unsubscribe());
|
||||||
}
|
|
||||||
|
|
||||||
openNewListForm(): void {
|
|
||||||
this._dialog.open(AddTaskListComponent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
selectActiveTaskList(taskList: TaskList): void {
|
selectActiveTaskList(taskList: TaskList): void {
|
||||||
@@ -53,4 +53,41 @@ export class TaskListsComponent implements OnInit, OnDestroy {
|
|||||||
isSelectionModeEnabled(): boolean {
|
isSelectionModeEnabled(): boolean {
|
||||||
return this._taskListService.isSelectionModeEnabled();
|
return this._taskListService.isSelectionModeEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isThereMultipleTaskListsSelected(): boolean {
|
||||||
|
return this._taskListService.isThereMultipleTaskListsSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
renameSelectedTaskList(): void {
|
||||||
|
this._dialog.open(
|
||||||
|
RenameTaskListComponent,
|
||||||
|
{
|
||||||
|
width: '25rem'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteSelectedTaskLists(): void {
|
||||||
|
const confirmData = {
|
||||||
|
title: 'Supprimer les task-lists sélectionnées ?',
|
||||||
|
description: 'Une fois supprimées, les task-lists seront perdues définitivement.',
|
||||||
|
confirmButtonLabel: 'Supprimer les task-lists',
|
||||||
|
confirmButtonType: 'alert'
|
||||||
|
} as ConfirmDialogModel;
|
||||||
|
|
||||||
|
const dialogRef = this._dialog.open(
|
||||||
|
ConfirmDialogComponent,
|
||||||
|
{
|
||||||
|
width: '30rem',
|
||||||
|
data: confirmData
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const afterDialogCloseSubscription = dialogRef.afterClosed().subscribe(result => {
|
||||||
|
if (result) {
|
||||||
|
this._taskListService.deleteSelectedTaskLists();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this._subscriptions.push(afterDialogCloseSubscription);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
108
src/styles.scss
108
src/styles.scss
@@ -1,23 +1,50 @@
|
|||||||
/* You can add global styles to this file, and also import other style files */
|
/* You can add global styles to this file, and also import other style files */
|
||||||
|
:root {
|
||||||
|
--primary: #fff;
|
||||||
|
--primary-text: #444444;
|
||||||
|
--primary-border: #ccc;
|
||||||
|
--primary-hover: #eee;
|
||||||
|
--secondary: #eee;
|
||||||
|
--secondary-hover: #c9c9c9;
|
||||||
|
--secondary-border: #bbb;
|
||||||
|
|
||||||
|
--disabled: #eee;
|
||||||
|
--disabled-text: #aaa;
|
||||||
|
|
||||||
|
--transparent: rgba(0,0,0, 0);
|
||||||
|
|
||||||
|
--shadow-1: rgba(0, 0, 0, 0.2);
|
||||||
|
--shadow-2: rgba(0, 0, 0, 0.14);
|
||||||
|
--shadow-3: rgba(0, 0, 0, 0.12);
|
||||||
|
--shadow-hover: #777;
|
||||||
|
|
||||||
|
--alert: #eb1d3f;
|
||||||
|
--alert-text: #fff;
|
||||||
|
--alert-hover: #c20d2b;
|
||||||
|
--alert-border: #b91b35;
|
||||||
|
|
||||||
|
--selection: #185eb4;
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
html, body { height: 100%; }
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: Roboto, "Helvetica Neue", sans-serif;
|
font-family: Roboto, "Helvetica Neue", sans-serif;
|
||||||
padding-top: 3.2rem;
|
padding-top: 3.2rem;
|
||||||
background-color: #555;
|
background-color: var(--primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.shadowed {
|
.shadowed {
|
||||||
box-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2),0px 1px 1px 0px rgba(0, 0, 0, 0.14),0px 1px 3px 0px rgba(0, 0, 0, 0.12);
|
box-shadow: 0px 2px 1px -1px var(--shadow-1),
|
||||||
|
0px 1px 1px 0px var(--shadow-2),
|
||||||
|
0px 1px 3px 0px var(--shadow-3);
|
||||||
transition: box-shadow .2s ease-out;
|
transition: box-shadow .2s ease-out;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
box-shadow: 0 .2em .5em #777;
|
box-shadow: 0 .2em .5em var(--shadow-hover);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,24 +53,32 @@ a.no-style {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
button {
|
button {
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-width: .1rem;
|
border-width: .1rem;
|
||||||
border-color: rgba(0,0,0, 0);
|
border-color: var(--transparent);
|
||||||
border-radius: .2rem;
|
border-radius: .2rem;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
padding: .5rem;
|
padding: .5rem;
|
||||||
color: #fff;
|
background-color: var(--transparent);
|
||||||
|
color: var(--primary-text);
|
||||||
|
|
||||||
transition: background-color .2s ease-out,
|
transition: background-color .2s ease-out,
|
||||||
border-color .2s ease-out;
|
border-color .2s ease-out;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: #666;
|
background-color: var(--primary-hover);
|
||||||
border-color: rgb(53, 53, 53);
|
border-color: var(--primary-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
background-color: var(--disabled);
|
||||||
|
color: var(--disabled-text);
|
||||||
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.icon {
|
&.icon {
|
||||||
@@ -52,20 +87,53 @@ button {
|
|||||||
min-width: 1rem;
|
min-width: 1rem;
|
||||||
min-height: 1rem;
|
min-height: 1rem;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
background-color: inherit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.raised {
|
&.raised {
|
||||||
background-color: #4a4a4a;
|
background-color: var(--primary); //#4a4a4a;
|
||||||
|
box-shadow: 0px 2px 1px -1px var(--shadow-1),
|
||||||
|
0px 1px 1px 0px var(--shadow-2),
|
||||||
|
0px 1px 3px 0px var(--shadow-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.stroked {
|
||||||
|
border-color: var(--primary-border);
|
||||||
|
|
||||||
|
&.primary {
|
||||||
|
background-color: var(--primary);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--primary-hover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.secondary {
|
||||||
|
background-color: var(--secondary);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--secondary-hover)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.alert {
|
&.alert {
|
||||||
background: #F93154;
|
background-color: var(--alert);
|
||||||
color: #fff;
|
color: var(--alert-text);
|
||||||
|
|
||||||
:hover {
|
&:hover {
|
||||||
background-color: #f83e5d;
|
background-color: var(--alert-hover);
|
||||||
border-color: #b91b35;
|
border-color: var(--alert-border);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dialog-actions {
|
||||||
|
margin-top: 1rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
> * {
|
||||||
|
flex: 1 1 45%;
|
||||||
|
max-width: 45%;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user