Skip to content

PB 1151: add warning message kml import partially out of bounds #1195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
05f1949
PB-1151: Notify user when imported file is not all in extent
ltkum Jan 13, 2025
7f25053
PB-1151: add translations
ltkum Jan 13, 2025
e0db29b
PB 1151: test corrections
ltkum Jan 14, 2025
457a79a
PB-1151: moving logic from store to layer
ltkum Jan 20, 2025
710a57f
PB-1151: correction to the cypress tests
ltkum Mar 13, 2025
c39ca4b
PB-1151: remove leftover from rebase
ltkum Mar 13, 2025
0d44bd4
PB-1432 Introduce tooltip based on floating-ui
schtibe Feb 17, 2025
4202258
PB-1432 Remove tippy composable
schtibe Feb 20, 2025
474ef78
PB-1432 Remove RangeTippy composable
schtibe Feb 21, 2025
1711e39
PB-1432 Remove the tippy residue
schtibe Feb 21, 2025
740af69
PB-1432 Replace tippy with geoadmin tooltip
schtibe Feb 17, 2025
3e84032
PB-1432 Replace "tippy" with tooltip in translation etc.
schtibe Feb 21, 2025
b65dd8a
PB-1432 Teleport the tooltip to the body
schtibe Feb 21, 2025
ef64de8
PB-1432 Only render tooltips in the DOM if they're shown
schtibe Feb 21, 2025
9983cf9
PB-1432 Give the tooltip a data-cy attribute based on its contents
schtibe Feb 21, 2025
0b41602
PB-1432 Allow geoadmin tooltip fallback on other axis
schtibe Feb 21, 2025
6b6bddc
PB-1432 Fix click event problem on drawing style button
schtibe Feb 21, 2025
6601b48
PB-1432 Fix the GeoAdminTooltip event handling
schtibe Feb 24, 2025
333caaf
PB-1432 Replace errorbutton with ext info button
schtibe Feb 24, 2025
42dd42a
Revert "PB-1432 Fix click event problem on drawing style button"
schtibe Feb 25, 2025
0515fed
PB-1432 Fix cypress tests with new floating tooltip
schtibe Feb 21, 2025
ed5e05d
Set slider value directly without click
schtibe Feb 25, 2025
feb7cf0
Pb-1432 Use mouseup event for setting the timeslider in tests
schtibe Feb 28, 2025
dd36eef
Typescriptify debounce method
schtibe Feb 28, 2025
7177edb
PB-1432 Refactor Transparency Slider
schtibe Feb 28, 2025
372f59e
PB-1432 Make the hover tooltip go away on click/tap
schtibe Feb 28, 2025
29b0600
PB-1432 Fix transparency slider in cypress
schtibe Feb 28, 2025
b0f0b70
PB-1432 Fix the error display on invalid KML layers
schtibe Feb 28, 2025
97a341c
PB-1432 Fix linting of GeoadminTooltip
schtibe Feb 28, 2025
3bb4f9c
Fix Transparency layer selection bug
schtibe Mar 3, 2025
a40df29
Revert "Fix Transparency layer selection bug"
schtibe Mar 3, 2025
3a767da
Fix layer opacity setting from new transparency slider
schtibe Mar 3, 2025
8c4e076
PB-1432 Restore civil icon tooltip content
schtibe Mar 13, 2025
de57c35
PB-1432 Add possibility for default padding to geoadmin tooltip
schtibe Mar 13, 2025
564447e
PB-1432 Use bootstrap utility classes for the tooltip padding
schtibe Mar 13, 2025
78bfb4c
PB-1432 Delay the tooltip a little bit
schtibe Mar 13, 2025
dc6781b
Revert "PB-1432 Delay the tooltip a little bit"
schtibe Mar 13, 2025
c04f8a1
PB-1432 Don't show the tooltip on mouseover if it's a touch device
schtibe Mar 13, 2025
929de9e
PB-1432 Add a "border" to the tooltip arrows
schtibe Mar 13, 2025
f7ce915
Sort all dependencies
schtibe Mar 13, 2025
2a8c7f8
PB-1432 Move data-cy attribution away from props
schtibe Mar 13, 2025
572c06c
PB-1432 Delay the tooltip a little bit
schtibe Mar 13, 2025
ccb5d2d
PB-1432 Fix the tooltip delay for mobile
schtibe Mar 13, 2025
82030ab
PB-1432 Update lock-file
schtibe Mar 13, 2025
26830e7
PB-1151: moving logic from store to layer
ltkum Jan 20, 2025
e05fee7
PB-1151: removing warningbutton component
ltkum Mar 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@
"@vue/eslint-config-prettier": "catalog:",
"@vue/eslint-config-typescript": "catalog:",
"@vue/tsconfig": "catalog:",
"eslint": "catalog:",
"eslint-plugin-cypress": "catalog:",
"eslint-plugin-mocha": "catalog:",
"eslint-plugin-perfectionist": "catalog:",
"eslint-plugin-prettier": "catalog:",
"eslint-plugin-vue": "catalog:",
"eslint": "catalog:",
"globals": "catalog:",
"prettier": "catalog:",
"prettier-plugin-jsdoc": "catalog:",
"typescript": "catalog:",
"prettier": "catalog:",
"typescript-eslint": "catalog:",
"vite": "catalog:",
"typescript": "catalog:",
"vite-plugin-dts": "catalog:",
"vite": "catalog:",
"vitest": "catalog:",
"vue-tsc": "catalog:"
},
Expand Down
7 changes: 3 additions & 4 deletions packages/mapviewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"delete:reports:unit": "rimraf tests/results/unit/ || true"
},
"dependencies": {
"@floating-ui/vue": "catalog:",
"@fortawesome/fontawesome-svg-core": "catalog:",
"@fortawesome/free-brands-svg-icons": "catalog:",
"@fortawesome/free-regular-svg-icons": "catalog:",
Expand Down Expand Up @@ -74,11 +75,10 @@
"proj4": "catalog:",
"reproject": "catalog:",
"sortablejs": "catalog:",
"tippy.js": "catalog:",
"vue": "catalog:",
"vue-chartjs": "catalog:",
"vue-i18n": "catalog:",
"vue-router": "catalog:",
"vue": "catalog:",
"vue3-social-sharing": "catalog:",
"vuex": "catalog:"
},
Expand All @@ -95,12 +95,12 @@
"@vue/tsconfig": "catalog:",
"axios-retry": "catalog:",
"chai": "catalog:",
"cypress": "catalog:",
"cypress-browser-permissions": "catalog:",
"cypress-real-events": "catalog:",
"cypress-recurse": "catalog:",
"cypress-vite": "catalog:",
"cypress-wait-until": "catalog:",
"cypress": "catalog:",
"dotenv": "catalog:",
"git-describe": "catalog:",
"gitconfig": "catalog:",
Expand All @@ -112,7 +112,6 @@
"sass": "catalog:",
"sharp": "catalog:",
"start-server-and-test": "catalog:",
"vite": "catalog:",
"vite-node": "catalog:",
"vite-plugin-static-copy": "catalog:",
"vite-plugin-vue-devtools": "catalog:",
Expand Down
39 changes: 39 additions & 0 deletions packages/mapviewer/src/api/layers/AbstractLayer.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ export default class AbstractLayer {
/** @type {Set<ErrorMessage>} */
this.errorMessages = new Set()
this.hasError = false
/** @type {Set<WarningMessage><} */
this.warningMessages = new Set()
this.hasWarning = false
this.timeConfig = timeConfig
this.hasMultipleTimestamps = this.timeConfig?.timeEntries?.length > 1
this.setCustomAttributes(customAttributes)
Expand Down Expand Up @@ -171,6 +174,42 @@ export default class AbstractLayer {
this.hasError = false
}

/**
* @param {WarningMessage} warningMessage
* @returns {boolean}
*/
containsWarningMessage(warningMessage) {
return this.warningMessages.has(warningMessage)
}

/** @returns {WarningMessage} */
getFirstWarningMessage() {
return this.warningMessages.values().next().value
}

/** @param {WarningMessage} warningMessage */
addWarningMessage(warningMessage) {
this.warningMessages.add(warningMessage)
this.hasWarning = true
}

/** @param {WarningMessage} warningMessage */
removeWarningMessage(warningMessage) {
// We need to find the error message that equals to remove it
for (let msg of this.warningMessages) {
if (msg.isEquals(warningMessage)) {
this.warningMessages.delete(msg)
break
}
}
this.hasWarning = !!this.warningMessages.size
}

clearWarningMessages() {
this.warningMessages.clear()
this.hasWarning = false
}

setCustomAttributes(customAttributes) {
if (customAttributes !== null) {
if (typeof customAttributes !== 'object') {
Expand Down
2 changes: 0 additions & 2 deletions packages/mapviewer/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { registerProj4 } from '@geoadmin/coordinates'
import log from '@geoadmin/log'
import { register } from 'ol/proj/proj4'
import proj4 from 'proj4'
import tippy from 'tippy.js'
import { createApp } from 'vue'

import App from '@/App.vue'
Expand Down Expand Up @@ -55,7 +54,6 @@ log.debug('Config is', {
BREAKPOINT_TABLET,
})

tippy.setDefaultProps({ theme: 'light-border' })
setupChartJS()

registerProj4(proj4)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<script setup>
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { onMounted, useTemplateRef } from 'vue'
import { useI18n } from 'vue-i18n'
import { useStore } from 'vuex'

import { EditMode } from '@/store/modules/drawing.store'
import { useTippyTooltip } from '@/utils/composables/useTippyTooltip'
import GeoadminTooltip from '@/utils/components/GeoadminTooltip.vue'

const { t } = useI18n()

const dispatcher = { dispatcher: 'AddVertexButton.vue' }

Expand All @@ -24,12 +27,11 @@ const emit = defineEmits(['button-mounted'])

const store = useStore()

const buttonRef = useTemplateRef('buttonRef')
useTippyTooltip(buttonRef, tooltipText, { placement: 'left' })
const elementRef = useTemplateRef('elementRef')

onMounted(() => {
// Emit an event to notify the parent component that the button is mounted
emit('button-mounted', buttonRef.value)
emit('button-mounted', elementRef.value.tooltipElement)
})

function addVertex() {
Expand All @@ -42,13 +44,18 @@ function addVertex() {
</script>

<template>
<button
ref="buttonRef"
class="overlay-button d-print-none"
@click="addVertex"
<GeoadminTooltip
ref="elementRef"
:tooltip-content="t(tooltipText)"
placement="left"
>
<font-awesome-icon :icon="['fas', 'plus']" />
</button>
<button
class="overlay-button d-print-none"
@click="addVertex"
>
<font-awesome-icon :icon="['fas', 'plus']" />
</button>
</GeoadminTooltip>
</template>

<style lang="scss" scoped>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const updateButtonPositions = () => {
}

const onFirstButtonMounted = (buttonElement) => {
buttonElement.setAttribute('data-cy', 'extend-from-first-node-button')
firstButtonOverlay = new Overlay({
element: buttonElement,
positioning: 'center-center',
Expand All @@ -98,6 +99,7 @@ const onFirstButtonMounted = (buttonElement) => {
}

const onLastButtonMounted = (buttonElement) => {
buttonElement.setAttribute('data-cy', 'extend-from-last-node-button')
lastButtonOverlay = new Overlay({
element: buttonElement,
positioning: 'center-center',
Expand Down Expand Up @@ -126,12 +128,10 @@ onUnmounted(() => {
<template>
<AddVertexButton
:reverse="true"
data-cy="extend-from-first-node-button"
@button-mounted="onFirstButtonMounted"
/>
<AddVertexButton
:reverse="false"
data-cy="extend-from-last-node-button"
@button-mounted="onLastButtonMounted"
/>
</template>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup>
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import DOMPurify from 'dompurify'
import { computed, inject, onMounted, ref, useTemplateRef, watch } from 'vue'
import { computed, inject, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useStore } from 'vuex'

Expand All @@ -14,8 +14,8 @@ import ShareWarningPopup from '@/modules/drawing/components/ShareWarningPopup.vu
import { DrawingState } from '@/modules/drawing/lib/export-utils'
import useSaveKmlOnChange from '@/modules/drawing/useKmlDataManagement.composable'
import { EditMode } from '@/store/modules/drawing.store'
import GeoadminTooltip from '@/utils/components/GeoadminTooltip.vue'
import ModalWithBackdrop from '@/utils/components/ModalWithBackdrop.vue'
import { useTippyTooltip } from '@/utils/composables/useTippyTooltip'
import debounce from '@/utils/debounce'

const dispatcher = { dispatcher: 'DrawingToolbox.vue' }
Expand All @@ -27,14 +27,15 @@ const store = useStore()

const emits = defineEmits(['removeLastPoint', 'closeDrawing'])

const drawingNameContainer = useTemplateRef('drawingNameContainer')

const drawMenuOpen = ref(true)
const showClearConfirmationModal = ref(false)
const showShareModal = ref(false)
const showNotSharedDrawingWarningModal = ref(false)
const showNotSharedDrawingWarning = computed(() => store.getters.showNotSharedDrawingWarning)
const isClosingDrawing = ref(false)
const showNoActiveKmlWarning = computed(() => !activeKmlLayer.value)

const tooltipText = computed(() => t(!activeKmlLayer.value ? 'drawing_empty_cannot_edit_name' : ''))
const isDesktopMode = computed(() => store.getters.isDesktopMode)
const isPhoneMode = computed(() => store.getters.isPhoneMode)
const isDrawingEmpty = computed(() => store.getters.isDrawingEmpty)
Expand Down Expand Up @@ -111,24 +112,6 @@ function onCloseClearConfirmation(confirmed) {
}
}

const tooltipText = computed(() => (!activeKmlLayer.value ? 'drawing_empty_cannot_edit_name' : ''))

const { removeTippy: removeNoActiveKmlWarning } = useTippyTooltip(drawingNameContainer, tooltipText)

onMounted(() => {
// if there's already an active KML layer, we can remove the tippy (as it will be empty, see template below)
if (activeKmlLayer.value) {
removeNoActiveKmlWarning()
}
})

watch(activeKmlLayer, () => {
if (activeKmlLayer.value) {
// no need for the message telling the user the drawing is empty, and he can't edit the drawing name
removeNoActiveKmlWarning()
}
})

function closeDrawing() {
isClosingDrawing.value = true
if (showNotSharedDrawingWarning.value) {
Expand Down Expand Up @@ -180,27 +163,32 @@ const debounceSaveDrawingName = debounce(async (newName) => {
class="card text-center drawing-toolbox-content shadow-lg rounded-bottom rounded-top-0 rounded-start-0"
:class="{ 'rounded-bottom-0': isPhoneMode }"
>
<div
v-if="online"
ref="drawingNameContainer"
class="d-flex justify-content-center align-items-center gap-2 mt-3 mx-4"
<GeoadminTooltip
:tooltip-content="tooltipText"
placement="bottom"
:disabled="!showNoActiveKmlWarning"
>
<label
for="drawing-name"
class="text-nowrap"
<div
v-if="online"
class="d-flex justify-content-center align-items-center gap-2 mt-3 mx-4"
>
{{ t('file_name') }}
</label>
<input
id="drawing-name"
v-model="drawingName"
type="text"
class="form-control"
data-cy="drawing-toolbox-file-name-input"
:placeholder="`${t('draw_layer_label')}`"
:disabled="!activeKmlLayer"
/>
</div>
<label
for="drawing-name"
class="text-nowrap"
>
{{ t('file_name') }}
</label>
<input
id="drawing-name"
v-model="drawingName"
type="text"
class="form-control"
data-cy="drawing-toolbox-file-name-input"
:placeholder="`${t('draw_layer_label')}`"
:disabled="!activeKmlLayer"
/>
</div>
</GeoadminTooltip>

<div class="card-body position-relative container">
<div
Expand Down
9 changes: 5 additions & 4 deletions packages/mapviewer/src/modules/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
"feedback_unsupported_format": "Dieser Dateityp wird leider nicht unterstützt. Bitte verwenden Sie eine .pdf, .zip, .jpg, .jpeg, .kml, .kmz oder .gpx Datei.",
"field_required": "Dieses Feld ist erforderlich",
"file_imported_success": "Datei erfolgreich importiert",
"file_imported_partially_out_of_bounds": "Die importierte Datei '{filename}' befindet sich teilweise außerhalb der Schweizer Grenzen. Einige Funktionalitäten stehen möglicherweise nicht zur Verfügung.",
"file_is_not_kml": "Dieses File ist keine KML Datei. ",
"file_name": "Zeichnungsname",
"file_too_large": "Die Datei ist zu gross (maximal erlaubte Grösse: {maxFileSize}).",
Expand Down Expand Up @@ -629,10 +630,10 @@
"time_hide": "Deaktivieren der Anzeige von Daten-Zeitständen.",
"time_select_year": "Wählen Sie ein Jahr aus",
"time_show": "Aktivieren der Anzeige von Daten-Zeitständen.",
"time_slider_legend_tippy_full_data": "Vollständige Daten",
"time_slider_legend_tippy_intro": "Der Zeitschieber zeigt verschiedene Farben an, je nachdem, ob die Karten Daten für das ausgewählte Jahr enthalten oder nicht.",
"time_slider_legend_tippy_no_data": "Keine Daten",
"time_slider_legend_tippy_partial_data": "Teilweise Daten",
"time_slider_legend_tooltip_full_data": "Vollständige Daten",
"time_slider_legend_tooltip_intro": "Der Zeitschieber zeigt verschiedene Farben an, je nachdem, ob die Karten Daten für das ausgewählte Jahr enthalten oder nicht.",
"time_slider_legend_tooltip_no_data": "Keine Daten",
"time_slider_legend_tooltip_partial_data": "Teilweise Daten",
"time_slider_no_time_layer_active_url_warning": "Es ist nicht möglich, einen Zeitschieberegler hinzuzufügen, wenn keine aktiven Zeitkarten vorhanden sind",
"title": "Titel",
"tooltip": "Tooltip",
Expand Down
9 changes: 5 additions & 4 deletions packages/mapviewer/src/modules/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
"feedback_unsupported_format": "This file format is not supported. Thanks for using another format for you attachment.",
"field_required": "This field is required",
"file_imported_success": "File successfully imported",
"file_imported_partially_out_of_bounds": "The imported file '{filename}' is partially outside the swiss boundaries. Some functionalities might not be available.",
"file_is_not_kml": "The file is not a KML file.",
"file_name": "Drawing name",
"file_too_large": "The file is too large (max size allowed {maxFileSize}).",
Expand Down Expand Up @@ -629,10 +630,10 @@
"time_hide": "Disable representation of data time stamps.",
"time_select_year": "Select a year",
"time_show": "Enable representation of data time stamps.",
"time_slider_legend_tippy_full_data": "Complete data",
"time_slider_legend_tippy_intro": "The time slider displays different colors depending on whether the maps have data for the selected year or not.",
"time_slider_legend_tippy_no_data": "No data.",
"time_slider_legend_tippy_partial_data": "Partial data",
"time_slider_legend_tooltip_full_data": "Complete data",
"time_slider_legend_tooltip_intro": "The time slider displays different colors depending on whether the maps have data for the selected year or not.",
"time_slider_legend_tooltip_no_data": "No data.",
"time_slider_legend_tooltip_partial_data": "Partial data",
"time_slider_no_time_layer_active_url_warning": "It is not possible to add a time slider, when there is no active time map available",
"title": "Title",
"tooltip": "Tooltip",
Expand Down
Loading