From adb55842a938e4f6e7247fd91d3dfeb12479031d Mon Sep 17 00:00:00 2001 From: minlovehua <321512939@qq.com> Date: Tue, 24 Dec 2024 18:38:46 +0800 Subject: [PATCH 1/2] feat(grid): support clear matchedCells when keywords is null --- packages/grid/src/grid.component.ts | 4 +--- packages/grid/src/services/match-cell.service.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/grid/src/grid.component.ts b/packages/grid/src/grid.component.ts index e2ed7a0f..e681c86c 100644 --- a/packages/grid/src/grid.component.ts +++ b/packages/grid/src/grid.component.ts @@ -150,9 +150,7 @@ export class AITableGrid extends AITableGridBase implements OnInit, OnDestroy { }); effect( () => { - if (this.aiKeywords()) { - this.aiTableGridMatchCellService.findMatchedCells(this.aiKeywords()!, this.aiReferences()); - } + this.aiTableGridMatchCellService.findMatchedCells(this.aiKeywords()!, this.aiReferences()); }, { allowSignalWrites: true } ); diff --git a/packages/grid/src/services/match-cell.service.ts b/packages/grid/src/services/match-cell.service.ts index a5dc53ab..7f543ebd 100644 --- a/packages/grid/src/services/match-cell.service.ts +++ b/packages/grid/src/services/match-cell.service.ts @@ -12,6 +12,10 @@ export class AITableGridMatchCellService { } findMatchedCells(keywords: string, references: AITableReferences) { + if (!keywords) { + this.clearMatchedCells(); + return; + } let matchedCells: string[] = []; this.aiTable.records().forEach((record) => { this.aiTable.fields().forEach((field) => { @@ -23,6 +27,10 @@ export class AITableGridMatchCellService { this.aiTable.matchedCells.set([...matchedCells]); } + private clearMatchedCells() { + this.aiTable.matchedCells.set([]); + } + private isCellMatchKeywords(aiTable: AITable, field: AITableField, recordId: string, keywords: string, references: AITableReferences) { const cellValue = AITableQueries.getFieldValue(aiTable, [recordId, field._id]); const transformValue = transformCellValue(aiTable, field, cellValue); From d015456209d5df090420cb5eac14cae0f95d79d7 Mon Sep 17 00:00:00 2001 From: minlovehua <321512939@qq.com> Date: Tue, 24 Dec 2024 18:39:20 +0800 Subject: [PATCH 2/2] fix(grid): support search by progress --- packages/grid/src/utils/field/index.ts | 3 ++- packages/grid/src/utils/field/progress.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/grid/src/utils/field/index.ts b/packages/grid/src/utils/field/index.ts index f09ee6dc..aaa4661a 100644 --- a/packages/grid/src/utils/field/index.ts +++ b/packages/grid/src/utils/field/index.ts @@ -2,6 +2,7 @@ import { AITableFieldType } from '../../index'; import { Field } from './field'; import { LinkField } from './link'; import { MemberField } from './member'; +import { ProgressField } from './progress'; import { SelectField } from './select'; import { TextField } from './text'; @@ -16,7 +17,7 @@ export const ViewOperationMap: Record = { [AITableFieldType.rate]: new TextField(), [AITableFieldType.link]: new LinkField(), [AITableFieldType.member]: new MemberField(), - [AITableFieldType.progress]: new TextField(), + [AITableFieldType.progress]: new ProgressField(), [AITableFieldType.createdBy]: new MemberField(), [AITableFieldType.updatedBy]: new MemberField() }; diff --git a/packages/grid/src/utils/field/progress.ts b/packages/grid/src/utils/field/progress.ts index f2201efc..946b040c 100644 --- a/packages/grid/src/utils/field/progress.ts +++ b/packages/grid/src/utils/field/progress.ts @@ -1,9 +1,12 @@ -import { AITableField } from '../../index'; +import { AITableField, isEmpty } from '../../index'; import { Field } from './field'; export class ProgressField extends Field { cellFullText(transformValue: number, field: AITableField): string[] { - const fullText = `${transformValue}%`; - return [fullText]; + let fullText: string[] = []; + if (!isEmpty(transformValue)) { + fullText.push(`${transformValue}%`); + } + return fullText; } }