@@ -29,6 +29,7 @@ const state = reactive({
29
29
loaded: false ,
30
30
matchedRouteScore: 0 ,
31
31
activeAppUrl: ' ' as string | undefined ,
32
+ activeDropdown: null as null | number ,
32
33
})
33
34
34
35
const isAnonymous = computed (() => ! state .user || state .user .anonymous )
@@ -120,6 +121,10 @@ function setI18nAndActiveApp(i18n?: any) {
120
121
state .loaded = true
121
122
}
122
123
124
+ function toggleDropdown(index : number ) {
125
+ state .activeDropdown = state .activeDropdown === index ? null : index
126
+ }
127
+
123
128
onMounted (() => {
124
129
getUserDetails ().then (user => {
125
130
state .user = user
@@ -254,7 +259,9 @@ onMounted(() => {
254
259
>
255
260
<li
256
261
v-if =" checkCondition(subitem)"
257
- @click =" state.activeAppUrl = (item as Link).activeAppUrl"
262
+ @click ="
263
+ state.activeAppUrl = (subitem as Link).activeAppUrl
264
+ "
258
265
:class =" {
259
266
active: (subitem as Link).activeAppUrl == state.activeAppUrl,
260
267
}"
@@ -376,10 +383,82 @@ onMounted(() => {
376
383
class =" absolute z-[1000] bg-white w-full duration-300 transition-opacity ease-in-out"
377
384
>
378
385
<nav class =" flex flex-col font-semibold" v-if =" state.mobileMenuOpen" >
379
- <a class =" nav-item-mobile" href =" /datahub/" >{{ t('catalogue') }}</a >
380
- <a class =" nav-item-mobile" href =" /mapstore/" >{{ t('viewer') }}</a >
381
- <a class =" nav-item-mobile" href =" /mapstore/#/home" >{{ t('maps') }}</a >
382
- <a class =" nav-item-mobile" href =" /geoserver/" >{{ t('services') }}</a >
386
+ <template v-for =" (item , index ) in state .menu " :key =" index " >
387
+ <template v-if =" ! item .type && checkCondition (item )" >
388
+ <a
389
+ :href =" (item as Link).url"
390
+ class =" nav-item-mobile"
391
+ @click =" state.activeAppUrl = (item as Link).activeAppUrl"
392
+ :class =" {
393
+ active: (item as Link).activeAppUrl == state.activeAppUrl,
394
+ }"
395
+ >
396
+ <div class =" flex items-center" >
397
+ <span class =" ml-1 first-letter:capitalize" >
398
+ {{
399
+ (item as Link).i18n
400
+ ? t((item as Link).i18n)
401
+ : (item as Link).label
402
+ }}
403
+ </span >
404
+ </div >
405
+ </a >
406
+ </template >
407
+ <template
408
+ v-else-if =" item .type === ' dropdown' && checkCondition (item )"
409
+ >
410
+ <div class =" group inline-block relative" >
411
+ <button
412
+ class =" nav-item-mobile after:hover:scale-x-0 flex items-center"
413
+ @click =" toggleDropdown(index)"
414
+ >
415
+ <span class =" lg:mr-2 md:mr-1 first-letter:capitalize" >{{
416
+ (item as Dropdown).i18n
417
+ ? t((item as Dropdown).i18n)
418
+ : (item as Dropdown).label
419
+ }}</span >
420
+ <ChevronDownIcon
421
+ class =" w-4 h-4"
422
+ stroke-width =" 4"
423
+ ></ChevronDownIcon >
424
+ </button >
425
+ <ul
426
+ class =" absolute border rounded w-full admin-dropdown z-[1002] bg-white"
427
+ v-show =" state.activeDropdown === index"
428
+ >
429
+ <template
430
+ v-for =" (subitem , subindex ) in (item as Dropdown ).items "
431
+ :key =" subindex "
432
+ >
433
+ <li
434
+ v-if =" checkCondition(subitem)"
435
+ @click ="
436
+ state.activeAppUrl = (subitem as Link).activeAppUrl
437
+ "
438
+ :class =" {
439
+ active: (subitem as Link).activeAppUrl == state.activeAppUrl,
440
+ }"
441
+ >
442
+ <a
443
+ :href =" replaceUrlsVariables(subitem.url)"
444
+ class =" capitalize !flex justify-center items-center"
445
+ >
446
+ <i
447
+ v-if =" subitem.icon"
448
+ :class =" subitem.icon"
449
+ class =" pr-1 block pb-[2px] subitem-icon"
450
+ style =" font-size : 1rem "
451
+ ></i >
452
+ <span class =" block" >{{
453
+ subitem.i18n ? t(subitem.i18n) : subitem.label
454
+ }}</span >
455
+ </a >
456
+ </li >
457
+ </template >
458
+ </ul >
459
+ </div >
460
+ </template >
461
+ </template >
383
462
<a v-if =" !isAnonymous" class =" nav-item-mobile" href =" /import/" >{{
384
463
t('datafeeder')
385
464
}}</a >
@@ -405,6 +484,8 @@ onMounted(() => {
405
484
@layer components {
406
485
.nav-item-mobile {
407
486
@apply text-xl block text-center py- 3 w-full border-b border-b-slate- 300 first-letter :capitalize ;
487
+ display : flex ;
488
+ justify-content : center ;
408
489
}
409
490
410
491
.nav-item {
0 commit comments