update btns

This commit is contained in:
Chneemann 2024-04-23 09:45:22 +02:00
parent c11220208c
commit 6db2a9bf42
5 changed files with 63 additions and 19 deletions

View file

@ -9,11 +9,14 @@
</div> </div>
<form <form
(ngSubmit)="onSubmit(taskForm)" (ngSubmit)="onSubmit(taskForm, overlayData)"
#taskForm="ngForm" #taskForm="ngForm"
onsubmit="return false" onsubmit="return false"
> >
<div class="content"> <div
class="content"
[ngClass]="{ 'edit-task-overlay-content': overlayData !== '' }"
>
<div class="left-side"> <div class="left-side">
<div class="title"> <div class="title">
<p>Title<span class="red-dot">*</span></p> <p>Title<span class="red-dot">*</span></p>
@ -257,11 +260,19 @@
type="button" type="button"
value="Clear" value="Clear"
(click)="removeTaskData()" (click)="removeTaskData()"
[ngStyle]="{ display: overlayData !== '' ? 'none' : 'block' }"
/>
<input
class="btn-delete"
type="button"
value="Delete"
(click)="deleteTaskData(overlayData)"
[ngStyle]="{ display: overlayData !== '' ? 'block' : 'none' }"
/> />
<input <input
class="btn-submit" class="btn-submit"
type="submit" type="submit"
value="Create Task" value="{{ overlayData !== '' ? 'Update Task' : 'Create Task' }}"
[disabled]=" [disabled]="
title.invalid || title.invalid ||
!taskData.title || !taskData.title ||

View file

@ -8,6 +8,12 @@ section {
width: 100%; width: 100%;
} }
.edit-task-overlay-content {
height: calc(700px - 128px);
padding: 0 6px;
overflow-y: auto;
}
input, input,
textarea, textarea,
select { select {
@ -54,7 +60,6 @@ p {
.d-none { .d-none {
display: none; display: none;
background-color: var(--white);
} }
/*------------- HEADER -------------*/ /*------------- HEADER -------------*/
@ -292,6 +297,27 @@ p {
} }
} }
.btn-delete {
width: 110px;
height: 56px;
padding: 12px;
margin: 12px 12px;
border-radius: 10px;
color: var(--red);
background-color: var(--white);
border: 1px solid var(--red);
font-size: 23px;
font-weight: 400;
transition: 125ms ease-in-out;
cursor: pointer;
&:hover {
color: var(--white);
background-color: var(--red);
border-color: var(--black);
box-shadow: 2px 2px 2px 0px rgba(0, 0, 0, 0.3);
}
}
/*------------- RESPONSIVE -------------*/ /*------------- RESPONSIVE -------------*/
@media screen and (max-width: 1250px) { @media screen and (max-width: 1250px) {

View file

@ -5,6 +5,7 @@ import { AssignedComponent } from './assigned/assigned.component';
import { User } from '../../interfaces/user.interface'; import { User } from '../../interfaces/user.interface';
import { FirebaseService } from '../../services/firebase.service'; import { FirebaseService } from '../../services/firebase.service';
import { Task } from '../../interfaces/task.interface'; import { Task } from '../../interfaces/task.interface';
import { OverlayService } from '../../services/overlay.service';
@Component({ @Component({
selector: 'app-add-task', selector: 'app-add-task',
@ -17,7 +18,6 @@ export class AddTaskComponent {
@ViewChild('title', { static: true }) titleField!: NgModel; @ViewChild('title', { static: true }) titleField!: NgModel;
@ViewChild('description', { static: true }) descriptionField!: NgModel; @ViewChild('description', { static: true }) descriptionField!: NgModel;
@ViewChild('category', { static: true }) categoryField!: NgModel; @ViewChild('category', { static: true }) categoryField!: NgModel;
@Input() task: string = '';
@Input() overlayData: string = ''; @Input() overlayData: string = '';
currentDate: string = new Date().toISOString().split('T')[0]; currentDate: string = new Date().toISOString().split('T')[0];
@ -28,7 +28,10 @@ export class AddTaskComponent {
searchInput: boolean = false; searchInput: boolean = false;
filteredUsers: User[] = []; filteredUsers: User[] = [];
constructor(public firebaseService: FirebaseService) {} constructor(
public firebaseService: FirebaseService,
private overlayService: OverlayService
) {}
taskData: Task = { taskData: Task = {
title: '', title: '',
@ -48,6 +51,7 @@ export class AddTaskComponent {
} }
loadEditTaskData() { loadEditTaskData() {
console.log(this.overlayData);
if (this.overlayData !== '') { if (this.overlayData !== '') {
const taskData = this.getTaskData(this.overlayData)[0]; const taskData = this.getTaskData(this.overlayData)[0];
this.taskData.title = taskData.title; this.taskData.title = taskData.title;
@ -59,6 +63,7 @@ export class AddTaskComponent {
this.taskData.subtasksDone = taskData.subtasksDone; this.taskData.subtasksDone = taskData.subtasksDone;
this.taskData.assigned = taskData.assigned; this.taskData.assigned = taskData.assigned;
this.taskData.date = taskData.date; this.taskData.date = taskData.date;
console.log(this.overlayData);
} }
} }
@ -149,6 +154,10 @@ export class AddTaskComponent {
this.clearFormData(); this.clearFormData();
} }
closeOverlay() {
this.overlayService.setOverlayData('', '');
}
untouchedFormFields() { untouchedFormFields() {
this.titleField.control.markAsUntouched(); this.titleField.control.markAsUntouched();
this.descriptionField.control.markAsUntouched(); this.descriptionField.control.markAsUntouched();
@ -165,14 +174,20 @@ export class AddTaskComponent {
this.taskData.subtasksDone = []; this.taskData.subtasksDone = [];
} }
onSubmit(ngForm: NgForm) { onSubmit(ngForm: NgForm, overlayData: string) {
if (ngForm.submitted && ngForm.form.valid) { if (ngForm.submitted && ngForm.form.valid) {
const { id, ...taskWithoutId } = this.taskData; if (overlayData === '') {
this.firebaseService.addNewTask(taskWithoutId); const { id, ...taskWithoutId } = this.taskData;
this.removeTaskData(); this.firebaseService.addNewTask(taskWithoutId);
this.removeTaskData();
} else {
this.closeOverlay();
}
} }
} }
deleteTaskData(overlayData: string) {}
@HostListener('document:click', ['$event']) @HostListener('document:click', ['$event'])
checkOpenNavbar(event: MouseEvent) { checkOpenNavbar(event: MouseEvent) {
const targetElement = event.target as HTMLElement; const targetElement = event.target as HTMLElement;

View file

@ -2,7 +2,5 @@
<div class="header"> <div class="header">
<app-btn-close (click)="closeDialog()"></app-btn-close> <app-btn-close (click)="closeDialog()"></app-btn-close>
</div> </div>
<div class="content"> <app-add-task [overlayData]="overlayData"></app-add-task>
<app-add-task [task]="'Edit'" [overlayData]="overlayData"></app-add-task>
</div>
</section> </section>

View file

@ -11,12 +11,6 @@ section {
justify-content: right; justify-content: right;
} }
.content {
height: calc(700px - 48px);
padding: 0 6px;
overflow-y: auto;
}
input, input,
textarea, textarea,
select { select {