Skip to content

Commit 6c5d2b6

Browse files
committed
feat: Add a helper action to control sticky visibility (close #1095)
1 parent 9758aa2 commit 6c5d2b6

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<template>
2+
<KAction
3+
v-if="sticky"
4+
v-bind="props"
5+
:toggled="sticky.visible"
6+
:handler="toggleSticky"
7+
/>
8+
</template>
9+
10+
<script setup>
11+
import _ from 'lodash'
12+
import { actionProps } from '../../utils/index.js'
13+
import { Layout } from '../../layout.js'
14+
import KAction from './KAction.vue'
15+
16+
// Props
17+
const props = defineProps({
18+
stickyId: {
19+
type: String,
20+
required: true
21+
},
22+
..._.omit(actionProps, ['url', 'handler', 'dialog', 'route', 'closePopup', 'toggled'])
23+
})
24+
25+
// Data
26+
const sticky = Layout.findSticky(props.stickyId)
27+
28+
// Functions
29+
function toggleSticky (context, value) {
30+
Layout.setStickyVisible(props.stickyId, value)
31+
}
32+
</script>

core/client/i18n/core_en.json

+4
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@
716716
"FILE_TOO_LARGE": "File {file} is too large. The size must be less than {size}Mb",
717717
"UPLOAD_FILE_SUCCEEDED": "File {file} has been successfully uploaded",
718718
"UPLOAD_FILE_ERRORED": "Cannot upload file {file} !"
719+
},
720+
"KToggleStickyVisibility": {
721+
"DISPLAY_POSITION": "Display geographical coordinates",
722+
"HIDE_POSITION": "Hide geographical coordinates"
719723
}
720724
}
721725

core/client/layout.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ export const Layout = {
305305
setStickyVisible (stickyId, visible) {
306306
const sticky = this.findSticky(stickyId)
307307
if (!sticky) {
308-
logger.error('[KDK] Cannot find sticky with id', stickyId)
308+
logger.error(`[KDK] Cannot find sticky with id '${stickyId}'`)
309309
return
310310
}
311311
_.set(sticky, 'visible', visible)

0 commit comments

Comments
 (0)