Browse Source

refactor(gui-v2): use same array definition syntax

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2716/head
Pranav C 2 years ago
parent
commit
63064bb699
  1. 2
      packages/nc-gui-v2/composables/useProject.ts
  2. 2
      packages/nc-gui-v2/composables/useTabs.ts
  3. 6
      packages/nc-gui-v2/composables/useViewData.ts
  4. 4
      packages/nc-gui-v2/composables/useViews.ts

2
packages/nc-gui-v2/composables/useProject.ts

@ -5,7 +5,7 @@ export default () => {
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const project = useState<ProjectType>('project') const project = useState<ProjectType>('project')
const tables = useState<Array<TableType>>('tables') const tables = useState<TableType[]>('tables')
const loadTables = async () => { const loadTables = async () => {
if (project.value.id) { if (project.value.id) {

2
packages/nc-gui-v2/composables/useTabs.ts

@ -7,7 +7,7 @@ export interface TabItem {
} }
export default () => { export default () => {
const tabs = useState<Array<TabItem>>('tabs', () => []) const tabs = useState<TabItem[]>('tabs', () => [])
const activeTab = useState<number>('activeTab', () => 0) const activeTab = useState<number>('activeTab', () => 0)
const addTab = (tabMeta: TabItem) => { const addTab = (tabMeta: TabItem) => {

6
packages/nc-gui-v2/composables/useViewData.ts

@ -4,7 +4,7 @@ import { useNuxtApp } from '#app'
import useProject from '~/composables/useProject' import useProject from '~/composables/useProject'
import { NOCO } from '~/lib/constants' import { NOCO } from '~/lib/constants'
const formatData = (list: Array<Record<string, any>>) => const formatData = (list: Record<string, any>[]) =>
list.map((row) => ({ list.map((row) => ({
row: { ...row }, row: { ...row },
oldRow: { ...row }, oldRow: { ...row },
@ -15,8 +15,8 @@ export default (
meta: Ref<TableType> | ComputedRef<TableType> | undefined, meta: Ref<TableType> | ComputedRef<TableType> | undefined,
viewMeta: Ref<TableType> | ComputedRef<TableType> | undefined, viewMeta: Ref<TableType> | ComputedRef<TableType> | undefined,
) => { ) => {
const data = ref<Array<Record<string, any>>>() const data = ref<Record<string, any>[]>()
const formattedData = ref<Array<{ row: Record<string, any>; oldRow: Record<string, any>; rowMeta?: any }>>() const formattedData = ref<{ row: Record<string, any>; oldRow: Record<string, any>; rowMeta?: any }[]>()
const paginationData = ref<PaginatedType>({ page: 1, pageSize: 25 }) const paginationData = ref<PaginatedType>({ page: 1, pageSize: 25 })
const { project } = useProject() const { project } = useProject()

4
packages/nc-gui-v2/composables/useViews.ts

@ -3,12 +3,12 @@ import type { Ref } from 'vue'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
export default function (meta: Ref<TableType>) { export default function (meta: Ref<TableType>) {
const views = ref<Array<GridType | FormType | KanbanType | GalleryType>>() const views = ref<(GridType | FormType | KanbanType | GalleryType)[]>()
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const loadViews = async () => { const loadViews = async () => {
if (meta.value?.id) if (meta.value?.id)
views.value = (await $api.dbView.list(meta.value?.id)).list as Array<GridType | FormType | KanbanType | GalleryType> views.value = (await $api.dbView.list(meta.value?.id)).list as (GridType | FormType | KanbanType | GalleryType)[]
} }
return { views, loadViews } return { views, loadViews }

Loading…
Cancel
Save