Skip to content

Commit

Permalink
feat(grid): add references param for cell editor and fix aiTableGridE…
Browse files Browse the repository at this point in the history
…ventService init params error (#211)
  • Loading branch information
pubuzhixing8 authored Dec 25, 2024
1 parent f1cefe4 commit fd1d642
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChangeDetectionStrategy, Component, computed, ElementRef, inject, Input, OnInit, output } from '@angular/core';
import { ChangeDetectionStrategy, Component, computed, ElementRef, inject, input, Input, OnInit, output } from '@angular/core';
import { ThyPopoverRef } from 'ngx-tethys/popover';
import { AITable, AITableField, AITableQueries, UpdateFieldValueOptions } from '../../core';
import { AITableReferences } from '../../types';

@Component({
selector: 'abstract-edit-cell',
Expand All @@ -15,6 +16,8 @@ export abstract class AbstractEditCellEditor<TValue, TFieldType extends AITableF

@Input({ required: true }) recordId!: string;

@Input({ required: true }) references!: AITableReferences;

updateFieldValue = output<UpdateFieldValueOptions<TValue>>();

modelValue!: TValue;
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/src/grid-base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class AITableGridBase implements OnInit {
}

initService() {
this.aiTableGridEventService.initialize(this.aiTable, this.aiFieldConfig()?.fieldPropertyEditor);
this.aiTableGridEventService.initialize(this.aiTable, this.aiFieldConfig()?.fieldRenderers);
this.aiTableGridSelectionService.initialize(this.aiTable);
this.aiTableGridMatchCellService.initialize(this.aiTable);
this.aiTableGridEventService.registerEvents(this.elementRef.nativeElement);
Expand Down
2 changes: 2 additions & 0 deletions packages/grid/src/grid.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ export class AITableGrid extends AITableGridBase implements OnInit, OnDestroy {
coordinate: this.coordinate(),
fieldId: fieldId!,
recordId: recordId!,
references: this.aiReferences(),
updateFieldValue: (value: UpdateFieldValueOptions<any>) => {
this.aiUpdateFieldValue.emit(value);
}
Expand Down Expand Up @@ -500,6 +501,7 @@ export class AITableGrid extends AITableGridBase implements OnInit, OnDestroy {
coordinate: this.coordinate(),
fieldId: fieldId!,
recordId: recordId!,
references: this.aiReferences(),
isHoverEdit: true,
updateFieldValue: (value: UpdateFieldValueOptions<any>) => {
this.aiUpdateFieldValue.emit(value);
Expand Down
3 changes: 2 additions & 1 deletion packages/grid/src/services/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class AITableGridEventService {
}

openCellEditor(aiTable: AITable, options: AITableOpenEditOptions) {
const { container, recordId, fieldId, isHoverEdit } = options;
const { container, recordId, fieldId, isHoverEdit, references } = options;
const component = this.getEditorComponent(this.aiTable.fieldsMap()[fieldId].type);
const offsetOriginPosition = this.getOriginPosition(aiTable, options);
this.cellEditorPopoverRef = this.thyPopover.open(component, {
Expand All @@ -165,6 +165,7 @@ export class AITableGridEventService {
initialState: {
fieldId: fieldId,
recordId: recordId,
references,
aiTable: aiTable
},
panelClass: 'grid-cell-editor',
Expand Down
1 change: 1 addition & 0 deletions packages/grid/src/types/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export interface AITableOpenEditOptions {
recordId: string;
fieldId: string;
coordinate: Coordinate;
references: AITableReferences;
container?: HTMLDivElement;
isHoverEdit?: boolean;
updateFieldValue: (options: UpdateFieldValueOptions<any>) => void;
Expand Down

0 comments on commit fd1d642

Please sign in to comment.