mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
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:
@@ -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,
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user