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

Commit296e25b

Browse files
authored
Merge pull request#1506 from lowcoder-org/fix/variable_header_control_type
Added validation check to input boxes of variables
2 parents5a374db +3e41004 commit296e25b

File tree

5 files changed

+78
-5
lines changed

5 files changed

+78
-5
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import{ControlParams}from"comps/controls/controlParams";
2+
import{CompAction,SimpleComp}from"lowcoder-core";
3+
import{ControlPropertyViewWrapper,PopupCard,Input}from"lowcoder-design";
4+
import{useEffect,useState}from"react";
5+
import{trans}from"i18n";
6+
import{checkName}from"../utils/rename";
7+
constSimpleVariableHeaderPropertyView=({params, comp, isCheck}:any)=>{
8+
const[error,setError]=useState<string|undefined>();
9+
const[value,setValue]=useState(comp.value);
10+
useEffect(()=>{
11+
setValue(comp.value);
12+
isCheck&&setError(undefined);
13+
},[comp]);
14+
return(
15+
<ControlPropertyViewWrapper{...params}>
16+
<Input
17+
value={value}
18+
placeholder={params.placeholder}
19+
onChange={(e)=>{
20+
consterror=isCheck&&checkName(e.target.value);
21+
isCheck&&setError(error||undefined);
22+
setValue(e.target.value);
23+
}}
24+
onBlur={(e)=>{
25+
if(!isCheck||!error)comp.dispatchChangeValueAction(value);
26+
else{
27+
setValue(comp.value);
28+
setError(undefined);
29+
}
30+
}}
31+
/>
32+
{isCheck&&<PopupCard
33+
editorFocus={!!error}
34+
title={error ?trans("error") :""}
35+
content={error}
36+
hasError={!!error}
37+
/>}
38+
</ControlPropertyViewWrapper>
39+
);
40+
}
41+
exportconstSimpleVariableHeaderComp=(isCheck:boolean=false)=>{
42+
returnclassSimpleVariableHeaderCompextendsSimpleComp<string>{
43+
overridereduce(action:CompAction): this{
44+
// if (isBroadcastAction<RenameAction>(action, CompActionTypes.RENAME)) {
45+
// if (this.getView() === action.action.oldName) {
46+
// return super.reduce(this.changeValueAction(action.action.name));
47+
// }
48+
// }
49+
returnsuper.reduce(action);
50+
}
51+
52+
readonlyIGNORABLE_DEFAULT_VALUE="";
53+
protectedgetDefaultValue():string{
54+
return"";
55+
}
56+
57+
getPropertyView(){
58+
returnthis.propertyView({});
59+
}
60+
61+
propertyView(params:ControlParams){
62+
return<SimpleVariableHeaderPropertyViewparams={params}comp={this}isCheck={isCheck}></SimpleVariableHeaderPropertyView>
63+
}
64+
}
65+
}

‎client/packages/lowcoder/src/comps/controls/actionSelector/executeQueryAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const ExecuteQueryPropertyView = ({
9999
constExecuteQueryTmpAction=(function(){
100100
constchildrenMap={
101101
queryName:SimpleNameComp,
102-
queryVariables:withDefault(keyValueListControl(false,[],"string"),[])
102+
queryVariables:withDefault(keyValueListControl(false,[],"variable"),[])
103103
};
104104
returnnewMultiCompBuilder(childrenMap,()=>{
105105
return()=>Promise.resolve(undefinedasunknown);

‎client/packages/lowcoder/src/comps/controls/keyValueControl.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { StringControl } from "./codeControl";
66
import{ControlParams}from"./controlParams";
77
import{dropdownControl}from"./dropdownControl";
88
import{ParamsStringControl}from"./paramsControl";
9+
import{SimpleVariableHeaderComp}from"../comps/simpleVariableHeaderComp";
910

1011
constKeyValueWrapper=styled.div`
1112
display: flex;
@@ -58,13 +59,20 @@ export type KeyValueControlParams = ControlParams & {
5859
exportfunctionkeyValueControl<TextendsOptionsType>(
5960
hasType:boolean=false,
6061
types:T,
61-
controlType:"params"|"string"="params"
62+
controlType:"params"|"string"|"variable"="params"
6263
){
63-
constchildrenMap={
64+
letchildrenMap={
6465
key:controlType==="params" ?ParamsStringControl :StringControl,
6566
value:controlType==="params" ?ParamsStringControl :StringControl,
6667
type:dropdownControl(types,types[0]?.value),
6768
};
69+
if(controlType==="variable"){
70+
childrenMap={
71+
key:SimpleVariableHeaderComp(true)asany,
72+
value:SimpleVariableHeaderComp()asany,
73+
type:dropdownControl(types,types[0]?.value),
74+
};
75+
}
6876
returnclassextendsnewMultiCompBuilder(childrenMap,(props)=>{
6977
returnhasType
7078
?{

‎client/packages/lowcoder/src/comps/controls/keyValueListControl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { keyValueControl, KeyValueControlParams } from "./keyValueControl"
1414
exportfunctionkeyValueListControl<TextendsOptionsType>(
1515
hasType:boolean=false,
1616
types:T|OptionsType=[],
17-
controlType:"params"|"string"="params"
17+
controlType:"params"|"string"|"variable"="params"
1818
){
1919
returnclassextendslist(keyValueControl(hasType,types,controlType)){
2020
getQueryParams(){

‎client/packages/lowcoder/src/comps/queries/queryComp/variablesComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { keyValueListControl } from "../../controls/keyValueListControl";
33

44
exportconstVariablesComp=newMultiCompBuilder(
55
{
6-
variables:withDefault(keyValueListControl(false,[],"string"),[{key:"",value:""}]),
6+
variables:withDefault(keyValueListControl(false,[],"variable"),[{key:"",value:""}]),
77
},
88
(props)=>props//props.variables
99
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp