Browse Source

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

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2716/head
Pranav C 3 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 project = useState<ProjectType>('project')
const tables = useState<Array<TableType>>('tables')
const tables = useState<TableType[]>('tables')
const loadTables = async () => {
if (project.value.id) {

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

@ -7,7 +7,7 @@ export interface TabItem {
}
export default () => {
const tabs = useState<Array<TabItem>>('tabs', () => [])
const tabs = useState<TabItem[]>('tabs', () => [])
const activeTab = useState<number>('activeTab', () => 0)
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 { NOCO } from '~/lib/constants'
const formatData = (list: Array<Record<string, any>>) =>
const formatData = (list: Record<string, any>[]) =>
list.map((row) => ({
row: { ...row },
oldRow: { ...row },
@ -15,8 +15,8 @@ export default (
meta: Ref<TableType> | ComputedRef<TableType> | undefined,
viewMeta: Ref<TableType> | ComputedRef<TableType> | undefined,
) => {
const data = ref<Array<Record<string, any>>>()
const formattedData = ref<Array<{ row: Record<string, any>; oldRow: Record<string, any>; rowMeta?: any }>>()
const data = ref<Record<string, any>[]>()
const formattedData = ref<{ row: Record<string, any>; oldRow: Record<string, any>; rowMeta?: any }[]>()
const paginationData = ref<PaginatedType>({ page: 1, pageSize: 25 })
const { project } = useProject()

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

@ -3,12 +3,12 @@ import type { Ref } from 'vue'
import { useNuxtApp } from '#app'
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 loadViews = async () => {
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 }

Loading…
Cancel
Save