Browse Source

Merge pull request #6890 from pranavxc/refactor/dayjs-config

refactor: Move dayjs global changes to plugin to avoid unnecessary code repetition
pull/6896/head
աӄա 1 year ago committed by GitHub
parent
commit
4acb5af651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      packages/nc-gui/components/cell/DatePicker.vue
  2. 5
      packages/nc-gui/components/cell/DateTimePicker.vue
  3. 7
      packages/nc-gui/plugins/a.dayjs.ts

5
packages/nc-gui/components/cell/DatePicker.vue

@ -1,6 +1,5 @@
<script setup lang="ts">
import dayjs from 'dayjs'
import updateLocale from 'dayjs/plugin/updateLocale'
import {
ActiveCellInj,
CellClickHookInj,
@ -24,10 +23,6 @@ interface Props {
const { modelValue, isPk } = defineProps<Props>()
const emit = defineEmits(['update:modelValue'])
dayjs.extend(updateLocale)
dayjs.updateLocale('en', {
weekStart: 1,
})
const { t } = useI18n()

5
packages/nc-gui/components/cell/DateTimePicker.vue

@ -1,7 +1,6 @@
<script setup lang="ts">
import dayjs from 'dayjs'
import { isSystemColumn } from 'nocodb-sdk'
import updateLocale from 'dayjs/plugin/updateLocale'
import {
ActiveCellInj,
CellClickHookInj,
@ -27,10 +26,6 @@ interface Props {
const { modelValue, isPk, isUpdatedFromCopyNPaste } = defineProps<Props>()
const emit = defineEmits(['update:modelValue'])
dayjs.extend(updateLocale)
dayjs.updateLocale('en', {
weekStart: 1,
})
const { isMssql, isXcdbBase } = useBase()

7
packages/nc-gui/plugins/a.dayjs.ts

@ -1,10 +1,11 @@
import { extend } from 'dayjs'
import dayjs, { extend } from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime.js'
import customParseFormat from 'dayjs/plugin/customParseFormat.js'
import duration from 'dayjs/plugin/duration.js'
import utc from 'dayjs/plugin/utc.js'
import weekday from 'dayjs/plugin/weekday.js'
import timezone from 'dayjs/plugin/timezone.js'
import updateLocale from 'dayjs/plugin/updateLocale'
import { defineNuxtPlugin } from '#imports'
export default defineNuxtPlugin(() => {
@ -14,4 +15,8 @@ export default defineNuxtPlugin(() => {
extend(duration)
extend(weekday)
extend(timezone)
extend(updateLocale)
dayjs.updateLocale('en', {
weekStart: 1,
})
})

Loading…
Cancel
Save