fix: bugfixes and optimization in OverlayComponent for improved performance and usability
This commit is contained in:
parent
cf4a994ad0
commit
0e0e2db776
10 changed files with 52 additions and 21 deletions
|
|
@ -19,4 +19,8 @@ export class OverlayService {
|
||||||
setOverlayData(overlay: string, data: any) {
|
setOverlayData(overlay: string, data: any) {
|
||||||
this.overlayDataSubject.next({ overlay, data });
|
this.overlayDataSubject.next({ overlay, data });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearOverlayData() {
|
||||||
|
this.overlayDataSubject.next(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@
|
||||||
class="btn-delete"
|
class="btn-delete"
|
||||||
type="button"
|
type="button"
|
||||||
value="{{ 'contactDialogForm.btnDelete' | translate }}"
|
value="{{ 'contactDialogForm.btnDelete' | translate }}"
|
||||||
(click)="deleteContact(selectedUser.id)"
|
(click)="toggleConfirmDialog()"
|
||||||
></app-form-btn>
|
></app-form-btn>
|
||||||
} @else {
|
} @else {
|
||||||
<app-form-btn
|
<app-form-btn
|
||||||
|
|
@ -154,3 +154,11 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- Confirm dialog -->
|
||||||
|
<app-confirm-dialog
|
||||||
|
*ngIf="showConfirmDialog"
|
||||||
|
[message]="'confirmDialogComponent.deleteContact' | translate"
|
||||||
|
(onConfirm)="deleteContact(selectedUser.id)"
|
||||||
|
(onCancel)="toggleConfirmDialog()"
|
||||||
|
></app-confirm-dialog>
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,19 @@ import { ApiService } from '../../../../../services/api.service';
|
||||||
import { ToastNotificationService } from '../../../../../services/toast-notification.service';
|
import { ToastNotificationService } from '../../../../../services/toast-notification.service';
|
||||||
import { UpdateNotifierService } from '../../../../../services/update-notifier.service';
|
import { UpdateNotifierService } from '../../../../../services/update-notifier.service';
|
||||||
import { User } from '../../../../../interfaces/user.interface';
|
import { User } from '../../../../../interfaces/user.interface';
|
||||||
|
import { ConfirmDialogComponent } from '../../../confirm-dialog/confirm-dialog.component';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-contact-form',
|
selector: 'app-contact-form',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [TranslateModule, FormsModule, FormBtnComponent],
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
TranslateModule,
|
||||||
|
FormsModule,
|
||||||
|
FormBtnComponent,
|
||||||
|
ConfirmDialogComponent,
|
||||||
|
],
|
||||||
templateUrl: './contact-form.component.html',
|
templateUrl: './contact-form.component.html',
|
||||||
styleUrl: './contact-form.component.scss',
|
styleUrl: './contact-form.component.scss',
|
||||||
})
|
})
|
||||||
|
|
@ -30,7 +38,7 @@ export class ContactFormComponent implements OnInit, OnChanges {
|
||||||
@Input() newColor: string = '';
|
@Input() newColor: string = '';
|
||||||
@Input() currentColor: string = '';
|
@Input() currentColor: string = '';
|
||||||
@Output() initialsEmitter = new EventEmitter<string>();
|
@Output() initialsEmitter = new EventEmitter<string>();
|
||||||
@Output() closeDialogEmitter = new EventEmitter<string>();
|
@Output() closeDialogEmitter = new EventEmitter<boolean>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public resizeService: ResizeService,
|
public resizeService: ResizeService,
|
||||||
|
|
@ -39,6 +47,8 @@ export class ContactFormComponent implements OnInit, OnChanges {
|
||||||
private updateNotifierService: UpdateNotifierService
|
private updateNotifierService: UpdateNotifierService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
showConfirmDialog = false;
|
||||||
|
|
||||||
contactData = {
|
contactData = {
|
||||||
firstName: '',
|
firstName: '',
|
||||||
lastName: '',
|
lastName: '',
|
||||||
|
|
@ -284,7 +294,11 @@ export class ContactFormComponent implements OnInit, OnChanges {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleConfirmDialog(): void {
|
||||||
|
this.showConfirmDialog = !this.showConfirmDialog;
|
||||||
|
}
|
||||||
|
|
||||||
closeDialog() {
|
closeDialog() {
|
||||||
this.closeDialogEmitter.emit('');
|
this.closeDialogEmitter.emit(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
@if (overlayData !== "new") {
|
@if (overlayData !== "new") {
|
||||||
<section>
|
<section class="overlay">
|
||||||
<div class="dialog">
|
<div class="dialog">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<img src="./../../../../assets/img/logo.svg" alt="" />
|
<img src="./../../../../assets/img/logo.svg" alt="" />
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
} @else {
|
} @else {
|
||||||
<section>
|
<section class="overlay">
|
||||||
<div class="dialog">
|
<div class="dialog">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<img src="./../../../../assets/img/logo.svg" alt="" />
|
<img src="./../../../../assets/img/logo.svg" alt="" />
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import { ColorPickerModule } from 'ngx-color-picker';
|
||||||
export class ContactOverlayComponent implements OnInit {
|
export class ContactOverlayComponent implements OnInit {
|
||||||
@Input() overlayData: any = [];
|
@Input() overlayData: any = [];
|
||||||
@Input() overlayType: string = '';
|
@Input() overlayType: string = '';
|
||||||
@Output() closeDialogEmitter = new EventEmitter<string>();
|
@Output() closeDialogEmitter = new EventEmitter<boolean>();
|
||||||
|
|
||||||
randomColor: string = this.getRandomColor();
|
randomColor: string = this.getRandomColor();
|
||||||
userInitials: string = '';
|
userInitials: string = '';
|
||||||
|
|
@ -52,7 +52,7 @@ export class ContactOverlayComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
closeDialog() {
|
closeDialog() {
|
||||||
this.closeDialogEmitter.emit('');
|
this.closeDialogEmitter.emit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||||
export class DialogOverlayComponent {
|
export class DialogOverlayComponent {
|
||||||
@Input() overlayData: string = '';
|
@Input() overlayData: string = '';
|
||||||
@Input() overlayType: string = '';
|
@Input() overlayType: string = '';
|
||||||
@Output() closeDialogEmitter = new EventEmitter<string>();
|
@Output() closeDialogEmitter = new EventEmitter<boolean>();
|
||||||
|
|
||||||
constructor(private router: Router) {}
|
constructor(private router: Router) {}
|
||||||
|
|
||||||
|
|
@ -24,6 +24,6 @@ export class DialogOverlayComponent {
|
||||||
*/
|
*/
|
||||||
closeOverlay() {
|
closeOverlay() {
|
||||||
this.router.navigate(['/login']);
|
this.router.navigate(['/login']);
|
||||||
this.closeDialogEmitter.emit('');
|
this.closeDialogEmitter.emit(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ import { ContactOverlayComponent } from './contact-overlay/contact-overlay.compo
|
||||||
CommonModule,
|
CommonModule,
|
||||||
TaskOverlayComponent,
|
TaskOverlayComponent,
|
||||||
TaskEditOverlayComponent,
|
TaskEditOverlayComponent,
|
||||||
DialogOverlayComponent,
|
|
||||||
ContactOverlayComponent,
|
ContactOverlayComponent,
|
||||||
|
DialogOverlayComponent,
|
||||||
],
|
],
|
||||||
templateUrl: './overlay.component.html',
|
templateUrl: './overlay.component.html',
|
||||||
styleUrl: './overlay.component.scss',
|
styleUrl: './overlay.component.scss',
|
||||||
|
|
@ -53,23 +53,26 @@ export class OverlayComponent implements OnInit {
|
||||||
* If the overlay type is 'dialog', navigates to the login route.
|
* If the overlay type is 'dialog', navigates to the login route.
|
||||||
* @param emitter The string to be emitted, which will also be set as the overlay data.
|
* @param emitter The string to be emitted, which will also be set as the overlay data.
|
||||||
*/
|
*/
|
||||||
onCloseOverlay(emitter: string) {
|
onCloseOverlay(emitter: boolean) {
|
||||||
this.overlayType === 'dialog' && this.router.navigate(['/login']);
|
|
||||||
this.overlayData = emitter;
|
this.overlayData = emitter;
|
||||||
|
this.overlayService.clearOverlayData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('document:click', ['$event'])
|
@HostListener('document:click', ['$event'])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listens for clicks on the overlay background and closes the overlay if the target element does not have the class 'overlay-content'.
|
* Checks if a click event occurred within the overlay but outside the content or dialog elements.
|
||||||
* @param event The click event.
|
* If so, closes the overlay by emitting an event.
|
||||||
|
*
|
||||||
|
* @param event The MouseEvent that triggered the check.
|
||||||
*/
|
*/
|
||||||
checkOpenContactEdit(event: MouseEvent) {
|
checkOpenContactEdit(event: MouseEvent) {
|
||||||
const targetElement = event.target as HTMLElement;
|
const targetElement = event.target as HTMLElement;
|
||||||
if (
|
if (
|
||||||
targetElement.closest('.overlay') &&
|
targetElement.closest('.overlay') &&
|
||||||
!targetElement.closest('.overlay-content')
|
(!targetElement.closest('.content') || !targetElement.closest('.dialog'))
|
||||||
) {
|
) {
|
||||||
this.onCloseOverlay('');
|
this.onCloseOverlay(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import { ApiService } from '../../../../services/api.service';
|
||||||
export class TaskEditOverlayComponent {
|
export class TaskEditOverlayComponent {
|
||||||
@Input() overlayData: string = '';
|
@Input() overlayData: string = '';
|
||||||
@Input() overlayType: string = '';
|
@Input() overlayType: string = '';
|
||||||
@Output() closeDialogEmitter = new EventEmitter<string>();
|
@Output() closeDialogEmitter = new EventEmitter<boolean>();
|
||||||
|
|
||||||
overlayMobile: boolean = false;
|
overlayMobile: boolean = false;
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ export class TaskEditOverlayComponent {
|
||||||
closeDialog() {
|
closeDialog() {
|
||||||
this.overlayMobile
|
this.overlayMobile
|
||||||
? this.router.navigate(['/board'])
|
? this.router.navigate(['/board'])
|
||||||
: this.closeDialogEmitter.emit('');
|
: this.closeDialogEmitter.emit(false);
|
||||||
this.removeTaskData();
|
this.removeTaskData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,8 @@
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- Confirm dialog -->
|
||||||
<app-confirm-dialog
|
<app-confirm-dialog
|
||||||
*ngIf="showConfirmDialog"
|
*ngIf="showConfirmDialog"
|
||||||
[message]="'confirmDialogComponent.deleteTask' | translate"
|
[message]="'confirmDialogComponent.deleteTask' | translate"
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import { ConfirmDialogComponent } from '../../confirm-dialog/confirm-dialog.comp
|
||||||
})
|
})
|
||||||
export class TaskOverlayComponent implements OnInit {
|
export class TaskOverlayComponent implements OnInit {
|
||||||
@Input() overlayData: string = '';
|
@Input() overlayData: string = '';
|
||||||
@Output() closeDialogEmitter = new EventEmitter<string>();
|
@Output() closeDialogEmitter = new EventEmitter<boolean>();
|
||||||
|
|
||||||
task: Task | null = null;
|
task: Task | null = null;
|
||||||
overlayMobile: boolean = false;
|
overlayMobile: boolean = false;
|
||||||
|
|
@ -94,7 +94,7 @@ export class TaskOverlayComponent implements OnInit {
|
||||||
* can be used to close the overlay from the parent component.
|
* can be used to close the overlay from the parent component.
|
||||||
*/
|
*/
|
||||||
closeDialog() {
|
closeDialog() {
|
||||||
this.closeDialogEmitter.emit('');
|
this.closeDialogEmitter.emit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue