From 7d8c8733899cd6d6d9c8ac4ed0f8e1f9ccc586a6 Mon Sep 17 00:00:00 2001 From: samuelmbabhazi Date: Fri, 18 Oct 2024 20:29:28 +0200 Subject: [PATCH 1/6] Fix employee fields edition --- .../job-employee/job-employee.component.ts | 22 ++++-- .../src/lib/table-components/editors/index.ts | 2 + ...ob-search-availability-editor.component.ts | 69 +++++++++++++++++++ .../non-editable-number-editor.component.ts | 19 +++++ .../shared/src/lib/table-components/index.ts | 2 + .../table-components.module.ts | 11 ++- 6 files changed, 119 insertions(+), 6 deletions(-) create mode 100644 packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts create mode 100644 packages/ui-core/shared/src/lib/table-components/editors/non-editable-number-editor.component.ts diff --git a/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts b/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts index f18f17bc82f..efd48de2348 100644 --- a/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts +++ b/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts @@ -29,7 +29,9 @@ import { NumberEditorComponent, EmployeeLinkEditorComponent, PaginationFilterBaseComponent, - SmartTableToggleComponent + SmartTableToggleComponent, + NonEditableNumberEditorComponent, + JobSearchAvailabilityComponent } from '@gauzy/ui-core/shared'; /** @@ -238,7 +240,11 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen width: '10%', // The width of the column isSortable: false, // Indicates whether the column is sortable isEditable: false, // Indicates whether the column is editable - valuePrepareFunction: (rawValue: any) => rawValue || 0 + valuePrepareFunction: (rawValue: any) => rawValue || 0, + editor: { + type: 'custom', + component: NonEditableNumberEditorComponent + } }); // Register the data table column @@ -251,7 +257,11 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen width: '10%', // The width of the column isSortable: false, // Indicates whether the column is sortable isEditable: false, // Indicates whether the column is editable - valuePrepareFunction: (rawValue: any) => rawValue || 0 + valuePrepareFunction: (rawValue: any) => rawValue || 0, + editor: { + type: 'custom', + component: NonEditableNumberEditorComponent + } }); // Register the data table column @@ -305,7 +315,7 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen type: 'custom', // The type of the column width: '20%', // The width of the column isSortable: false, // Indicates whether the column is sortable - isEditable: false, // Indicates whether the column is editable + isEditable: true, // Indicates whether the column is editable renderComponent: SmartTableToggleComponent, componentInitFunction: (instance: SmartTableToggleComponent, cell: Cell) => { // Get the employee data from the cell @@ -318,6 +328,10 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen instance.toggleChange.pipe(untilDestroyed(this)).subscribe((toggle: boolean) => { this.updateJobSearchAvailability(employee, toggle); }); + }, + editor: { + type: 'custom', + component: JobSearchAvailabilityComponent } }); } diff --git a/packages/ui-core/shared/src/lib/table-components/editors/index.ts b/packages/ui-core/shared/src/lib/table-components/editors/index.ts index 790692b98b1..4579c69546c 100644 --- a/packages/ui-core/shared/src/lib/table-components/editors/index.ts +++ b/packages/ui-core/shared/src/lib/table-components/editors/index.ts @@ -1,2 +1,4 @@ export * from './number-editor.component'; export * from './employee-link-editor.component'; +export * from './job-search-availability-editor.component'; +export * from './non-editable-number-editor.component'; diff --git a/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts b/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts new file mode 100644 index 00000000000..a0b5ab35917 --- /dev/null +++ b/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts @@ -0,0 +1,69 @@ +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { IEmployee } from '@gauzy/contracts'; +import { JobService, ToastrService } from '@gauzy/ui-core/core'; +import { Cell, DefaultEditor } from 'angular2-smart-table'; +import { BehaviorSubject, Observable } from 'rxjs'; + +@Component({ + template: `
+ +
` +}) +export class JobSearchAvailabilityComponent extends DefaultEditor implements OnInit { + private _checked$: BehaviorSubject = new BehaviorSubject(false); + @Input() cell!: Cell; + @Output() toggleChange: EventEmitter = new EventEmitter(); + + constructor(private readonly _jobService: JobService, private readonly _toastrService: ToastrService) { + super(); + } + + public get checked$(): Observable { + return this._checked$.asObservable(); + } + + ngOnInit() { + if (this.cell) { + const employee: IEmployee = this.cell.getRow()?.getData(); + if (employee) { + this.value = employee.isJobSearchActive; // Initialize the toggle value + } + } + } + + @Input() public set value(checked: boolean) { + this._checked$.next(checked); + } + + onCheckedChange(isChecked: boolean) { + this.toggleChange.emit(isChecked); // Emit the toggle change event + this._checked$.next(isChecked); + this.updateJobSearchAvailability(isChecked); // Update job search availability + } + + async updateJobSearchAvailability(isJobSearchActive: boolean): Promise { + if (!this.cell) return; // Ensure 'cell' is available + const employee: IEmployee = this.cell.getRow()?.getData(); + if (!employee) return; // Ensure employee data is available + + try { + await this._jobService.updateJobSearchStatus(employee.id, { + isJobSearchActive, + organizationId: employee.organizationId, + tenantId: employee.tenantId + }); + + const toastrMessageKey = isJobSearchActive + ? 'TOASTR.MESSAGE.EMPLOYEE_JOB_STATUS_ACTIVE' + : 'TOASTR.MESSAGE.EMPLOYEE_JOB_STATUS_INACTIVE'; + + this._toastrService.success(toastrMessageKey, { name: employee.fullName }); + } catch (error) { + this._toastrService.danger(error); + } + } +} diff --git a/packages/ui-core/shared/src/lib/table-components/editors/non-editable-number-editor.component.ts b/packages/ui-core/shared/src/lib/table-components/editors/non-editable-number-editor.component.ts new file mode 100644 index 00000000000..c3dde52b6e2 --- /dev/null +++ b/packages/ui-core/shared/src/lib/table-components/editors/non-editable-number-editor.component.ts @@ -0,0 +1,19 @@ +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Cell, DefaultEditor } from 'angular2-smart-table'; + +@Component({ + template: ` +
+ {{ cellValue }} +
+ ` +}) +export class NonEditableNumberEditorComponent extends DefaultEditor implements OnInit { + cellValue!: string; + + @Input() cell!: Cell; + + ngOnInit() { + this.cellValue = this.cell.getValue(); + } +} diff --git a/packages/ui-core/shared/src/lib/table-components/index.ts b/packages/ui-core/shared/src/lib/table-components/index.ts index b79500375cd..5e99fb49c3e 100644 --- a/packages/ui-core/shared/src/lib/table-components/index.ts +++ b/packages/ui-core/shared/src/lib/table-components/index.ts @@ -11,6 +11,7 @@ export * from './document-date/document-date.component'; export * from './document-url/document-url.component'; export * from './editors/number-editor.component'; export * from './editors/employee-link-editor.component'; +export * from './editors/job-search-availability-editor.component'; export * from './email/email.component'; export * from './employee-links/employee-links.component'; export * from './employee-with-links/employee-with-links.component'; @@ -39,6 +40,7 @@ export * from './toggle-switch/toggle-switch.component'; export * from './trust-html/trust-html.component'; export * from './value-with-units/value-with-units.component'; export * from './visibility/visibility.component'; +export * from './editors/non-editable-number-editor.component'; // export * from './table-components.module'; diff --git a/packages/ui-core/shared/src/lib/table-components/table-components.module.ts b/packages/ui-core/shared/src/lib/table-components/table-components.module.ts index ccb528adb55..be2665fe4c8 100644 --- a/packages/ui-core/shared/src/lib/table-components/table-components.module.ts +++ b/packages/ui-core/shared/src/lib/table-components/table-components.module.ts @@ -5,7 +5,12 @@ import { NbIconModule, NbTooltipModule, NbBadgeModule, NbToggleModule, NbButtonM import { TranslateModule } from '@ngx-translate/core'; import { ComponentsModule } from '../components/components.module'; import { PipesModule } from '../pipes/pipes.module'; -import { EmployeeLinkEditorComponent, NumberEditorComponent } from './editors'; +import { + EmployeeLinkEditorComponent, + JobSearchAvailabilityComponent, + NonEditableNumberEditorComponent, + NumberEditorComponent +} from './editors'; import { AllowScreenshotCaptureComponent } from './allow-screenshot-capture/allow-screenshot-capture.component'; import { AssignedToComponent } from './assigned-to/assigned-to.component'; import { ClickableLinkComponent } from './clickable-link/clickable-link.component'; @@ -104,7 +109,9 @@ import { TaskBadgeViewComponentModule } from '../tasks/task-badge-view/task-badg ToggleSwitchComponent, TrustHtmlLinkComponent, ValueWithUnitComponent, - VisibilityComponent + VisibilityComponent, + NonEditableNumberEditorComponent, + JobSearchAvailabilityComponent ], exports: [ AllowScreenshotCaptureComponent, From ff381720a7fc37e363a231a77ced645a6d24eb99 Mon Sep 17 00:00:00 2001 From: samuelmbabhazi Date: Fri, 18 Oct 2024 20:47:18 +0200 Subject: [PATCH 2/6] Rename jobSearchAvailability component --- .../src/lib/components/job-employee/job-employee.component.ts | 4 ++-- .../editors/job-search-availability-editor.component.ts | 2 +- .../src/lib/table-components/table-components.module.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts b/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts index efd48de2348..7c05b33868c 100644 --- a/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts +++ b/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts @@ -31,7 +31,7 @@ import { PaginationFilterBaseComponent, SmartTableToggleComponent, NonEditableNumberEditorComponent, - JobSearchAvailabilityComponent + JobSearchAvailabilityEditorComponent } from '@gauzy/ui-core/shared'; /** @@ -331,7 +331,7 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen }, editor: { type: 'custom', - component: JobSearchAvailabilityComponent + component: JobSearchAvailabilityEditorComponent } }); } diff --git a/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts b/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts index a0b5ab35917..a30586a6290 100644 --- a/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts +++ b/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts @@ -13,7 +13,7 @@ import { BehaviorSubject, Observable } from 'rxjs'; > ` }) -export class JobSearchAvailabilityComponent extends DefaultEditor implements OnInit { +export class JobSearchAvailabilityEditorComponent extends DefaultEditor implements OnInit { private _checked$: BehaviorSubject = new BehaviorSubject(false); @Input() cell!: Cell; @Output() toggleChange: EventEmitter = new EventEmitter(); diff --git a/packages/ui-core/shared/src/lib/table-components/table-components.module.ts b/packages/ui-core/shared/src/lib/table-components/table-components.module.ts index be2665fe4c8..5a784137780 100644 --- a/packages/ui-core/shared/src/lib/table-components/table-components.module.ts +++ b/packages/ui-core/shared/src/lib/table-components/table-components.module.ts @@ -7,7 +7,7 @@ import { ComponentsModule } from '../components/components.module'; import { PipesModule } from '../pipes/pipes.module'; import { EmployeeLinkEditorComponent, - JobSearchAvailabilityComponent, + JobSearchAvailabilityEditorComponent, NonEditableNumberEditorComponent, NumberEditorComponent } from './editors'; @@ -111,7 +111,7 @@ import { TaskBadgeViewComponentModule } from '../tasks/task-badge-view/task-badg ValueWithUnitComponent, VisibilityComponent, NonEditableNumberEditorComponent, - JobSearchAvailabilityComponent + JobSearchAvailabilityEditorComponent ], exports: [ AllowScreenshotCaptureComponent, From 434c237c7efec50faf4b21268c0093497e8840eb Mon Sep 17 00:00:00 2001 From: samuelmbabhazi Date: Fri, 18 Oct 2024 22:13:19 +0200 Subject: [PATCH 3/6] coderabbitai suggestion integrations --- .../job-search-availability-editor.component.ts | 3 ++- .../non-editable-number-editor.component.ts | 15 ++++++++++++--- .../table-components/table-components.module.ts | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts b/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts index a30586a6290..7e6bb917498 100644 --- a/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts +++ b/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts @@ -63,7 +63,8 @@ export class JobSearchAvailabilityEditorComponent extends DefaultEditor implemen this._toastrService.success(toastrMessageKey, { name: employee.fullName }); } catch (error) { - this._toastrService.danger(error); + const errorMessage = error?.message || 'An error occurred while updating the job search availability.'; + this._toastrService.danger(errorMessage); } } } diff --git a/packages/ui-core/shared/src/lib/table-components/editors/non-editable-number-editor.component.ts b/packages/ui-core/shared/src/lib/table-components/editors/non-editable-number-editor.component.ts index c3dde52b6e2..c8b85b59518 100644 --- a/packages/ui-core/shared/src/lib/table-components/editors/non-editable-number-editor.component.ts +++ b/packages/ui-core/shared/src/lib/table-components/editors/non-editable-number-editor.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { Cell, DefaultEditor } from 'angular2-smart-table'; @Component({ @@ -9,11 +9,20 @@ import { Cell, DefaultEditor } from 'angular2-smart-table'; ` }) export class NonEditableNumberEditorComponent extends DefaultEditor implements OnInit { - cellValue!: string; + cellValue!: string | number; @Input() cell!: Cell; ngOnInit() { - this.cellValue = this.cell.getValue(); + const value = this.cell.getValue(); + if (value === null || value === undefined) { + console.warn('Cell value is null or undefined'); + this.cellValue = ''; + } else if (typeof value === 'number' || typeof value === 'string') { + this.cellValue = value; + } else { + console.error('Unexpected cell value type:', typeof value); + this.cellValue = ''; + } } } diff --git a/packages/ui-core/shared/src/lib/table-components/table-components.module.ts b/packages/ui-core/shared/src/lib/table-components/table-components.module.ts index 5a784137780..aaeee1761bb 100644 --- a/packages/ui-core/shared/src/lib/table-components/table-components.module.ts +++ b/packages/ui-core/shared/src/lib/table-components/table-components.module.ts @@ -136,6 +136,8 @@ import { TaskBadgeViewComponentModule } from '../tasks/task-badge-view/task-badg InvoiceTotalValueComponent, NotesWithTagsComponent, NumberEditorComponent, + JobSearchAvailabilityEditorComponent, + NonEditableNumberEditorComponent, OrganizationWithTagsComponent, PhoneUrlComponent, PictureNameTagsComponent, From 9b70600f632a8f98c5bdbe2ed870f973ded96ac9 Mon Sep 17 00:00:00 2001 From: "Rahul R." Date: Mon, 21 Oct 2024 13:02:07 +0530 Subject: [PATCH 4/6] fix: use common toggle switcher for job search status --- .../job-employee/job-employee.component.ts | 3 +- ...ob-search-availability-editor.component.ts | 106 +++++++++--------- 2 files changed, 56 insertions(+), 53 deletions(-) diff --git a/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts b/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts index b728ac9b77e..d4e7cc071ad 100644 --- a/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts +++ b/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts @@ -30,9 +30,8 @@ import { NumberEditorComponent, EmployeeLinkEditorComponent, PaginationFilterBaseComponent, - SmartTableToggleComponent, NonEditableNumberEditorComponent, - JobSearchAvailabilityEditorComponent + JobSearchAvailabilityEditorComponent, ToggleSwitcherComponent } from '@gauzy/ui-core/shared'; diff --git a/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts b/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts index 7e6bb917498..411ac536866 100644 --- a/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts +++ b/packages/ui-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts @@ -1,70 +1,74 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { IEmployee } from '@gauzy/contracts'; -import { JobService, ToastrService } from '@gauzy/ui-core/core'; +import { AfterViewInit, ChangeDetectorRef, Component, Input, OnInit, ViewChild } from '@angular/core'; +import { filter, tap } from 'rxjs'; import { Cell, DefaultEditor } from 'angular2-smart-table'; -import { BehaviorSubject, Observable } from 'rxjs'; +import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; +import { IEmployee, IOrganization } from '@gauzy/contracts'; +import { distinctUntilChange } from '@gauzy/ui-core/common'; +import { JobSearchStoreService, Store } from '@gauzy/ui-core/core'; +import { ToggleSwitcherComponent } from '../toggle-switcher/toggle-switcher.component'; +@UntilDestroy({ checkProperties: true }) @Component({ - template: `
- -
` + template: ` + + ` }) -export class JobSearchAvailabilityEditorComponent extends DefaultEditor implements OnInit { - private _checked$: BehaviorSubject = new BehaviorSubject(false); +export class JobSearchAvailabilityEditorComponent extends DefaultEditor implements AfterViewInit, OnInit { + public organization: IOrganization; + public employee: IEmployee; + + // Reference to the cell object @Input() cell!: Cell; - @Output() toggleChange: EventEmitter = new EventEmitter(); - constructor(private readonly _jobService: JobService, private readonly _toastrService: ToastrService) { - super(); - } + // Reference to the ToggleSwitcherComponent instance + @ViewChild(ToggleSwitcherComponent) switcher!: ToggleSwitcherComponent; - public get checked$(): Observable { - return this._checked$.asObservable(); + constructor( + private readonly _cdr: ChangeDetectorRef, + private readonly _store: Store, + private readonly _jobSearchStoreService: JobSearchStoreService + ) { + super(); } ngOnInit() { - if (this.cell) { - const employee: IEmployee = this.cell.getRow()?.getData(); - if (employee) { - this.value = employee.isJobSearchActive; // Initialize the toggle value - } - } + this._store.selectedOrganization$ + .pipe( + distinctUntilChange(), + filter((organization: IOrganization) => !!organization), + tap((organization: IOrganization) => { + this.organization = organization; + this.employee = this.cell.getRow()?.getData(); + }), + untilDestroyed(this) + ) + .subscribe(); } - @Input() public set value(checked: boolean) { - this._checked$.next(checked); - } - - onCheckedChange(isChecked: boolean) { - this.toggleChange.emit(isChecked); // Emit the toggle change event - this._checked$.next(isChecked); - this.updateJobSearchAvailability(isChecked); // Update job search availability + ngAfterViewInit(): void { + if (!this.switcher) { + return; + } + this.switcher.value = this.employee?.isJobSearchActive || false; + this._cdr.detectChanges(); // Force change detection to update the UI } - async updateJobSearchAvailability(isJobSearchActive: boolean): Promise { - if (!this.cell) return; // Ensure 'cell' is available - const employee: IEmployee = this.cell.getRow()?.getData(); - if (!employee) return; // Ensure employee data is available - + /** + * Updates the job search availability status of an employee within the organization. + * + * @param isJobSearchActive - A boolean flag indicating whether the job search is active. + */ + updateJobSearchAvailability(isJobSearchActive: boolean): void { try { - await this._jobService.updateJobSearchStatus(employee.id, { - isJobSearchActive, - organizationId: employee.organizationId, - tenantId: employee.tenantId - }); - - const toastrMessageKey = isJobSearchActive - ? 'TOASTR.MESSAGE.EMPLOYEE_JOB_STATUS_ACTIVE' - : 'TOASTR.MESSAGE.EMPLOYEE_JOB_STATUS_INACTIVE'; - - this._toastrService.success(toastrMessageKey, { name: employee.fullName }); + // Call the service to update the job search availability status + this._jobSearchStoreService.updateJobSearchAvailability( + this.organization, + this.employee, + isJobSearchActive + ); } catch (error) { - const errorMessage = error?.message || 'An error occurred while updating the job search availability.'; - this._toastrService.danger(errorMessage); + // Log the error for debugging purposes + console.log('Error while updating job search availability:', error); } } } From b5c93175aae786f29d69a7a6f739dcf162f746e0 Mon Sep 17 00:00:00 2001 From: "Rahul R." Date: Mon, 21 Oct 2024 13:04:37 +0530 Subject: [PATCH 5/6] feat: apply code rabbit suggestions --- .../lib/components/job-employee/job-employee.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts b/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts index d4e7cc071ad..44521abaabe 100644 --- a/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts +++ b/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts @@ -10,7 +10,7 @@ import { TranslateService } from '@ngx-translate/core'; import { Cell } from 'angular2-smart-table'; import { NgxPermissionsService } from 'ngx-permissions'; import { ID, IEmployee, IOrganization, LanguagesEnum, PermissionsEnum } from '@gauzy/contracts'; -import { API_PREFIX, distinctUntilChange } from '@gauzy/ui-core/common'; +import { API_PREFIX, distinctUntilChange, isNotNullOrUndefined } from '@gauzy/ui-core/common'; import { PageDataTableRegistryService, EmployeesService, @@ -242,7 +242,7 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen width: '10%', // The width of the column isSortable: false, // Indicates whether the column is sortable isEditable: false, // Indicates whether the column is editable - valuePrepareFunction: (rawValue: any) => rawValue || 0, + valuePrepareFunction: (rawValue: any) => (isNotNullOrUndefined(rawValue) ? rawValue : 0), editor: { type: 'custom', component: NonEditableNumberEditorComponent @@ -259,7 +259,7 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen width: '10%', // The width of the column isSortable: false, // Indicates whether the column is sortable isEditable: false, // Indicates whether the column is editable - valuePrepareFunction: (rawValue: any) => rawValue || 0, + valuePrepareFunction: (rawValue: any) => (isNotNullOrUndefined(rawValue) ? rawValue : 0), editor: { type: 'custom', component: NonEditableNumberEditorComponent From 0eb8b3b03506c593bb9baa6a92dea92740990e7a Mon Sep 17 00:00:00 2001 From: "Rahul R." Date: Mon, 21 Oct 2024 13:25:09 +0530 Subject: [PATCH 6/6] fix: implement refresh the data table on edit cancellation --- .../job-employee/job-employee.component.html | 1 + .../job-employee/job-employee.component.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.html b/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.html index 5578d94fe8c..1a25595f902 100644 --- a/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.html +++ b/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.html @@ -32,6 +32,7 @@

[settings]="settingsSmartTable" [source]="smartTableSource" (editConfirm)="onEditConfirm($event)" + (editCancel)="onEditCancel($event)" (userRowSelect)="onSelectEmployee($event)" > diff --git a/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts b/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts index 44521abaabe..a538278d573 100644 --- a/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts +++ b/packages/plugins/job-employee-ui/src/lib/components/job-employee/job-employee.component.ts @@ -544,6 +544,21 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen } } + /** + * Handles the cancellation of an edit operation in the smart table. + * Refreshes the data table to reflect any changes made. + * + * @param event - The event object containing details about the canceled edit. + * + */ + onEditCancel(event: any): void { + // Optionally, you can log the event for debugging purposes + console.log('Edit canceled for row:', event); + + // Refresh the data table to revert any changes made during the edit + this.smartTableSource.refresh(); + } + /** * Applies translations to the Smart Table settings when the language changes. * This method listens for the onLangChange event from the translateService.