Browse Source

geodata: cell type WIP

pull/4140/head
flisowna 2 years ago
parent
commit
31d9197266
  1. 1
      packages/nc-gui/components.d.ts
  2. 46
      packages/nc-gui/components/cell/GeoData.vue
  3. 5
      packages/nc-gui/components/smartsheet/Cell.vue
  4. 3
      packages/nc-gui/components/smartsheet/header/CellIcon.vue
  5. 3
      packages/nc-gui/composables/useColumn.ts
  6. 1
      packages/nc-gui/lang/en.json
  7. 6
      packages/nc-gui/utils/columnUtils.ts
  8. 1
      packages/nocodb-sdk/src/lib/Api.ts
  9. 1
      packages/nocodb-sdk/src/lib/UITypes.ts
  10. 1
      packages/nocodb-sdk/src/lib/XcUIBuilder.ts
  11. 6
      packages/nocodb-sdk/src/lib/sqlUi/MssqlUi.ts
  12. 1
      scripts/sdk/swagger.json

1
packages/nc-gui/components.d.ts vendored

@ -27,6 +27,7 @@ declare module '@vue/runtime-core' {
AForm: typeof import('ant-design-vue/es')['Form']
AFormItem: typeof import('ant-design-vue/es')['FormItem']
AInput: typeof import('ant-design-vue/es')['Input']
AInputGroup: typeof import('ant-design-vue/es')['InputGroup']
AInputNumber: typeof import('ant-design-vue/es')['InputNumber']
AInputPassword: typeof import('ant-design-vue/es')['InputPassword']
AInputSearch: typeof import('ant-design-vue/es')['InputSearch']

46
packages/nc-gui/components/cell/GeoData.vue

@ -0,0 +1,46 @@
<script lang="ts" setup>
import type { VNodeRef } from '@vue/runtime-core'
import { EditModeInj, inject, useVModel } from '#imports'
interface Props {
modelValue?: number | null | string
}
interface Emits {
(event: 'update:modelValue', model: number): void
}
const props = defineProps<Props>()
const emits = defineEmits<Emits>()
const editEnabled = inject(EditModeInj)
const vModel = useVModel(props, 'modelValue', emits)
const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
</script>
<template>
<div>
TEST
<a-input-group v-if="editEnabled">
<a-input
:ref="focus"
v-model="vModel"
class="outline-none px-2 border-none w-full h-full text-sm"
type="number"
step="0.1"
@blur="editEnabled = false"
/>
<a-input />
</a-input-group>
<span v-else class="text-sm">{{ vModel }}</span>
</div>
</template>
<style scoped lang="scss">
input[type='number']:focus {
@apply ring-transparent;
}
</style>

5
packages/nc-gui/components/smartsheet/Cell.vue

@ -71,6 +71,7 @@ const {
isURL,
isEmail,
isJSON,
isGeoData,
isDate,
isYear,
isDateTime,
@ -130,6 +131,9 @@ const syncAndNavigate = (dir: NavigateDir, e: KeyboardEvent) => {
@keydown.shift.enter.exact="syncAndNavigate(NavigateDir.PREV, $event)"
>
<LazyCellTextArea v-if="isTextArea" v-model="vModel" />
<!-- TODO: review the hacky type checking here (we had to move geoData check at the beginning atm,
otherwise isString would kick in also for the current GeoData types, since it's abstractType is also a string) -->
<LazyCellGeoData v-else-if="isGeoData" v-model="vModel" />
<LazyCellCheckbox v-else-if="isBoolean" v-model="vModel" />
<LazyCellAttachment v-else-if="isAttachment" v-model="vModel" :row-index="props.rowIndex" />
<LazyCellSingleSelect v-else-if="isSingleSelect" v-model="vModel" />
@ -151,6 +155,7 @@ const syncAndNavigate = (dir: NavigateDir, e: KeyboardEvent) => {
<LazyCellText v-else-if="isString" v-model="vModel" />
<LazyCellJson v-else-if="isJSON" v-model="vModel" />
<LazyCellText v-else v-model="vModel" />
<div v-if="(isLocked || (isPublic && readOnly && !isForm)) && !isAttachment" class="nc-locked-overlay" @click.stop.prevent />
</div>
</template>

3
packages/nc-gui/components/smartsheet/header/CellIcon.vue

@ -24,6 +24,7 @@ import PercentIcon from '~icons/mdi/percent-outline'
import DecimalIcon from '~icons/mdi/decimal'
import SpecificDBTypeIcon from '~icons/mdi/database-settings'
import DurationIcon from '~icons/mdi/timer-outline'
import GeoDataIcon from '~icons/mdi/map-marker'
const props = defineProps<{ columnMeta?: ColumnType }>()
@ -38,6 +39,8 @@ const icon = computed(() => {
return KeyIcon
} else if (additionalColMeta.isJSON.value) {
return JSONIcon
} else if (additionalColMeta.isGeoData.value) {
return GeoDataIcon
} else if (additionalColMeta.isDate.value) {
return CalendarIcon
} else if (additionalColMeta.isDateTime.value) {

3
packages/nc-gui/composables/useColumn.ts

@ -28,6 +28,7 @@ export function useColumn(column: Ref<ColumnType | undefined>) {
const isTime = computed(() => abstractType.value === 'time' || uiDatatype.value === UITypes.Time)
const isDateTime = computed(() => abstractType.value === 'datetime' || uiDatatype.value === UITypes.DateTime)
const isJSON = computed(() => uiDatatype.value === UITypes.JSON)
const isGeoData = computed(() => uiDatatype.value === UITypes.GeoData)
const isEnum = computed(() => uiDatatype.value === UITypes.SingleSelect)
const isSingleSelect = computed(() => uiDatatype.value === UITypes.SingleSelect)
const isSet = computed(() => uiDatatype.value === UITypes.MultiSelect)
@ -56,6 +57,7 @@ export function useColumn(column: Ref<ColumnType | undefined>) {
UITypes.AutoNumber,
UITypes.SpecificDBType,
UITypes.Geometry,
UITypes.GeoData,
UITypes.Duration,
].includes(uiDatatype.value),
)
@ -76,6 +78,7 @@ export function useColumn(column: Ref<ColumnType | undefined>) {
isTime,
isDateTime,
isJSON,
isGeoData,
isEnum,
isSet,
isURL,

1
packages/nc-gui/lang/en.json

@ -130,6 +130,7 @@
"Currency": "Currency",
"Percent": "Percent",
"Duration": "Duration",
"GeoData": "GeoData",
"Rating": "Rating",
"Formula": "Formula",
"Rollup": "Rollup",

6
packages/nc-gui/utils/columnUtils.ts

@ -7,6 +7,7 @@ import TextSubject from '~icons/mdi/text-subject'
import JSONIcon from '~icons/mdi/code-json'
import SpecificDBTypeIcon from '~icons/mdi/database-settings'
import Attachment from '~icons/mdi/attachment'
import Marker from '~icons/mdi/map-marker'
import CheckboxMarkedOutline from '~icons/mdi/checkbox-marked-outline'
import FormatListBulletedSquare from '~icons/mdi/format-list-bulleted-square'
import ArrowDownDropCircle from '~icons/mdi/arrow-down-drop-circle'
@ -138,6 +139,11 @@ const uiTypes = [
name: UITypes.Geometry,
icon: RulerSquareCompass,
},
{
name: UITypes.GeoData,
icon: Marker,
},
{
name: UITypes.JSON,
icon: JSONIcon,

1
packages/nocodb-sdk/src/lib/Api.ts

@ -595,6 +595,7 @@ export type ColumnReqType =
| 'Year'
| 'Time'
| 'PhoneNumber'
| 'GeoData'
| 'Email'
| 'URL'
| 'Number'

1
packages/nocodb-sdk/src/lib/UITypes.ts

@ -16,6 +16,7 @@ enum UITypes {
Year = 'Year',
Time = 'Time',
PhoneNumber = 'PhoneNumber',
GeoData = 'GeoData',
Email = 'Email',
URL = 'URL',
Number = 'Number',

1
packages/nocodb-sdk/src/lib/XcUIBuilder.ts

@ -22,6 +22,7 @@ enum XcType {
Year = 'Year',
Time = 'Time',
PhoneNumber = 'PhoneNumber',
GeoData = 'GeoData',
Email = 'Email',
URL = 'URL',
Number = 'Number',

6
packages/nocodb-sdk/src/lib/sqlUi/MssqlUi.ts

@ -1095,6 +1095,9 @@ export class MssqlUi {
case 'Collaborator':
colProp.dt = 'varchar';
break;
case 'GeoData':
colProp.dt = 'varchar';
break;
case 'Date':
colProp.dt = 'varchar';
@ -1249,6 +1252,9 @@ export class MssqlUi {
case 'Decimal':
return ['decimal', 'float'];
case 'GeoData':
return ['decimal', 'float'];
case 'Currency':
return [
'int',

1
scripts/sdk/swagger.json

@ -8726,6 +8726,7 @@
"Year",
"Time",
"PhoneNumber",
"GeoData",
"Email",
"URL",
"Number",

Loading…
Cancel
Save