Browse Source

refactor/gui v2 added Date column

pull/3011/head
Muhammed Mustafa 2 years ago
parent
commit
a4f380e187
  1. 25
      packages/nc-gui-v2/components/smartsheet-column/DateOptions.vue
  2. 1
      packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue
  3. 12
      packages/nc-gui-v2/utils/dateTimeUtils.ts

25
packages/nc-gui-v2/components/smartsheet-column/DateOptions.vue

@ -0,0 +1,25 @@
<script setup lang="ts">
import { useColumnCreateStoreOrThrow } from '#imports'
import { dateFormats } from '~/utils/dateTimeUtils'
const { formState } = $(useColumnCreateStoreOrThrow())
if (!formState.meta?.date_format) {
if (!formState.meta) formState.meta = {}
formState.meta.date_format = dateFormats[0]
}
</script>
<template>
<a-form-item label="Date Format">
<a-select v-model:value="formState.meta.date_format" size="small">
<a-select-option v-for="(format, i) of dateFormats" :key="i" :value="format">
<div class="flex flex-row items-center">
<div class="text-xs">
{{ format }}
</div>
</div>
</a-select-option>
</a-select>
</a-form-item>
</template>

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

@ -92,6 +92,7 @@ watchEffect(() => {
<SmartsheetColumnRatingOptions v-if="formState.uidt === UITypes.Rating" />
<SmartsheetColumnCheckboxOptions v-if="formState.uidt === UITypes.Checkbox" />
<SmartsheetColumnLookupOptions v-if="formState.uidt === UITypes.Lookup" />
<SmartsheetColumnDateOptions v-if="formState.uidt === UITypes.Date" />
<div>
<div

12
packages/nc-gui-v2/utils/dateTimeUtils.ts

@ -4,6 +4,18 @@ export const timeAgo = (date: any) => {
return dayjs.utc(date).fromNow()
}
export const dateFormats = [
'DD-MM-YYYY',
'MM-DD-YYYY',
'YYYY-MM-DD',
'DD/MM/YYYY',
'MM/DD/YYYY',
'YYYY/MM/DD',
'DD MM YYYY',
'MM DD YYYY',
'YYYY MM DD',
]
export const handleTZ = (val: any) => {
if (!val) {
return

Loading…
Cancel
Save