diff --git a/src/app/components/add-task/add-task.component.html b/src/app/components/add-task/add-task.component.html index 8e8c610..c12fa1b 100644 --- a/src/app/components/add-task/add-task.component.html +++ b/src/app/components/add-task/add-task.component.html @@ -1,5 +1,10 @@ -
-
+
+
Add Tasks
diff --git a/src/app/components/add-task/add-task.component.scss b/src/app/components/add-task/add-task.component.scss index 209b81d..0332398 100644 --- a/src/app/components/add-task/add-task.component.scss +++ b/src/app/components/add-task/add-task.component.scss @@ -5,7 +5,6 @@ section { .content { display: flex; - margin-top: 48px; width: 100%; } @@ -53,9 +52,15 @@ p { } } +.d-none { + display: none; + background-color: var(--white); +} + /*------------- HEADER -------------*/ .headline { + margin-bottom: 48px; .title { font-size: 61px; font-weight: 700; @@ -86,6 +91,30 @@ p { } } +.assigned-badget { + display: flex; + margin-top: 6px; + height: 40px; +} + +.circle { + display: flex; + justify-content: center; + align-items: center; + width: 30px; + min-width: 30px; + height: 30px; + border-radius: 100%; + border: 2px solid var(--white); + margin-right: 6px; + .initials { + font-size: 12px; + font-weight: 400; + color: var(--white); + text-shadow: 1px 1px 2px var(--black); + } +} + .subtask { position: relative; .add { @@ -147,30 +176,6 @@ p { } } -.assigned-badget { - display: flex; - margin-top: 6px; - height: 40px; -} - -.circle { - display: flex; - justify-content: center; - align-items: center; - width: 30px; - min-width: 30px; - height: 30px; - border-radius: 100%; - border: 2px solid var(--white); - margin-right: 6px; - .initials { - font-size: 12px; - font-weight: 400; - color: var(--white); - text-shadow: 1px 1px 2px var(--black); - } -} - /*------------- MIDDLE -------------*/ .middle-spacer { diff --git a/src/app/components/add-task/add-task.component.ts b/src/app/components/add-task/add-task.component.ts index 1e6c7c5..4ec4822 100644 --- a/src/app/components/add-task/add-task.component.ts +++ b/src/app/components/add-task/add-task.component.ts @@ -1,5 +1,11 @@ import { CommonModule } from '@angular/common'; -import { Component, ElementRef, HostListener, ViewChild } from '@angular/core'; +import { + Component, + ElementRef, + HostListener, + Input, + ViewChild, +} from '@angular/core'; import { FormsModule, NgForm, NgModel } from '@angular/forms'; import { AssignedComponent } from './assigned/assigned.component'; import { User } from '../../interfaces/user.interface'; @@ -17,6 +23,8 @@ export class AddTaskComponent { @ViewChild('title', { static: true }) titleField!: NgModel; @ViewChild('description', { static: true }) descriptionField!: NgModel; @ViewChild('category', { static: true }) categoryField!: NgModel; + @Input() task: string = ''; + @Input() overlayData: string = ''; currentDate: string = new Date().toISOString().split('T')[0]; dateInPast: boolean = false; @@ -40,6 +48,37 @@ export class AddTaskComponent { date: this.currentDate, }; + ngOnInit() { + if (this.overlayData !== '') { + this.loadEditTaskData(); + } + const storedTaskData = localStorage.getItem('taskData'); + if (storedTaskData) { + this.taskData = JSON.parse(storedTaskData); + } else { + this.saveTaskData(); + } + } + + loadEditTaskData() { + const taskData = this.getTaskData(this.overlayData)[0]; + this.taskData.title = taskData.title; + this.taskData.description = taskData.description; + this.taskData.category = taskData.category; + this.taskData.status = taskData.status; + this.taskData.priority = taskData.priority; + this.taskData.subtasksTitle = taskData.subtasksTitle; + this.taskData.subtasksDone = taskData.subtasksDone; + this.taskData.assigned = taskData.assigned; + this.taskData.date = taskData.date; + } + + getTaskData(taskId: string) { + return this.firebaseService + .getAllTasks() + .filter((task) => task.id === taskId); + } + receiveAssigned(assigned: string[]) { this.taskData.assigned = assigned; } @@ -59,15 +98,6 @@ export class AddTaskComponent { this.saveTaskData(); } - ngOnInit() { - const storedTaskData = localStorage.getItem('taskData'); - if (storedTaskData) { - this.taskData = JSON.parse(storedTaskData); - } else { - this.saveTaskData(); - } - } - updateSearchInput() { if (this.searchValue) { this.searchInput = this.searchValue.toLowerCase().length > 0; diff --git a/src/app/shared/components/overlay/task-edit-overlay/task-edit-overlay.component.html b/src/app/shared/components/overlay/task-edit-overlay/task-edit-overlay.component.html index cae9de9..b490bbf 100644 --- a/src/app/shared/components/overlay/task-edit-overlay/task-edit-overlay.component.html +++ b/src/app/shared/components/overlay/task-edit-overlay/task-edit-overlay.component.html @@ -2,135 +2,7 @@
- -
-
-
-

Title*

- -
- @if (!title.valid && title.touched) { -

You must enter a title.

- } -
-
-
-

Description*

- -
- @if (!description.valid && description.touched) { -

You must enter a description. (min. 10 letters)

- } -
-
-
-

Due date*

- -
- @if (!date.valid && date.touched) { -

You must enter a date.

- } @if (dateInPast && date.valid) { -

The date must be in the future

- } -
-
-
-

Prio

-
- - - -
-
-
-
+
+ +
diff --git a/src/app/shared/components/overlay/task-edit-overlay/task-edit-overlay.component.scss b/src/app/shared/components/overlay/task-edit-overlay/task-edit-overlay.component.scss index f9900fc..afc2ed4 100644 --- a/src/app/shared/components/overlay/task-edit-overlay/task-edit-overlay.component.scss +++ b/src/app/shared/components/overlay/task-edit-overlay/task-edit-overlay.component.scss @@ -1,5 +1,5 @@ section { - width: 525px; + width: 925px; height: 700px; padding: 48px 40px 48px 40px; border-radius: 30px; @@ -9,11 +9,11 @@ section { .header { display: flex; justify-content: right; - margin-bottom: 32px; } .content { - height: calc(700px - 104px); + height: calc(700px - 48px); + padding: 0 6px; overflow-y: auto; } @@ -105,3 +105,47 @@ p { .btn:hover { box-shadow: 2px 2px 2px 0px rgba(0, 0, 0, 0.3); } + +// ASSIGNED + +.assigned { + position: relative; + .open { + position: absolute; + top: 55px; + right: 20px; + width: 14px; + height: 7px; + } + .close { + position: absolute; + top: 45px; + right: 15px; + width: 25px; + height: 25px; + } +} + +.assigned-badget { + display: flex; + margin-top: 6px; + height: 40px; +} + +.circle { + display: flex; + justify-content: center; + align-items: center; + width: 30px; + min-width: 30px; + height: 30px; + border-radius: 100%; + border: 2px solid var(--white); + margin-right: 6px; + .initials { + font-size: 12px; + font-weight: 400; + color: var(--white); + text-shadow: 1px 1px 2px var(--black); + } +} diff --git a/src/app/shared/components/overlay/task-edit-overlay/task-edit-overlay.component.ts b/src/app/shared/components/overlay/task-edit-overlay/task-edit-overlay.component.ts index 38f9967..4c02972 100644 --- a/src/app/shared/components/overlay/task-edit-overlay/task-edit-overlay.component.ts +++ b/src/app/shared/components/overlay/task-edit-overlay/task-edit-overlay.component.ts @@ -5,100 +5,38 @@ import { BtnCloseComponent } from '../../buttons/btn-close/btn-close.component'; import { FormsModule, NgForm } from '@angular/forms'; import { Task } from '../../../../interfaces/task.interface'; import { CommonModule } from '@angular/common'; +import { User } from '../../../../interfaces/user.interface'; +import { AssignedComponent } from '../../../../components/add-task/assigned/assigned.component'; +import { AddTaskComponent } from '../../../../components/add-task/add-task.component'; @Component({ selector: 'app-task-edit-overlay', standalone: true, - imports: [BtnCloseComponent, FormsModule, CommonModule], + imports: [ + BtnCloseComponent, + FormsModule, + CommonModule, + AssignedComponent, + AddTaskComponent, + ], templateUrl: './task-edit-overlay.component.html', styleUrl: './task-edit-overlay.component.scss', }) -export class TaskEditOverlayComponent implements OnInit { +export class TaskEditOverlayComponent { @Input() overlayData: string = ''; @Output() closeDialogEmitter = new EventEmitter(); - dateInPast: boolean = false; - - taskDataEdit: Task = { - title: '', - description: '', - category: '', - status: 'todo', - priority: 'medium', - subtasksTitle: [], - subtasksDone: [], - assigned: [], - date: '', - }; - constructor( public firebaseService: FirebaseService, private overlayService: OverlayService ) {} - ngOnInit() { - const taskData = this.getTaskData(this.overlayData)[0]; - this.taskDataEdit.title = taskData.title; - this.taskDataEdit.description = taskData.description; - this.taskDataEdit.category = taskData.category; - this.taskDataEdit.status = taskData.status; - this.taskDataEdit.priority = taskData.priority; - this.taskDataEdit.subtasksTitle = taskData.subtasksTitle; - this.taskDataEdit.subtasksDone = taskData.subtasksDone; - this.taskDataEdit.assigned = taskData.assigned; - this.taskDataEdit.date = taskData.date; - } - closeDialog() { this.closeDialogEmitter.emit(''); this.removeTaskData(); } - getTaskData(taskId: string) { - return this.firebaseService - .getAllTasks() - .filter((task) => task.id === taskId); - } - - saveTaskData() { - localStorage.setItem('taskDataEdit', JSON.stringify(this.taskDataEdit)); - } - removeTaskData() { - localStorage.removeItem('taskDataEdit'); - this.clearFormData(); - } - - clearFormData() { - this.taskDataEdit.title = ''; - this.taskDataEdit.description = ''; - this.taskDataEdit.date = ''; - this.taskDataEdit.category = ''; - this.taskDataEdit.assigned = []; - this.taskDataEdit.subtasksTitle = []; - this.taskDataEdit.subtasksDone = []; - } - - checkDateInput() { - const currentDateForm = this.taskDataEdit.date.replaceAll('-', ''); - const currentDate = new Date() - .toISOString() - .split('T')[0] - .replaceAll('-', ''); - currentDateForm < currentDate - ? (this.dateInPast = true) - : (this.dateInPast = false); - } - - tooglePriority(prio: string) { - this.taskDataEdit.priority !== prio - ? (this.taskDataEdit.priority = prio) - : this.taskDataEdit.priority; - this.saveTaskData(); - } - - onSubmit(ngForm: NgForm) { - if (ngForm.submitted && ngForm.form.valid) { - } + localStorage.removeItem('taskData'); } }