Skip to content

Commit bf8c331

Browse files
exposed sortedData, added sort change event in list/grid comp
1 parent f2400d2 commit bf8c331

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

client/packages/lowcoder/src/comps/comps/listViewComp/listView.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ export function ListView(props: Props) {
369369
newData.splice(toIndex, 0, movedItem);
370370

371371
children.listData.dispatchChangeValueAction(newData);
372+
children.onEvent.getView()('sortChange');
372373
};
373374

374375
// log.debug("renders: ", renders);

client/packages/lowcoder/src/comps/comps/listViewComp/listViewComp.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
withFunction,
3030
WrapContextNodeV2,
3131
} from "lowcoder-core";
32-
import { JSONArray, JSONValue } from "util/jsonTypes";
32+
import { JSONArray, JSONObject, JSONValue } from "util/jsonTypes";
3333
import { depthEqual, lastValueIfEqual, shallowEqual } from "util/objectUtils";
3434
import { CompTree, getAllCompItems, IContainer } from "../containerBase";
3535
import { SimpleContainerComp, toSimpleContainerData } from "../containerBase/simpleContainerComp";
@@ -40,6 +40,7 @@ import { listPropertyView } from "./listViewPropertyView";
4040
import { getData } from "./listViewUtils";
4141
import { withMethodExposing } from "comps/generators/withMethodExposing";
4242
import { SliderControl } from "@lowcoder-ee/comps/controls/sliderControl";
43+
import { eventHandlerControl, sortChangeEvent } from "@lowcoder-ee/comps/controls/eventHandlerControl";
4344

4445
const childrenMap = {
4546
noOfRows: withIsLoadingMethod(NumberOrJSONObjectArrayControl), // FIXME: migrate "noOfRows" to "data"
@@ -62,6 +63,7 @@ const childrenMap = {
6263
horizontal: withDefault(BoolControl, false),
6364
minHorizontalWidth: withDefault(RadiusControl, '100px'),
6465
enableSorting: withDefault(BoolControl, false),
66+
onEvent: eventHandlerControl([sortChangeEvent] as const),
6567
};
6668

6769
const ListViewTmpComp = new UICompBuilder(childrenMap, () => <></>)
@@ -183,6 +185,15 @@ ListViewPropertyComp = withExposingConfigs(ListViewPropertyComp, [
183185
return data;
184186
},
185187
}),
188+
depsConfig({
189+
name: "sortedData",
190+
desc: trans("listView.dataDesc"),
191+
depKeys: ["listData"],
192+
func: (input) => {
193+
const { data } = getData(input.listData as JSONObject[]);
194+
return data;
195+
},
196+
}),
186197
new CompDepsConfig(
187198
"pageNo",
188199
(comp) => ({index: comp.children.pagination.children.pageNo.exposingNode() }),

client/packages/lowcoder/src/comps/comps/listViewComp/listViewPropertyView.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function listPropertyView(compType: ListCompType) {
5555

5656
{(useContext(EditorContext).editorModeStatus === "logic" || useContext(EditorContext).editorModeStatus === "both") && (
5757
<Section name={sectionNames.interaction}>
58+
{children.onEvent.getPropertyView()}
5859
{hiddenPropertyView(children)}
5960
{showDataLoadingIndicatorsPropertyView(children)}
6061
{children.enableSorting.propertyView({

client/packages/lowcoder/src/comps/controls/eventHandlerControl.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,11 @@ export const resetEvent: EventConfigType = {
489489
value: "reset",
490490
description: trans("event.resetDesc"),
491491
};
492-
492+
export const sortChangeEvent: EventConfigType = {
493+
label: trans("event.sortChange"),
494+
value: "sortChange",
495+
description: trans("event.sortChangeDesc"),
496+
};
493497

494498
// Meeting Events
495499

client/packages/lowcoder/src/i18n/locales/en.ts

+2
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ export const en = {
463463
"resetDesc": "Triggers on Reset timer",
464464
"refresh": "Refresh",
465465
"refreshDesc": "Triggers on Refresh",
466+
"sortChange": "Sort Change",
467+
"sortChangeDesc": "Triggers on Sorting Changes",
466468
},
467469

468470

0 commit comments

Comments
 (0)