clean code
This commit is contained in:
parent
780743215e
commit
c11220208c
1 changed files with 32 additions and 34 deletions
|
|
@ -1,11 +1,5 @@
|
|||
import { CommonModule } from '@angular/common';
|
||||
import {
|
||||
Component,
|
||||
ElementRef,
|
||||
HostListener,
|
||||
Input,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { Component, 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';
|
||||
|
|
@ -49,18 +43,12 @@ export class AddTaskComponent {
|
|||
};
|
||||
|
||||
ngOnInit() {
|
||||
if (this.overlayData !== '') {
|
||||
this.loadEditTaskData();
|
||||
}
|
||||
const storedTaskData = localStorage.getItem('taskData');
|
||||
if (storedTaskData) {
|
||||
this.taskData = JSON.parse(storedTaskData);
|
||||
} else {
|
||||
this.saveTaskData();
|
||||
}
|
||||
this.loadLocalStorageData();
|
||||
}
|
||||
|
||||
loadEditTaskData() {
|
||||
if (this.overlayData !== '') {
|
||||
const taskData = this.getTaskData(this.overlayData)[0];
|
||||
this.taskData.title = taskData.title;
|
||||
this.taskData.description = taskData.description;
|
||||
|
|
@ -72,6 +60,16 @@ export class AddTaskComponent {
|
|||
this.taskData.assigned = taskData.assigned;
|
||||
this.taskData.date = taskData.date;
|
||||
}
|
||||
}
|
||||
|
||||
loadLocalStorageData() {
|
||||
const storedTaskData = localStorage.getItem('taskData');
|
||||
if (storedTaskData) {
|
||||
this.taskData = JSON.parse(storedTaskData);
|
||||
} else {
|
||||
this.saveTaskData();
|
||||
}
|
||||
}
|
||||
|
||||
getTaskData(taskId: string) {
|
||||
return this.firebaseService
|
||||
|
|
@ -79,10 +77,6 @@ export class AddTaskComponent {
|
|||
.filter((task) => task.id === taskId);
|
||||
}
|
||||
|
||||
receiveAssigned(assigned: string[]) {
|
||||
this.taskData.assigned = assigned;
|
||||
}
|
||||
|
||||
addSubtask(subtaskName: string) {
|
||||
this.taskData.subtasksTitle.unshift(subtaskName);
|
||||
this.taskData.subtasksDone.push(false);
|
||||
|
|
@ -98,15 +92,6 @@ export class AddTaskComponent {
|
|||
this.saveTaskData();
|
||||
}
|
||||
|
||||
updateSearchInput() {
|
||||
if (this.searchValue) {
|
||||
this.searchInput = this.searchValue.toLowerCase().length > 0;
|
||||
} else {
|
||||
this.searchInput = false;
|
||||
}
|
||||
return this.searchInput;
|
||||
}
|
||||
|
||||
searchTask(): void {
|
||||
this.updateSearchInput();
|
||||
this.filteredUsers = this.firebaseService
|
||||
|
|
@ -119,6 +104,19 @@ export class AddTaskComponent {
|
|||
);
|
||||
}
|
||||
|
||||
updateSearchInput() {
|
||||
if (this.searchValue) {
|
||||
this.searchInput = this.searchValue.toLowerCase().length > 0;
|
||||
} else {
|
||||
this.searchInput = false;
|
||||
}
|
||||
return this.searchInput;
|
||||
}
|
||||
|
||||
receiveAssigned(assigned: string[]) {
|
||||
this.taskData.assigned = assigned;
|
||||
}
|
||||
|
||||
toggleAssignedMenu() {
|
||||
this.isAssignedOpen = !this.isAssignedOpen;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue