From ac6233c2cb208f1fe772362fdc90a99606747aa5 Mon Sep 17 00:00:00 2001 From: cnouguier Date: Fri, 19 Aug 2022 21:21:47 +0200 Subject: [PATCH] wip: Upgrade to Quasar 2 / Vue 3 #393 --- src/App.vue | 2 +- src/components/BillingSubscriptionChooser.vue | 2 +- src/components/CatalogActivity.vue | 59 ++++++++----- src/components/EventActivity.vue | 2 +- src/components/EventActivityPanel.vue | 4 +- src/components/EventCard.vue | 2 +- src/components/EventEditor.vue | 41 ++++----- src/components/EventTemplateEditor.vue | 26 +++--- .../EventTemplateWorkflowEditor.vue | 19 ++-- src/components/EventTemplateWorkflowForm.vue | 2 +- src/components/PlanEditor.vue | 7 +- src/components/PlanObjectivesEditor.vue | 88 +++++++++++-------- src/i18n/aktnmap_en.json | 2 +- src/i18n/aktnmap_fr.json | 2 +- 14 files changed, 147 insertions(+), 111 deletions(-) diff --git a/src/App.vue b/src/App.vue index 3a4172e3..227c1fdb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -88,7 +88,7 @@ export default { this.nbCompletedRequests++ this.stopProgress() // Forward to global error handler - this.$events.$emit('error', hook.error) + this.$events.emit('error', hook.error) }) this.$events.on('error', error => { // Translate the message if a translation key exists diff --git a/src/components/BillingSubscriptionChooser.vue b/src/components/BillingSubscriptionChooser.vue index ffc12b27..ef40ea71 100644 --- a/src/components/BillingSubscriptionChooser.vue +++ b/src/components/BillingSubscriptionChooser.vue @@ -6,7 +6,7 @@
{{$t('plans.' + plan + '_LABEL')}}
-
+
{{$t('plans.' + plan + '_PRICE')}}
diff --git a/src/components/CatalogActivity.vue b/src/components/CatalogActivity.vue index c44a5449..bc7e8399 100644 --- a/src/components/CatalogActivity.vue +++ b/src/components/CatalogActivity.vue @@ -2,27 +2,29 @@ @@ -52,18 +54,13 @@ export default { AlertForm: kCoreUtils.loadComponent('AlertForm') }, mixins: [ - activityMixin, - kMapMixins.activity, - kMapMixins.featureSelection, - kMapMixins.featureService, - kMapMixins.infobox, - kMapMixins.style, - kMapMixins.weacast, - kMapMixins.context, kMapMixins.map.baseMap, + kMapMixins.map.canvasLayers, kMapMixins.map.geojsonLayers, + kMapMixins.map.heatmapLayers, kMapMixins.map.forecastLayers, kMapMixins.map.fileLayers, + kMapMixins.map.georasterLayers, kMapMixins.map.editLayers, kMapMixins.map.style, kMapMixins.map.tooltip, @@ -73,6 +70,14 @@ export default { kMapMixins.map.tiledWindLayers, kMapMixins.map.mapillaryLayers, kMapMixins.map.gsmapLayers, + activityMixin, + kMapMixins.activity, + kMapMixins.featureSelection, + kMapMixins.featureService, + kMapMixins.infobox, + kMapMixins.style, + kMapMixins.weacast, + kMapMixins.context, mixins.alerts, mixins.plans ], @@ -119,6 +124,13 @@ export default { return date.toLocaleString(kCoreUtils.getLocale(), { year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' }) }, + async configureMap (container) { + // Avoid reentrance during awaited operations + if (!container || this.mapContainer) return + this.mapContainer = container + // Wait until map is ready + await this.initializeMap(container) + }, async configureActivity () { // Wait until map is ready await this.initializeMap() @@ -228,7 +240,7 @@ export default { this.refreshEventsLayer() // We do not manage pagination now if (this.events.items.length > MAX_ITEMS) { - this.$events.$emit('error', new Error(this.$t('errors.EVENTS_LIMIT'))) + this.$events.emit('error', new Error(this.$t('errors.EVENTS_LIMIT'))) } }, async refreshAlertsLayer () { @@ -257,7 +269,7 @@ export default { this.refreshAlertsLayer() // We do not manage pagination now if (this.alerts.items.length > MAX_ITEMS) { - this.$events.$emit('error', new Error(this.$t('errors.ALERTS_LIMIT'))) + this.$events.emit('error', new Error(this.$t('errors.ALERTS_LIMIT'))) } }, async refreshObjectivesLayer () { @@ -580,23 +592,22 @@ export default { /* TOOO this.alerts = this.configureCollection('alerts', () => ({ geoJson: true, $skip: 0, $limit: MAX_ITEMS }), () => ({}), { nbItemsPerPage: 0 }) - */ - this.alerts.$on('collection-refreshed', this.onAlertCollectionRefreshed) - /* TODO + + this.alerts.on('collection-refreshed', this.onAlertCollectionRefreshed) + this.events = this.configureCollection('events', () => Object.assign({ geoJson: true, $skip: 0, $limit: MAX_ITEMS, $select: ['_id', 'name', 'description', 'icon', 'location', 'createdAt', 'updatedAt', 'expireAt', 'deletedAt'] }, this.getPlanQuery()), () => this.getPlanObjectiveQuery(), { nbItemsPerPage: 0 }) - */ - this.events.$on('collection-refreshed', this.onEventCollectionRefreshed) + this.events.on('collection-refreshed', this.onEventCollectionRefreshed) */ this.$engineEvents.on('edit-start', this.onEditStartEvent) this.$engineEvents.on('edit-stop', this.onEditStopEvent) }, beforeUnmount () { - this.alerts.$off('collection-refreshed', this.onAlertCollectionRefreshed) - this.events.$off('collection-refreshed', this.onEventCollectionRefreshed) + //this.alerts.$off('collection-refreshed', this.onAlertCollectionRefreshed) + //this.events.off('collection-refreshed', this.onEventCollectionRefreshed) this.$engineEvents.off('edit-start', this.onEditStartEvent) this.$engineEvents.off('edit-stop', this.onEditStopEvent) } diff --git a/src/components/EventActivity.vue b/src/components/EventActivity.vue index bb6367e9..669a793a 100644 --- a/src/components/EventActivity.vue +++ b/src/components/EventActivity.vue @@ -291,7 +291,7 @@ export default { } // We do not manage pagination now if (this.items.length < this.nbTotalItems) { - this.$events.$emit('error', new Error(this.$t('errors.EVENT_LOG_LIMIT'))) + this.$events.emit('error', new Error(this.$t('errors.EVENT_LOG_LIMIT'))) } this.refreshParticipantsLayer() }, diff --git a/src/components/EventActivityPanel.vue b/src/components/EventActivityPanel.vue index 01c3c4f5..4a12a4d0 100644 --- a/src/components/EventActivityPanel.vue +++ b/src/components/EventActivityPanel.vue @@ -87,10 +87,10 @@ export default { return _.get(participant, 'icon.color', '') }, onZoomClicked (participant) { - this.$events.$emit('zoom-to-participant', participant) + this.$events.emit('zoom-to-participant', participant) }, onStateClicked (participant) { - this.$events.$emit('filter-participant-states', participant) + this.$events.emit('filter-participant-states', participant) } }, created () { diff --git a/src/components/EventCard.vue b/src/components/EventCard.vue index 7ca81c39..1455ce52 100644 --- a/src/components/EventCard.vue +++ b/src/components/EventCard.vue @@ -634,7 +634,7 @@ export default { this.coordinatorLabel = this.$t('EventCard.NO_PARTICPANTS_AWAITING_LABEL') } if (logs.data.length < logs.total) { - this.$events.$emit('error', new Error(this.$t('errors.EVENT_LOG_LIMIT'))) + this.$events.emit('error', new Error(this.$t('errors.EVENT_LOG_LIMIT'))) } } catch (_) { } diff --git a/src/components/EventEditor.vue b/src/components/EventEditor.vue index 797a66d8..b09f1412 100644 --- a/src/components/EventEditor.vue +++ b/src/components/EventEditor.vue @@ -1,20 +1,21 @@ @@ -70,19 +71,15 @@ export default { notify: undefined } }, - methods: { - getButtons () { - if (this.getEditorMode() === 'create') { - return [ - { id: 'close-button', label: 'CANCEL', renderer: 'form-button', outline: true, handler: () => this.closeModal() }, - { id: 'apply-button', label: this.applyButton, renderer: 'form-button', handler: () => this.apply() } - ] - } + computed: { + buttons () { return [ { id: 'close-button', label: 'CANCEL', renderer: 'form-button', outline: true, handler: () => this.closeModal() }, { id: 'apply-button', label: this.applyButton, renderer: 'form-button', handler: () => this.apply() } ] - }, + } + }, + methods: { async loadObject () { if (this.templateId) { if (!this.template) this.template = await this.$api.getService('event-templates').get(this.templateId) diff --git a/src/components/EventTemplateEditor.vue b/src/components/EventTemplateEditor.vue index 17b529d2..014a34c8 100644 --- a/src/components/EventTemplateEditor.vue +++ b/src/components/EventTemplateEditor.vue @@ -1,23 +1,28 @@