|
1 | | -import{StringControl}from"comps/controls/codeControl"; |
2 | | -import{BoolControl}from"comps/controls/boolControl"; |
3 | 1 | import{MultiCompBuilder}from"comps/generators/multi"; |
| 2 | +import{withDefault}from"comps/generators/simpleGenerators"; |
4 | 3 | import{BranchDiv}from"lowcoder-design"; |
| 4 | +import{KeyValue}from"types/common"; |
| 5 | +import{BoolControl}from"comps/controls/boolControl"; |
| 6 | +import{StringControl}from"comps/controls/codeControl"; |
| 7 | +import{keyValueListControl}from"../keyValueControl"; |
| 8 | +import{keyValueListToSearchStr}from"../../../util/appUtils"; |
5 | 9 | import{trans}from"i18n"; |
6 | 10 |
|
7 | | -exportconstGoToURLAction=(function(){ |
8 | | -constchildrenMap={ |
9 | | -url:StringControl, |
10 | | -inNewTab:BoolControl, |
| 11 | +constchildrenMap={ |
| 12 | +url:StringControl, |
| 13 | +query:withDefault(keyValueListControl(false,[],"string"),[ |
| 14 | +{key:"",value:""}, |
| 15 | +]), |
| 16 | +hash:withDefault(keyValueListControl(false,[],"string"),[ |
| 17 | +{key:"",value:""}, |
| 18 | +]), |
| 19 | +inNewTab:BoolControl, |
| 20 | +}; |
| 21 | + |
| 22 | +exportconstGoToURLAction=newMultiCompBuilder(childrenMap,(props)=>{ |
| 23 | +return()=>{ |
| 24 | +constqueryParams=keyValueListToSearchStr( |
| 25 | +props.query.map((i)=>i.getView()asKeyValue) |
| 26 | +); |
| 27 | +consthashParams=keyValueListToSearchStr( |
| 28 | +props.hash.map((i)=>i.getView()asKeyValue) |
| 29 | +); |
| 30 | +consturlWithParams=`${props.url}${queryParams ?`?${queryParams}` :""}${hashParams ?`#${hashParams}` :""}`; |
| 31 | + |
| 32 | +window.open(urlWithParams,props.inNewTab ?"_blank" :"_self"); |
11 | 33 | }; |
12 | | -returnnewMultiCompBuilder(childrenMap,(props)=>{ |
13 | | -return()=>{ |
14 | | -window.open(props.url,props.inNewTab ?"_blank" :"_self"); |
15 | | -}; |
| 34 | +}) |
| 35 | +.setPropertyViewFn((children)=>{ |
| 36 | +return( |
| 37 | +<> |
| 38 | +<BranchDiv> |
| 39 | +{children.url.propertyView({ |
| 40 | +label:"URL", |
| 41 | +layout:"vertical", |
| 42 | +})} |
| 43 | +</BranchDiv> |
| 44 | +<BranchDiv> |
| 45 | +{children.query.propertyView({ |
| 46 | +label:trans("eventHandler.queryParams"), |
| 47 | +layout:"vertical", |
| 48 | +})} |
| 49 | +</BranchDiv> |
| 50 | +<BranchDiv> |
| 51 | +{children.hash.propertyView({ |
| 52 | +label:trans("eventHandler.hashParams"), |
| 53 | +layout:"vertical", |
| 54 | +})} |
| 55 | +</BranchDiv> |
| 56 | +<BranchDiv$type="switch"> |
| 57 | +{children.inNewTab.propertyView({ |
| 58 | +label:trans("eventHandler.openInNewTab"), |
| 59 | +layout:"vertical", |
| 60 | +})} |
| 61 | +</BranchDiv> |
| 62 | +</> |
| 63 | +); |
16 | 64 | }) |
17 | | -.setPropertyViewFn((children)=>{ |
18 | | -return( |
19 | | -<> |
20 | | -<BranchDiv> |
21 | | -{children.url.propertyView({ |
22 | | -label:"URL", |
23 | | -layout:"vertical", |
24 | | -})} |
25 | | -</BranchDiv> |
26 | | -<BranchDiv$type="switch"> |
27 | | -{children.inNewTab.propertyView({ |
28 | | -label:trans("eventHandler.openInNewTab"), |
29 | | -})} |
30 | | -</BranchDiv> |
31 | | -</> |
32 | | -); |
33 | | -}) |
34 | | -.build(); |
35 | | -})(); |
| 65 | +.build(); |