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

Commit65aeca5

Browse files
allow table summary row
1 parent64d5bbd commit65aeca5

File tree

8 files changed

+1060
-2
lines changed

8 files changed

+1060
-2
lines changed

‎client/packages/lowcoder/src/comps/comps/avatarGroup.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { clickEvent, eventHandlerControl, refreshEvent } from "../controls/event
1212
importstyledfrom"styled-components";
1313
import{useContext,ReactElement,useEffect}from"react";
1414
import{MultiCompBuilder,stateComp,withDefault}from"../generators";
15-
import{EditorContext}from"comps/editorState";
15+
import{CompNameContext,EditorContext}from"comps/editorState";
1616
import{IconControl}from"../controls/iconControl";
1717
import{ColorControl}from"../controls/colorControl";
1818
import{optionsControl}from"../controls/optionsControl";
@@ -105,6 +105,30 @@ const childrenMap = {
105105
};
106106

107107
constAvatarGroupView=(props:RecordConstructorToView<typeofchildrenMap>&{dispatch:(action:CompAction)=>void;})=>{
108+
constcomp=useContext(EditorContext).getUICompByName(useContext(CompNameContext));
109+
110+
constupdateAvatars=()=>{
111+
debugger;
112+
if(!comp)return;
113+
// comp?.children.comp.children?.avatars?.children.manual.dispatchChangeValueAction({
114+
// initOptions: [
115+
// { src: "https://api.dicebear.com/7.x/miniavs/svg?seed=1", label: String.fromCharCode(65 + Math.ceil(Math.random() * 25)) },
116+
// // { AvatarIcon: "/icon:antd/startwotone" },
117+
// // { label: String.fromCharCode(65 + Math.ceil(Math.random() * 25)) },
118+
// // { label: String.fromCharCode(65 + Math.ceil(Math.random() * 25)) },
119+
// ],
120+
// });
121+
// comp?.children.comp.children?.avatars.children.manual.children.manual.dispatch([
122+
// { src: "https://api.dicebear.com/7.x/miniavs/svg?seed=1", label: String.fromCharCode(65 + Math.ceil(Math.random() * 25)) }
123+
// ])
124+
comp?.children.comp.children?.avatars.children.manual.children.manual.dispatch(
125+
comp?.children.comp.children?.avatars.children.manual.children.manual.setChildrensAction([
126+
{src:"https://api.dicebear.com/7.x/miniavs/svg?seed=1",label:String.fromCharCode(65+Math.ceil(Math.random()*25))}
127+
])
128+
);
129+
}
130+
131+
108132
return(
109133
<Container
110134
$style={props.style}
@@ -127,6 +151,7 @@ const AvatarGroupView = (props: RecordConstructorToView<typeof childrenMap> & {
127151
onClick={()=>{
128152
props.onEvent("click")
129153
props.dispatch(changeChildAction("currentAvatar",itemasJSONObject,false));
154+
updateAvatars();
130155
}}
131156
>
132157
{item.label}

‎client/packages/lowcoder/src/comps/comps/tableComp/column/tableColumnListComp.tsx

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ import {
1717
import{shallowEqual}from"react-redux";
1818
import{JSONObject,JSONValue}from"util/jsonTypes";
1919
import{lastValueIfEqual}from"util/objectUtils";
20+
import{SummaryColumnComp}from"./tableSummaryColumnComp";
2021

2122
/**
2223
* column list
2324
*/
2425
constColumnListTmpComp=list(ColumnComp);
26+
constSummaryColumnListTmpComp=list(SummaryColumnComp);
2527

2628
/**
2729
* rowExample is used for code prompts
@@ -190,3 +192,139 @@ export class ColumnListComp extends ColumnListTmpComp {
190192
returnthis.forEachAction(ColumnComp.setSelectionAction(key));
191193
}
192194
}
195+
196+
exportclassSummaryColumnListCompextendsSummaryColumnListTmpComp{
197+
overridereduce(action:CompAction): this{
198+
if(isMyCustomAction<ActionDataType>(action,"dataChanged")){
199+
constrowExample=action.value.rowExample;
200+
const{ readOnly}=getReduceContext();
201+
letcomp=this;
202+
if(action.value.doGeneColumn&&(action.value.dynamicColumn||!readOnly)){
203+
constactions=this.geneColumnsAction(rowExample,action.value.data);
204+
comp=this.reduce(this.multiAction(actions));
205+
}
206+
returncomp;
207+
}
208+
returnsuper.reduce(action);
209+
}
210+
211+
getChangeSet(){
212+
constchangeSet:Record<string,Record<string,JSONValue>>={};
213+
constcolumns=this.getView();
214+
columns.forEach((column)=>{
215+
constcolumnChangeSet=column.getChangeSet();
216+
Object.keys(columnChangeSet).forEach((dataIndex)=>{
217+
Object.keys(columnChangeSet[dataIndex]).forEach((key)=>{
218+
if(!_.isNil(columnChangeSet[dataIndex][key])){
219+
if(!changeSet[key])changeSet[key]={};
220+
changeSet[key][dataIndex]=columnChangeSet[dataIndex][key];
221+
}
222+
});
223+
});
224+
});
225+
returnchangeSet;
226+
}
227+
228+
dispatchClearChangeSet(){
229+
constcolumns=this.getView();
230+
columns.forEach((column)=>column.dispatchClearChangeSet());
231+
}
232+
233+
/**
234+
* If the table data changes, call this method to trigger the action
235+
*/
236+
dataChangedAction(param:{
237+
rowExample:JSONObject;
238+
doGeneColumn:boolean;
239+
dynamicColumn:boolean;
240+
data:Array<JSONObject>;
241+
}){
242+
returncustomAction<ActionDataType>(
243+
{
244+
type:"dataChanged",
245+
...param,
246+
},
247+
true
248+
);
249+
}
250+
251+
/**
252+
* According to the data, adjust the column
253+
*/
254+
privategeneColumnsAction(rowExample:RowExampleType,data:Array<JSONObject>){
255+
// If no data, return directly
256+
if(rowExample===undefined||rowExample===null){
257+
return[];
258+
}
259+
constdataKeys=Object.keys(rowExample);
260+
if(dataKeys.length===0){
261+
return[];
262+
}
263+
constcolumnsView=this.getView();
264+
constactions:Array<any>=[];
265+
letdeleteCnt=0;
266+
columnsView.forEach((column,index)=>{
267+
if(column.getView().isCustom){
268+
return;
269+
}
270+
constdataIndex=column.getView().dataIndex;
271+
if(dataIndex===COLUMN_CHILDREN_KEY||!dataKeys.find((key)=>dataIndex===key)){
272+
// to Delete
273+
actions.push(this.deleteAction(index-deleteCnt));
274+
deleteCnt+=1;
275+
}
276+
});
277+
// The order should be the same as the data
278+
dataKeys.forEach((key)=>{
279+
if(key===COLUMN_CHILDREN_KEY&&supportChildrenTree(data)){
280+
return;
281+
}
282+
if(!columnsView.find((column)=>column.getView().dataIndex===key)){
283+
// to Add
284+
actions.push(this.pushAction(newPrimaryColumn(key,calcColumnWidth(key,data))));
285+
}
286+
});
287+
if(actions.length===0){
288+
return[];
289+
}
290+
returnactions;
291+
}
292+
293+
withParamsNode(){
294+
constcolumns=this.getView();
295+
constnodes=_(columns)
296+
.map((col)=>col.children.render.getOriginalComp().node())
297+
.toPairs()
298+
.fromPairs()
299+
.value();
300+
constresult=lastValueIfEqual(
301+
this,
302+
"withParamsNode",
303+
[fromRecord(nodes),nodes]asconst,
304+
(a,b)=>shallowEqual(a[1],b[1])
305+
)[0];
306+
returnresult;
307+
}
308+
309+
getColumnsNode<TextendskeyofSummaryColumnComp["children"]>(
310+
field:T
311+
):RecordNode<Record<string,ReturnType<SummaryColumnComp["children"][T]["node"]>>>{
312+
constcolumns=this.getView();
313+
constnodes=_(columns)
314+
.map((col)=>col.children[field].node()asReturnType<SummaryColumnComp["children"][T]["node"]>)
315+
.toPairs()
316+
.fromPairs()
317+
.value();
318+
constresult=lastValueIfEqual(
319+
this,
320+
"col_nodes_"+field,
321+
[fromRecord(nodes),nodes]asconst,
322+
(a,b)=>shallowEqual(a[1],b[1])
323+
)[0];
324+
returnresult;
325+
}
326+
327+
setSelectionAction(key:string){
328+
returnthis.forEachAction(ColumnComp.setSelectionAction(key));
329+
}
330+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp