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 { NzTableModule } from 'ng-zorro-antd/table';
import { NzButtonModule } from 'ng-zorro-antd/button';
......@@ -263,9 +263,10 @@ import { JobFormComponent } from '../../components/job-form/job-form.component';
</nz-modal>
}
`,
changeDetection: ChangeDetectionStrategy.Default,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DashboardComponent implements OnInit {
private readonly cdr = inject(ChangeDetectorRef);
readonly jobStateService = inject(JobStateService);
private readonly jobApiService = inject(JobApiService);
private readonly messageService = inject(NzMessageService);
......@@ -306,18 +307,21 @@ export class DashboardComponent implements OnInit {
this.isEditMode = false;
this.selectedJob = null;
this.showJobFormModal = true;
this.cdr.markForCheck();
}
editJob(job: Job): void {
this.isEditMode = true;
this.selectedJob = job;
this.showJobFormModal = true;
this.cdr.markForCheck();
}
viewJobDetail(job: Job): void {
this.selectedJob = job;
this.showDetailModal = true;
console.log('Opening job detail for:', job.title);
this.cdr.markForCheck();
}
confirmDeleteJob(job: Job): void {
......@@ -337,9 +341,11 @@ export class DashboardComponent implements OnInit {
next: () => {
this.jobStateService.removeJob(job.id);
this.messageService.success(`Job "${job.title}" deleted successfully`);
this.cdr.markForCheck();
},
error: (error) => {
this.messageService.error(`Failed to delete job: ${error.message}`);
this.cdr.markForCheck();
}
});
}
......@@ -361,6 +367,7 @@ export class DashboardComponent implements OnInit {
this.selectedJob = null;
this.isEditMode = false;
this.jobFormLoading.set(false);
this.cdr.markForCheck();
}
closeDetailModal(): void {
......@@ -368,6 +375,7 @@ export class DashboardComponent implements OnInit {
this.showDetailModal = false;
this.selectedJob = null;
console.log('Detail modal closed, state reset');
this.cdr.markForCheck();
}
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