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

Commit238163d

Browse files
set/read dataRange and timeRange data using form
1 parent5f4861c commit238163d

File tree

3 files changed

+68
-2
lines changed

3 files changed

+68
-2
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ export const dateRangeControl = (function () {
286286
constchildrenMap={
287287
start:stringExposingStateControl("start"),
288288
end:stringExposingStateControl("end"),
289+
...formDataChildren,
289290
...commonChildren,
290291
};
291292

@@ -367,6 +368,8 @@ export const dateRangeControl = (function () {
367368
tooltip:trans("date.formatTip"),
368369
})}
369370
</Section>
371+
372+
<FormDataPropertyView{...children}/>
370373

371374
{(useContext(EditorContext).editorModeStatus==="logic"||useContext(EditorContext).editorModeStatus==="both")&&(
372375
<><Sectionname={sectionNames.validation}>
@@ -572,4 +575,21 @@ DateRangeComp = withMethodExposing(DateRangeComp, [
572575
comp.children.end.getView().reset();
573576
},
574577
},
578+
{
579+
method:{
580+
name:"setRange",
581+
params:[],
582+
},
583+
execute:(comp,values)=>{
584+
if(values.length!==1){
585+
returnPromise.reject(trans("formComp.valuesLengthError"));
586+
}
587+
constdata=values[0]as{start:string,end:string};
588+
if(typeofdata!=="object"||data===null||Array.isArray(data)||!data.hasOwnProperty('start')||!data.hasOwnProperty('end')){
589+
returnPromise.reject(trans("formComp.valueTypeError"));
590+
}
591+
comp.children.start.getView().onChange(data.start);
592+
comp.children.end.getView().onChange(data.end);
593+
},
594+
},
575595
]);

‎client/packages/lowcoder/src/comps/comps/dateComp/timeComp.tsx‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ export const timeRangeControl = (function () {
251251
constchildrenMap={
252252
start:stringExposingStateControl("start"),
253253
end:stringExposingStateControl("end"),
254+
...formDataChildren,
254255
...commonChildren,
255256
};
256257

@@ -319,6 +320,8 @@ export const timeRangeControl = (function () {
319320
tooltip:trans("time.formatTip"),
320321
})}
321322
</Section>
323+
324+
<FormDataPropertyView{...children}/>
322325

323326
{(useContext(EditorContext).editorModeStatus==="logic"||useContext(EditorContext).editorModeStatus==="both")&&(
324327
<><Sectionname={sectionNames.validation}>
@@ -472,4 +475,21 @@ TimeRangeComp = withMethodExposing(TimeRangeComp, [
472475
comp.children.end.getView().reset();
473476
},
474477
},
478+
{
479+
method:{
480+
name:"setRange",
481+
params:[],
482+
},
483+
execute:(comp,values)=>{
484+
if(values.length!==1){
485+
returnPromise.reject(trans("formComp.valuesLengthError"));
486+
}
487+
constdata=values[0]as{start:string,end:string};
488+
if(typeofdata!=="object"||data===null||Array.isArray(data)||!data.hasOwnProperty('start')||!data.hasOwnProperty('end')){
489+
returnPromise.reject(trans("formComp.valueTypeError"));
490+
}
491+
comp.children.start.getView().onChange(data.start);
492+
comp.children.end.getView().onChange(data.end);
493+
},
494+
},
475495
]);

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
321321
setData(data:JSONObject,initialData?:JSONObject){
322322
// For the properties, first find in data, then initialData, subcomponent default value (resetValue), empty value (clearValue)
323323
constnewData={ ...(initialData??this.children.initialData.getView()), ...data};
324+
324325
returnthis.runMethodOfItems(
325326
{
326327
name:"setValue",
@@ -331,8 +332,19 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
331332
returnvalue!==undefined ?[valueasEvalParamType] :undefined;
332333
},
333334
},
335+
{
336+
name:"setRange",
337+
getParams:(t)=>{
338+
// use component name when formDataKey is empty
339+
constkey=t.children.comp.children.formDataKey?.getView()||t.children.name.getView();
340+
constvalue=newData[key] ?newData[key] :undefined;
341+
returnvalue!==undefined ?[valueasEvalParamType] :undefined;
342+
},
343+
},
334344
{name:"resetValue"},
335-
{name:"clearValue"}
345+
{name:"resetAll"},
346+
{name:"clearValue"},
347+
{name:"clearAll"}
336348
);
337349
}
338350
reset(){
@@ -443,10 +455,24 @@ export const FormComp = withExposingConfigs(FormTmpComp, [
443455
func:(input)=>{
444456
constdata:Record<string,unknown>={};
445457
Object.entries(input.container).forEach(([name,value])=>{
458+
446459
constexposingValues=valueasany;
447460
if(exposingValues?.hasOwnProperty("formDataKey")){
448461
// use component name when formDataKey is empty
449-
data[exposingValues["formDataKey"]||name]=exposingValues["value"];
462+
letinputValue=exposingValues['value'];
463+
// for timeRange/dateRange we don't have value
464+
// instead we have start and end
465+
if(
466+
!inputValue
467+
&&exposingValues?.hasOwnProperty('start')
468+
&&exposingValues?.hasOwnProperty('end')
469+
){
470+
inputValue={
471+
start:exposingValues['start'],
472+
end:exposingValues['end'],
473+
}
474+
}
475+
data[exposingValues["formDataKey"]||name]=inputValue;
450476
}
451477
});
452478
returndata;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp