Browse Source

Merge pull request #2975 from nocodb/feat/gui-v2-duration-options

feat(gui-v2): duration options
pull/2982/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
07fb5bff4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/nc-gui-v2/components/cell/Duration.vue
  2. 30
      packages/nc-gui-v2/components/smartsheet-column/DurationOptions.vue
  3. 1
      packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue
  4. 0
      packages/nc-gui-v2/utils/durationUtils.ts
  5. 2
      packages/nc-gui-v2/utils/index.ts

2
packages/nc-gui-v2/components/cell/Duration.vue

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, inject, ref } from '#imports' import { computed, inject, ref } from '#imports'
import { ColumnInj } from '~/context' import { ColumnInj } from '~/context'
import { convertDurationToSeconds, convertMS2Duration, durationOptions } from '~/utils/durationHelper' import { convertDurationToSeconds, convertMS2Duration, durationOptions } from '~/utils'
interface Props { interface Props {
modelValue: number | string modelValue: number | string

30
packages/nc-gui-v2/components/smartsheet-column/DurationOptions.vue

@ -0,0 +1,30 @@
<script setup lang="ts">
import { useColumnCreateStoreOrThrow } from '#imports'
import { durationOptions } from '@/utils'
const { formState, validateInfos, setAdditionalValidations, sqlUi, onDataTypeChange, onAlter } = useColumnCreateStoreOrThrow()
const durationOptionList =
durationOptions.map((o) => ({
...o,
// h:mm:ss (e.g. 3:45, 1:23:40)
title: `${o.title} ${o.example}`,
})) || []
</script>
<template>
<a-row>
<a-col :span="24">
<span class="prose-sm mt-2">A duration of time in minutes or seconds (e.g. 1:23).</span>
</a-col>
<a-col :span="24">
<a-form-item label="Duration Format">
<a-select v-model:value="formState.meta.duration" size="small" class="w-52">
<a-select-option v-for="(duration, i) of durationOptionList" :key="i" :value="duration.id">
{{ duration.title }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
</a-row>
</template>

1
packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue

@ -88,6 +88,7 @@ watchEffect(() => {
</a-form-item> </a-form-item>
<SmartsheetColumnCurrencyOptions v-if="formState.uidt === UITypes.Currency" /> <SmartsheetColumnCurrencyOptions v-if="formState.uidt === UITypes.Currency" />
<SmartsheetColumnDurationOptions v-if="formState.uidt === UITypes.Duration" />
<div> <div>
<div <div

0
packages/nc-gui-v2/utils/durationHelper.ts → packages/nc-gui-v2/utils/durationUtils.ts

2
packages/nc-gui-v2/utils/index.ts

@ -1,7 +1,7 @@
export * from './colorsUtils' export * from './colorsUtils'
export * from './dateTimeUtils' export * from './dateTimeUtils'
export * from './deepCompare' export * from './deepCompare'
export * from './durationHelper' export * from './durationUtils'
export * from './errorUtils' export * from './errorUtils'
export * from './fileUtils' export * from './fileUtils'
export * from './filterUtils' export * from './filterUtils'

Loading…
Cancel
Save