11<template >
2- <div id =" app" >
2+ <div class =" container" >
3+ <div class =" container-config" >
4+ <div class =" container-config-item" >
5+ <label for =" ctrlEnableDragNDrop" >
6+ Allow Drag'n'drop
7+ </label >
8+ <input
9+ type =" checkbox"
10+ v-model =" ctrlEnableDragNDrop"
11+ id =" ctrlEnableDragNDrop"
12+ >
13+ </div >
14+ <div class =" container-config-item config-max-depth" >
15+ <div >
16+ <label for =" ctrlEnableMaxDepth" >
17+ Enable max depth
18+ </label >
19+ <input
20+ type =" checkbox"
21+ v-model =" ctrlEnableMaxDepth"
22+ id =" ctrlEnableMaxDepth"
23+ >
24+ </div >
25+ <div >
26+ <label for =" ctrlMaxDepth" >
27+ Max Depth:
28+ </label >
29+ <input
30+ v-model.number =" ctrlMaxDepth"
31+ type =" number"
32+ min =" 0"
33+ :disabled =" ! ctrlEnableMaxDepth"
34+ id =" ctrlMaxDepth"
35+ >
36+ </div >
37+ </div >
38+ <div class =" container-config-item config-slots" >
39+ <div >
40+ <label for =" ctrlEnableGroupOperatorSlot" >
41+ Enable Group Operator Slot
42+ </label >
43+ <input
44+ type =" checkbox"
45+ v-model =" ctrlEnableGroupOperatorSlot"
46+ id =" ctrlEnableGroupOperatorSlot"
47+ >
48+ </div >
49+ <div >
50+ <label for =" ctrlEnableGroupControlSlot" >
51+ Enable Group Control Slot
52+ </label >
53+ <input
54+ type =" checkbox"
55+ v-model =" ctrlEnableGroupControlSlot"
56+ id =" ctrlEnableGroupControlSlot"
57+ >
58+ </div >
59+ <div >
60+ <label for =" ctrlEnableRuleSlot" >
61+ Enable Rule Slot
62+ </label >
63+ <input
64+ type =" checkbox"
65+ v-model =" ctrlEnableRuleSlot"
66+ id =" ctrlEnableRuleSlot"
67+ >
68+ </div >
69+ </div >
70+ </div >
371 <query-builder
4- :config =" config "
72+ :config =" getConfig "
573 v-model =" query"
74+ class =" query-builder"
675 >
7- <template #groupOperator =" props " >
76+ <template
77+ v-if =" ctrlEnableGroupOperatorSlot "
78+ #groupOperator =" props "
79+ >
880 <div class =" query-builder-group-slot__group-selection" >
981 <span class =" query-builder-group-slot__group-operator" >SLOT #groupOperator</span >
1082 <select
2294 </div >
2395 </template >
2496
25- <template #groupControl =" props " >
97+ <template
98+ v-if =" ctrlEnableGroupControlSlot "
99+ #groupControl =" props "
100+ >
26101 <group-ctrl-slot :group-ctrl =" props" />
27102 </template >
28103
29- <template #rule =" props " >
104+ <template
105+ v-if =" ctrlEnableRuleSlot "
106+ #rule =" props "
107+ >
30108 <rule-slot :ruleCtrl =" props" />
31109 </template >
32110 </query-builder >
@@ -52,9 +130,25 @@ import RuleSlot from './RuleSlot.vue';
52130 },
53131})
54132export default class App extends Vue {
133+ ctrlEnableDragNDrop: boolean = true ;
134+
135+ ctrlEnableMaxDepth: boolean = false ;
136+
137+ ctrlMaxDepth: number = 3 ;
138+
139+ ctrlEnableGroupOperatorSlot: boolean = true ;
140+
141+ ctrlEnableGroupControlSlot: boolean = true ;
142+
143+ ctrlEnableRuleSlot: boolean = true ;
144+
55145 query: RuleSet | null = {
56146 operatorIdentifier: ' OR' ,
57147 children: [
148+ {
149+ identifier: ' txt' ,
150+ value: ' A' ,
151+ },
58152 {
59153 operatorIdentifier: ' AND' ,
60154 children: [
@@ -143,6 +237,7 @@ export default class App extends Vue {
143237 initialValue: 10 ,
144238 },
145239 ],
240+ maxDepth: undefined ,
146241 colors: [
147242 ' hsl(88, 50%, 55%)' ,
148243 ' hsl(187, 100%, 45%)' ,
@@ -154,6 +249,22 @@ export default class App extends Vue {
154249 ghostClass: ' ghost' ,
155250 },
156251 }
252+
253+ get getConfig(): QueryBuilderConfig {
254+ const config: QueryBuilderConfig = { ... this .config };
255+
256+ if (! config .dragging ) {
257+ config .dragging = {};
258+ }
259+ config .dragging .disabled = ! this .ctrlEnableDragNDrop ;
260+
261+ config .maxDepth = Math .abs (this .ctrlMaxDepth || 0 );
262+ if (! this .ctrlEnableMaxDepth ) {
263+ config .maxDepth = undefined ;
264+ }
265+
266+ return config ;
267+ }
157268}
158269 </script >
159270
@@ -167,9 +278,30 @@ body {
167278 font-size : 16px ;
168279}
169280
170- #app {
171- margin : 30px auto ;
281+ .container {
172282 width : 90% ;
283+ margin : 30px auto ;
284+ display : flex ;
285+ flex-direction : column ;
286+ }
287+
288+ .container-config {
289+ border : 1px solid hsl (0 , 0% , 75% );
290+ margin-bottom : 30px ;
291+ padding : 10px ;
292+ display : grid ;
293+ grid-template-columns : 1fr 1fr 1fr ;
294+ }
295+
296+ // .container-config-item {
297+ //
298+ // }
299+
300+ .config-max-depth #ctrlMaxDepth {
301+ width : 70px ;
302+ }
303+
304+ .query-builder {
173305 border : 1px solid hsl (0 , 0% , 75% );
174306}
175307
0 commit comments