Skip to content

Commit 49d45bf

Browse files
committed
wip: Reorganize sticky map-based components #1085
1 parent 84c72c0 commit 49d45bf

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

core/client/components/action/KToggleStickyVisibility.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const sticky = Layout.findSticky(props.stickyId)
2727
2828
// Functions
2929
function toggleSticky (context, value) {
30-
Layout.setStickyVisible(props.stickyId, value)
30+
if (value) Layout.showSticky(props.stickyId)
31+
else Layout.hideSticky(props.stickyId)
3132
}
3233
</script>

core/client/i18n/core_en.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -718,13 +718,13 @@
718718
"UPLOAD_FILE_ERRORED": "Cannot upload file {file} !"
719719
},
720720
"KToggleWidgetVisibility": {
721-
"DISPLAY_LEGEND": "Display legend",
721+
"SHOW_LEGEND": "Show legend",
722722
"HIDE_LEGEND": "Hide legend"
723723
},
724724
"KToggleStickyVisibility": {
725-
"DISPLAY_POSITION": "Display geographical coordinates",
725+
"SHOW_POSITION": "Show geographical coordinates",
726726
"HIDE_POSITION": "Hide geographical coordinates",
727-
"DISPLAY_NORTH": "Display north arrow",
727+
"SHOW_NORTH": "Show north arrow",
728728
"HIDE_NORTH": "Hide north arrow"
729729
}
730730
}

core/client/i18n/core_fr.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -716,13 +716,13 @@
716716
"UPLOAD_FILE_ERRORED": "Impossible de transférer le fichier {file} !"
717717
},
718718
"KToggleWidgetVisibility": {
719-
"DISPLAY_LEGEND": "Afficher la légende",
719+
"SHOW_LEGEND": "Afficher la légende",
720720
"HIDE_LEGEND": "Masquer la légende"
721721
},
722722
"KToggleStickyVisibility": {
723-
"DISPLAY_POSITION": "Afficher les coordonnées géographiques",
723+
"SHOW_POSITION": "Afficher les coordonnées géographiques",
724724
"HIDE_POSITION": "Masquer les coordonnées géographiques",
725-
"DISPLAY_NORTH": "Afficher la flèche d’orientation vers le nord",
725+
"SHOW_NORTH": "Afficher la flèche d’orientation vers le nord",
726726
"HIDE_NORTH": "Masquer la flèche d’orientation vers le nord"
727727
}
728728
}

core/client/layout.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,21 @@ export const Layout = {
302302
findSticky (stickyId) {
303303
return _.find(this.getStickies().components, { id: stickyId })
304304
},
305-
setStickyVisible (stickyId, visible) {
305+
showSticky (stickyId) {
306306
const sticky = this.findSticky(stickyId)
307307
if (!sticky) {
308308
logger.error(`[KDK] Cannot find sticky with id '${stickyId}'`)
309309
return
310310
}
311-
_.set(sticky, 'visible', visible)
311+
_.set(sticky, 'visible', true)
312+
},
313+
hideSticky (stickyId) {
314+
const sticky = this.findSticky(stickyId)
315+
if (!sticky) {
316+
logger.error(`[KDK] Cannot find sticky with id '${stickyId}'`)
317+
return
318+
}
319+
_.set(sticky, 'visible', false)
312320
},
313321
getFab () {
314322
return this.getElement('fab')
@@ -447,10 +455,10 @@ export const Layout = {
447455
clearWindow (placement) {
448456
this.clearElement(`windows.${placement}`)
449457
},
450-
findWindow (widget) {
458+
findWindow (widgeId) {
451459
for (const placement of this.placements) {
452460
const window = this.getWindow(placement)
453-
if (_.find(window.components, { id: widget })) {
461+
if (_.find(window.components, { id: widgeId })) {
454462
return { placement, window }
455463
}
456464
}

map/client/components/stickies/KPosition.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import KAction from '../../../../core/client/components/action/KAction.vue'
3030
const props = defineProps({
3131
target: {
3232
type: String,
33-
default: 'target'
33+
default: 'target-sticky'
3434
}
3535
})
3636
@@ -59,7 +59,7 @@ async function onCopy () {
5959
6060
onMounted(() => {
6161
// Show target sticky
62-
if (props.target) Layout.setStickyVisible(props.target, true)
62+
if (props.target) Layout.showSticky(props.target)
6363
// Listen move events
6464
CurrentActivity.value.$engineEvents.on('movestart', updatePosition)
6565
CurrentActivity.value.$engineEvents.on('move', updatePosition)
@@ -69,7 +69,7 @@ onMounted(() => {
6969
})
7070
// Hooks
7171
onBeforeUnmount(() => {
72-
if (props.target) Layout.setStickyVisible(props.target, false)
72+
if (props.target) Layout.hideSticky(props.target)
7373
// Stop listening move events
7474
CurrentActivity.value.$engineEvents.off('movestart', updatePosition)
7575
CurrentActivity.value.$engineEvents.off('move', updatePosition)

0 commit comments

Comments
 (0)