Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

chore: open filter panel and then get values

Wenzhao Hufa6bd022ecb1
diff --git a/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts b/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts
index 71aeeb181c..163c8c8a80 100644
--- a/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts
+++ b/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts
@@ -21,7 +21,7 @@ import { SetSheetsFilterRangeMutation, UniverSheetsFilterPlugin } from '@univerj
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { RefRangeService, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';
import type { IEditorBridgeServiceVisibleParam } from '@univerjs/sheets-ui';
-import { CloseFilterPanelOperation, FILTER_PANEL_OPENED_KEY, OpenFilterPanelCommand } from '../sheets-filter.operation';
+import { CloseFilterPanelOperation, FILTER_PANEL_OPENED_KEY, OpenFilterPanelOperation } from '../sheets-filter.operation';
import { SheetsFilterPanelService } from '../../../services/sheets-filter-panel.service';
const SetCellEditVisibleOperation: IOperation<IEditorBridgeServiceVisibleParam> = {
@@ -92,7 +92,7 @@ function createFilterOperationTestBed() {
const commandService = get(ICommandService);
[
- OpenFilterPanelCommand,
+ OpenFilterPanelOperation,
CloseFilterPanelOperation,
SetCellEditVisibleOperation,
].forEach((command) => commandService.registerCommand(command));
@@ -124,7 +124,7 @@ describe('test sheets filter ui operations', () => {
describe('test "OpenFilerPanelOperation"', () => {
it('should return false when the filter model is not found', () => {
const spy = vi.spyOn(sheetsFilterPanelService, 'setupCol');
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
@@ -139,7 +139,7 @@ describe('test sheets filter ui operations', () => {
subUnitId: 'sheet1',
range: { startRow: 0, startColumn: 0, endRow: 5, endColumn: 5 },
} as ISetSheetsFilterRangeMutationParams)).toBeTruthy();
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
diff --git a/packages/sheets-filter-ui/src/commands/operations/sheets-filter.operation.ts b/packages/sheets-filter-ui/src/commands/operations/sheets-filter.operation.ts
index 22bfc0856e..c26ecc7a63 100644
--- a/packages/sheets-filter-ui/src/commands/operations/sheets-filter.operation.ts
+++ b/packages/sheets-filter-ui/src/commands/operations/sheets-filter.operation.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { ICommand, IOperation } from '@univerjs/core';
+import type { IOperation } from '@univerjs/core';
import { CommandType, ICommandService, IContextService, Quantity } from '@univerjs/core';
import { SheetsFilterService } from '@univerjs/sheets-filter';
import { ILayoutService } from '@univerjs/ui';
@@ -24,7 +24,7 @@ import { SheetsFilterPanelService } from '../../services/sheets-filter-panel.ser
export const FILTER_PANEL_OPENED_KEY = 'FILTER_PANEL_OPENED';
-export interface IOpenFilterPanelCommandParams {
+export interface IOpenFilterPanelOperationParams {
unitId: string;
subUnitId: string;
@@ -34,10 +34,10 @@ export interface IOpenFilterPanelCommandParams {
/**
* The operation to open the filter panel and prepare for changing the filter conditions on a given column.
*/
-export const OpenFilterPanelCommand: ICommand<IOpenFilterPanelCommandParams> = {
- id: 'sheet.commadn.open-filter-panel',
- type: CommandType.COMMAND,
- handler: async (accessor, params: IOpenFilterPanelCommandParams) => {
+export const OpenFilterPanelOperation: IOperation<IOpenFilterPanelOperationParams> = {
+ id: 'sheet.operation.open-filter-panel',
+ type: CommandType.OPERATION,
+ handler: (accessor, params: IOpenFilterPanelOperationParams) => {
const contextService = accessor.get(IContextService);
const sheetsFilterService = accessor.get(SheetsFilterService);
const sheetsFilterPanelService = accessor.get(SheetsFilterPanelService);
@@ -50,7 +50,7 @@ export const OpenFilterPanelCommand: ICommand<IOpenFilterPanelCommandParams> = {
const filterModel = sheetsFilterService.getFilterModel(unitId, subUnitId);
if (!filterModel) return false;
- const result = await sheetsFilterPanelService.setupCol(filterModel, col);
+ const result = sheetsFilterPanelService.setupCol(filterModel, col);
if (!result) return false;
if (!contextService.getContextValue(FILTER_PANEL_OPENED_KEY)) {
diff --git a/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts b/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
index bf7ea1c824..4d77b8b389 100644
--- a/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
+++ b/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
@@ -22,7 +22,7 @@ import { RemoveSheetsFilterMutation, SetSheetsFilterCriteriaMutation, SetSheetsF
import { IMenuService, IPlatformService, IShortcutService, MenuService, PlatformService, ShortcutService } from '@univerjs/ui';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, SmartToggleSheetsFilterCommand } from '../../commands/commands/sheets-filter.command';
-import { CloseFilterPanelOperation, OpenFilterPanelCommand } from '../../commands/operations/sheets-filter.operation';
+import { CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
import { ClearFilterCriteriaMenuItemFactory, ReCalcFilterMenuItemFactory, SmartToggleFilterMenuItemFactory } from '../sheets-filter.menu';
const TEST_WORKBOOK_DATA_DEMO: IWorkbookData = {
@@ -82,7 +82,7 @@ function createSheetsFilterMenuTestBed() {
SmartToggleSheetsFilterCommand,
ClearSheetsFilterCriteriaCommand,
ReCalcSheetsFilterCommand,
- OpenFilterPanelCommand,
+ OpenFilterPanelOperation,
CloseFilterPanelOperation,
].forEach((command) => commandService.registerCommand(command));
}
diff --git a/packages/sheets-filter-ui/src/controllers/sheets-filter-permission.controller.ts b/packages/sheets-filter-ui/src/controllers/sheets-filter-permission.controller.ts
index 310684edd0..0b9f074c08 100644
--- a/packages/sheets-filter-ui/src/controllers/sheets-filter-permission.controller.ts
+++ b/packages/sheets-filter-ui/src/controllers/sheets-filter-permission.controller.ts
@@ -23,7 +23,7 @@ import { SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';
import { SheetsFilterService } from '@univerjs/sheets-filter';
import { RangeProtectionPermissionViewPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetFilterPermission } from '@univerjs/sheets';
import { SmartToggleSheetsFilterCommand } from '../commands/commands/sheets-filter.command';
-import { type IOpenFilterPanelCommandParams, OpenFilterPanelCommand } from '../commands/operations/sheets-filter.operation';
+import { type IOpenFilterPanelOperationParams, OpenFilterPanelOperation } from '../commands/operations/sheets-filter.operation';
export interface IUniverSheetsFilterUIConfig {
menu: MenuConfig;
@@ -63,8 +63,8 @@ export class SheetsFilterPermissionController extends Disposable {
this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t('permission.dialog.filterErr'));
}
}
- if (command.id === OpenFilterPanelCommand.id) {
- const params = command.params as IOpenFilterPanelCommandParams;
+ if (command.id === OpenFilterPanelOperation.id) {
+ const params = command.params as IOpenFilterPanelOperationParams;
const { unitId, subUnitId } = params;
const filterRange = this._sheetsFilterService.getFilterModel(unitId, subUnitId)?.getRange();
const colRange = Tools.deepClone(filterRange);
diff --git a/packages/sheets-filter-ui/src/controllers/sheets-filter-ui.controller.ts b/packages/sheets-filter-ui/src/controllers/sheets-filter-ui.controller.ts
index ea15a86c48..1f8e786376 100644
--- a/packages/sheets-filter-ui/src/controllers/sheets-filter-ui.controller.ts
+++ b/packages/sheets-filter-ui/src/controllers/sheets-filter-ui.controller.ts
@@ -28,7 +28,7 @@ import { SheetsFilterService } from '@univerjs/sheets-filter';
import { MessageType } from '@univerjs/design';
import { ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, SetSheetsFilterCriteriaCommand, SmartToggleSheetsFilterCommand } from '../commands/commands/sheets-filter.command';
import { FilterPanel } from '../views/components/SheetsFilterPanel';
-import { ChangeFilterByOperation, CloseFilterPanelOperation, FILTER_PANEL_OPENED_KEY, OpenFilterPanelCommand } from '../commands/operations/sheets-filter.operation';
+import { ChangeFilterByOperation, CloseFilterPanelOperation, FILTER_PANEL_OPENED_KEY, OpenFilterPanelOperation } from '../commands/operations/sheets-filter.operation';
import { SheetsFilterPanelService } from '../services/sheets-filter-panel.service';
import { SmartToggleFilterShortcut } from './sheets-filter.shortcut';
import { ClearFilterCriteriaMenuItemFactory, ReCalcFilterMenuItemFactory, SmartToggleFilterMenuItemFactory } from './sheets-filter.menu';
@@ -93,7 +93,7 @@ export class SheetsFilterUIController extends SheetsFilterMobileUIController {
ClearSheetsFilterCriteriaCommand,
ReCalcSheetsFilterCommand,
ChangeFilterByOperation,
- OpenFilterPanelCommand,
+ OpenFilterPanelOperation,
CloseFilterPanelOperation,
].forEach((c) => {
this.disposeWithMe(this._commandService.registerCommand(c));
diff --git a/packages/sheets-filter-ui/src/index.ts b/packages/sheets-filter-ui/src/index.ts
index 2af4893bfe..177f562bca 100644
--- a/packages/sheets-filter-ui/src/index.ts
+++ b/packages/sheets-filter-ui/src/index.ts
@@ -27,10 +27,10 @@ export {
ReCalcSheetsFilterCommand,
} from './commands/commands/sheets-filter.command';
export {
- OpenFilterPanelCommand,
+ OpenFilterPanelOperation,
CloseFilterPanelOperation,
ChangeFilterByOperation,
- type IOpenFilterPanelCommandParams,
+ type IOpenFilterPanelOperationParams,
} from './commands/operations/sheets-filter.operation';
// #endregion
diff --git a/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts b/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts
index f7fc0cb462..ccd588b07b 100644
--- a/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts
+++ b/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts
@@ -21,8 +21,8 @@ import { afterEach, beforeEach, describe, expect, it, vitest } from 'vitest';
import { CustomFilterOperator, SheetsFilterService, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import type { IEditorBridgeServiceVisibleParam } from '@univerjs/sheets-ui';
import { ByConditionsModel, ByValuesModel, FilterBy, SheetsFilterPanelService } from '../sheets-filter-panel.service';
-import type { IOpenFilterPanelCommandParams } from '../../commands/operations/sheets-filter.operation';
-import { CloseFilterPanelOperation, OpenFilterPanelCommand } from '../../commands/operations/sheets-filter.operation';
+import type { IOpenFilterPanelOperationParams } from '../../commands/operations/sheets-filter.operation';
+import { CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
import { E_ITEMS, ITEMS, WithCustomFilterModelFactory, WithMergedCellFilterFactory, WithMultiEmptyCellsModelFactory, WithTwoFilterColumnsFactory, WithValuesAndEmptyFilterModelFactory, WithValuesFilterModelFactory } from '../../__testing__/data';
import type { IFilterConditionFormParams } from '../../models/conditions';
import { FilterConditionItems } from '../../models/conditions';
@@ -74,7 +74,7 @@ function createSheetsFilterPanelServiceTestBed(workbookData: IWorkbookData) {
const commandService = get(ICommandService);
[
- OpenFilterPanelCommand,
+ OpenFilterPanelOperation,
CloseFilterPanelOperation,
SetSheetsFilterCriteriaCommand,
SetCellEditVisibleOperation,
@@ -110,11 +110,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should initialize by conditional model when the filter column is by custom filters', () => {
prepare(WithCustomFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams)).toBe(true);
+ } as IOpenFilterPanelOperationParams)).toBe(true);
expect(sheetsFilterPanelService.filterBy).toBe(FilterBy.CONDITIONS);
const filterByModel = sheetsFilterPanelService.filterByModel as ByConditionsModel;
@@ -128,11 +128,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should update the filter condition item when the primary operator changes', () => {
prepare(WithCustomFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams)).toBe(true);
+ } as IOpenFilterPanelOperationParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByConditionsModel;
@@ -157,11 +157,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should update primary operator when the secondary operator changes (in some conditions)', () => {
prepare(WithCustomFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams)).toBe(true);
+ } as IOpenFilterPanelOperationParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByConditionsModel;
@@ -186,11 +186,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should execute command when "apply" is called', async () => {
prepare(WithCustomFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams)).toBe(true);
+ } as IOpenFilterPanelOperationParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByConditionsModel;
filterByModel.onConditionFormChange({ val1: '5' });
@@ -205,11 +205,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should initialize by filters when the filter column holds "filters"', () => {
prepare(WithValuesFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams)).toBeTruthy();
+ } as IOpenFilterPanelOperationParams)).toBeTruthy();
expect(sheetsFilterPanelService.filterBy).toBe(FilterBy.VALUES);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -220,11 +220,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should initialize with blank content', () => {
prepare(WithValuesAndEmptyFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams)).toBeTruthy();
+ } as IOpenFilterPanelOperationParams)).toBeTruthy();
expect(sheetsFilterPanelService.filterBy).toBe(FilterBy.VALUES);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -241,11 +241,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should count empty cells', () => {
prepare(WithMultiEmptyCellsModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams)).toBeTruthy();
+ } as IOpenFilterPanelOperationParams)).toBeTruthy();
expect(sheetsFilterPanelService.filterBy).toBe(FilterBy.VALUES);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -263,11 +263,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should filter out the items from the panel if its row is already filtered out by other column', () => {
prepare(WithTwoFilterColumnsFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 1,
- } as IOpenFilterPanelCommandParams)).toBeTruthy();
+ } as IOpenFilterPanelOperationParams)).toBeTruthy();
expect(sheetsFilterPanelService.filterBy).toBe(FilterBy.VALUES);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -308,11 +308,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('merged cell should use value of the top left corner', () => {
prepare(WithMergedCellFilterFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 1,
- } as IOpenFilterPanelCommandParams)).toBeTruthy();
+ } as IOpenFilterPanelOperationParams)).toBeTruthy();
expect(sheetsFilterPanelService.filterBy).toBe(FilterBy.VALUES);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -346,11 +346,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should update the filter items when toggle checked status', () => {
prepare(WithValuesFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams)).toBe(true);
+ } as IOpenFilterPanelOperationParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
filterByModel.onFilterCheckToggled(ITEMS[0], true);
@@ -371,11 +371,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should execute command when "apply" is called', async () => {
prepare(WithValuesFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams)).toBe(true);
+ } as IOpenFilterPanelOperationParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
filterByModel.onFilterCheckToggled(ITEMS[0], true);
@@ -402,11 +402,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should update the filter items when searching', () => {
prepare(WithValuesFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams)).toBe(true);
+ } as IOpenFilterPanelOperationParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -418,11 +418,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should toggle all applied to searched results', () => {
prepare(WithValuesFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams)).toBe(true);
+ } as IOpenFilterPanelOperationParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
@@ -436,11 +436,11 @@ describe('test "SheetsFilterPanelService"', () => {
it('should filter only applied to searched results', () => {
prepare(WithValuesFilterModelFactory());
- expect(commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ expect(commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams)).toBe(true);
+ } as IOpenFilterPanelOperationParams)).toBe(true);
const filterByModel = sheetsFilterPanelService.filterByModel as ByValuesModel;
diff --git a/packages/sheets-filter-ui/src/services/sheets-filter-panel.service.ts b/packages/sheets-filter-ui/src/services/sheets-filter-panel.service.ts
index 9e72be5b11..de364ea0ef 100644
--- a/packages/sheets-filter-ui/src/services/sheets-filter-panel.service.ts
+++ b/packages/sheets-filter-ui/src/services/sheets-filter-panel.service.ts
@@ -113,34 +113,38 @@ export class SheetsFilterPanelService extends Disposable {
this._hasCriteria$.complete();
}
- async setupCol(filterModel: FilterModel, col: number): Promise<boolean> {
+ setupCol(filterModel: FilterModel, col: number): { result: Promise<boolean> } {
this.terminate();
this._filterModel = filterModel;
this._col$.next(col);
+ let result;
+
// We use filter type that (if) has been set on the column as the default filter type.
const filterColumn = filterModel.getFilterColumn(col);
if (filterColumn) {
const info = filterColumn.getColumnData();
if (info.customFilters) {
this._hasCriteria$.next(true);
- return this._setupByConditions(filterModel, col);
+ result = { result: this._setupByConditions(filterModel, col) };
}
if (info.filters) {
this._hasCriteria$.next(true);
- return this._setupByValues(filterModel, col);
+ result = { result: this._setupByValues(filterModel, col) };
}
// Use value values by default.
this._hasCriteria$.next(false);
- return this._setupByValues(filterModel, col);
+ result = { result: this._setupByValues(filterModel, col) };
}
// By default we filter by values.
this._hasCriteria$.next(false);
- return this._setupByValues(filterModel, col);
+ result = { result: this._setupByValues(filterModel, col) };
+
+ return result;
};
changeFilterBy(filterBy: FilterBy): boolean {
diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx
index 363770d351..c5a4efba2a 100644
--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx
+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.stories.tsx
@@ -24,8 +24,8 @@ import { IMenuService, IShortcutService, MenuService, ShortcutService } from '@u
import { SetCellEditVisibleOperation } from '@univerjs/sheets-ui';
import { SheetsFilterPanelService } from '../../services/sheets-filter-panel.service';
import { ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, SetSheetsFilterCriteriaCommand, SmartToggleSheetsFilterCommand } from '../../commands/commands/sheets-filter.command';
-import type { IOpenFilterPanelCommandParams } from '../../commands/operations/sheets-filter.operation';
-import { ChangeFilterByOperation, CloseFilterPanelOperation, OpenFilterPanelCommand } from '../../commands/operations/sheets-filter.operation';
+import type { IOpenFilterPanelOperationParams } from '../../commands/operations/sheets-filter.operation';
+import { ChangeFilterByOperation, CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
import enUS from '../../locale/en-US';
import zhCN from '../../locale/zh-CN';
import ruRU from '../../locale/ru-RU';
@@ -76,16 +76,16 @@ function createFilterStorybookBed(workbookData: IWorkbookData, locale: LocaleTyp
SetSheetsFilterCriteriaCommand,
ClearSheetsFilterCriteriaCommand,
ReCalcSheetsFilterCommand,
- OpenFilterPanelCommand,
+ OpenFilterPanelOperation,
CloseFilterPanelOperation,
ChangeFilterByOperation,
].forEach((command) => commandService.registerCommand(command));
- commandService.syncExecuteCommand(OpenFilterPanelCommand.id, {
+ commandService.syncExecuteCommand(OpenFilterPanelOperation.id, {
unitId: 'test',
subUnitId: 'sheet1',
col: 0,
- } as IOpenFilterPanelCommandParams);
+ } as IOpenFilterPanelOperationParams);
}
}
diff --git a/packages/sheets-filter-ui/src/views/widgets/filter-button.shape.ts b/packages/sheets-filter-ui/src/views/widgets/filter-button.shape.ts
index 9e0afd3ea3..7c2fb5a4bd 100644
--- a/packages/sheets-filter-ui/src/views/widgets/filter-button.shape.ts
+++ b/packages/sheets-filter-ui/src/views/widgets/filter-button.shape.ts
@@ -17,7 +17,7 @@
import { ICommandService, IContextService, Inject, ThemeService } from '@univerjs/core';
import { type IMouseEvent, type IPointerEvent, type IShapeProps, Shape, type UniverRenderingContext2D } from '@univerjs/engine-render';
-import { FILTER_PANEL_OPENED_KEY, type IOpenFilterPanelCommandParams, OpenFilterPanelCommand } from '../../commands/operations/sheets-filter.operation';
+import { FILTER_PANEL_OPENED_KEY, type IOpenFilterPanelOperationParams, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
import { FilterButton } from './drawings';
export const FILTER_ICON_SIZE = 16;
@@ -112,16 +112,16 @@ export class SheetsFilterButtonShape extends Shape<ISheetsFilterButtonShapeProps
const { col, unitId, subUnitId } = this._filterParams!;
const opened = this._contextService.getContextValue(FILTER_PANEL_OPENED_KEY);
- if (opened || !this._commandService.hasCommand(OpenFilterPanelCommand.id)) {
+ if (opened || !this._commandService.hasCommand(OpenFilterPanelOperation.id)) {
return;
}
setTimeout(() => {
- this._commandService.executeCommand(OpenFilterPanelCommand.id, {
+ this._commandService.executeCommand(OpenFilterPanelOperation.id, {
unitId,
subUnitId,
col,
- } as IOpenFilterPanelCommandParams);
+ } as IOpenFilterPanelOperationParams);
}, 200);
}