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

Commit67ca218

Browse files
added setChildrensAction in list
1 parent04a5968 commit67ca218

File tree

1 file changed

+29
-1
lines changed
  • client/packages/lowcoder/src/comps/generators

1 file changed

+29
-1
lines changed

‎client/packages/lowcoder/src/comps/generators/list.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export type CustomListAction<CompCtor extends CompConstructor = CompConstructor>
2626
>;
2727

2828
typeListAction<CompCtorextendsCompConstructor=CompConstructor>=
29+
|{
30+
type:"setChildrens";
31+
value:Array<ConstructorToDataType<CompCtor>>;
32+
}
2933
|{
3034
type:"push";
3135
value:ConstructorToDataType<CompCtor>;
@@ -145,7 +149,19 @@ export function list<ChildCompCtor extends CompConstructor<any, any>>(
145149

146150
privatereduceCustom(action:ListAction<ChildCompCtor>): this{
147151
switch(action.type){
148-
case"push":
152+
case"setChildrens":{
153+
constchildrenMap:Record<number,ConstructorToComp<ChildCompCtor>>={};
154+
constchildrenOrder:number[]=[];
155+
action.value.forEach((children:any,key:number)=>{
156+
childrenMap[key]=newChild(this.dispatch,String(key),children);
157+
childrenOrder.push(key);
158+
})
159+
returnsetFieldsNoTypeCheck(this,{
160+
children:childrenMap,
161+
childrenOrder:childrenOrder,
162+
});
163+
}
164+
case"push":{
149165
constkey=this.genKey();
150166
constnewChildren={
151167
...this.children,
@@ -155,6 +171,7 @@ export function list<ChildCompCtor extends CompConstructor<any, any>>(
155171
children:newChildren,
156172
childrenOrder:[...this.childrenOrder,key],
157173
});
174+
}
158175
case"pushComp":{
159176
constkey=this.genKey();
160177
constnewChildren={
@@ -209,6 +226,17 @@ export function list<ChildCompCtor extends CompConstructor<any, any>>(
209226
}
210227
}
211228
}
229+
230+
setChildrensAction(value:Array<ConstructorToDataType<ChildCompCtor>>){
231+
returncustomAction<ListAction<ChildCompCtor>>(
232+
{
233+
type:"setChildrens",
234+
value:value,
235+
},
236+
true
237+
);
238+
}
239+
212240
pushAction(value:ConstructorToDataType<ChildCompCtor>){
213241
returncustomAction<ListAction<ChildCompCtor>>(
214242
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp