Skip to content

Commit

Permalink
Merge branch 'develop' into fix/8457-employee-edition-fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-rocket authored Oct 21, 2024
2 parents 6a0c75e + 0db3a2c commit 0517849
Show file tree
Hide file tree
Showing 19 changed files with 134 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ <h4>
{{ integration?.lastSyncedAt || integration?.updatedAt | dateTimeFormat }}
</div>
<div class="col-2 p-0 float-left text-truncate">
<ngx-toggle-switch
<ngx-toggle-switcher
[value]="integration?.isActive"
[label]="false"
(switched)="updateIntegrationTenant(integration, $event)"
></ngx-toggle-switch>
(onSwitched)="updateIntegrationTenant(integration, $event)"
></ngx-toggle-switcher>
</div>
<div class="col-1 p-0 text-right text-truncate">
<div
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@
"build:package:config:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/config build:prod",
"build:package:plugin": "cross-env NODE_ENV=development NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugin build",
"build:package:plugin:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugin build",
"build:package:plugins:pre": "yarn run build:package:ui-config && yarn run build:package:ui-core && yarn run build:package:ui-auth && yarn run build:package:plugin:onboarding-ui && yarn run build:package:plugin:legal-ui && yarn run build:package:plugin:job-search-ui && yarn run build:package:plugin:job-matching-ui && yarn run build:package:plugin:job-employee-ui && yarn run build:package:plugin:job-proposal-ui && yarn run build:package:plugin:public-layout-ui && yarn run build:package:plugin:maintenance-ui && yarn run build:package:plugin:integration-ai-ui && yarn run build:package:plugin:integration-hubstaff-ui",
"build:package:plugins:pre:prod": "yarn run build:package:ui-config:prod && yarn run build:package:ui-core:prod && yarn run build:package:ui-auth && yarn run build:package:plugin:onboarding-ui:prod && yarn run build:package:plugin:legal-ui:prod && yarn run build:package:plugin:job-search-ui:prod && yarn run build:package:plugin:job-matching-ui:prod && yarn run build:package:plugin:job-employee-ui:prod && yarn run build:package:plugin:job-proposal-ui:prod && yarn run build:package:plugin:public-layout-ui:prod && yarn run build:package:plugin:maintenance-ui:prod && yarn run build:package:plugin:integration-ai-ui:prod && yarn run build:package:plugin:integration-hubstaff-ui:prod",
"build:package:plugins:pre": "yarn run build:package:ui-config && yarn run build:package:ui-core && yarn run build:package:ui-auth && yarn run build:package:plugin:onboarding-ui && yarn run build:package:plugin:legal-ui && yarn run build:package:plugin:job-search-ui && yarn run build:package:plugin:job-matching-ui && yarn run build:package:plugin:job-employee-ui && yarn run build:package:plugin:job-proposal-ui && yarn run build:package:plugin:public-layout-ui && yarn run build:package:plugin:maintenance-ui && yarn run build:integration-ui-plugins",
"build:package:plugins:pre:prod": "yarn run build:package:ui-config:prod && yarn run build:package:ui-core:prod && yarn run build:package:ui-auth:prod && yarn run build:package:plugin:onboarding-ui:prod && yarn run build:package:plugin:legal-ui:prod && yarn run build:package:plugin:job-search-ui:prod && yarn run build:package:plugin:job-matching-ui:prod && yarn run build:package:plugin:job-employee-ui:prod && yarn run build:package:plugin:job-proposal-ui:prod && yarn run build:package:plugin:public-layout-ui:prod && yarn run build:package:plugin:maintenance-ui:prod && yarn run build:integration-ui-plugins:prod",
"build:package:plugins:post": "yarn run build:package:plugin:integration-jira && yarn run build:package:plugin:integration-ai && yarn run build:package:plugin:sentry && yarn run build:package:plugin:jitsu-analytic && yarn run build:package:plugin:product-reviews && yarn run build:package:plugin:job-search && yarn run build:package:plugin:job-proposal && yarn run build:package:plugin:integration-github && yarn run build:package:plugin:knowledge-base && yarn run build:package:plugin:changelog && yarn run build:package:plugin:integration-hubstaff && yarn run build:package:plugin:integration-upwork",
"build:package:plugins:post:prod": "yarn run build:package:plugin:integration-jira:prod && yarn run build:package:plugin:integration-ai:prod && yarn run build:package:plugin:sentry:prod && yarn run build:package:plugin:jitsu-analytic:prod && yarn run build:package:plugin:product-reviews:prod && yarn run build:package:plugin:job-search:prod && yarn run build:package:plugin:job-proposal:prod && yarn run build:package:plugin:integration-github:prod && yarn run build:package:plugin:knowledge-base:prod && yarn run build:package:plugin:changelog:prod && yarn run build:package:plugin:integration-hubstaff:prod && yarn run build:package:plugin:integration-upwork:prod",
"build:package:plugin:integration-ai": "cross-env NODE_ENV=development NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/integration-ai build",
Expand All @@ -160,13 +160,15 @@
"build:package:plugin:job-search": "cross-env NODE_ENV=development NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/job-search build",
"build:package:plugin:job-search:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/job-search build:prod",
"build:package:plugin:integration-ai-ui": "cross-env NODE_ENV=development NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/integration-ai-ui lib:build",
"build:package:plugin:integration-ai-ui:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/integration-ai-ui lib:build:prod",
"build:package:plugin:integration-hubstaff-ui": "cross-env NODE_ENV=development NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/integration-hubstaff-ui lib:build",
"build:package:plugin:integration-hubstaff-ui:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/integration-hubstaff-ui lib:build:prod",
"build:package:plugin:integration-github-ui": "cross-env NODE_ENV=development NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/integration-github-ui lib:build",
"build:package:plugin:integration-github-ui:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/integration-github-ui lib:build:prod",
"build:package:plugin:integration-upwork-ui": "cross-env NODE_ENV=development NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/integration-upwork-ui lib:build",
"build:package:plugin:integration-ai-ui:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/integration-ai-ui lib:build:prod",
"build:package:plugin:integration-hubstaff-ui:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/integration-hubstaff-ui lib:build:prod",
"build:package:plugin:integration-github-ui:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/integration-github-ui lib:build:prod",
"build:package:plugin:integration-upwork-ui:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/integration-upwork-ui lib:build:prod",
"build:integration-ui-plugins": "yarn run build:package:plugin:integration-ai-ui && yarn run build:package:plugin:integration-hubstaff-ui && yarn run build:package:plugin:integration-upwork-ui && yarn run build:package:plugin:integration-github-ui",
"build:integration-ui-plugins:prod": "yarn run build:package:plugin:integration-ai-ui:prod && yarn run build:package:plugin:integration-hubstaff-ui:prod && yarn run build:package:plugin:integration-upwork-ui:prod && yarn run build:package:plugin:integration-github-ui:prod",
"build:package:plugin:job-employee-ui": "cross-env NODE_ENV=development NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/job-employee-ui lib:build",
"build:package:plugin:job-employee-ui:prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/job-employee-ui lib:build:prod",
"build:package:plugin:job-matching-ui": "cross-env NODE_ENV=development NODE_OPTIONS=--max-old-space-size=12288 yarn --cwd ./packages/plugins/job-matching-ui lib:build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
ProjectComponent,
GithubRepositoryComponent,
GithubIssueTitleDescriptionComponent,
ToggleSwitchComponent,
ToggleSwitcherComponent,
ResyncButtonComponent,
PaginationFilterBaseComponent,
IPaginationBase,
Expand Down Expand Up @@ -402,17 +402,17 @@ export class GithubViewComponent extends PaginationFilterBaseComponent implement
title: this.getTranslation('SM_TABLE.ENABLED_DISABLED_SYNC'),
type: 'custom',
isFilterable: false,
renderComponent: ToggleSwitchComponent,
componentInitFunction: (instance: ToggleSwitchComponent, cell: Cell) => {
renderComponent: ToggleSwitcherComponent,
componentInitFunction: (instance: ToggleSwitcherComponent, cell: Cell) => {
// Get the data of the entire row
const rowData = cell.getRow().getData();

// Set properties on the ToggleSwitchComponent instance
// Set properties on the ToggleSwitcherComponent instance
instance.rowData = rowData;
instance.value = rowData?.customFields?.repository?.hasSyncEnabled || false;

// Subscribe to the 'switched' event of the ToggleSwitchComponent
instance.switched.subscribe({
// Subscribe to the 'switched' event of the ToggleSwitcherComponent
instance.onSwitched.subscribe({
// When the switch state changes, execute the following callback
next: (hasSyncEnabled: boolean) => {
// Call the 'updateGithubRepository' method with the row data and the new switch state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
ToastrService,
PageTabsetRegistryId,
PageTabRegistryService,
PageDataTableRegistryId
PageDataTableRegistryId,
JobSearchStoreService
} from '@gauzy/ui-core/core';
import { I18nService } from '@gauzy/ui-core/i18n';
import {
Expand All @@ -32,6 +33,7 @@ import {
SmartTableToggleComponent,
NonEditableNumberEditorComponent,
JobSearchAvailabilityEditorComponent
ToggleSwitcherComponent
} from '@gauzy/ui-core/shared';

/**
Expand Down Expand Up @@ -77,6 +79,7 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen
private readonly _store: Store,
private readonly _employeesService: EmployeesService,
private readonly _jobService: JobService,
private readonly _jobSearchStoreService: JobSearchStoreService,
private readonly _toastrService: ToastrService,
private readonly _currencyPipe: CurrencyPipe,
private readonly _i18nService: I18nService,
Expand Down Expand Up @@ -208,7 +211,7 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen
registerDataTableColumns(_pageDataTableRegistryService: PageDataTableRegistryService): void {
// Register the data table column
_pageDataTableRegistryService.registerPageDataTableColumn({
dataTableId: 'job-employee', // The identifier for the data table location
dataTableId: this.dataTableId, // The identifier for the data table location
columnId: 'name', // The identifier for the column
order: 0, // The order of the column in the table
title: () => this.getTranslation('JOB_EMPLOYEE.EMPLOYEE'), // The title of the column
Expand All @@ -232,7 +235,7 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen

// Register the data table column
_pageDataTableRegistryService.registerPageDataTableColumn({
dataTableId: 'job-employee', // The identifier for the data table location
dataTableId: this.dataTableId, // The identifier for the data table location
columnId: 'availableJobs', // The identifier for the column
order: 1, // The order of the column in the table
title: () => this.getTranslation('JOB_EMPLOYEE.AVAILABLE_JOBS'), // The title of the column
Expand All @@ -249,7 +252,7 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen

// Register the data table column
_pageDataTableRegistryService.registerPageDataTableColumn({
dataTableId: 'job-employee', // The identifier for the data table location
dataTableId: this.dataTableId, // The identifier for the data table location
columnId: 'appliedJobs', // The identifier for the column
order: 2, // The order of the column in the table
title: () => this.getTranslation('JOB_EMPLOYEE.APPLIED_JOBS'), // The title of the column
Expand All @@ -266,7 +269,7 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen

// Register the data table column
_pageDataTableRegistryService.registerPageDataTableColumn({
dataTableId: 'job-employee', // The identifier for the data table location
dataTableId: this.dataTableId, // The identifier for the data table location
columnId: 'billRateValue', // The identifier for the column
order: 3, // The order of the column in the table
title: () => this.getTranslation('JOB_EMPLOYEE.BILLING_RATE'), // The title of the column
Expand All @@ -288,7 +291,7 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen

// Register the data table column
_pageDataTableRegistryService.registerPageDataTableColumn({
dataTableId: 'job-employee', // The identifier for the data table location
dataTableId: this.dataTableId, // The identifier for the data table location
columnId: 'minimumBillingRate', // The identifier for the column
order: 4, // The order of the column in the table
title: () => this.getTranslation('JOB_EMPLOYEE.MINIMUM_BILLING_RATE'), // The title of the column
Expand All @@ -308,25 +311,28 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen

// Register the data table column
_pageDataTableRegistryService.registerPageDataTableColumn({
dataTableId: 'job-employee', // The identifier for the data table location
dataTableId: this.dataTableId, // The identifier for the data table location
columnId: 'isJobSearchActive', // The identifier for the column
order: 5, // The order of the column in the table
title: () => this.getTranslation('JOB_EMPLOYEE.JOB_SEARCH_STATUS'), // The title of the column
type: 'custom', // The type of the column
width: '20%', // The width of the column
isSortable: false, // Indicates whether the column is sortable
isEditable: true, // Indicates whether the column is editable
renderComponent: SmartTableToggleComponent,
componentInitFunction: (instance: SmartTableToggleComponent, cell: Cell) => {
renderComponent: ToggleSwitcherComponent,
componentInitFunction: (instance: ToggleSwitcherComponent, cell: Cell) => {
// Get the employee data from the cell
const employee: IEmployee = cell.getRow().getData();

// Set the label property to false to hide the label
instance.label = false;
// Set the initial value of the toggle
instance.value = employee.isJobSearchActive;

// Subscribe to the toggleChange event
instance.toggleChange.pipe(untilDestroyed(this)).subscribe((toggle: boolean) => {
this.updateJobSearchAvailability(employee, toggle);
instance.onSwitched.subscribe((toggle: boolean) => {
// Call the JobSearchStoreService to update the job search availability
this._jobSearchStoreService.updateJobSearchAvailability(this.organization, employee, toggle);
});
},
editor: {
Expand Down Expand Up @@ -539,42 +545,6 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen
}
}

/**
* Updates the job search availability status of an employee within the organization.
* @param employee - The employee object to update.
* @param isJobSearchActive - A boolean flag indicating whether the job search is active.
* @returns {Promise<void>} - A Promise resolving to void.
*/
async updateJobSearchAvailability(employee: IEmployee, isJobSearchActive: boolean): Promise<void> {
try {
// Ensure the organization context is available before proceeding.
if (!this.organization) {
return;
}

// Destructure organization properties for clarity.
const { id: organizationId, tenantId } = this.organization;

// Update the job search status using the employeesService.
await this._jobService.updateJobSearchStatus(employee.id, {
isJobSearchActive,
organizationId,
tenantId
});

// Display a success toastr notification based on the job search status.
const toastrMessageKey = isJobSearchActive
? 'TOASTR.MESSAGE.EMPLOYEE_JOB_STATUS_ACTIVE'
: 'TOASTR.MESSAGE.EMPLOYEE_JOB_STATUS_INACTIVE';

const fullName = employee.fullName.trim() || 'Unknown Employee';
this._toastrService.success(toastrMessageKey, { name: fullName });
} catch (error) {
// Display an error toastr notification in case of any exceptions.
this._toastrService.danger(error);
}
}

/**
* Applies translations to the Smart Table settings when the language changes.
* This method listens for the onLangChange event from the translateService.
Expand Down
3 changes: 2 additions & 1 deletion packages/ui-core/core/src/lib/services/job/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './job-preset.service';
export * from './job-search-category.service';
export * from './job-search-occupation.service';
export * from './job.service';
export * from './job.service';
export * from './job-search.store.service';
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { firstValueFrom } from 'rxjs';
import { ID, IEmployeePresetInput, IGetJobPresetInput, IJobPreset, IMatchingCriterions } from '@gauzy/contracts';
import { toParams } from '@gauzy/ui-core/common';
import { API_PREFIX } from '@gauzy/ui-core/common';
import { API_PREFIX, toParams } from '@gauzy/ui-core/common';

@Injectable({
providedIn: 'root'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Injectable } from '@angular/core';
import { IEmployee, IOrganization } from '@gauzy/contracts';
import { JobService } from './job.service';
import { ToastrService } from '../notification/toastr.service';

@Injectable({
providedIn: 'root'
})
export class JobSearchStoreService {
constructor(private readonly _jobService: JobService, private readonly _toastrService: ToastrService) {}

/**
* Updates the job search availability status of an employee within the organization.
*
* @param organization - The current organization context.
* @param employee - The employee object to update.
* @param isJobSearchActive - A boolean flag indicating whether the job search is active.
* @returns {Promise<void>} - A Promise resolving to void.
*/
async updateJobSearchAvailability(
organization: IOrganization | undefined,
employee: IEmployee,
isJobSearchActive: boolean
): Promise<void> {
try {
// Ensure the organization context is available before proceeding.
if (!organization) {
console.warn('No organization provided to update job search availability.');
return;
}

// Destructure organization properties for clarity.
const { id: organizationId, tenantId } = organization;

// Update the job search status using the employeesService.
await this._jobService.updateJobSearchStatus(employee.id, {
isJobSearchActive,
organizationId,
tenantId
});

// Display a success toastr notification based on the job search status.
const toastrMessageKey = isJobSearchActive
? 'TOASTR.MESSAGE.EMPLOYEE_JOB_STATUS_ACTIVE'
: 'TOASTR.MESSAGE.EMPLOYEE_JOB_STATUS_INACTIVE';

const fullName = employee.fullName.trim() || 'Unknown Employee';
this._toastrService.success(toastrMessageKey, { name: fullName });
} catch (error) {
// Display an error toastr notification in case of any exceptions.
const errorMessage = error?.message || 'An error occurred while updating the job search availability.';
console.error('Error while updating job search availability:', error?.message);
this._toastrService.danger(errorMessage);
}
}
}
Loading

0 comments on commit 0517849

Please sign in to comment.