Skip to content

Commit 967aa8b

Browse files
authored
Merge pull request #756 from geoadmin/develop
New Release v1.13.0 - #minor
2 parents 8c29798 + 1f2d687 commit 967aa8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2336
-402
lines changed

package-lock.json

+10-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@fortawesome/free-solid-svg-icons": "^6.5.1",
4040
"@fortawesome/vue-fontawesome": "^3.0.6",
4141
"@geoblocks/cesium-compass": "^0.5.0",
42-
"@geoblocks/mapfishprint": "^0.2.7",
42+
"@geoblocks/mapfishprint": "github:geoblocks/mapfishprint#4c47539f391af3c641f9455efe0d31ebdc145cfe",
4343
"@geoblocks/ol-maplibre-layer": "^0.1.3",
4444
"@ivanv/vue-collapse-transition": "^1.0.2",
4545
"@mapbox/togeojson": "^0.16.2",

src/api/layers/layers.api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ const generateClassForLayerConfig = (layerConfig, id, allOtherLayers, lang) => {
195195
* @param {String} layerId The unique layer ID used in our backends
196196
* @returns {Promise<String>} HTML content of the layer's legend
197197
*/
198-
export const getLayerLegend = (lang, layerId) => {
198+
export const getLayerDescription = (lang, layerId) => {
199199
return new Promise((resolve, reject) => {
200200
axios
201201
.get(`${API_BASE_URL}rest/services/all/MapServer/${layerId}/legend?lang=${lang}`)

src/api/print.api.js

+36-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,31 @@ const PRINTING_DEFAULT_POLL_INTERVAL = 2000 // interval between each polling of
1616
const PRINTING_DEFAULT_POLL_TIMEOUT = 600000 // ms (10 minutes)
1717

1818
const SERVICE_PRINT_URL = `${API_SERVICES_BASE_URL}print3/print/default`
19+
20+
class GeoAdminCustomizer extends BaseCustomizer {
21+
/** @param {string[]} layerIDsToExclude List of layer names to exclude from the print */
22+
constructor(layerIDsToExclude) {
23+
super()
24+
this.layerIDsToExclude = layerIDsToExclude
25+
this.layerFilter = this.layerFilter.bind(this)
26+
}
27+
28+
/**
29+
* Filter out layers that should not be printed. This function is automatically called when the
30+
* encodeMap is called using this customizer.
31+
*
32+
* @param {State} layerState
33+
* @returns {boolean} True to convert this layer, false to skip it
34+
*/
35+
layerFilter(layerState) {
36+
if (this.layerIDsToExclude.includes(layerState.layer.get('id'))) {
37+
return false
38+
}
39+
// Call parent layerFilter method for other layers
40+
return super.layerFilter(layerState)
41+
}
42+
}
43+
1944
/**
2045
* Tool to transform an OpenLayers map into a "spec" for MapFishPrint3 (meaning a big JSON) that can
2146
* then be used as request body for printing.
@@ -169,6 +194,8 @@ export class PrintError extends Error {
169194
* Default is `false`
170195
* @param {CoordinateSystem} [config.projection=null] The projection used by the map, necessary when
171196
* the grid is to be printed (it can otherwise be null). Default is `null`
197+
* @param {String[]} [config.excludedLayerIDs=[]] List of the IDs of OpenLayers layer to exclude
198+
* from the print. Default is `[]`
172199
*/
173200
async function transformOlMapToPrintParams(olMap, config) {
174201
const {
@@ -181,6 +208,7 @@ async function transformOlMapToPrintParams(olMap, config) {
181208
lang = null,
182209
printGrid = false,
183210
projection = null,
211+
excludedLayerIDs = [],
184212
} = config
185213

186214
if (!qrCodeUrl) {
@@ -202,6 +230,8 @@ async function transformOlMapToPrintParams(olMap, config) {
202230
throw new PrintError('Missing projection to print the grid')
203231
}
204232

233+
const customizer = new GeoAdminCustomizer(excludedLayerIDs)
234+
205235
const attributionsOneLine = attributions.length > 0 ? ${attributions.join(', ')}` : ''
206236

207237
try {
@@ -210,7 +240,7 @@ async function transformOlMapToPrintParams(olMap, config) {
210240
scale,
211241
printResolution: PRINTING_RESOLUTION,
212242
dpi: PRINTING_RESOLUTION,
213-
customizer: new BaseCustomizer([0, 0, 10000, 10000]),
243+
customizer: customizer,
214244
})
215245
if (printGrid) {
216246
encodedMap.layers.unshift({
@@ -239,7 +269,7 @@ async function transformOlMapToPrintParams(olMap, config) {
239269
layout: layout.name,
240270
}
241271
if (layersWithLegends.length > 0) {
242-
spec.attributes.legends = {
272+
spec.attributes.legend = {
243273
name: i18n.global.t('legend'),
244274
classes: layersWithLegends.map((layer) => {
245275
return {
@@ -277,6 +307,8 @@ async function transformOlMapToPrintParams(olMap, config) {
277307
* Default is `false`
278308
* @param {CoordinateSystem} [config.projection=null] The projection used by the map, necessary when
279309
* the grid is to be printed (it can otherwise be null). Default is `null`
310+
* @param {String[]} [config.excludedLayerIDs=[]] List of IDs of OpenLayers layer to exclude from
311+
* the print. Default is `[]`
280312
* @returns {Promise<MFPReportResponse>} A job running on our printing backend (needs to be polled
281313
* using {@link waitForPrintJobCompletion} to wait until its completion)
282314
*/
@@ -291,6 +323,7 @@ export async function createPrintJob(map, config) {
291323
lang = null,
292324
printGrid = false,
293325
projection = null,
326+
excludedLayerIDs = [],
294327
} = config
295328
try {
296329
const printingSpec = await transformOlMapToPrintParams(map, {
@@ -303,6 +336,7 @@ export async function createPrintJob(map, config) {
303336
lang,
304337
printGrid,
305338
projection,
339+
excludedLayerIDs,
306340
})
307341
log.debug('Starting print for spec', printingSpec)
308342
return await requestReport(SERVICE_PRINT_URL, printingSpec)

src/api/topics.api.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import axios from 'axios'
22

33
import GeoAdminGroupOfLayers from '@/api/layers/GeoAdminGroupOfLayers.class'
4-
import { API_BASE_URL } from '@/config'
4+
import { API_BASE_URL, ENVIRONMENT } from '@/config'
55
import {
66
getBackgroundLayerFromLegacyUrlParams,
77
getLayersFromLegacyUrlParams,
@@ -51,7 +51,13 @@ const readTopicTreeRecursive = (node, availableLayers) => {
5151
try {
5252
children.push(readTopicTreeRecursive(topicChild, availableLayers))
5353
} catch (err) {
54-
log.error(`Child ${topicChild.id} can't be loaded`, err)
54+
if (ENVIRONMENT === 'development') {
55+
log.warn(
56+
`Child ${topicChild.id} can't be loaded, probably due to data integration work ongoing: ${err.message}`
57+
)
58+
} else {
59+
log.error(`Child ${topicChild.id} can't be loaded`, err)
60+
}
5561
}
5662
})
5763
return new GeoAdminGroupOfLayers({ id: `${node.id}`, name: node.label, layers: children })

src/modules/drawing/DrawingModule.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ function removeLastPointOnDeleteKeyUp(event) {
156156
}
157157
158158
async function closeDrawing() {
159-
store.dispatch('setShowLoadingBar', { loading: true, ...dispatcher })
159+
const requester = 'closing-drawing'
160+
store.dispatch('setLoadingBarRequester', { requester, ...dispatcher })
160161
161162
log.debug(
162163
`Closing drawing menu: isModified=${isDrawingModified.value}, isNew=${isNewDrawing.value}, isEmpty=${isDrawingEmpty.value}`
@@ -175,7 +176,7 @@ async function closeDrawing() {
175176
}
176177
177178
await store.dispatch('toggleDrawingOverlay', dispatcher)
178-
store.dispatch('setShowLoadingBar', { loading: false, ...dispatcher })
179+
store.dispatch('clearLoadingBarRequester', { requester, ...dispatcher })
179180
}
180181
</script>
181182

src/modules/infobox/components/styling/FeatureStyleEdit.vue

+3-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { computed, ref, toRefs, watch } from 'vue'
66
import { useStore } from 'vuex'
77
88
import EditableFeature, { EditableFeatureTypes } from '@/api/features/EditableFeature.class'
9-
import { IS_TESTING_WITH_CYPRESS } from '@/config'
109
import FeatureAreaInfo from '@/modules/infobox/components/FeatureAreaInfo.vue'
1110
import DrawingStyleColorSelector from '@/modules/infobox/components/styling/DrawingStyleColorSelector.vue'
1211
import DrawingStyleIconSelector from '@/modules/infobox/components/styling/DrawingStyleIconSelector.vue'
@@ -60,18 +59,11 @@ watch(description, () => {
6059
})
6160
6261
// Here we need to declare the debounce method globally otherwise it does not work (it is based
63-
// on closure which will not work if the debounce mehtod is defined in a watcher)
62+
// on closure which will not work if the debounce method is defined in a watcher)
6463
// The title debounce needs to be quick in order to be displayed on the map
65-
// NOTE: to avoid race condition on cypress between the update of a feature and the closing of
66-
// the drawing we need to speed up the debouncing, otherwise the dispatch changeFeatureTitle
67-
// will trigger a save kml when the features have been already removed from the KML drawing layer
68-
// resulting in an empty drawing.
69-
const debounceTitleUpdate = debounce(updateFeatureTitle, IS_TESTING_WITH_CYPRESS ? 1 : 100)
64+
const debounceTitleUpdate = debounce(updateFeatureTitle, 100)
7065
// The description don't need a quick debounce as it is not displayed on the map
71-
const debounceDescriptionUpdate = debounce(
72-
updateFeatureDescription,
73-
IS_TESTING_WITH_CYPRESS ? 1 : 300
74-
)
66+
const debounceDescriptionUpdate = debounce(updateFeatureDescription, 300)
7567
7668
function updateFeatureTitle() {
7769
store.dispatch('changeFeatureTitle', {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* The name of the OpenLayer layer that is used to render the print area.
3+
*
4+
* @type {String}
5+
*/
6+
export const PRINT_AREA_LAYER_ID = 'printAreaLayer'

src/modules/map/components/openlayers/utils/usePrint.composable.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { getGenerateQRCodeUrl } from '@/api/qrcode.api.js'
66
import { createShortLink } from '@/api/shortlink.api.js'
77
import log from '@/utils/logging'
88

9-
// const dispatcher = { dispatcher: 'usePrint.composable' }
9+
import { PRINT_AREA_LAYER_ID } from './printConstants'
10+
11+
const dispatcher = { dispatcher: 'usePrint.composable' }
1012

1113
/** @enum */
1214
export const PrintStatus = {
@@ -35,8 +37,9 @@ export function usePrint(map) {
3537
* @returns {Promise<String | null>}
3638
*/
3739
async function print(printGrid = false, printLegend = false) {
40+
const requester = 'print-map'
3841
try {
39-
// TODO PB-362 : show laoding bar
42+
store.dispatch('setLoadingBarRequester', { requester, ...dispatcher })
4043
if (currentJobReference.value) {
4144
await abortCurrentJob()
4245
}
@@ -59,7 +62,8 @@ export function usePrint(map) {
5962
: [],
6063
lang: store.state.i18n.lang,
6164
printGrid: printGrid,
62-
projection: store.state.map.projection,
65+
projection: store.state.position.projection,
66+
excludedLayerIDs: [PRINT_AREA_LAYER_ID],
6367
})
6468
currentJobReference.value = printJob.ref
6569
const result = await waitForPrintJobCompletion(printJob)
@@ -70,7 +74,7 @@ export function usePrint(map) {
7074
printStatus.value = PrintStatus.FINISHED_FAILED
7175
return null
7276
} finally {
73-
// TODO PB-362 : hide laoding bar
77+
store.dispatch('clearLoadingBarRequester', { requester, ...dispatcher })
7478
currentJobReference.value = null
7579
}
7680
}

src/modules/map/components/openlayers/utils/usePrintAreaRenderer.composable.js

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { Fill, Style } from 'ol/style'
77
import { computed, watch } from 'vue'
88
import { useStore } from 'vuex'
99

10+
import { PRINT_AREA_LAYER_ID } from './printConstants'
11+
1012
const dispatcher = { dispatcher: 'print-area-renderer.composable' }
1113

1214
function createWorldPolygon() {
@@ -36,6 +38,7 @@ function createWorldPolygon() {
3638
features: [worldPolygon],
3739
}),
3840
style: transparentStyle,
41+
id: PRINT_AREA_LAYER_ID,
3942
})
4043
return vectorLayer
4144
}

src/modules/menu/components/LayerCatalogueItem.vue

+10-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useStore } from 'vuex'
1414
1515
import AbstractLayer from '@/api/layers/AbstractLayer.class'
1616
import GeoAdminGroupOfLayers from '@/api/layers/GeoAdminGroupOfLayers.class'
17-
import LayerLegendPopup from '@/modules/menu/components/LayerLegendPopup.vue'
17+
import LayerDescriptionPopup from '@/modules/menu/components/LayerDescriptionPopup.vue'
1818
import TextSearchMarker from '@/utils/components/TextSearchMarker.vue'
1919
import TextTruncate from '@/utils/components/TextTruncate.vue'
2020
import { LV95 } from '@/utils/coordinates/coordinateSystems'
@@ -46,7 +46,7 @@ const { item, compact, depth, search } = toRefs(props)
4646
// Declaring own properties (ex-data)
4747
4848
const showChildren = ref(false)
49-
const showLayerLegend = ref(false)
49+
const showLayerDescription = ref(false)
5050
5151
// Mapping the store to the component
5252
const store = useStore()
@@ -67,7 +67,7 @@ const activeLayers = computed(() => store.state.layers.activeLayers)
6767
const openThemesIds = computed(() => store.state.topics.openedTreeThemesIds)
6868
6969
const hasChildren = computed(() => item.value?.layers?.length > 0)
70-
const hasLegend = computed(() => canBeAddedToTheMap.value && item.value?.hasDescription)
70+
const hasDescription = computed(() => canBeAddedToTheMap.value && item.value?.hasDescription)
7171
const isPhoneMode = computed(() => store.getters.isPhoneMode)
7272
7373
/**
@@ -272,11 +272,11 @@ function containsLayer(layers, searchText) {
272272
<FontAwesomeIcon icon="fa fa-search-plus" />
273273
</button>
274274
<button
275-
v-if="hasLegend"
275+
v-if="hasDescription"
276276
class="btn"
277277
:class="{ 'btn-lg': !compact }"
278278
:data-cy="`catalogue-tree-item-info-${item.id}`"
279-
@click.stop="showLayerLegend = true"
279+
@click.stop="showLayerDescription = true"
280280
>
281281
<FontAwesomeIcon icon="info-circle" />
282282
</button>
@@ -297,7 +297,11 @@ function containsLayer(layers, searchText) {
297297
/>
298298
</ul>
299299
</CollapseTransition>
300-
<LayerLegendPopup v-if="showLayerLegend" :layer="item" @close="showLayerLegend = false" />
300+
<LayerDescriptionPopup
301+
v-if="showLayerDescription"
302+
:layer="item"
303+
@close="showLayerDescription = false"
304+
/>
301305
</div>
302306
</template>
303307

0 commit comments

Comments
 (0)