update dashboard

parent 0db63e9d
import { Component, ChangeDetectionStrategy, inject, OnInit, signal } from '@angular/core'; import { Component, ChangeDetectionStrategy, inject, OnInit, signal, ChangeDetectorRef } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { NzTableModule } from 'ng-zorro-antd/table'; import { NzTableModule } from 'ng-zorro-antd/table';
import { NzButtonModule } from 'ng-zorro-antd/button'; import { NzButtonModule } from 'ng-zorro-antd/button';
...@@ -263,9 +263,10 @@ import { JobFormComponent } from '../../components/job-form/job-form.component'; ...@@ -263,9 +263,10 @@ import { JobFormComponent } from '../../components/job-form/job-form.component';
</nz-modal> </nz-modal>
} }
`, `,
changeDetection: ChangeDetectionStrategy.Default, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class DashboardComponent implements OnInit { export class DashboardComponent implements OnInit {
private readonly cdr = inject(ChangeDetectorRef);
readonly jobStateService = inject(JobStateService); readonly jobStateService = inject(JobStateService);
private readonly jobApiService = inject(JobApiService); private readonly jobApiService = inject(JobApiService);
private readonly messageService = inject(NzMessageService); private readonly messageService = inject(NzMessageService);
...@@ -306,18 +307,21 @@ export class DashboardComponent implements OnInit { ...@@ -306,18 +307,21 @@ export class DashboardComponent implements OnInit {
this.isEditMode = false; this.isEditMode = false;
this.selectedJob = null; this.selectedJob = null;
this.showJobFormModal = true; this.showJobFormModal = true;
this.cdr.markForCheck();
} }
editJob(job: Job): void { editJob(job: Job): void {
this.isEditMode = true; this.isEditMode = true;
this.selectedJob = job; this.selectedJob = job;
this.showJobFormModal = true; this.showJobFormModal = true;
this.cdr.markForCheck();
} }
viewJobDetail(job: Job): void { viewJobDetail(job: Job): void {
this.selectedJob = job; this.selectedJob = job;
this.showDetailModal = true; this.showDetailModal = true;
console.log('Opening job detail for:', job.title); console.log('Opening job detail for:', job.title);
this.cdr.markForCheck();
} }
confirmDeleteJob(job: Job): void { confirmDeleteJob(job: Job): void {
...@@ -337,9 +341,11 @@ export class DashboardComponent implements OnInit { ...@@ -337,9 +341,11 @@ export class DashboardComponent implements OnInit {
next: () => { next: () => {
this.jobStateService.removeJob(job.id); this.jobStateService.removeJob(job.id);
this.messageService.success(`Job "${job.title}" deleted successfully`); this.messageService.success(`Job "${job.title}" deleted successfully`);
this.cdr.markForCheck();
}, },
error: (error) => { error: (error) => {
this.messageService.error(`Failed to delete job: ${error.message}`); this.messageService.error(`Failed to delete job: ${error.message}`);
this.cdr.markForCheck();
} }
}); });
} }
...@@ -361,6 +367,7 @@ export class DashboardComponent implements OnInit { ...@@ -361,6 +367,7 @@ export class DashboardComponent implements OnInit {
this.selectedJob = null; this.selectedJob = null;
this.isEditMode = false; this.isEditMode = false;
this.jobFormLoading.set(false); this.jobFormLoading.set(false);
this.cdr.markForCheck();
} }
closeDetailModal(): void { closeDetailModal(): void {
...@@ -368,6 +375,7 @@ export class DashboardComponent implements OnInit { ...@@ -368,6 +375,7 @@ export class DashboardComponent implements OnInit {
this.showDetailModal = false; this.showDetailModal = false;
this.selectedJob = null; this.selectedJob = null;
console.log('Detail modal closed, state reset'); console.log('Detail modal closed, state reset');
this.cdr.markForCheck();
} }
onEditJobFromDetail(job: Job): void { onEditJobFromDetail(job: Job): void {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment