Browse Source

chore(gui): lint

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3569/head
Pranav C 2 years ago
parent
commit
48a1e36faf
  1. 3
      packages/nc-gui/components/smartsheet/Cell.vue
  2. 18
      packages/nc-gui/components/smartsheet/Grid.vue
  3. 2
      packages/nc-gui/components/smartsheet/Row.vue
  4. 2
      packages/nc-gui/components/smartsheet/expanded-form/index.vue
  5. 6
      packages/nc-gui/components/tabs/Smartsheet.vue
  6. 2
      packages/nc-gui/composables/useSmartsheetRowStore.ts
  7. 4
      packages/nc-gui/composables/useViewData.ts
  8. 6
      packages/nc-gui/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue

3
packages/nc-gui/components/smartsheet/Cell.vue

@ -15,9 +15,9 @@ import {
toRef, toRef,
useColumn, useColumn,
useDebounceFn, useDebounceFn,
useSmartsheetRowStoreOrThrow,
useVModel, useVModel,
} from '#imports' } from '#imports'
import { useSmartsheetRowStoreOrThrow } from '~/composables/useSmartsheetRowStore'
import { NavigateDir } from '~/lib' import { NavigateDir } from '~/lib'
interface Props { interface Props {
@ -65,7 +65,6 @@ const syncValue = useDebounceFn(function () {
emit('save') emit('save')
}, 1000) }, 1000)
const isAutoSaved = $computed(() => { const isAutoSaved = $computed(() => {
return [ return [
UITypes.SingleLineText, UITypes.SingleLineText,

18
packages/nc-gui/components/smartsheet/Grid.vue

@ -248,7 +248,8 @@ const onKeyDown = async (e: KeyboardEvent) => {
e.preventDefault() e.preventDefault()
if (selected.row < data.value.length - 1) selected.row++ if (selected.row < data.value.length - 1) selected.row++
break break
default: { default:
{
const rowObj = data.value[selected.row] const rowObj = data.value[selected.row]
const columnObj = fields.value[selected.col] const columnObj = fields.value[selected.col]
@ -326,16 +327,21 @@ const showContextMenu = (e: MouseEvent, target?: { row: number; col: number }) =
const rowRefs = $ref<any[]>() const rowRefs = $ref<any[]>()
/** save/update records before unmounting the component */
onBeforeUnmount(async () => { onBeforeUnmount(async () => {
console.log(rowRefs) console.log(rowRefs)
for (const [index, currentRow] of Object.entries(data.value)) { let index = -1
for (const currentRow of data.value) {
index++
/** if new record save row and save the LTAR cells */
if (currentRow.rowMeta.new) { if (currentRow.rowMeta.new) {
const syncLTARRefs = rowRefs[index]!.syncLTARRefs const syncLTARRefs = rowRefs[index]!.syncLTARRefs
const savedRow = await updateOrSaveRow(currentRow, null) const savedRow = await updateOrSaveRow(currentRow, '')
await syncLTARRefs(savedRow) await syncLTARRefs(savedRow)
currentRow.rowMeta.changed = false currentRow.rowMeta.changed = false
continue continue
} }
/** if existing row check updated cell and invoke update method */
if (currentRow.rowMeta.changed) { if (currentRow.rowMeta.changed) {
currentRow.rowMeta.changed = false currentRow.rowMeta.changed = false
for (const field of meta?.value.columns ?? []) { for (const field of meta?.value.columns ?? []) {
@ -347,7 +353,6 @@ onBeforeUnmount(async () => {
} }
} }
}) })
</script> </script>
<template> <template>
@ -423,7 +428,7 @@ onBeforeUnmount(async () => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<SmartsheetRow ref="rowRefs" v-for="(row, rowIndex) of data" :key="rowIndex" :row="row"> <SmartsheetRow v-for="(row, rowIndex) of data" ref="rowRefs" :key="rowIndex" :row="row">
<template #default="{ state }"> <template #default="{ state }">
<tr class="nc-grid-row"> <tr class="nc-grid-row">
<td key="row-index" class="caption nc-grid-cell pl-5 pr-1"> <td key="row-index" class="caption nc-grid-cell pl-5 pr-1">
@ -443,8 +448,7 @@ onBeforeUnmount(async () => {
<a-checkbox v-model:checked="row.rowMeta.selected" /> <a-checkbox v-model:checked="row.rowMeta.selected" />
</div> </div>
<span class="flex-1" /> <span class="flex-1" />
<div v-if="!readOnly && !isLocked" class="nc-expand" <div v-if="!readOnly && !isLocked" class="nc-expand" :class="{ 'nc-comment': row.rowMeta?.commentCount }">
:class="{ 'nc-comment': row.rowMeta?.commentCount }">
<span <span
v-if="row.rowMeta?.commentCount" v-if="row.rowMeta?.commentCount"
class="py-1 px-3 rounded-full text-xs cursor-pointer select-none transform hover:(scale-110)" class="py-1 px-3 rounded-full text-xs cursor-pointer select-none transform hover:(scale-110)"

2
packages/nc-gui/components/smartsheet/Row.vue

@ -35,7 +35,7 @@ reloadHook.on(() => {
provide(ReloadRowDataHookInj, reloadHook) provide(ReloadRowDataHookInj, reloadHook)
defineExpose({ defineExpose({
syncLTARRefs syncLTARRefs,
}) })
</script> </script>

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

@ -6,11 +6,11 @@ import Cell from '../Cell.vue'
import VirtualCell from '../VirtualCell.vue' import VirtualCell from '../VirtualCell.vue'
import Comments from './Comments.vue' import Comments from './Comments.vue'
import Header from './Header.vue' import Header from './Header.vue'
import { ReloadRowDataHookInj } from '~/context'
import { import {
FieldsInj, FieldsInj,
IsFormInj, IsFormInj,
MetaInj, MetaInj,
ReloadRowDataHookInj,
computedInject, computedInject,
provide, provide,
ref, ref,

6
packages/nc-gui/components/tabs/Smartsheet.vue

@ -21,7 +21,6 @@ import {
import type { TabItem } from '~/composables' import type { TabItem } from '~/composables'
const { activeTab } = defineProps<{ const { activeTab } = defineProps<{
activeTab: TabItem activeTab: TabItem
}>() }>()
@ -38,10 +37,7 @@ const fields = ref<ColumnType[]>([])
// TabMetaInj, // TabMetaInj,
// computed(() => ({} as TabItem)), // computed(() => ({} as TabItem)),
// ) // )
provide( provide(TabMetaInj, ref(activeTab))
TabMetaInj,
ref(activeTab),
)
const meta = computed<TableType>(() => metas.value?.[activeTab?.id as string]) const meta = computed<TableType>(() => metas.value?.[activeTab?.id as string])
const reloadEventHook = createEventHook<void>() const reloadEventHook = createEventHook<void>()

2
packages/nc-gui/composables/useSmartsheetRowStore.ts

@ -134,7 +134,7 @@ const [useProvideSmartsheetRowStore, useSmartsheetRowStore] = useInjectionState(
removeLTARRef, removeLTARRef,
syncLTARRefs, syncLTARRefs,
loadRow, loadRow,
currentRow currentRow,
} }
}, 'smartsheet-row-store') }, 'smartsheet-row-store')

4
packages/nc-gui/composables/useViewData.ts

@ -251,11 +251,11 @@ export function useViewData(
} }
} }
async function updateOrSaveRow(row: Row, property: string) { async function updateOrSaveRow(row: Row, property?: string) {
if (row.rowMeta.new) { if (row.rowMeta.new) {
return await insertRow(row.row, formattedData.value.indexOf(row)) return await insertRow(row.row, formattedData.value.indexOf(row))
} else { } else {
await updateRowProperty(row, property) await updateRowProperty(row, property!)
} }
} }

6
packages/nc-gui/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { TabItem } from '~/composables' import type { TabItem } from '~/composables'
import { TabMetaInj } from '~/context' import { TabMetaInj } from '#imports'
const { getMeta } = useMetas() const { getMeta } = useMetas()
const route = useRoute() const route = useRoute()
@ -20,7 +20,7 @@ getMeta(route.params.title as string, true).finally(() => {
<div v-if="loading" class="flex items-center justify-center h-full w-full"> <div v-if="loading" class="flex items-center justify-center h-full w-full">
<a-spin size="large" /> <a-spin size="large" />
</div> </div>
<TabsSmartsheet :active-tab="activeTab" :key="route.params.title" v-else /> <TabsSmartsheet v-else :key="route.params.title" :active-tab="activeTab" />
</template> </template>
<style scoped></style> <style scoped></style>

Loading…
Cancel
Save