Browse Source

refactor(gui-v2): centeralise imports to #imports

pull/3087/head
Wing-Kam Wong 2 years ago
parent
commit
d869db13ad
  1. 4
      packages/nc-gui-v2/components/cell/Checkbox.vue
  2. 3
      packages/nc-gui-v2/components/cell/Currency.vue
  3. 2
      packages/nc-gui-v2/components/cell/DatePicker.vue
  4. 5
      packages/nc-gui-v2/components/cell/DateTimePicker.vue
  5. 3
      packages/nc-gui-v2/components/cell/Decimal.vue
  6. 15
      packages/nc-gui-v2/components/cell/Duration.vue
  7. 4
      packages/nc-gui-v2/components/cell/Email.vue
  8. 3
      packages/nc-gui-v2/components/cell/Float.vue
  9. 3
      packages/nc-gui-v2/components/cell/Integer.vue
  10. 3
      packages/nc-gui-v2/components/cell/Json.vue
  11. 5
      packages/nc-gui-v2/components/cell/MultiSelect.vue
  12. 4
      packages/nc-gui-v2/components/cell/Percent.vue
  13. 3
      packages/nc-gui-v2/components/cell/Rating.vue
  14. 5
      packages/nc-gui-v2/components/cell/SingleSelect.vue
  15. 3
      packages/nc-gui-v2/components/cell/Text.vue
  16. 3
      packages/nc-gui-v2/components/cell/TextArea.vue
  17. 4
      packages/nc-gui-v2/components/cell/TimePicker.vue
  18. 6
      packages/nc-gui-v2/components/cell/Url.vue
  19. 4
      packages/nc-gui-v2/components/cell/YearPicker.vue

4
packages/nc-gui-v2/components/cell/Checkbox.vue

@ -1,7 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { inject } from '#imports' import { ColumnInj, IsFormInj, getMdiIcon, inject } from '#imports'
import { ColumnInj, IsFormInj } from '~/context'
import { getMdiIcon } from '@/utils'
interface Props { interface Props {
modelValue?: boolean | undefined | number modelValue?: boolean | undefined | number

3
packages/nc-gui-v2/components/cell/Currency.vue

@ -1,7 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { VNodeRef } from '@vue/runtime-core' import type { VNodeRef } from '@vue/runtime-core'
import { computed, inject, ref, useVModel } from '#imports' import { ColumnInj, ReadonlyInj, computed, inject, useVModel } from '#imports'
import { ColumnInj, EditModeInj } from '~/context'
interface Props { interface Props {
modelValue: number | null modelValue: number | null

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

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { ColumnInj, ReadonlyInj } from '~/context' import { ColumnInj, ReadonlyInj } from '#imports'
interface Props { interface Props {
modelValue: string | null modelValue: string | null

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

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { ReadonlyInj } from '~/context' import { ReadonlyInj } from '#imports'
interface Props { interface Props {
modelValue: string | null modelValue: string | null
@ -64,11 +64,12 @@ watch(
:bordered="false" :bordered="false"
class="!w-full px-1" class="!w-full px-1"
format="YYYY-MM-DD HH:mm" format="YYYY-MM-DD HH:mm"
:placeholder="isDateInvalid ? 'Invalid date' : !readOnlyMode ? 'Select date and time' : ''" :placeholder="isDateInvalid ? 'Invalid date' : !editEnabled ? 'Select date and time' : ''"
:allow-clear="!editEnabled" :allow-clear="!editEnabled"
:input-read-only="true" :input-read-only="true"
:dropdown-class-name="randomClass" :dropdown-class-name="randomClass"
:open="editEnabled ? false : open" :open="editEnabled ? false : open"
:disabled="!editEnabled"
@click="open = !open" @click="open = !open"
@ok="open = !open" @ok="open = !open"
> >

3
packages/nc-gui-v2/components/cell/Decimal.vue

@ -1,7 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { VNodeRef } from '@vue/runtime-core' import type { VNodeRef } from '@vue/runtime-core'
import { inject, ref, useVModel } from '#imports' import { ReadonlyInj, inject, useVModel } from '#imports'
import {EditModeInj, ReadonlyInj} from '~/context'
interface Props { interface Props {
modelValue: number | null | string modelValue: number | null | string

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

@ -1,7 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, inject, ref } from '#imports' import {
import {ColumnInj, ReadonlyInj} from '~/context' ColumnInj,
import { convertDurationToSeconds, convertMS2Duration, durationOptions } from '~/utils' ReadonlyInj,
computed,
convertDurationToSeconds,
convertMS2Duration,
durationOptions,
inject,
ref,
} from '#imports'
interface Props { interface Props {
modelValue: number | string | null modelValue: number | string | null
@ -65,7 +72,7 @@ const submitDuration = () => {
<template> <template>
<div class="duration-cell-wrapper"> <div class="duration-cell-wrapper">
<input <input
v-if="editEnabled" v-if="editEnabled"
ref="durationInput" ref="durationInput"
v-model="localState" v-model="localState"
:placeholder="durationPlaceholder" :placeholder="durationPlaceholder"

4
packages/nc-gui-v2/components/cell/Email.vue

@ -1,8 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { VNodeRef } from '@vue/runtime-core' import type { VNodeRef } from '@vue/runtime-core'
import { computed, inject, ref, useVModel } from '#imports' import { ReadonlyInj, computed, inject, isEmail, useVModel } from '#imports'
import { isEmail } from '~/utils'
import { EditModeInj } from '~/context'
interface Props { interface Props {
modelValue: string | null modelValue: string | null

3
packages/nc-gui-v2/components/cell/Float.vue

@ -1,7 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { VNodeRef } from '@vue/runtime-core' import type { VNodeRef } from '@vue/runtime-core'
import { inject, ref, useVModel } from '#imports' import { ReadonlyInj, inject, useVModel } from '#imports'
import { EditModeInj } from '~/context'
interface Props { interface Props {
modelValue: number | null modelValue: number | null

3
packages/nc-gui-v2/components/cell/Integer.vue

@ -1,7 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { VNodeRef } from '@vue/runtime-core' import type { VNodeRef } from '@vue/runtime-core'
import { inject, ref, useVModel } from '#imports' import { ReadonlyInj, inject, useVModel } from '#imports'
import { EditModeInj } from '~/context'
interface Props { interface Props {
modelValue: number | null modelValue: number | null

3
packages/nc-gui-v2/components/cell/Json.vue

@ -1,8 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { Modal as AModal } from 'ant-design-vue' import { Modal as AModal } from 'ant-design-vue'
import Editor from '~/components/monaco/Editor.vue' import Editor from '~/components/monaco/Editor.vue'
import { computed, inject, ref, useVModel, watch } from '#imports' import { ReadonlyInj, computed, inject, ref, useVModel, watch } from '#imports'
import { EditModeInj } from '~/context'
interface Props { interface Props {
modelValue: string | Record<string, any> | undefined modelValue: string | Record<string, any> | undefined

5
packages/nc-gui-v2/components/cell/MultiSelect.vue

@ -1,8 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { Select as AntSelect } from 'ant-design-vue' import type { Select as AntSelect } from 'ant-design-vue'
import type { SelectOptionType } from 'nocodb-sdk' import type { SelectOptionType } from 'nocodb-sdk'
import { computed, inject } from '#imports' import { ActiveCellInj, ColumnInj, computed, inject } from '#imports'
import { ActiveCellInj, ColumnInj } from '~/context'
import MdiCloseCircle from '~icons/mdi/close-circle' import MdiCloseCircle from '~icons/mdi/close-circle'
interface Props { interface Props {
@ -20,7 +19,7 @@ const column = inject(ColumnInj)
// const isForm = inject<boolean>('isForm', false) // const isForm = inject<boolean>('isForm', false)
// FIXME: use editEnabled to control the UI permission // FIXME: use editEnabled to control the UI permission
const editEnabled = inject(ReadonlyInj) // const editEnabled = inject(ReadonlyInj)
const active = inject(ActiveCellInj, ref(false)) const active = inject(ActiveCellInj, ref(false))

4
packages/nc-gui-v2/components/cell/Percent.vue

@ -1,7 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, inject } from '#imports' import { ColumnInj, ReadonlyInj, computed, getPercentStep, inject, isValidPercent, renderPercent } from '#imports'
import { ColumnInj } from '~/context'
import { getPercentStep, isValidPercent, renderPercent } from '@/utils/percentUtils'
interface Props { interface Props {
modelValue: number | string | null modelValue: number | string | null

3
packages/nc-gui-v2/components/cell/Rating.vue

@ -1,6 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, inject } from '#imports' import { ColumnInj, ReadonlyInj, computed, inject } from '#imports'
import { ColumnInj } from '~/context'
interface Props { interface Props {
modelValue?: number | null modelValue?: number | null

5
packages/nc-gui-v2/components/cell/SingleSelect.vue

@ -1,8 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { Select as AntSelect } from 'ant-design-vue' import type { Select as AntSelect } from 'ant-design-vue'
import type { SelectOptionType } from 'nocodb-sdk' import type { SelectOptionType } from 'nocodb-sdk'
import { computed, inject } from '#imports' import { ActiveCellInj, ColumnInj, computed, inject } from '#imports'
import { ActiveCellInj, ColumnInj } from '~/context'
interface Props { interface Props {
modelValue: string | undefined modelValue: string | undefined
@ -17,7 +16,7 @@ const column = inject(ColumnInj)
// const isForm = inject<boolean>('isForm', false) // const isForm = inject<boolean>('isForm', false)
// FIXME: use editEnabled to control the UI permission // FIXME: use editEnabled to control the UI permission
const editEnabled = inject(ReadonlyInj) // const editEnabled = inject(ReadonlyInj)
const active = inject(ActiveCellInj, ref(false)) const active = inject(ActiveCellInj, ref(false))

3
packages/nc-gui-v2/components/cell/Text.vue

@ -1,7 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { VNodeRef } from '@vue/runtime-core' import type { VNodeRef } from '@vue/runtime-core'
import { inject, ref, useVModel } from '#imports' import { ReadonlyInj, inject } from '#imports'
import { EditModeInj } from '~/context'
interface Props { interface Props {
modelValue: string | null modelValue: string | null

3
packages/nc-gui-v2/components/cell/TextArea.vue

@ -1,7 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { VNodeRef } from '@vue/runtime-core' import type { VNodeRef } from '@vue/runtime-core'
import { computed, inject, ref } from '#imports' import { ReadonlyInj, computed, inject } from '#imports'
import { EditModeInj } from '~/context'
interface Props { interface Props {
modelValue: string | null modelValue: string | null

4
packages/nc-gui-v2/components/cell/TimePicker.vue

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { onClickOutside } from '@vueuse/core' import { onClickOutside } from '@vueuse/core'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { ReadonlyInj } from '~/context' import { ReadonlyInj } from '#imports'
interface Props { interface Props {
modelValue?: string | null modelValue?: string | null
@ -13,7 +13,7 @@ const emit = defineEmits(['update:modelValue'])
const { isMysql } = useProject() const { isMysql } = useProject()
const editEnabled = inject(EditModeInj) const editEnabled = inject(ReadonlyInj)
let isTimeInvalid = $ref(false) let isTimeInvalid = $ref(false)

6
packages/nc-gui-v2/components/cell/Url.vue

@ -1,8 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { VNodeRef } from '@vue/runtime-core' import type { VNodeRef } from '@vue/runtime-core'
import { computed, inject, ref } from '#imports' import { ColumnInj, ReadonlyInj, computed, inject, isValidURL } from '#imports'
import { ColumnInj, EditModeInj } from '~/context'
import { isValidURL } from '~/utils'
interface Props { interface Props {
modelValue: string | null modelValue: string | null
@ -14,7 +12,7 @@ const emit = defineEmits(['update:modelValue'])
const column = inject(ColumnInj)! const column = inject(ColumnInj)!
const editEnabled = inject(EditModeInj) const editEnabled = inject(ReadonlyInj)
const vModel = computed({ const vModel = computed({
get: () => value, get: () => value,

4
packages/nc-gui-v2/components/cell/YearPicker.vue

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { onClickOutside } from '@vueuse/core' import { onClickOutside } from '@vueuse/core'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { ReadonlyInj } from '~/context' import { ReadonlyInj } from '#imports'
interface Props { interface Props {
modelValue: number | string | null modelValue: number | string | null
@ -11,7 +11,7 @@ const { modelValue } = defineProps<Props>()
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const editEnabled = inject(EditModeInj) const editEnabled = inject(ReadonlyInj)
let isYearInvalid = $ref(false) let isYearInvalid = $ref(false)

Loading…
Cancel
Save