Remove seemingly redundant interface option

@Oreilles Seeing the geometry type is already configured in the schema configuration, this particular option on the interface feels redundant (?)
This commit is contained in:
rijkvanzanten
2021-10-25 13:10:25 -04:00
parent cc26b04974
commit e5e09a051e

View File

@@ -1,14 +1,5 @@
<template>
<div class="form-grid">
<div v-if="!nativeGeometryType && geometryFormat !== 'lnglat'" class="field half-left">
<div class="type-label">{{ t('interfaces.map.geometry_type') }}</div>
<v-select
v-model="geometryType"
:placeholder="t('any')"
:show-deselect="true"
:items="GEOMETRY_TYPES.map((value) => ({ value, text: value }))"
/>
</div>
<div class="field">
<div class="type-label">{{ t('interfaces.map.default_view') }}</div>
<div ref="mapContainer" class="map"></div>
@@ -18,10 +9,9 @@
<script lang="ts">
import { useI18n } from 'vue-i18n';
import { ref, defineComponent, PropType, watch, onMounted, onUnmounted, computed, toRefs } from 'vue';
import { ref, defineComponent, PropType, onMounted, onUnmounted, computed, toRefs } from 'vue';
import { GEOMETRY_TYPES } from '@directus/shared/constants';
import { Field, GeometryType, GeometryOptions } from '@directus/shared/types';
import { getGeometryFormatForType } from '@/utils/geometry';
import { GeometryOptions } from '@directus/shared/types';
import { getBasemapSources, getStyleFromBasemapSource } from '@/utils/geometry/basemap';
import 'maplibre-gl/dist/maplibre-gl.css';
import { Map, CameraOptions } from 'maplibre-gl';
@@ -30,40 +20,17 @@ import getSetting from '@/utils/get-setting';
export default defineComponent({
props: {
collection: {
type: String,
required: true,
},
fieldData: {
type: Object as PropType<Field>,
default: null,
},
value: {
type: Object as PropType<GeometryOptions & { defaultView?: CameraOptions }>,
default: null,
},
},
emits: ['input'],
setup(props, { emit }) {
setup(props) {
const { t } = useI18n();
const isGeometry = props.fieldData.type == 'geometry';
const nativeGeometryType = isGeometry ? (props.fieldData!.schema!.geometry_type as GeometryType) : undefined;
const geometryFormat = isGeometry ? ('native' as const) : getGeometryFormatForType(props.fieldData.type);
const geometryType = ref<GeometryType>(
geometryFormat.value == 'lnglat' ? 'Point' : nativeGeometryType ?? props.value?.geometryType
);
const defaultView = ref<CameraOptions | undefined>(props.value?.defaultView);
watch(
[geometryType, defaultView],
() => {
const type = geometryFormat == 'lnglat' ? 'Point' : geometryType;
emit('input', { defaultView, geometryFormat, geometryType: type });
},
{ immediate: true }
);
const mapContainer = ref<HTMLElement | null>(null);
let map: Map;
@@ -93,17 +60,14 @@ export default defineComponent({
};
});
});
onUnmounted(() => {
map.remove();
});
return {
t,
isGeometry,
nativeGeometryType,
geometryFormat,
GEOMETRY_TYPES,
geometryType,
mapContainer,
};
},