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