Browse Source

refactor(gui-v2): update injection key name

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2990/head
Pranav C 2 years ago
parent
commit
ad19f4deb0
  1. 6
      packages/nc-gui-v2/components/smartsheet/VirtualCell.vue
  2. 10
      packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue
  3. 4
      packages/nc-gui-v2/components/virtual-cell/Formula.vue
  4. 12
      packages/nc-gui-v2/components/virtual-cell/HasMany.vue
  5. 4
      packages/nc-gui-v2/components/virtual-cell/Lookup.vue
  6. 12
      packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue
  7. 4
      packages/nc-gui-v2/components/virtual-cell/Rollup.vue
  8. 1
      packages/nc-gui-v2/components/virtual-cell/components/ItemChip.vue
  9. 3
      packages/nc-gui-v2/components/virtual-cell/components/ListItems.vue
  10. 2
      packages/nc-gui-v2/context/index.ts

6
packages/nc-gui-v2/components/smartsheet/VirtualCell.vue

@ -2,7 +2,7 @@
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import { provide, toRef, useVirtualCell } from '#imports' import { provide, toRef, useVirtualCell } from '#imports'
import type { Row } from '~/composables' import type { Row } from '~/composables'
import { ActiveCellInj, ColumnInj, RowInj, ValueInj } from '~/context' import { ActiveCellInj, CellValueInj, ColumnInj, RowInj } from '~/context'
import { NavigateDir } from '~/lib' import { NavigateDir } from '~/lib'
interface Props { interface Props {
@ -19,10 +19,10 @@ const active = toRef(props, 'active', false)
const row = toRef(props, 'row') const row = toRef(props, 'row')
provide(ColumnInj, column) provide(ColumnInj, column)
provide(ValueInj, value) provide(CellValueInj, value)
provide(ActiveCellInj, active) provide(ActiveCellInj, active)
provide(RowInj, row) provide(RowInj, row)
provide(ValueInj, toRef(props, 'modelValue')) provide(CellValueInj, toRef(props, 'modelValue'))
const { isLookup, isBt, isRollup, isMm, isHm, isFormula, isCount } = useVirtualCell(column) const { isLookup, isBt, isRollup, isMm, isHm, isFormula, isCount } = useVirtualCell(column)
</script> </script>

10
packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue

@ -3,12 +3,12 @@ import type { ColumnType } from 'nocodb-sdk'
import ItemChip from './components/ItemChip.vue' import ItemChip from './components/ItemChip.vue'
import ListItems from './components/ListItems.vue' import ListItems from './components/ListItems.vue'
import { useProvideLTARStore } from '#imports' import { useProvideLTARStore } from '#imports'
import { ColumnInj, ReloadViewDataHookInj, RowInj, ValueInj } from '~/context' import { CellValueInj, ColumnInj, ReloadViewDataHookInj, RowInj } from '~/context'
import MdiExpandIcon from '~icons/mdi/arrow-expand' import MdiExpandIcon from '~icons/mdi/arrow-expand'
const column = inject(ColumnInj) const column = inject(ColumnInj)
const reloadTrigger = inject(ReloadViewDataHookInj) const reloadTrigger = inject(ReloadViewDataHookInj)
const value = inject(ValueInj) const cellValue = inject(CellValueInj)
const row = inject(RowInj) const row = inject(RowInj)
const active = false const active = false
const localState = null const localState = null
@ -25,13 +25,13 @@ await loadRelatedTableMeta()
<template> <template>
<div class="flex w-full chips-wrapper align-center" :class="{ active }"> <div class="flex w-full chips-wrapper align-center" :class="{ active }">
<div class="chips d-flex align-center flex-grow"> <div class="chips d-flex align-center flex-grow">
<template v-if="value || localState"> <template v-if="cellValue || localState">
<ItemChip :item="value" :value="value[relatedTablePrimaryValueProp]" @unlink="unlink(value || localState)" /> <ItemChip :item="cellValue" :value="cellValue[relatedTablePrimaryValueProp]" @unlink="unlink(cellValue || localState)" />
</template> </template>
</div> </div>
<div class="flex-1 flex justify-end gap-1"> <div class="flex-1 flex justify-end gap-1">
<MdiExpandIcon <MdiExpandIcon
class="text-sm nc-action-icon text-gray-500/50 hover:text-gray-500 select-none transform group-hover:(text-pink-500 scale-120)" class="text-sm nc-action-icon text-gray-500/50 hover:text-gray-500 select-none group-hover:(text-gray-500)"
@click="listItemsDlg = true" @click="listItemsDlg = true"
/> />
</div> </div>

4
packages/nc-gui-v2/components/virtual-cell/Formula.vue

@ -1,12 +1,12 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, useProject } from '#imports' import { computed, useProject } from '#imports'
import { ColumnInj, ValueInj } from '~/context' import { CellValueInj, ColumnInj } from '~/context'
import { handleTZ } from '~/utils/dateTimeUtils' import { handleTZ } from '~/utils/dateTimeUtils'
import { replaceUrlsWithLink } from '~/utils/urlUtils' import { replaceUrlsWithLink } from '~/utils/urlUtils'
const column = inject(ColumnInj) const column = inject(ColumnInj)
const value = inject(ValueInj) const value = inject(CellValueInj)
const { isPg } = useProject() const { isPg } = useProject()

12
packages/nc-gui-v2/components/virtual-cell/HasMany.vue

@ -3,13 +3,13 @@ import type { ColumnType } from 'nocodb-sdk'
import ItemChip from './components/ItemChip.vue' import ItemChip from './components/ItemChip.vue'
import ListChildItems from './components/ListChildItems.vue' import ListChildItems from './components/ListChildItems.vue'
import ListItems from './components/ListItems.vue' import ListItems from './components/ListItems.vue'
import { useProvideLTARStore } from '~/composables' import { useProvideLTARStore } from '#imports'
import { ColumnInj, ReloadViewDataHookInj, RowInj, ValueInj } from '~/context' import { CellValueInj, ColumnInj, ReloadViewDataHookInj, RowInj } from '~/context'
import MdiExpandIcon from '~icons/mdi/arrow-expand' import MdiExpandIcon from '~icons/mdi/arrow-expand'
import MdiPlusIcon from '~icons/mdi/plus' import MdiPlusIcon from '~icons/mdi/plus'
const column = inject(ColumnInj) const column = inject(ColumnInj)
const value = inject(ValueInj) const cellValue = inject(CellValueInj)
const row = inject(RowInj) const row = inject(RowInj)
const reloadTrigger = inject(ReloadViewDataHookInj) const reloadTrigger = inject(ReloadViewDataHookInj)
@ -27,9 +27,9 @@ await loadRelatedTableMeta()
<template> <template>
<div class="flex align-center gap-1 w-full min-full chips-wrapper"> <div class="flex align-center gap-1 w-full min-full chips-wrapper">
<div class="chips flex align-center img-container flex-grow hm-items flex-nowrap min-w-0 overflow-hidden"> <div class="chips flex align-center img-container flex-grow hm-items flex-nowrap min-w-0 overflow-hidden">
<template v-if="value"> <template v-if="cellValue">
<ItemChip v-for="(ch, i) in value" :key="i" :value="ch[relatedTablePrimaryValueProp]" @unlink="unlink(ch)" /> <ItemChip v-for="(ch, i) in cellValue" :key="i" :value="ch[relatedTablePrimaryValueProp]" @unlink="unlink(ch)" />
<span v-if="value?.length === 10" class="caption pointer ml-1 grey--text" @click="childListDlg = true">more... </span> <span v-if="cellValue?.length === 10" class="caption pointer ml-1 grey--text" @click="childListDlg = true">more... </span>
</template> </template>
</div> </div>
<div class="flex-grow flex justify-end gap-1"> <div class="flex-grow flex justify-end gap-1">

4
packages/nc-gui-v2/components/virtual-cell/Lookup.vue

@ -2,7 +2,7 @@
import type { ColumnType, LinkToAnotherRecordType, LookupType } from 'nocodb-sdk' import type { ColumnType, LinkToAnotherRecordType, LookupType } from 'nocodb-sdk'
import { RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk' import { RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk'
import { useColumn } from '~/composables' import { useColumn } from '~/composables'
import { ColumnInj, MetaInj, ReadonlyInj, ValueInj } from '~/context' import { CellValueInj, ColumnInj, MetaInj, ReadonlyInj } from '~/context'
const { metas, getMeta } = useMetas() const { metas, getMeta } = useMetas()
@ -10,7 +10,7 @@ provide(ReadonlyInj, true)
const column = inject(ColumnInj) as ColumnType & { colOptions: LookupType } const column = inject(ColumnInj) as ColumnType & { colOptions: LookupType }
const meta = inject(MetaInj) const meta = inject(MetaInj)
const value = inject(ValueInj) const value = inject(CellValueInj)
const arrValue = computed(() => (Array.isArray(value?.value) ? value?.value : [value?.value])) const arrValue = computed(() => (Array.isArray(value?.value) ? value?.value : [value?.value]))
const relationColumn = meta?.value.columns?.find((c) => c.id === column.colOptions.fk_relation_column_id) as ColumnType & { const relationColumn = meta?.value.columns?.find((c) => c.id === column.colOptions.fk_relation_column_id) as ColumnType & {

12
packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue

@ -3,14 +3,14 @@ import type { ColumnType } from 'nocodb-sdk'
import ItemChip from './components/ItemChip.vue' import ItemChip from './components/ItemChip.vue'
import ListChildItems from './components/ListChildItems.vue' import ListChildItems from './components/ListChildItems.vue'
import ListItems from './components/ListItems.vue' import ListItems from './components/ListItems.vue'
import { useProvideLTARStore } from '~/composables' import { useProvideLTARStore } from '#imports'
import { ColumnInj, ReloadViewDataHookInj, RowInj, ValueInj } from '~/context' import { CellValueInj, ColumnInj, ReloadViewDataHookInj, RowInj } from '~/context'
import MdiExpandIcon from '~icons/mdi/arrow-expand' import MdiExpandIcon from '~icons/mdi/arrow-expand'
import MdiPlusIcon from '~icons/mdi/plus' import MdiPlusIcon from '~icons/mdi/plus'
const column = inject(ColumnInj) const column = inject(ColumnInj)
const row = inject(RowInj) const row = inject(RowInj)
const value = inject(ValueInj) const cellValue = inject(CellValueInj)
const reloadTrigger = inject(ReloadViewDataHookInj) const reloadTrigger = inject(ReloadViewDataHookInj)
const listItemsDlg = ref(false) const listItemsDlg = ref(false)
@ -29,10 +29,10 @@ await loadRelatedTableMeta()
<div class="flex align-center gap-1 w-full h-full chips-wrapper"> <div class="flex align-center gap-1 w-full h-full chips-wrapper">
<!-- <template v-if="!isForm"> --> <!-- <template v-if="!isForm"> -->
<div class="chips flex align-center img-container flex-grow hm-items flex-nowrap min-w-0 overflow-hidden"> <div class="chips flex align-center img-container flex-grow hm-items flex-nowrap min-w-0 overflow-hidden">
<template v-if="value"> <template v-if="cellValue">
<ItemChip v-for="(ch, i) in value" :key="i" :value="ch[relatedTablePrimaryValueProp]" @unlink="unlink(ch)" /> <ItemChip v-for="(ch, i) in cellValue" :key="i" :value="ch[relatedTablePrimaryValueProp]" @unlink="unlink(ch)" />
<span v-if="value?.length === 10" class="caption pointer ml-1 grey--text" @click="childListDlg = true">more... </span> <span v-if="cellValue?.length === 10" class="caption pointer ml-1 grey--text" @click="childListDlg = true">more... </span>
</template> </template>
</div> </div>
<div class="flex-1 flex justify-end gap-1"> <div class="flex-1 flex justify-end gap-1">

4
packages/nc-gui-v2/components/virtual-cell/Rollup.vue

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ValueInj } from '~/context' import { CellValueInj } from '~/context'
const value = inject(ValueInj) const value = inject(CellValueInj)
</script> </script>
<template> <template>

1
packages/nc-gui-v2/components/virtual-cell/components/ItemChip.vue

@ -1,5 +1,4 @@
<script setup lang="ts"> <script setup lang="ts">
import { useLTARStoreOrThrow } from '~/composables'
import { ActiveCellInj, ReadonlyInj } from '~/context' import { ActiveCellInj, ReadonlyInj } from '~/context'
import MdiCloseThickIcon from '~icons/mdi/close-thick' import MdiCloseThickIcon from '~icons/mdi/close-thick'

3
packages/nc-gui-v2/components/virtual-cell/components/ListItems.vue

@ -1,6 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useVModel } from '#imports' import { useLTARStoreOrThrow, useVModel } from '#imports'
import { useLTARStoreOrThrow } from '~/composables'
import MdiReloadIcon from '~icons/mdi/reload' import MdiReloadIcon from '~icons/mdi/reload'
const props = defineProps<{ modelValue: boolean }>() const props = defineProps<{ modelValue: boolean }>()

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

@ -17,7 +17,7 @@ export const ChangePageInj: InjectionKey<ReturnType<typeof useViewData>['changeP
export const IsFormInj: InjectionKey<boolean> = Symbol('is-form-injection') export const IsFormInj: InjectionKey<boolean> = Symbol('is-form-injection')
export const IsGridInj: InjectionKey<boolean> = Symbol('is-grid-injection') export const IsGridInj: InjectionKey<boolean> = Symbol('is-grid-injection')
export const IsLockedInj: InjectionKey<boolean> = Symbol('is-locked-injection') export const IsLockedInj: InjectionKey<boolean> = Symbol('is-locked-injection')
export const ValueInj: InjectionKey<Ref<any>> = Symbol('value-injection') export const CellValueInj: InjectionKey<Ref<any>> = Symbol('cell-value-injection')
export const ActiveViewInj: InjectionKey<Ref<GridType | FormType | KanbanType | GalleryType>> = Symbol('active-view-injection') export const ActiveViewInj: InjectionKey<Ref<GridType | FormType | KanbanType | GalleryType>> = Symbol('active-view-injection')
export const ReadonlyInj: InjectionKey<any> = Symbol('readonly-injection') export const ReadonlyInj: InjectionKey<any> = Symbol('readonly-injection')
export const ReloadViewDataHookInj: InjectionKey<EventHook<void>> = Symbol('reload-view-data-injection') export const ReloadViewDataHookInj: InjectionKey<EventHook<void>> = Symbol('reload-view-data-injection')

Loading…
Cancel
Save