avoid validation errors when clearing the mould
This commit is contained in:
parent
a5af2cc11e
commit
31297d93ae
3 changed files with 11 additions and 10 deletions
|
|
@ -309,7 +309,7 @@
|
||||||
? 'block'
|
? 'block'
|
||||||
: 'none'
|
: 'none'
|
||||||
}"
|
}"
|
||||||
(click)="removeTaskData()"
|
(click)="removeTaskData(taskForm)"
|
||||||
></app-form-btn>
|
></app-form-btn>
|
||||||
<app-form-btn
|
<app-form-btn
|
||||||
[class]="'btn-delete'"
|
[class]="'btn-delete'"
|
||||||
|
|
|
||||||
|
|
@ -180,8 +180,9 @@ export class AddTaskComponent implements OnInit {
|
||||||
localStorage.setItem('taskData', JSON.stringify(this.taskData));
|
localStorage.setItem('taskData', JSON.stringify(this.taskData));
|
||||||
}
|
}
|
||||||
|
|
||||||
removeTaskData() {
|
removeTaskData(form: NgForm) {
|
||||||
localStorage.removeItem('taskData');
|
localStorage.removeItem('taskData');
|
||||||
|
this.clearForm(form);
|
||||||
this.clearFormData();
|
this.clearFormData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,9 +190,13 @@ export class AddTaskComponent implements OnInit {
|
||||||
this.overlayService.setOverlayData('', '');
|
this.overlayService.setOverlayData('', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearForm(form: NgForm) {
|
||||||
|
form.controls['title'].reset();
|
||||||
|
form.controls['description'].reset();
|
||||||
|
form.controls['category'].reset();
|
||||||
|
}
|
||||||
|
|
||||||
clearFormData() {
|
clearFormData() {
|
||||||
this.taskData.title = '';
|
|
||||||
this.taskData.description = '';
|
|
||||||
this.taskData.date = this.currentDate;
|
this.taskData.date = this.currentDate;
|
||||||
this.taskData.category = '';
|
this.taskData.category = '';
|
||||||
this.taskData.assigned = [];
|
this.taskData.assigned = [];
|
||||||
|
|
@ -226,7 +231,7 @@ export class AddTaskComponent implements OnInit {
|
||||||
if (allowedValues.includes(overlayData)) {
|
if (allowedValues.includes(overlayData)) {
|
||||||
const { id, ...taskWithoutId } = this.taskData;
|
const { id, ...taskWithoutId } = this.taskData;
|
||||||
this.firebaseService.addNewTask(taskWithoutId);
|
this.firebaseService.addNewTask(taskWithoutId);
|
||||||
this.removeTaskData();
|
this.removeTaskData(ngForm);
|
||||||
this.closeOverlay();
|
this.closeOverlay();
|
||||||
} else {
|
} else {
|
||||||
if (this.getTaskData(overlayData).length > 0) {
|
if (this.getTaskData(overlayData).length > 0) {
|
||||||
|
|
@ -255,8 +260,4 @@ export class AddTaskComponent implements OnInit {
|
||||||
this.isAssignedOpen = false;
|
this.isAssignedOpen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
this.removeTaskData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
{{ user.firstName }}
|
{{ user.firstName }}
|
||||||
{{ user.lastName }}
|
{{ user.lastName }}
|
||||||
@if (user.id === firebaseService.getCurrentUserId()) {
|
@if (user.id === firebaseService.getCurrentUserId()) {
|
||||||
<p> {{ "contacts.you" | translate }}</p>
|
{{ "contacts.you" | translate }}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@if(user.uId === "" || user.id === firebaseService.getCurrentUserId()) {
|
@if(user.uId === "" || user.id === firebaseService.getCurrentUserId()) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue