transaction edit dialog supports map

This commit is contained in:
MaysWind
2023-08-16 00:47:09 +08:00
parent 4224a833b4
commit c968ded99a
2 changed files with 59 additions and 7 deletions
+16 -5
View File
@@ -1,5 +1,5 @@
<template> <template>
<div ref="mapContainer" style="width: 100%" :style="{ 'height': mapHeight }"></div> <div ref="mapContainer" style="width: 100%" :class="mapClass" :style="finalMapStyle"></div>
<slot name="error-title" <slot name="error-title"
:mapSupported="mapSupported" :mapDependencyLoaded="mapDependencyLoaded" :mapSupported="mapSupported" :mapDependencyLoaded="mapDependencyLoaded"
v-if="!mapSupported || !mapDependencyLoaded"></slot> v-if="!mapSupported || !mapDependencyLoaded"></slot>
@@ -9,6 +9,9 @@
</template> </template>
<script> <script>
import {
copyObjectTo
} from '@/lib/common.js';
import { import {
createMapHolder, createMapHolder,
initMapInstance, initMapInstance,
@@ -20,6 +23,8 @@ import {
export default { export default {
props: [ props: [
'height', 'height',
'mapClass',
'mapStyle',
'geoLocation' 'geoLocation'
], ],
expose: [ expose: [
@@ -40,12 +45,18 @@ export default {
} }
}, },
computed: { computed: {
mapHeight() { finalMapStyle() {
if (this.mapSupported && this.mapDependencyLoaded) { const styles = copyObjectTo(this.mapStyle, {});
return this.height;
if (this.height) {
styles.height = this.height;
} }
return '0'; if (!this.mapSupported || !this.mapDependencyLoaded) {
styles.height = '0';
}
return styles;
} }
}, },
methods: { methods: {
@@ -42,7 +42,7 @@
<v-tab value="basicInfo"> <v-tab value="basicInfo">
<span>{{ $t('Basic Information') }}</span> <span>{{ $t('Basic Information') }}</span>
</v-tab> </v-tab>
<v-tab value="map" :disabled="!transaction.geoLocation"> <v-tab value="map" :disabled="!transaction.geoLocation" v-if="mapProvider">
<span>{{ $t('Location on Map') }}</span> <span>{{ $t('Location on Map') }}</span>
</v-tab> </v-tab>
</v-tabs> </v-tabs>
@@ -232,7 +232,17 @@
<v-window-item value="map"> <v-window-item value="map">
<v-row> <v-row>
<v-col cols="12" md="12"> <v-col cols="12" md="12">
<map-view ref="map" map-class="transaction-edit-map-view" :geo-location="transaction.geoLocation">
<template #error-title="{ mapSupported, mapDependencyLoaded }">
<span class="text-subtitle-1" v-if="!mapSupported"><b>{{ $t('Unsupported Map Provider') }}</b></span>
<span class="text-subtitle-1" v-else-if="!mapDependencyLoaded"><b>{{ $t('Cannot Initialize Map') }}</b></span>
</template>
<template #error-content>
<p class="text-body-1">
{{ $t('Please refresh the page and try again. If the error is still displayed, make sure that server map settings are set correctly.') }}
</p>
</template>
</map-view>
</v-col> </v-col>
</v-row> </v-row>
</v-window-item> </v-window-item>
@@ -442,6 +452,15 @@ export default {
} }
}, },
watch: { watch: {
'activeTab': function (newValue) {
if (newValue === 'map') {
this.$nextTick(() => {
if (this.$refs.map) {
this.$refs.map.init();
}
});
}
},
'transaction.sourceAmount': function (newValue, oldValue) { 'transaction.sourceAmount': function (newValue, oldValue) {
if (this.mode === 'view') { if (this.mode === 'view') {
return; return;
@@ -637,4 +656,26 @@ export default {
.transaction-edit-timezone.v-input input::placeholder { .transaction-edit-timezone.v-input input::placeholder {
color: rgba(var(--v-theme-on-background), var(--v-high-emphasis-opacity)) !important; color: rgba(var(--v-theme-on-background), var(--v-high-emphasis-opacity)) !important;
} }
.transaction-edit-map-view {
height: 220px;
}
@media (min-height: 630px) {
.transaction-edit-map-view {
height: 300px;
}
}
@media (min-height: 750px) {
.transaction-edit-map-view {
height: 400px;
}
}
@media (min-height: 900px) {
.transaction-edit-map-view {
height: 500px;
}
}
</style> </style>