-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8462 from ever-co/fix/8457-employee-edition-fields
[Fix] Employee Fields Edition on Job Page
- Loading branch information
Showing
7 changed files
with
151 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/ui-core/shared/src/lib/table-components/editors/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
74 changes: 74 additions & 0 deletions
74
...-core/shared/src/lib/table-components/editors/job-search-availability-editor.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { AfterViewInit, ChangeDetectorRef, Component, Input, OnInit, ViewChild } from '@angular/core'; | ||
import { filter, tap } from 'rxjs'; | ||
import { Cell, DefaultEditor } from 'angular2-smart-table'; | ||
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: ` | ||
<ngx-toggle-switcher [label]="false" (onSwitched)="updateJobSearchAvailability($event)"></ngx-toggle-switcher> | ||
` | ||
}) | ||
export class JobSearchAvailabilityEditorComponent extends DefaultEditor implements AfterViewInit, OnInit { | ||
public organization: IOrganization; | ||
public employee: IEmployee; | ||
|
||
// Reference to the cell object | ||
@Input() cell!: Cell; | ||
|
||
// Reference to the ToggleSwitcherComponent instance | ||
@ViewChild(ToggleSwitcherComponent) switcher!: ToggleSwitcherComponent; | ||
|
||
constructor( | ||
private readonly _cdr: ChangeDetectorRef, | ||
private readonly _store: Store, | ||
private readonly _jobSearchStoreService: JobSearchStoreService | ||
) { | ||
super(); | ||
} | ||
|
||
ngOnInit() { | ||
this._store.selectedOrganization$ | ||
.pipe( | ||
distinctUntilChange(), | ||
filter((organization: IOrganization) => !!organization), | ||
tap((organization: IOrganization) => { | ||
this.organization = organization; | ||
this.employee = this.cell.getRow()?.getData(); | ||
}), | ||
untilDestroyed(this) | ||
) | ||
.subscribe(); | ||
} | ||
|
||
ngAfterViewInit(): void { | ||
if (!this.switcher) { | ||
return; | ||
} | ||
this.switcher.value = this.employee?.isJobSearchActive || false; | ||
this._cdr.detectChanges(); // Force change detection to update the UI | ||
} | ||
|
||
/** | ||
* 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 { | ||
// Call the service to update the job search availability status | ||
this._jobSearchStoreService.updateJobSearchAvailability( | ||
this.organization, | ||
this.employee, | ||
isJobSearchActive | ||
); | ||
} catch (error) { | ||
// Log the error for debugging purposes | ||
console.log('Error while updating job search availability:', error); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...s/ui-core/shared/src/lib/table-components/editors/non-editable-number-editor.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { Cell, DefaultEditor } from 'angular2-smart-table'; | ||
|
||
@Component({ | ||
template: ` | ||
<div> | ||
{{ cellValue }} | ||
</div> | ||
` | ||
}) | ||
export class NonEditableNumberEditorComponent extends DefaultEditor implements OnInit { | ||
cellValue!: string | number; | ||
|
||
@Input() cell!: Cell; | ||
|
||
ngOnInit() { | ||
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 = ''; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters