Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit84c165b

Browse files
mapped nest_component and set_properties action
1 parentd6cea0c commit84c165b

File tree

3 files changed

+95
-12
lines changed

3 files changed

+95
-12
lines changed

‎client/packages/lowcoder/src/comps/comps/chatComp/components/ChatMain.tsx‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import styled from "styled-components";
1919
import{ChatCompProps}from"../chatCompTypes";
2020
import{message}from"antd";
2121
import{EditorContext}from"@lowcoder-ee/comps/editorState";
22-
import{addComponentAction}from"../../preLoadComp/actions/componentManagement";
22+
import{addComponentAction,nestComponentAction}from"../../preLoadComp/actions/componentManagement";
23+
import{configureComponentAction}from"../../preLoadComp/actions/componentConfiguration";
2324

2425
constChatContainer=styled.div<{$autoHeight?:boolean}>`
2526
display: flex;
@@ -92,7 +93,7 @@ export function ChatMain(props: ChatCompProps) {
9293

9394
// Keep the ref updated with the latest editorState
9495
useEffect(()=>{
95-
console.log("EDITOR STATE CHANGE ---> ",editorState);
96+
//console.log("EDITOR STATE CHANGE ---> ", editorState);
9697
editorStateRef.current=editorState;
9798
},[editorState]);
9899

@@ -129,6 +130,30 @@ export function ChatMain(props: ChatCompProps) {
129130
actionPayload:action_payload,
130131
selectedComponent:action_parameters,
131132
selectedEditorComponent:null,
133+
selectedNestComponent:null,
134+
editorState:editorStateRef.current
135+
});
136+
break;
137+
case"nest_component":
138+
awaitnestComponentAction.execute({
139+
actionKey:action_name,
140+
actionValue:"",
141+
actionPayload:action_payload,
142+
selectedComponent:action_parameters,
143+
selectedEditorComponent:null,
144+
selectedNestComponent:null,
145+
editorState:editorStateRef.current
146+
});
147+
break;
148+
case"set_properties":
149+
debugger;
150+
awaitconfigureComponentAction.execute({
151+
actionKey:action_name,
152+
actionValue:action_parameters,
153+
actionPayload:action_payload,
154+
selectedEditorComponent:null,
155+
selectedComponent:null,
156+
selectedNestComponent:null,
132157
editorState:editorStateRef.current
133158
});
134159
break;

‎client/packages/lowcoder/src/comps/comps/preLoadComp/actions/componentConfiguration.ts‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import{message}from"antd";
22
import{ActionConfig,ActionExecuteParams}from"../types";
3+
import{getEditorComponentInfo}from"../utils";
34

45
exportconstconfigureComponentAction:ActionConfig={
56
key:'configure-components',
@@ -19,10 +20,40 @@ export const configureComponentAction: ActionConfig = {
1920
}
2021
},
2122
execute:async(params:ActionExecuteParams)=>{
22-
const{ selectedEditorComponent, actionValue}=params;
23+
const{ selectedEditorComponent,actionValue:name, actionValue, actionPayload, editorState}=params;
24+
constotherProps=actionPayload;
25+
// const { name, ...otherProps } = actionPayload;
2326

2427
try{
25-
constconfig=JSON.parse(actionValue);
28+
constcomponentInfo=getEditorComponentInfo(editorState,name);
29+
30+
if(!componentInfo){
31+
message.error(`Component "${selectedEditorComponent}" not found`);
32+
return;
33+
}
34+
35+
const{componentKey:parentKey, items}=componentInfo;
36+
37+
if(!parentKey){
38+
message.error(`Parent component "${selectedEditorComponent}" not found in layout`);
39+
return;
40+
}
41+
42+
constparentItem=items[parentKey];
43+
if(!parentItem){
44+
message.error(`Parent component "${selectedEditorComponent}" not found in items`);
45+
return;
46+
}
47+
48+
constitemComp=parentItem.children.comp;
49+
constitemData=itemComp.toJsonValue();
50+
constconfig={
51+
...itemData,
52+
...otherProps
53+
};
54+
itemComp.dispatchChangeValueAction(config);
55+
56+
debugger;
2657
console.log('Configuring component:',selectedEditorComponent,'with config:',config);
2758
message.info(`Configure action for component "${selectedEditorComponent}"`);
2859

‎client/packages/lowcoder/src/comps/comps/preLoadComp/actions/componentManagement.ts‎

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,17 @@ export const nestComponentAction: ActionConfig = {
137137
requiresInput:false,
138138
isNested:true,
139139
execute:async(params:ActionExecuteParams)=>{
140-
const{ selectedEditorComponent, selectedNestComponent, editorState}=params;
141-
140+
// const { selectedEditorComponent, selectedNestComponent, editorState, actionPayload } = params;
141+
const{ editorState, actionPayload,selectedComponent:selectedNestComponent}=params;
142+
const{ name, layout,target:selectedEditorComponent, ...otherProps}=actionPayload;
143+
142144
if(!selectedEditorComponent||!selectedNestComponent||!editorState){
143145
message.error('Parent component, child component, and editor state are required');
144146
return;
145147
}
146148

147-
constparentComponentInfo=getEditorComponentInfo(editorState,selectedEditorComponent);
149+
const[editorComponent, ...childComponents]=selectedEditorComponent.split('.');
150+
constparentComponentInfo=getEditorComponentInfo(editorState,editorComponent);
148151

149152
if(!parentComponentInfo){
150153
message.error(`Parent component "${selectedEditorComponent}" not found`);
@@ -174,10 +177,15 @@ export const nestComponentAction: ActionConfig = {
174177
}
175178

176179
try{
177-
180+
letcompName=name;
178181
constnameGenerator=editorState.getNameGenerator();
179182
constcompInfo=parseCompType(selectedNestComponent);
180-
constcompName=nameGenerator.genItemName(compInfo.compName);
183+
if(!compName){
184+
compName=nameGenerator.genItemName(compInfo.compName);
185+
}
186+
// const nameGenerator = editorState.getNameGenerator();
187+
// const compInfo = parseCompType(selectedNestComponent);
188+
// const compName = nameGenerator.genItemName(compInfo.compName);
181189
constkey=genRandomKey();
182190

183191
constmanifest=uiCompRegistry[selectedNestComponent];
@@ -193,15 +201,33 @@ export const nestComponentAction: ActionConfig = {
193201
defaultDataFn=manifest?.defaultDataFn;
194202
}
195203

204+
letcompDefaultValue=defaultDataFn ?defaultDataFn(compName,nameGenerator,editorState) :undefined;
205+
constcompInitialValue={
206+
...(compDefaultValueasany||{}),
207+
...otherProps,
208+
}
209+
196210
constwidgetValue:GridItemDataType={
197211
compType:selectedNestComponent,
198212
name:compName,
199-
comp:defaultDataFn ?defaultDataFn(compName,nameGenerator,editorState) :undefined,
213+
comp:compInitialValue,
200214
};
201215

202216
constparentContainer=parentItem.children.comp;
203-
204-
constrealContainer=parentContainer.realSimpleContainer();
217+
letoriginalContainer=parentContainer;
218+
for(constchildComponentofchildComponents){
219+
originalContainer=originalContainer.children[childComponent];
220+
}
221+
if(originalContainer?.children?.[0]?.children?.view){
222+
originalContainer=originalContainer?.children?.[0]?.children?.view;
223+
}
224+
225+
if(!originalContainer){
226+
message.error(`Container "${selectedEditorComponent}" cannot accept nested components`);
227+
return;
228+
}
229+
230+
constrealContainer=originalContainer.realSimpleContainer();
205231
if(!realContainer){
206232
message.error(`Container "${selectedEditorComponent}" cannot accept nested components`);
207233
return;
@@ -223,6 +249,7 @@ export const nestComponentAction: ActionConfig = {
223249
h:layoutInfo.h||5,
224250
pos:itemPos,
225251
isDragging:false,
252+
...(layout||{}),
226253
};
227254

228255
realContainer.dispatch(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp