1
- import { useState } from 'react' ;
1
+ import { useState , useEffect } from 'react' ;
2
2
import {
3
3
UICompBuilder ,
4
4
NameConfig ,
@@ -26,7 +26,7 @@ import { useResizeDetector } from "react-resize-detector";
26
26
import Notification from 'ol-ext/control/Notification'
27
27
28
28
import { boolObjectOptionControl } from './BoolObjectOptionControl' ;
29
-
29
+ import { featureControl } from './FeaturesControl' ;
30
30
31
31
export const CompStyles = [
32
32
{
@@ -91,6 +91,7 @@ export const CompStyles = [
91
91
north: false,
92
92
}
93
93
*/
94
+
94
95
var GEOComp = ( function ( ) {
95
96
96
97
//The events supported
@@ -164,17 +165,61 @@ var GEOComp = (function () {
164
165
events : jsonObjectExposingStateControl ( "events" ) ,
165
166
event : jsonObjectExposingStateControl ( "event" ) ,
166
167
feature : jsonObjectExposingStateControl ( "feature" ) ,
167
- buttons : withDefault ( JSONObjectControl , "{menu:false,north:false,save:false}" ) ,
168
- features : withDefault (
169
- JSONObjectControl ,
170
- "{modify:true,split:false,tracker:false,timeline:false,gpsCentered:true,largeButtons:false,scaleToBottom:false}"
171
- ) ,
172
168
onEvent : eventHandlerControl ( eventDefintions ) ,
173
- test : boolObjectOptionControl ( [
174
- { label : "modify" , state : true } ,
175
- { label : "splitHorizontal" , state : false } ,
176
- { label : "splitVertical" , state : false } ,
177
- ] )
169
+ features : document . lowcoderdev ?
170
+ withDefault ( JSONObjectControl ,
171
+ `{
172
+ menu: false,
173
+ zoom: true,
174
+ fullscreen: true,
175
+ layers: true,
176
+ center: true,
177
+ modify: false,
178
+ split: false,
179
+ tracker: false,
180
+ timeline: false,
181
+ gpsCentered: false,
182
+ largeButtons: true,
183
+ scaleToBottom: false,
184
+ "modify:select": true,
185
+ "modify:point": true,
186
+ "modify:line": true,
187
+ "modify:polygon": true,
188
+ "modify:delete": true,
189
+ "modify:redo": true,
190
+ "modify:undo": true,
191
+ save: false,
192
+ splitVertical: false,
193
+ splitHorizontal: false,
194
+ north: false
195
+ }`
196
+ ) :
197
+ featureControl ( {
198
+ menu : false ,
199
+ zoom : true ,
200
+ fullscreen : true ,
201
+ layers : true ,
202
+ center : true ,
203
+ modify : false ,
204
+ split : false ,
205
+ tracker : false ,
206
+ timeline : false ,
207
+ gpsCentered : false ,
208
+ largeButtons : true ,
209
+ scaleToBottom : false ,
210
+ "modify:select" : true ,
211
+ "modify:point" : true ,
212
+ "modify:line" : true ,
213
+ "modify:polygon" : true ,
214
+ "modify:delete" : true ,
215
+ "modify:redo" : true ,
216
+ "modify:undo" : true ,
217
+ save : false ,
218
+ splitVertical : false ,
219
+ splitHorizontal : false ,
220
+ north : false
221
+ } ) ,
222
+
178
223
} ;
179
224
180
225
@@ -192,22 +237,22 @@ var GEOComp = (function () {
192
237
layers : any ;
193
238
bbox : any ;
194
239
defaults : any ;
195
- buttons : any ;
240
+ feature : any ;
196
241
features : any ;
197
242
menuTitle : string ;
198
243
menuContent : string ;
199
244
autoHeight : boolean ;
200
245
events : any ;
201
246
event : any ;
202
- feature : any
203
- test : any
204
247
} ) => {
205
248
const doDebug = function ( ) {
206
249
return props . defaults && props . defaults . debug === true
207
250
}
251
+
208
252
//Default size of component
209
253
const [ dimensions , setDimensions ] = useState ( { width : 650 , height : 400 } ) ;
210
254
//Catch the resizing of component
255
+
211
256
const { width, height, ref : conRef } = useResizeDetector ( {
212
257
onResize : ( ) => {
213
258
const container = conRef . current ;
@@ -229,6 +274,12 @@ var GEOComp = (function () {
229
274
}
230
275
} ) ;
231
276
277
+
278
+ //Check if feature is Enabled
279
+ const featureEnabled = function ( name : any ) {
280
+ return props . features [ name ] == true
281
+ }
282
+
232
283
//Cache for all events
233
284
var _events = { }
234
285
//The event handler will also sent the event value to use
@@ -253,7 +304,7 @@ var GEOComp = (function () {
253
304
props . feature . onChange ( eventObj )
254
305
break ;
255
306
case 'window:resize' :
256
- if ( props . features && props . features . scaleToBottom == true && props . autoHeight ) {
307
+ if ( featureEnabled ( ' scaleToBottom' ) && props . autoHeight ) {
257
308
const el = eventObj . el
258
309
const rec = eventObj . windowSize
259
310
const bounds = eventObj . bounds . getBoundingClientRect ( )
@@ -309,13 +360,12 @@ var GEOComp = (function () {
309
360
zoom = { props . zoom }
310
361
maxZoom = { props . maxZoom }
311
362
rotation = { props . rotation }
312
- buttons = { props . buttons }
313
363
menuContent = { props . menuContent }
314
364
menuTitle = { props . menuTitle }
315
365
defaults = { props . defaults }
316
- features = { props . features }
317
366
layers = { props . layers }
318
367
onEvent = { handleEvent }
368
+ features = { props . features }
319
369
/>
320
370
</ div >
321
371
</ div >
@@ -338,11 +388,7 @@ var GEOComp = (function () {
338
388
{ children . onEvent . propertyView ( ) }
339
389
</ Section >
340
390
< Section name = "Behavior" >
341
- { children . test . propertyView ( { label : "test features" } ) }
342
- { children . features . propertyView ( { label : "Enabled features" } ) }
343
- { children . buttons . propertyView ( { label : "Visible buttons" } ) }
344
- { children . menuTitle . propertyView ( { label : "Menu title" } ) }
345
- { children . menuContent . propertyView ( { label : "Menu content" } ) }
391
+ { children . features . propertyView ( { title : "Enabled features & Buttons" } ) }
346
392
</ Section >
347
393
< Section name = "Styles" >
348
394
{ children . autoHeight . getPropertyView ( ) }
@@ -360,6 +406,7 @@ var GEOComp = (function () {
360
406
. build ( ) ;
361
407
} ) ( ) ;
362
408
409
+
363
410
//Add autoheight to component
364
411
GEOComp = class extends GEOComp {
365
412
autoHeight ( ) : boolean {
0 commit comments