clean code
This commit is contained in:
parent
33515b1e61
commit
19f27f6c43
2 changed files with 33 additions and 47 deletions
|
|
@ -48,9 +48,9 @@ select {
|
|||
resize: none;
|
||||
}
|
||||
|
||||
input:invalid,
|
||||
textarea:invalid,
|
||||
select:invalid {
|
||||
input.ng-invalid.ng-touched,
|
||||
textarea.ng-invalid.ng-touched,
|
||||
select.ng-invalid.ng-touched {
|
||||
border: 1px dashed red;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,12 @@
|
|||
import { CommonModule } from '@angular/common';
|
||||
import { Component, HostListener, Input, ViewChild } from '@angular/core';
|
||||
import {
|
||||
AfterViewInit,
|
||||
Component,
|
||||
HostListener,
|
||||
Input,
|
||||
OnInit,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { FormsModule, NgForm, NgModel } from '@angular/forms';
|
||||
import { AssignedComponent } from './assigned/assigned.component';
|
||||
import { User } from '../../interfaces/user.interface';
|
||||
|
|
@ -17,10 +24,7 @@ import { ActivatedRoute } from '@angular/router';
|
|||
templateUrl: './add-task.component.html',
|
||||
styleUrl: './add-task.component.scss',
|
||||
})
|
||||
export class AddTaskComponent {
|
||||
@ViewChild('title', { static: true }) titleField!: NgModel;
|
||||
@ViewChild('description', { static: true }) descriptionField!: NgModel;
|
||||
@ViewChild('category', { static: true }) categoryField!: NgModel;
|
||||
export class AddTaskComponent implements OnInit {
|
||||
@Input() overlayData: string = '';
|
||||
@Input() overlayType: string = '';
|
||||
@Input() overlayMobile: boolean = false;
|
||||
|
|
@ -60,14 +64,13 @@ export class AddTaskComponent {
|
|||
this.loadLocalStorageData();
|
||||
}
|
||||
|
||||
openDialog(userId: any, event: MouseEvent) {
|
||||
this.AssignedDialogId = userId;
|
||||
this.updateDialogPosition(event);
|
||||
loadEditTaskData() {
|
||||
if (this.overlayData !== '') {
|
||||
const taskData = this.getTaskData(this.overlayData)[0];
|
||||
Object.assign(this.taskData, taskData);
|
||||
} else if (this.overlayType === 'newTaskOverlay') {
|
||||
this.taskData.status = this.overlayData;
|
||||
}
|
||||
|
||||
updateDialogPosition(event: MouseEvent) {
|
||||
this.dialogX = event.clientX + 25;
|
||||
this.dialogY = event.clientY + 10;
|
||||
}
|
||||
|
||||
routeParams() {
|
||||
|
|
@ -80,30 +83,6 @@ export class AddTaskComponent {
|
|||
}
|
||||
}
|
||||
|
||||
closeDialog() {
|
||||
this.AssignedDialogId = '';
|
||||
}
|
||||
|
||||
loadEditTaskData() {
|
||||
if (this.overlayData !== '' && this.overlayType !== 'newTaskOverlay') {
|
||||
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;
|
||||
} else if (
|
||||
this.overlayData !== 'none' &&
|
||||
this.overlayType === 'newTaskOverlay'
|
||||
) {
|
||||
this.taskData.status = this.overlayData;
|
||||
}
|
||||
}
|
||||
|
||||
loadLocalStorageData() {
|
||||
const storedTaskData = localStorage.getItem('taskData');
|
||||
if (storedTaskData) {
|
||||
|
|
@ -113,6 +92,20 @@ export class AddTaskComponent {
|
|||
}
|
||||
}
|
||||
|
||||
openDialog(userId: any, event: MouseEvent) {
|
||||
this.AssignedDialogId = userId;
|
||||
this.updateDialogPosition(event);
|
||||
}
|
||||
|
||||
updateDialogPosition(event: MouseEvent) {
|
||||
this.dialogX = event.clientX + 25;
|
||||
this.dialogY = event.clientY + 10;
|
||||
}
|
||||
|
||||
closeDialog() {
|
||||
this.AssignedDialogId = '';
|
||||
}
|
||||
|
||||
getTaskData(taskId: string) {
|
||||
return this.firebaseService
|
||||
.getAllTasks()
|
||||
|
|
@ -187,7 +180,6 @@ export class AddTaskComponent {
|
|||
|
||||
removeTaskData() {
|
||||
localStorage.removeItem('taskData');
|
||||
this.untouchedFormFields();
|
||||
this.clearFormData();
|
||||
}
|
||||
|
||||
|
|
@ -195,12 +187,6 @@ export class AddTaskComponent {
|
|||
this.overlayService.setOverlayData('', '');
|
||||
}
|
||||
|
||||
untouchedFormFields() {
|
||||
this.titleField.control.markAsUntouched();
|
||||
this.descriptionField.control.markAsUntouched();
|
||||
this.categoryField.control.markAsUntouched();
|
||||
}
|
||||
|
||||
clearFormData() {
|
||||
this.taskData.title = '';
|
||||
this.taskData.description = '';
|
||||
|
|
|
|||
Loading…
Reference in a new issue