Browse Source

refactor(gui-v2): lint and other corrections

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3025/head
Pranav C 2 years ago
parent
commit
8c883fe1e1
  1. 2
      packages/nc-gui-v2/components/smartsheet/Grid.vue
  2. 13
      packages/nc-gui-v2/components/smartsheet/Row.vue
  3. 10
      packages/nc-gui-v2/components/smartsheet/expanded-form/Header.vue
  4. 11
      packages/nc-gui-v2/components/smartsheet/expanded-form/index.vue

2
packages/nc-gui-v2/components/smartsheet/Grid.vue

@ -349,7 +349,7 @@ const expandForm = (row: Row, state: Record<string, any>) => {
<span class="flex-1" />
<span
v-if="row.rowMeta?.commentCount"
class="py-1 px-3 rounded-full text-[11px]"
class="py-1 px-3 rounded-full text-xs"
:style="{ backgroundColor: enumColor.light[row.rowMeta.commentCount % enumColor.light.length] }"
@click="expandForm(row, state)"
>{{ row.rowMeta.commentCount }}</span

13
packages/nc-gui-v2/components/smartsheet/Row.vue

@ -1,25 +1,24 @@
<script lang="ts" setup>
import type { Row } from '~/composables'
import { useSmartsheetStoreOrThrow } from '~/composables'
import { useProvideSmartsheetRowStore } from '~/composables/useSmartsheetRowStore'
import { useProvideSmartsheetRowStore, useSmartsheetStoreOrThrow } from '#imports'
interface Props {
row: Row
}
const props = defineProps<Props>()
const row = toRef(props, 'row')
const currentRow = toRef(props, 'row')
const { meta } = useSmartsheetStoreOrThrow()
const { isNew, state, syncLTARRefs } = useProvideSmartsheetRowStore(meta, row)
const { isNew, state, syncLTARRefs } = useProvideSmartsheetRowStore(meta, currentRow)
// on changing isNew(new record insert) status sync LTAR cell values
watch(isNew, async (nextVal, prevVal) => {
if (prevVal && !nextVal) {
await syncLTARRefs(row.value.row)
await syncLTARRefs(currentRow.value.row)
// update row values without invoking api
row.value.row = { ...row.value.row, ...state.value }
row.value.oldRow = { ...row.value.row, ...state.value }
currentRow.value.row = { ...currentRow.value.row, ...state.value }
currentRow.value.oldRow = { ...currentRow.value.row, ...state.value }
}
})
</script>

10
packages/nc-gui-v2/components/smartsheet/expanded-form/Header.vue

@ -1,7 +1,11 @@
<script lang="ts" setup>
import { computed, useSmartsheetStoreOrThrow, useUIPermission } from '#imports'
import { useSmartsheetRowStoreOrThrow } from '~/composables/useSmartsheetRowStore'
import { useExpandedFormStoreOrThrow } from '~/composables/useExpandedFormStore'
import {
computed,
useExpandedFormStoreOrThrow,
useSmartsheetRowStoreOrThrow,
useSmartsheetStoreOrThrow,
useUIPermission,
} from '#imports'
import MdiDoorOpen from '~icons/mdi/door-open'
import MdiDoorClosed from '~icons/mdi/door-closed'

11
packages/nc-gui-v2/components/smartsheet/expanded-form/index.vue

@ -1,16 +1,14 @@
<script setup lang="ts">
import { computedInject } from '@vueuse/core'
import type { ColumnType, TableType } from 'nocodb-sdk'
import { isVirtualCol } from 'nocodb-sdk'
import { useVModel } from '@vueuse/core'
import { computed, provide, toRef, watch } from 'vue'
import Comments from './Comments.vue'
import Header from './Header.vue'
import { provide, toRef, useProvideExpandedFormStore, useProvideSmartsheetStore, useVModel, watch } from '#imports'
import { NOCO } from '~/lib'
import { extractPkFromRow } from '~/utils'
import { useNuxtApp } from '#app'
import { useProvideSmartsheetStore } from '~/composables'
import type { Row } from '~/composables'
import { useProvideExpandedFormStore } from '~/composables/useExpandedFormStore'
import { FieldsInj, IsFormInj, MetaInj } from '~/context'
interface Props {
@ -25,16 +23,15 @@ interface Props {
const props = defineProps<Props>()
const emits = defineEmits(['update:modelValue'])
const _fields = inject(FieldsInj, ref([]))
const row = toRef(props, 'row')
const state = toRef(props, 'state')
const meta = toRef(props, 'meta')
const fields = computed(() => {
const _fields = computedInject(FieldsInj, (_fields) => {
if (props.useMetaFields) {
return meta.value.columns ?? []
}
return _fields.value
return _fields?.value ?? []
})
provide(MetaInj, meta)

Loading…
Cancel
Save