Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Employee Field Shows [Object Object] on Edit and Should Be Non-editable on Job Page #8453

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
EmployeeLinksComponent,
IPaginationBase,
NumberEditorComponent,
EmployeeLinkEditorComponent,
PaginationFilterBaseComponent,
SmartTableToggleComponent
} from '@gauzy/ui-core/shared';
Expand Down Expand Up @@ -212,14 +213,18 @@ export class JobEmployeeComponent extends PaginationFilterBaseComponent implemen
type: 'custom', // The type of the column
width: '20%', // The width of the column
isSortable: true, // Indicates whether the column is sortable
isEditable: true, // Indicates whether the column is editable
isEditable: false, // Indicates whether the column is editable
renderComponent: EmployeeLinksComponent,
valuePrepareFunction: (_: any, cell: Cell) => this.prepareEmployeeValue(_, cell),
componentInitFunction: (instance: EmployeeLinksComponent, cell: Cell) => {
// Get the row data from the cell
instance.rowData = cell.getRow().getData();
// Get the value from the cell
instance.value = cell.getValue();
},
editor: {
type: 'custom',
component: EmployeeLinkEditorComponent // Use the custom component for display
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Component, Input, OnInit } from '@angular/core';
import { IEmployee, IUser } from '@gauzy/contracts';
import { Cell, DefaultEditor } from 'angular2-smart-table';

@Component({
template: `
<ng-container *ngIf="value">
<a *ngIf="value?.name">
<img *ngIf="value.imageUrl" width="18px" height="18px" [src]="value.imageUrl" />
<div class="names-wrapper">
{{ value.name }}
</div>
</a>
</ng-container>
`,
styleUrls: ['../employee-links/employee-links.component.scss']
})
export class EmployeeLinkEditorComponent extends DefaultEditor implements OnInit {
@Input() cell!: Cell; // Input to access the cell data
value!: IUser;

ngOnInit() {
const employee: IEmployee | undefined = this.cell.getRow().getData();
this.value = employee?.user ?? null;
}
}
1 change: 1 addition & 0 deletions packages/ui-core/shared/src/lib/table-components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export * from './date-view/date-view.component';
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 './email/email.component';
export * from './employee-links/employee-links.component';
export * from './employee-with-links/employee-with-links.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { ValueWithUnitComponent } from './value-with-units/value-with-units.comp
import { VisibilityComponent } from './visibility/visibility.component';
import { DirectivesModule } from '../directives/directives.module';
import { TaskBadgeViewComponentModule } from '../tasks/task-badge-view/task-badge-view.module';
import { EmployeeLinkEditorComponent } from '../public-api';

@NgModule({
imports: [
Expand Down Expand Up @@ -86,6 +87,7 @@ import { TaskBadgeViewComponentModule } from '../tasks/task-badge-view/task-badg
InvoiceTotalValueComponent,
NotesWithTagsComponent,
NumberEditorComponent,
EmployeeLinkEditorComponent,
OrganizationWithTagsComponent,
PhoneUrlComponent,
PictureNameTagsComponent,
Expand Down
Loading