## Description This PR enables server side filtering for the table widget. #### PR fixes following issue(s) Fixes #25529 #### Type of change - New feature (non-breaking change which adds functionality) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - should test that the filter apply button text color should be clear and visible - should test that the value property of `table.filters` is number when number is provided inside the filter. - should test that client side filtering is disabled when server side filtering is enabled - should test that `filters` property appears as an autocomplete. - All the cases mentioned in this [test plan](https://docs.google.com/spreadsheets/d/1TgKPH5XPzIuaHAPooYr5o5jrhpjxFhBTq_Q6wv5rnVk/edit#gid=1701564241) - [ ] Jest - [ ] Cypress - should test that server side filtering properties exists in the property pane - should test that select query gets executed on filter change and no data is filtered from client-side when serverside filtering is turned on - should test that removing the table filter executes the query - should test that data is filtered client-side when serverside filtering is turned off > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
232 lines
5.7 KiB
TypeScript
232 lines
5.7 KiB
TypeScript
import type {
|
|
ColumnProperties,
|
|
CompactMode,
|
|
ReactTableFilter,
|
|
TableStyles,
|
|
SortOrderTypes,
|
|
} from "./component/Constants";
|
|
import type { WidgetProps } from "widgets/BaseWidget";
|
|
import type { WithMeta } from "widgets/MetaHOC";
|
|
import type { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
|
import { IconNames } from "@blueprintjs/icons";
|
|
import type { ColumnAction } from "components/propertyControls/ColumnActionSelectorControl";
|
|
import type { Alignment } from "@blueprintjs/core";
|
|
import type { IconName } from "@blueprintjs/icons";
|
|
import type { ButtonVariant } from "components/constants";
|
|
import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag";
|
|
|
|
export type EditableCell = {
|
|
column: string;
|
|
index: number;
|
|
value: string | number | null;
|
|
initialValue: string;
|
|
inputValue: string;
|
|
};
|
|
|
|
export enum PaginationDirection {
|
|
INITIAL = "INITIAL",
|
|
PREVIOUS_PAGE = "PREVIOUS_PAGE",
|
|
NEXT_PAGE = "NEXT_PAGE",
|
|
}
|
|
|
|
export enum EditableCellActions {
|
|
SAVE = "SAVE",
|
|
DISCARD = "DISCARD",
|
|
}
|
|
|
|
export enum InlineEditingSaveOptions {
|
|
ROW_LEVEL = "ROW_LEVEL",
|
|
TABLE_LEVEL = "TABLE_LEVEL",
|
|
CUSTOM = "CUSTOM",
|
|
}
|
|
|
|
interface AddNewRowProps {
|
|
isAddRowInProgress: boolean;
|
|
allowAddNewRow: boolean;
|
|
onAddNewRowSave: string;
|
|
onAddNewRowDiscard: string;
|
|
defaultNewRow: Record<string, unknown>;
|
|
}
|
|
export interface TableWidgetProps
|
|
extends WidgetProps,
|
|
WithMeta,
|
|
TableStyles,
|
|
AddNewRowProps {
|
|
pristine: boolean;
|
|
nextPageKey?: string;
|
|
prevPageKey?: string;
|
|
label: string;
|
|
searchText: string;
|
|
defaultSearchText: string;
|
|
defaultSelectedRowIndex?: number | string;
|
|
defaultSelectedRowIndices?: number[] | string;
|
|
tableData: Array<Record<string, unknown>>;
|
|
onPageChange?: string;
|
|
pageSize: number;
|
|
onRowSelected?: string;
|
|
onSearchTextChanged: string;
|
|
onSort: string;
|
|
selectedRowIndex?: number;
|
|
selectedRowIndices: number[];
|
|
serverSidePaginationEnabled?: boolean;
|
|
multiRowSelection?: boolean;
|
|
enableClientSideSearch?: boolean;
|
|
hiddenColumns?: string[];
|
|
columnOrder?: string[];
|
|
frozenColumnIndices: Record<string, number>;
|
|
canFreezeColumn?: boolean;
|
|
columnNameMap?: { [key: string]: string };
|
|
columnTypeMap?: {
|
|
[key: string]: { type: string; format: string; inputFormat?: string };
|
|
};
|
|
columnWidthMap?: { [key: string]: number };
|
|
filters?: ReactTableFilter[];
|
|
compactMode?: CompactMode;
|
|
isSortable?: boolean;
|
|
primaryColumnId?: string;
|
|
primaryColumns: Record<string, ColumnProperties>;
|
|
derivedColumns: Record<string, ColumnProperties>;
|
|
sortOrder: {
|
|
column: string;
|
|
order: SortOrderTypes | null;
|
|
};
|
|
totalRecordsCount?: number;
|
|
transientTableData: {
|
|
[key: string]: Record<string, string>;
|
|
};
|
|
editableCell?: EditableCell;
|
|
primaryColor: string;
|
|
borderRadius: string;
|
|
boxShadow?: string;
|
|
inlineEditingSaveOption?: InlineEditingSaveOptions;
|
|
showInlineEditingOptionDropdown?: boolean;
|
|
variant?: TableVariant;
|
|
isEditableCellsValid: Record<string, boolean>;
|
|
selectColumnFilterText?: Record<string, string>;
|
|
isAddRowInProgress: boolean;
|
|
newRow: Record<string, unknown>;
|
|
firstEditableColumnIdByOrder: string;
|
|
enableServerSideFiltering: boolean;
|
|
onTableFilterUpdate: string;
|
|
}
|
|
|
|
export enum TableVariantTypes {
|
|
DEFAULT = "DEFAULT",
|
|
VARIANT2 = "VARIANT2",
|
|
VARIANT3 = "VARIANT3",
|
|
}
|
|
|
|
export type TableVariant = keyof typeof TableVariantTypes;
|
|
|
|
export const ORIGINAL_INDEX_KEY = "__originalIndex__";
|
|
|
|
export const PRIMARY_COLUMN_KEY_VALUE = "__primaryKey__";
|
|
|
|
export const DEFAULT_COLUMN_WIDTH = 150;
|
|
|
|
export const COLUMN_MIN_WIDTH = 60;
|
|
|
|
export const TABLE_COLUMN_ORDER_KEY = "tableWidgetColumnOrder";
|
|
|
|
export enum ColumnTypes {
|
|
TEXT = "text",
|
|
URL = "url",
|
|
NUMBER = "number",
|
|
IMAGE = "image",
|
|
VIDEO = "video",
|
|
DATE = "date",
|
|
BUTTON = "button",
|
|
ICON_BUTTON = "iconButton",
|
|
MENU_BUTTON = "menuButton",
|
|
SELECT = "select",
|
|
EDIT_ACTIONS = "editActions",
|
|
CHECKBOX = "checkbox",
|
|
SWITCH = "switch",
|
|
}
|
|
|
|
export enum ReadOnlyColumnTypes {
|
|
TEXT = "text",
|
|
URL = "url",
|
|
NUMBER = "number",
|
|
IMAGE = "image",
|
|
VIDEO = "video",
|
|
DATE = "date",
|
|
CHECKBOX = "checkbox",
|
|
SWITCH = "switch",
|
|
SELECT = "select",
|
|
}
|
|
|
|
export const ActionColumnTypes = [
|
|
ColumnTypes.BUTTON,
|
|
ColumnTypes.ICON_BUTTON,
|
|
ColumnTypes.MENU_BUTTON,
|
|
ColumnTypes.EDIT_ACTIONS,
|
|
];
|
|
|
|
export const FilterableColumnTypes = [
|
|
ColumnTypes.TEXT,
|
|
ColumnTypes.URL,
|
|
ColumnTypes.NUMBER,
|
|
ColumnTypes.DATE,
|
|
ColumnTypes.SELECT,
|
|
ColumnTypes.CHECKBOX,
|
|
ColumnTypes.SWITCH,
|
|
];
|
|
|
|
export const DEFAULT_BUTTON_COLOR = "rgb(3, 179, 101)";
|
|
|
|
export const DEFAULT_BUTTON_LABEL = "Action";
|
|
|
|
export const DEFAULT_MENU_VARIANT = "PRIMARY";
|
|
|
|
export const DEFAULT_MENU_BUTTON_LABEL = "Open menu";
|
|
|
|
export type TransientDataPayload = {
|
|
[key: string]: string | number | boolean;
|
|
__originalIndex__: number;
|
|
};
|
|
|
|
export type OnColumnEventArgs = {
|
|
rowIndex: number;
|
|
action: string;
|
|
onComplete?: () => void;
|
|
triggerPropertyName: string;
|
|
eventType: EventType;
|
|
row?: Record<string, unknown>;
|
|
additionalData?: Record<string, unknown>;
|
|
};
|
|
|
|
export const ICON_NAMES = Object.keys(IconNames).map(
|
|
(name: string) => IconNames[name as keyof typeof IconNames],
|
|
);
|
|
|
|
export type ButtonColumnActions = ColumnAction & {
|
|
eventType: EventType;
|
|
iconName?: IconName;
|
|
variant: ButtonVariant;
|
|
backgroundColor?: string;
|
|
iconAlign?: Alignment;
|
|
borderRadius?: string;
|
|
isVisible?: boolean;
|
|
isDisabled?: boolean;
|
|
boxShadow?: string;
|
|
};
|
|
|
|
export enum DateInputFormat {
|
|
EPOCH = "Epoch",
|
|
MILLISECONDS = "Milliseconds",
|
|
}
|
|
|
|
export const defaultEditableCell = {
|
|
column: "",
|
|
index: -1,
|
|
inputValue: "",
|
|
value: "",
|
|
initialValue: "",
|
|
};
|
|
|
|
export const DEFAULT_COLUMN_NAME = "Table Column";
|
|
|
|
export const ALLOW_TABLE_WIDGET_SERVER_SIDE_FILTERING =
|
|
FEATURE_FLAG["release_table_serverside_filtering_enabled"];
|