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

Commitad537a3

Browse files
authored
Merge pull requestlowcoder-org#675 from raheeliftikhar5/bug-fixes-2-6
Bug fixes
2 parents697c308 +50bf25a commitad537a3

22 files changed

+223
-78
lines changed

‎client/packages/lowcoder/src/comps/comps/buttonComp/dropdownComp.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,16 @@ const DropdownTmpComp = (function () {
8383
key:option.label+" - "+index,
8484
disabled:option.disabled,
8585
icon:hasIcon&&<span>{option.prefixIcon}</span>,
86-
onEvent:option.onEvent,
86+
index,
8787
}));
8888

8989
constmenu=(
9090
<Menu
9191
items={items}
92-
onClick={({ key})=>items.find((o)=>o.key===key)?.onEvent("click")}
92+
onClick={({ key})=>{
93+
constitem=items.find((o)=>o.key===key);
94+
item&&props.options[item.index]?.onEvent("click");
95+
}}
9396
/>
9497
);
9598

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ export function ListView(props: Props) {
176176
return<divkey={itemIdx}style={{flex:"auto"}}></div>;
177177
}
178178
constcontainerProps=containerFn(
179-
{[itemIndexName]:itemIdx,[itemDataName]:getCurrentItemParams(data,itemIdx)},
179+
{
180+
[itemIndexName]:itemIdx,
181+
[itemDataName]:getCurrentItemParams(data,itemIdx)
182+
},
180183
String(itemIdx)
181184
).getView();
182185
constunMountFn=()=>{

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

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
}from"comps/controls/codeControl";
88
import{styleControl}from"comps/controls/styleControl";
99
import{ListViewStyle}from"comps/controls/styleControlConstants";
10-
import{UICompBuilder,withDefault,withPropertyViewFn,withViewFn}from"comps/generators";
10+
import{UICompBuilder,stateComp,valueComp,withDefault,withPropertyViewFn,withViewFn}from"comps/generators";
1111
import{
1212
CompDepsConfig,
1313
depsConfig,
@@ -37,6 +37,7 @@ import { ContextContainerComp } from "./contextContainerComp";
3737
import{ListView}from"./listView";
3838
import{listPropertyView}from"./listViewPropertyView";
3939
import{getData}from"./listViewUtils";
40+
import{withMethodExposing}from"comps/generators/withMethodExposing";
4041

4142
constchildrenMap={
4243
noOfRows:withIsLoadingMethod(NumberOrJSONObjectArrayControl),// FIXME: migrate "noOfRows" to "data"
@@ -80,10 +81,10 @@ export class ListViewImplComp extends ListViewTmpComp implements IContainer {
8081
}
8182
overridereduce(action:CompAction): this{
8283
// console.info("listView reduce. action: ", action);
83-
8484
letcomp=reduceInContext({inEventContext:true},()=>super.reduce(action));
85+
8586
if(action.type===CompActionTypes.UPDATE_NODES_V2){
86-
const{ itemCount}=getData(comp.children.noOfRows.getView());
87+
const{ itemCount}=getData(comp.children.noOfRows.getView());
8788
constpagination=comp.children.pagination.getView();
8889
consttotal=pagination.total||itemCount;
8990
constoffset=(pagination.current-1)*pagination.pageSize;
@@ -151,11 +152,11 @@ export class ListViewImplComp extends ListViewTmpComp implements IContainer {
151152

152153
constListViewRenderComp=withViewFn(ListViewImplComp,(comp)=><ListViewcomp={comp}/>);
153154
constListPropertyView=listPropertyView("listView");
154-
constListViewPropertyComp=withPropertyViewFn(ListViewRenderComp,(comp)=>{
155+
letListViewPropertyComp=withPropertyViewFn(ListViewRenderComp,(comp)=>{
155156
return<ListPropertyViewcomp={comp}/>;
156157
});
157158

158-
exportconstListViewComp=withExposingConfigs(ListViewPropertyComp,[
159+
ListViewPropertyComp=withExposingConfigs(ListViewPropertyComp,[
159160
newCompDepsConfig(
160161
"items",
161162
(comp)=>({data:comp.itemsNode()}),
@@ -171,9 +172,31 @@ export const ListViewComp = withExposingConfigs(ListViewPropertyComp, [
171172
returndata;
172173
},
173174
}),
175+
// new CompDepsConfig(
176+
// "index",
177+
// (comp) => ({index: comp.children.itemIndexName.node() }),
178+
// (input) => input.index.value,
179+
// "index", // trans("listView.itemsDesc")
180+
// ),
174181
NameConfigHidden,
175182
]);
176183

184+
exportconstListViewComp=withMethodExposing(ListViewPropertyComp,[
185+
{
186+
method:{
187+
name:"setPage",
188+
description:"",
189+
params:[{name:"page",type:"number"}],
190+
},
191+
execute:(comp,values)=>{
192+
constpage=values[0]asnumber;
193+
if(page&&page>0){
194+
comp.children.pagination.children.pageNo.dispatchChangeValueAction(page);
195+
}
196+
},
197+
},
198+
])
199+
177200
exportfunctiondefaultListViewData(compName:string,nameGenerator:NameGenerator){
178201
return{
179202
noOfRows:
@@ -232,7 +255,7 @@ export function defaultListViewData(compName: string, nameGenerator: NameGenerat
232255
compType:"rating",
233256
name:nameGenerator.genItemName("rating"),
234257
comp:{
235-
value:"{{currentItem.rate / 2}}",
258+
defaultValue:"{{currentItem.rate / 2}}",
236259
max:"5",
237260
label:{
238261
text:"",

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import{BoolControl}from"comps/controls/boolControl";
1111
import{dropdownControl}from"comps/controls/dropdownControl";
1212
import{LabelControl}from"comps/controls/labelControl";
13-
import{numberExposingStateControl}from"comps/controls/codeStateControl";
13+
import{numberExposingStateControl,stringExposingStateControl}from"comps/controls/codeStateControl";
1414
importNPfrom"number-precision";
1515

1616
import{
@@ -234,6 +234,7 @@ const UndefinedNumberControl = codeControl<number | undefined>((value: any) => {
234234
});
235235

236236
constchildrenMap={
237+
defaultValue:stringExposingStateControl("defaultValue"),// It is more convenient for string to handle various states, save raw input here
237238
value:numberExposingStateControl("value"),// It is more convenient for string to handle various states, save raw input here
238239
placeholder:StringControl,
239240
disabled:BoolCodeControl,
@@ -261,6 +262,17 @@ const childrenMap = {
261262

262263
constCustomInputNumber=(props:RecordConstructorToView<typeofchildrenMap>)=>{
263264
constref=useRef<HTMLInputElement|null>(null);
265+
constdefaultValue=props.defaultValue.value;
266+
267+
useEffect(()=>{
268+
letvalue=0;
269+
if(defaultValue==='null'&&props.allowNull){
270+
value=NaN;
271+
}elseif(!isNaN(Number(defaultValue))){
272+
value=Number(defaultValue);
273+
}
274+
props.value.onChange(value);
275+
},[defaultValue]);
264276

265277
constformatFn=(value:number)=>
266278
format(value,props.allowNull,props.formatter,props.precision,props.thousandsSeparator);
@@ -271,7 +283,9 @@ const CustomInputNumber = (props: RecordConstructorToView<typeof childrenMap>) =
271283
constoldValue=props.value.value;
272284
constnewValue=parseNumber(tmpValue,props.allowNull);
273285
props.value.onChange(newValue);
274-
oldValue!==newValue&&props.onEvent("change");
286+
if((oldValue!==newValue)){
287+
props.onEvent("change");
288+
}
275289
};
276290

277291
useEffect(()=>{
@@ -363,7 +377,7 @@ const NumberInputTmpComp = (function () {
363377
.setPropertyViewFn((children)=>(
364378
<>
365379
<Sectionname={sectionNames.basic}>
366-
{children.value.propertyView({label:trans("prop.defaultValue")})}
380+
{children.defaultValue.propertyView({label:trans("prop.defaultValue")})}
367381
{placeholderPropertyView(children)}
368382
{children.formatter.propertyView({label:trans("numberInput.formatter")})}
369383
</Section>

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { migrateOldData } from "comps/generators/simpleGenerators";
1515
import{disabledPropertyView,hiddenPropertyView}from"comps/utils/propertyUtils";
1616
import{trans}from"i18n";
1717

18-
import{useContext}from"react";
18+
import{useContext,useEffect,useRef}from"react";
1919
import{EditorContext}from"comps/editorState";
2020

2121
constEventOptions=[changeEvent]asconst;
@@ -36,6 +36,7 @@ function fixOldData(oldData: any) {
3636

3737
constRatingBasicComp=(function(){
3838
constchildrenMap={
39+
defaultValue:numberExposingStateControl("defaultValue"),
3940
value:numberExposingStateControl("value"),
4041
max:withDefault(NumberControl,"5"),
4142
label:LabelControl,
@@ -46,6 +47,21 @@ const RatingBasicComp = (function () {
4647
...formDataChildren,
4748
};
4849
returnnewUICompBuilder(childrenMap,(props)=>{
50+
constdefaultValue={ ...props.defaultValue}.value;
51+
constvalue={ ...props.value}.value;
52+
constchangeRef=useRef(false)
53+
54+
useEffect(()=>{
55+
props.value.onChange(defaultValue);
56+
},[defaultValue]);
57+
58+
useEffect(()=>{
59+
if(!changeRef.current)return;
60+
61+
props.onEvent("change");
62+
changeRef.current=false;
63+
},[value]);
64+
4965
returnprops.label({
5066
style:props.style,
5167
children:(
@@ -54,7 +70,7 @@ const RatingBasicComp = (function () {
5470
value={props.value.value}
5571
onChange={(e)=>{
5672
props.value.onChange(e);
57-
props.onEvent("change");
73+
changeRef.current=true;
5874
}}
5975
allowHalf={props.allowHalf}
6076
disabled={props.disabled}
@@ -67,7 +83,7 @@ const RatingBasicComp = (function () {
6783
return(
6884
<>
6985
<Sectionname={sectionNames.basic}>
70-
{children.value.propertyView({label:trans("prop.defaultValue")})}
86+
{children.defaultValue.propertyView({label:trans("prop.defaultValue")})}
7187
{children.max.propertyView({
7288
label:trans("rating.max"),
7389
})}

‎client/packages/lowcoder/src/comps/comps/selectInputComp/checkboxComp.tsx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ const CheckboxGroup = styled(AntdCheckboxGroup)<{
102102

103103
constCheckboxBasicComp=(function(){
104104
constchildrenMap={
105-
value:arrayStringExposingStateControl("value",["1"]),
105+
defaultValue:arrayStringExposingStateControl("defaultValue"),
106+
value:arrayStringExposingStateControl("value"),
106107
label:LabelControl,
107108
disabled:BoolCodeControl,
108109
onEvent:ChangeEventHandlerControl,
@@ -115,7 +116,10 @@ const CheckboxBasicComp = (function () {
115116
...formDataChildren,
116117
};
117118
returnnewUICompBuilder(childrenMap,(props)=>{
118-
const[validateState,handleValidate]=useSelectInputValidate(props);
119+
const[
120+
validateState,
121+
handleChange,
122+
]=useSelectInputValidate(props);
119123
returnprops.label({
120124
required:props.required,
121125
style:props.style,
@@ -134,9 +138,7 @@ const CheckboxBasicComp = (function () {
134138
disabled:option.disabled,
135139
}))}
136140
onChange={(values)=>{
137-
handleValidate(valuesasstring[]);
138-
props.value.onChange(valuesasstring[]);
139-
props.onEvent("change");
141+
handleChange(valuesasstring[]);
140142
}}
141143
/>
142144
),

‎client/packages/lowcoder/src/comps/comps/selectInputComp/multiSelectComp.tsx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,24 @@ import { SelectInputInvalidConfig, useSelectInputValidate } from "./selectInputC
1414

1515
import{PaddingControl}from"../../controls/paddingControl";
1616
import{MarginControl}from"../../controls/marginControl";
17+
import{useEffect,useRef}from"react";
1718

1819
constMultiSelectBasicComp=(function(){
1920
constchildrenMap={
2021
...SelectChildrenMap,
21-
value:arrayStringExposingStateControl("value",["1","2"]),
22+
defaultValue:arrayStringExposingStateControl("defaultValue",["1","2"]),
23+
value:arrayStringExposingStateControl("value"),
2224
style:styleControl(MultiSelectStyle),
2325
margin:MarginControl,
2426
padding:PaddingControl,
2527
};
2628
returnnewUICompBuilder(childrenMap,(props,dispatch)=>{
2729
constvalueSet=newSet<any>(props.options.map((o)=>o.value));// Filter illegal default values entered by the user
28-
const[validateState,handleValidate]=useSelectInputValidate(props);
30+
const[
31+
validateState,
32+
handleChange,
33+
]=useSelectInputValidate(props);
34+
2935
returnprops.label({
3036
required:props.required,
3137
style:props.style,
@@ -34,11 +40,7 @@ const MultiSelectBasicComp = (function () {
3440
{...props}
3541
mode={"multiple"}
3642
value={props.value.value.filter?.((v)=>valueSet.has(v))}
37-
onChange={(value)=>{
38-
handleValidate(value);
39-
props.value.onChange(value);
40-
props.onEvent("change");
41-
}}
43+
onChange={handleChange}
4244
dispatch={dispatch}
4345
/>
4446
),

‎client/packages/lowcoder/src/comps/comps/selectInputComp/radioComp.tsx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ const Radio = styled(AntdRadioGroup)<{
8383

8484
constRadioBasicComp=(function(){
8585
returnnewUICompBuilder(RadioChildrenMap,(props)=>{
86-
const[validateState,handleValidate]=useSelectInputValidate(props);
86+
const[
87+
validateState,
88+
handleChange,
89+
]=useSelectInputValidate(props);
8790
returnprops.label({
8891
required:props.required,
8992
style:props.style,
@@ -95,9 +98,7 @@ const RadioBasicComp = (function () {
9598
$style={props.style}
9699
$layout={props.layout}
97100
onChange={(e)=>{
98-
handleValidate(e.target.value);
99-
props.value.onChange(e.target.value);
100-
props.onEvent("change");
101+
handleChange(e.target.value);
101102
}}
102103
options={props.options
103104
.filter((option)=>option.value!==undefined&&!option.hidden)

‎client/packages/lowcoder/src/comps/comps/selectInputComp/radioCompConstants.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const RadioLayoutOptions = [
3030
]asconst;
3131

3232
exportconstRadioChildrenMap={
33+
defaultValue:stringExposingStateControl("value"),
3334
value:stringExposingStateControl("value"),
3435
label:LabelControl,
3536
disabled:BoolCodeControl,
@@ -46,6 +47,9 @@ export const RadioChildrenMap = {
4647
exportconstRadioPropertyView=(
4748
children:RecordConstructorToComp<
4849
typeofRadioChildrenMap&{hidden:typeofBoolCodeControl}&{
50+
defaultValue:
51+
|ReturnType<typeofstringExposingStateControl>
52+
|ReturnType<typeofarrayStringExposingStateControl>;
4953
value:
5054
|ReturnType<typeofstringExposingStateControl>
5155
|ReturnType<typeofarrayStringExposingStateControl>;
@@ -55,7 +59,7 @@ export const RadioPropertyView = (
5559
<>
5660
<Sectionname={sectionNames.basic}>
5761
{children.options.propertyView({})}
58-
{children.value.propertyView({label:trans("prop.defaultValue")})}
62+
{children.defaultValue.propertyView({label:trans("prop.defaultValue")})}
5963
</Section>
6064

6165
{["logic","both"].includes(useContext(EditorContext).editorModeStatus)&&(

‎client/packages/lowcoder/src/comps/comps/selectInputComp/segmentedControl.tsx‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const Segmented = styled(AntdSegmented)<{ $style: SegmentStyleType }>`
6262
`;
6363

6464
constSegmentChildrenMap={
65+
defaultValue:stringExposingStateControl("value"),
6566
value:stringExposingStateControl("value"),
6667
label:LabelControl,
6768
disabled:BoolCodeControl,
@@ -76,7 +77,11 @@ const SegmentChildrenMap = {
7677

7778
constSegmentedControlBasicComp=(function(){
7879
returnnewUICompBuilder(SegmentChildrenMap,(props)=>{
79-
const[validateState,handleValidate]=useSelectInputValidate(props);
80+
const[
81+
validateState,
82+
handleValidate,
83+
handleChange,
84+
]=useSelectInputValidate(props);
8085
returnprops.label({
8186
required:props.required,
8287
style:props.style,
@@ -88,9 +93,7 @@ const SegmentedControlBasicComp = (function () {
8893
value={props.value.value}
8994
$style={props.style}
9095
onChange={(value)=>{
91-
handleValidate(value.toString());
92-
props.value.onChange(value.toString());
93-
props.onEvent("change");
96+
handleChange(value.toString());
9497
}}
9598
options={props.options
9699
.filter((option)=>option.value!==undefined&&!option.hidden)
@@ -109,7 +112,7 @@ const SegmentedControlBasicComp = (function () {
109112
<>
110113
<Sectionname={sectionNames.basic}>
111114
{children.options.propertyView({})}
112-
{children.value.propertyView({label:trans("prop.defaultValue")})}
115+
{children.defaultValue.propertyView({label:trans("prop.defaultValue")})}
113116
</Section>
114117

115118
{["logic","both"].includes(useContext(EditorContext).editorModeStatus)&&(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp