Skip to content

Commit

Permalink
Merge pull request #1212 from geoadmin/develop
Browse files Browse the repository at this point in the history
New Release v1.51.1 - #patch
  • Loading branch information
pakb authored Jan 20, 2025
2 parents ce8e886 + 4a133e2 commit f20620d
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/api/print.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class GeoAdminCustomizer extends BaseCustomizer {
if (symbolizer.strokeWidth) {
symbolizer.strokeWidth = adjustWidth(symbolizer.strokeWidth, this.printResolution)
}
symbolizer.graphicXOffset = symbolizer.graphicXOffset ?? 0
symbolizer.graphicYOffset = symbolizer.graphicYOffset ?? 0
}

/**
Expand Down Expand Up @@ -134,7 +136,7 @@ class GeoAdminCustomizer extends BaseCustomizer {
)
: 0
// don't ask why it works, but that's the best I could do.
symbolizer.gaphicYOffset = Math.round(1000 * symbolizer.gaphicYOffset ?? 0) / 1000
symbolizer.graphicYOffset = Math.round(1000 * symbolizer.graphicYOffset ?? 0) / 1000
}
if (size) {
symbolizer.graphicWidth = adjustWidth(size[0] * scale, this.printResolution)
Expand Down
16 changes: 11 additions & 5 deletions src/api/profile/profile.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,27 +220,33 @@ export default async (profileCoordinates, projection) => {
}
let lastCoordinate = null
let lastDist = 0
// The segment is divided into chunks if the amount of coordinates in the segment is greater than MAX_CHUNK_LENGTH
const requestsForChunks = coordinateChunks.map((chunk) =>
getProfileDataForChunk(chunk, lastCoordinate, lastDist, projection)
)

const chunks = []
for (const chunkResponse of await Promise.allSettled(requestsForChunks)) {
if (chunkResponse.status === 'fulfilled') {
const segment = parseProfileFromBackendResponse(
const chunk = parseProfileFromBackendResponse(
chunkResponse.value,
lastDist,
projection
)
if (segment) {
const newSegmentLastPoint = segment.points.slice(-1)[0]
if (chunk) {
const newSegmentLastPoint = chunk.points.slice(-1)[0]
lastCoordinate = newSegmentLastPoint.coordinate
lastDist = newSegmentLastPoint.dist
segments.push(segment)
chunks.push(chunk)
}
} else {
log.error('Error while getting profile for chunk', chunkResponse.reason?.message)
}
}
// Here the chunks are merged into a single segment
const mergedChunks = new ElevationProfileSegment(
chunks.reduce((acc, segment) => acc.concat(segment.points), [])
)
segments.push(mergedChunks)
}
return new ElevationProfile(segments)
}
14 changes: 8 additions & 6 deletions src/modules/drawing/components/DrawingToolbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ const debounceSaveDrawingName = debounce(async (newName) => {
data-cy="drawing-toolbox-delete-button"
@click="showClearConfirmationModal = true"
>
{{ $t('delete') }}
{{ i18n.t('delete') }}
</button>
</div>
<div class="col d-grid">
Expand All @@ -255,7 +255,7 @@ const debounceSaveDrawingName = debounce(async (newName) => {
data-cy="drawing-toolbox-share-button"
@click="showShareModal = true"
>
{{ $t('share') }}
{{ i18n.t('share') }}
</button>
</div>
</div>
Expand Down Expand Up @@ -292,7 +292,9 @@ const debounceSaveDrawingName = debounce(async (newName) => {
@click="drawMenuOpen = !drawMenuOpen"
>
<FontAwesomeIcon :icon="drawMenuOpen ? 'caret-up' : 'caret-down'" />
<span class="ms-2">{{ $t(drawMenuOpen ? 'close_menu' : 'open_menu') }}</span>
<span class="ms-2">{{
i18n.t(drawMenuOpen ? 'close_menu' : 'open_menu')
}}</span>
</button>
</div>
</div>
Expand All @@ -302,20 +304,20 @@ const debounceSaveDrawingName = debounce(async (newName) => {
fluid
@close="onCloseClearConfirmation"
>
{{ $t('confirm_remove_all_features') }}
{{ i18n.t('confirm_remove_all_features') }}
</ModalWithBackdrop>
<ModalWithBackdrop
v-if="showShareModal"
fluid
:title="$t('share')"
:title="i18n.t('share')"
@close="showShareModal = false"
>
<SharePopup :kml-layer="activeKmlLayer" />
</ModalWithBackdrop>
<ModalWithBackdrop
v-if="showNotSharedDrawingWarningModal"
fluid
:title="$t('warning')"
:title="i18n.t('warning')"
@close="onCloseWarningModal()"
>
<ShareWarningPopup :kml-layer="activeKmlLayer" @accept="onAcceptWarningModal()" />
Expand Down
4 changes: 3 additions & 1 deletion src/modules/menu/components/help/ReportProblemButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ function selectItem(dropdownItem) {
</div>
<DropdownButton
label="feedback_description"
:title="feedback.category ?? 'select_category'"
:title="
feedback.category ? `feedback_category_${feedback.category}` : 'select_category'
"
:current-value="feedback.category"
:items="feedbackCategories"
data-cy="report-problem-category"
Expand Down
4 changes: 4 additions & 0 deletions src/modules/menu/components/print/MenuPrintSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ function close() {
async function printMap() {
try {
const documentUrl = await print(printGrid.value, printLegend.value)
// force hides the "drawing lost" warning when we open the print result
await store.dispatch('setIsOpeningNewTab', { isOpeningNewTab: true, ...dispatcher })
if (documentUrl) {
if (window.navigator.userAgent.indexOf('MSIE ') > -1) {
window.open(documentUrl)
Expand All @@ -115,6 +117,8 @@ async function printMap() {
}
} catch (error) {
log.error('Print failed', error)
} finally {
await store.dispatch('setIsOpeningNewTab', { isOpeningNewTab: false, ...dispatcher })
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/store/modules/ui.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ export default {
* @type Boolean
*/
showDragAndDropOverlay: false,

/**
* Flag set to true when the app is opening a new tab.
*
* This helps us decide to show or not show a warning popup for lost changes if the user
* closes the tab. In some cases, we are opening a new tab ourselves (print result) and
* don't want this popup to show up.
*
* @type Boolean
*/
isOpeningNewTab: false,
},
getters: {
showLoadingBar(state) {
Expand Down Expand Up @@ -451,6 +462,9 @@ export default {
setShowDragAndDropOverlay({ commit }, { showDragAndDropOverlay, dispatcher }) {
commit('setShowDragAndDropOverlay', { showDragAndDropOverlay, dispatcher })
},
setIsOpeningNewTab({ commit }, { isOpeningNewTab, dispatcher }) {
commit('setIsOpeningNewTab', { isOpeningNewTab, dispatcher })
},
},
mutations: {
setSize(state, { height, width }) {
Expand Down Expand Up @@ -520,5 +534,7 @@ export default {
removeWarning: (state, { warning }) => state.warnings.delete(warning),
setShowDragAndDropOverlay: (state, { showDragAndDropOverlay }) =>
(state.showDragAndDropOverlay = showDragAndDropOverlay),
setIsOpeningNewTab: (state, { isOpeningNewTab }) =>
(state.isOpeningNewTab = isOpeningNewTab),
},
}
8 changes: 6 additions & 2 deletions src/views/MapView.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup>
import { computed, defineAsyncComponent, onMounted, onUnmounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useStore } from 'vuex'
import { IS_TESTING_WITH_CYPRESS } from '@/config/staging.config'
Expand Down Expand Up @@ -27,13 +28,16 @@ import log from '@/utils/logging'
const DrawingModule = defineAsyncComponent(() => import('@/modules/drawing/DrawingModule.vue'))
const store = useStore()
const i18n = useI18n()
const showNotSharedDrawingWarningModal = ref(false)
const is3DActive = computed(() => store.state.cesium.active)
const isDrawingMode = computed(() => store.state.drawing.drawingOverlay.show)
const activeKmlLayer = computed(() => store.getters.activeKmlLayer)
const isPhoneMode = computed(() => store.state.ui.mode === UIModes.PHONE)
const showLoadingBar = computed(() => store.getters.showLoadingBar)
const showDragAndDropOverlay = computed(() => store.state.ui.showDragAndDropOverlay)
const isOpeningNewTab = computed(() => store.state.ui.isOpeningNewTab)
const showNotSharedDrawingWarning = computed(() => store.getters.showNotSharedDrawingWarning)
const loadDrawingModule = computed(() => {
return (
Expand All @@ -49,7 +53,7 @@ onMounted(() => {
})
const beforeUnloadHandler = (event) => {
if (showNotSharedDrawingWarning.value) {
if (showNotSharedDrawingWarning.value && !isOpeningNewTab.value) {
showNotSharedDrawingWarningModal.value = true
// This provokes the alert message to appear when trying to close the tab.
// During Cypress tests this causes the test to run indefinitely, so to prevent this we skip the alert.
Expand All @@ -71,7 +75,7 @@ onUnmounted(() => {
<ModalWithBackdrop
v-if="showNotSharedDrawingWarningModal"
fluid
:title="$t('warning')"
:title="i18n.t('warning')"
@close="showNotSharedDrawingWarningModal = false"
>
<ShareWarningPopup
Expand Down

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions tests/cypress/tests-e2e/importToolFile.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,56 @@ describe('The Import File Tool', () => {
cy.get('[data-cy="import-file-content"]').should('be.visible')
cy.get('[data-cy="import-file-online-content"]').should('be.visible')

// Import big KML file with chunks and verify profile that there are no segments
cy.log(
'Test import big KML file divided into multiple chunks by the API and verify profile'
)
const bigKmlFileName = 'big-external-kml-file.kml'
const bigKmlFileFixture = `import-tool/${bigKmlFileName}`

cy.readStoreValue('state.layers.activeLayers').should('be.empty')
cy.openMenuIfMobile()

cy.fixture(bigKmlFileFixture, null).as('kmlFixture')
cy.get('[data-cy="file-input"]').selectFile('@kmlFixture', {
force: true,
})
cy.get('[data-cy="import-file-local-btn"]:visible').click()
cy.get('[data-cy="import-file-load-button"]:visible').click()

const profileIntercept = '**/rest/services/profile.json**'
cy.intercept(profileIntercept, {
fixture: 'service-alti/profile.fixture.json',
}).as('profile')

cy.closeMenuIfMobile()

cy.get('[data-cy="window-close"]').click()
cy.get('[data-cy="ol-map"]').click(150, 400)

cy.get('[data-cy="show-profile"]').click()
Object.entries({
profile_elevation_difference: '0.00m',
profile_elevation_down: '0.20m',
profile_elevation_up: '0.20m',
profile_poi_down: "1'342m",
profile_poi_up: "1'342m",
profile_distance: '9.00m',
profile_slope_distance: '9.01m',
}).forEach(([key, value]) => {
cy.get(`[data-cy="profile-popup-info-${key}"]`).should('contain.text', value)
})
cy.get('[data-cy="profile-graph"]').trigger('mouseenter')
cy.get('[data-cy="profile-graph"]').trigger('mousemove', 'center')
cy.get('[data-cy="profile-popup-tooltip"] .distance').should('contain.text', '3 m')
cy.get('[data-cy="profile-popup-tooltip"] .elevation').should('contain.text', '1341.8 m')
cy.get('[data-cy="profile-segment-button-0"]').should('be.not.exist')
cy.get('[data-cy="infobox-close"]').click()
cy.openMenuIfMobile()
cy.get(`[data-cy^="button-remove-layer-${bigKmlFileName}-"]:visible`).click()
cy.get('[data-cy="menu-tray-tool-section"]:visible').click()
cy.get('[data-cy="menu-advanced-tools-import-file"]:visible').click()

//---------------------------------------------------------------------
// Test the import of an online KML file
cy.log('Test online import')
Expand Down
2 changes: 2 additions & 0 deletions tests/cypress/tests-e2e/reportProblem.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ describe('Testing the report problem form', () => {
openForm()
cy.get('@categoryDropdown').click()
cy.get('@categoryOther').click()
cy.get('@categoryDropdown').should('contain.text', 'Other')
cy.get('@textArea').type(text)
cy.get('@emailInput').type('this.is.not.a.valid@email')
cy.get('@submit').click()
Expand Down Expand Up @@ -143,6 +144,7 @@ describe('Testing the report problem form', () => {
})
cy.get('@categoryDropdown').click()
cy.get('[data-cy="dropdown-item-thematic_map"]:visible').click()
cy.get('@categoryDropdown').should('contain.text', 'A thematic map layer')
cy.get('@emailInput').type(validEmail)
cy.get('@textArea').type(text)
cy.get('@submit').scrollIntoView()
Expand Down

0 comments on commit f20620d

Please sign in to comment.