Skip to content

Commit 4ffe2fa

Browse files
committed
wip: Reorganize sticky map-based components #1085
1 parent c914509 commit 4ffe2fa

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

map/client/components/stickies/KPosition.vue

+22-8
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@
33
id="position"
44
class="row items-center no-padding k-position"
55
>
6-
<span class="text-caption q-pl-sm q-pr-sm">
6+
<span class="text-weight-regular q-pl-sm q-pr-sm">
77
{{ formattedPosition }}
88
</span>
99
<KAction
1010
id="copy-position"
1111
icon="las la-copy"
1212
tooltip="KPosition.COPY"
13-
size="sm"
13+
size="0.75rem"
1414
:handler="onCopy"
1515
/>
16+
<KAction
17+
id="close-position"
18+
icon="cancel"
19+
tooltip="KPosition.CLOSE"
20+
size="0.75rem"
21+
:handler="onClose"
22+
/>
1623
</div>
1724
</template>
1825

@@ -27,7 +34,11 @@ import KAction from '../../../../core/client/components/action/KAction.vue'
2734
2835
// Props
2936
const props = defineProps({
30-
target: {
37+
stickyId: {
38+
type: String,
39+
default: 'position-sticky'
40+
},
41+
targetId: {
3142
type: String,
3243
default: 'target-sticky'
3344
}
@@ -39,7 +50,7 @@ const position = ref(null)
3950
4051
// Computed
4152
const formattedPosition = computed(() => {
42-
if (_.isNil(position.value)) return i18n.t('KPositionIndicator.OUTSIDE_MAP')
53+
if (_.isNil(position.value)) return i18n.t('KPosition.OUTSIDE_MAP')
4354
return formatUserCoordinates(position.value.latitude, position.value.longitude, Store.get('locationFormat', 'FFf'))
4455
})
4556
@@ -50,15 +61,18 @@ function updatePosition () {
5061
async function onCopy () {
5162
try {
5263
await copyToClipboard(formattedPosition.value)
53-
Notify.create({ type: 'positive', message: i18n.t('KPositionIndicator.POSITION_COPIED') })
64+
Notify.create({ type: 'positive', message: i18n.t('KPosition.POSITION_COPIED') })
5465
} catch (error) {
55-
Notify.create({ type: 'negative', message: i18n.t('KPositionIndicator.CANNOT_COPY_POSITION') })
66+
Notify.create({ type: 'negative', message: i18n.t('KPosition.CANNOT_COPY_POSITION') })
5667
}
5768
}
69+
async function onClose () {
70+
if (!_.isEmpty(props.stickyId)) Layout.hideSticky(props.stickyId)
71+
}
5872
5973
onMounted(() => {
6074
// Show target sticky
61-
if (props.target) Layout.showSticky(props.target)
75+
if (!_.isEmpty(props.target)) Layout.showSticky(props.target)
6276
// Listen move events
6377
if (CurrentActivity.value) {
6478
CurrentActivity.value.$engineEvents.on('movestart', updatePosition)
@@ -70,7 +84,7 @@ onMounted(() => {
7084
})
7185
// Hooks
7286
onBeforeUnmount(() => {
73-
if (props.target) Layout.hideSticky(props.target)
87+
if (!_.isEmpty(props.target)) Layout.hideSticky(props.target)
7488
// Stop listening move events
7589
if (CurrentActivity.value) {
7690
CurrentActivity.value.$engineEvents.off('movestart', updatePosition)

0 commit comments

Comments
 (0)