Skip to content

Commit 466348a

Browse files
committed
Omg got steps working
1 parent 643e286 commit 466348a

File tree

2 files changed

+78
-33
lines changed

2 files changed

+78
-33
lines changed

client/packages/lowcoder/src/comps/comps/tourComp/componentSelectorControl.tsx

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { trans } from "@lowcoder-ee/i18n";
2-
import { getPromiseAfterDispatch } from "@lowcoder-ee/util/promiseUtils";
3-
import { CompParams, ConstructorToDataType, customAction, routeByNameAction } from "lowcoder-core";
4-
import { ExecuteAction, ParamsConfig } from "@lowcoder-ee/comps/controls/actionSelector/executeCompTypes";
2+
import { CompParams, ConstructorToDataType, MultiBaseComp } from "lowcoder-core";
3+
import { ParamsConfig } from "@lowcoder-ee/comps/controls/actionSelector/executeCompTypes";
54
import { CompNameContext, EditorContext, EditorState } from "@lowcoder-ee/comps/editorState";
65
import { mapValues } from "lodash";
76
import { Dropdown } from "components/Dropdown";
@@ -48,6 +47,7 @@ const ExecuteCompTmpAction = (function() {
4847
};
4948
return new MultiCompBuilder(childrenMap, () => {
5049
return () => undefined as (React.RefObject<HTMLElement> | undefined);
50+
// return () => Promise.resolve(undefined as unknown);
5151
})
5252
.setPropertyViewFn(() => <></>)
5353
.build();
@@ -72,20 +72,45 @@ export function targetCompAction(params: ExecuteCompActionOptions) {
7272
}
7373
}
7474

75-
selectedComp: (GridItemComp | HookComp | InstanceType<typeof TemporaryStateItemComp>) | undefined;
75+
selectedComp: React.RefObject<HTMLDivElement> | undefined;
7676
compList: (GridItemComp | HookComp | InstanceType<typeof TemporaryStateItemComp>)[] = [];
7777

7878
updateSelectedComp(compName: string): void {
7979
const compListItem = this.compList.find((compItem) => compItem.children.name.getView() === compName);
8080
if (compListItem) {
81-
this.selectedComp = compListItem;
81+
console.log(`setting selected comp to ${compListItem}`)
82+
this.selectedComp = ((compListItem as MultiBaseComp).children.comp as GridItemComp).getRef();
8283
}
8384
}
8485

8586
override getView(): () => (React.RefObject<HTMLElement> | undefined) {
86-
return () => this.selectedComp?.getRef();
87+
return () => this.selectedComp;
8788
}
8889

90+
// override getView() {
91+
// const name = this.children.name.getView();
92+
// if (!name) {
93+
// return () => Promise.resolve();
94+
// }
95+
// return () =>
96+
// getPromiseAfterDispatch(
97+
// this.dispatch,
98+
// routeByNameAction(
99+
// name,
100+
// customAction<ExecuteAction>(
101+
// {
102+
// type: "execute",
103+
// methodName: this.children.methodName.getView(),
104+
// params: this.children.params.getView().map((x) => x.getView())
105+
// },
106+
// false
107+
// )
108+
// ),
109+
// {
110+
// notHandledError: trans("eventHandler.notHandledError")
111+
// }
112+
// );
113+
// }
89114
exposingNode() {
90115
return this.node();
91116
}
@@ -94,8 +119,30 @@ export function targetCompAction(params: ExecuteCompActionOptions) {
94119
return (
95120
<EditorContext.Consumer>
96121
{(editorState) => {
97-
const compList: (GridItemComp | HookComp | InstanceType<typeof TemporaryStateItemComp>)[] = compListGetter(editorState);
122+
this.compList = compListGetter(editorState);
123+
const compMethods: Record<string, Record<string, ParamsConfig>> = {};
98124

125+
this.compList.forEach((item) => {
126+
compMethods[item.children.name.getView()] = mapValues(
127+
item.exposingInfo().methods,
128+
(v) => v.params
129+
);
130+
});
131+
132+
function changeMethodAction(compName: string, methodName: string) {
133+
console.log("sldjafldkdf")
134+
const currentMethods = compMethods[compName] ?? {};
135+
const params = currentMethods[methodName];
136+
return {
137+
name: compName,
138+
methodName: methodName,
139+
params: params?.map((p) => ({
140+
compType: p.type,
141+
name: p.name,
142+
})),
143+
};
144+
}
145+
99146
const name = this.children.name.getView();
100147
return (
101148
<>
@@ -104,7 +151,7 @@ export function targetCompAction(params: ExecuteCompActionOptions) {
104151
<Dropdown
105152
showSearch={true}
106153
value={name}
107-
options={compList
154+
options={this.compList
108155
.filter((item) => item.children.name.getView() !== compName)
109156
.map((item) => ({
110157
label: item.children.name.getView(),
@@ -115,6 +162,11 @@ export function targetCompAction(params: ExecuteCompActionOptions) {
115162
console.log(`the value is ${value}`);
116163
// After the value is changed, update `selectedComp`
117164
this.updateSelectedComp(value);
165+
166+
console.log("am i here? ")
167+
return this.dispatchChangeValueAction(
168+
changeMethodAction(value, Object.keys(compMethods[value])[0])
169+
)
118170
}}
119171
/>
120172
)}

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

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
11
import { ViewDocIcon } from "assets/icons";
2-
import { ArrayControl, BoolCodeControl, StringControl } from "comps/controls/codeControl";
2+
import { BoolCodeControl, StringControl } from "comps/controls/codeControl";
33
import { dropdownControl } from "comps/controls/dropdownControl";
4-
import { MultiCompBuilder, withContext, withDefault } from "comps/generators";
4+
import { MultiCompBuilder, withDefault } from "comps/generators";
55
import { list } from "comps/generators/list";
66
import { ToViewReturn } from "comps/generators/multi";
77
import { genRandomKey } from "comps/utils/idGenerator";
8-
import { disabledPropertyView, hiddenPropertyView } from "comps/utils/propertyUtils";
8+
import { hiddenPropertyView } from "comps/utils/propertyUtils";
99
import { trans } from "i18n";
10-
import _, { mapValues } from "lodash";
10+
import { mapValues } from "lodash";
1111
import {
1212
Comp,
13-
CompAction,
14-
CompActionTypes,
1513
CompParams,
1614
ConstructorToDataType,
1715
ConstructorToView,
1816
fromRecord,
1917
MultiBaseComp,
2018
withFunction
2119
} from "lowcoder-core";
22-
import { AutoArea, controlItem, Option } from "lowcoder-design";
20+
import { controlItem, Option } from "lowcoder-design";
2321
import styled from "styled-components";
24-
import { lastValueIfEqual } from "util/objectUtils";
2522
import { getNextEntityName } from "util/stringUtils";
26-
import { JSONObject, JSONValue } from "util/jsonTypes";
27-
import { ControlItemCompBuilder } from "comps/generators/controlCompBuilder";
28-
import { reduceInContext } from "../utils/reduceContext";
29-
import { optionsControl } from "lowcoder-sdk";
3023
import { TargetCompAction } from "@lowcoder-ee/comps/comps/tourComp/componentSelectorControl";
3124

3225
const OptionTypes = [
@@ -302,23 +295,23 @@ export function tourStepsControl<T extends TourStepControlType>(
302295
const PlacementOptions = [
303296
{ label: "Center", value: "center"},
304297
{ label: "Left", value: "left"},
305-
{ label: "LeftTop", value: "leftTop"},
306-
{ label: "LeftBottom", value: "leftBottom"},
298+
{ label: "Left Top", value: "leftTop"},
299+
{ label: "Left Bottom", value: "leftBottom"},
307300
{ label: "Right", value: "right"},
308-
{ label: "RightTop", value: "rightTop"},
309-
{ label: "RightBottom", value: "rightBottom"},
301+
{ label: "Right Top", value: "rightTop"},
302+
{ label: "Right Bottom", value: "rightBottom"},
310303
{ label: "Top", value: "top"},
311-
{ label: "TopLeft", value: "topLeft"},
312-
{ label: "TopRight", value: "topRight"},
304+
{ label: "Top Left", value: "topLeft"},
305+
{ label: "Top Right", value: "topRight"},
313306
{ label: "Bottom", value: "bottom"},
314-
{ label: "BottomLeft", value: "bottomLeft"},
315-
{ label: "BottomRight", value: "bottomRight"},
307+
{ label: "Bottom Left", value: "bottomLeft"},
308+
{ label: "Bottom Right", value: "bottomRight"},
316309
];
317310

318311
let TourStep = new MultiCompBuilder(
319312
{
320313
target: TargetCompAction,
321-
// target: FunctionControl,
314+
// target: dropdownControl(editorState.getAllUICompMap(), ""),
322315
arrow: BoolCodeControl,
323316
title: StringControl,
324317
description: StringControl,
@@ -341,10 +334,10 @@ TourStep = class extends TourStep implements TourStepCompProperty {
341334
placeholder: "Welcome to lowcoder, this is your first tutorial step",
342335
})}
343336
{this.children.target.propertyView()}
344-
{/*{this.children.placement.propertyView({*/}
345-
{/* label: trans("textShow.verticalAlignment"),*/}
346-
{/* radioButton: true,*/}
347-
{/*})}*/}
337+
{this.children.placement.propertyView({
338+
label: trans("textShow.verticalAlignment"),
339+
radioButton: false
340+
})}
348341
{hiddenPropertyView(this.children)}
349342
</>
350343
);

0 commit comments

Comments
 (0)