Browse Source

refactor(gui-v2): move constants to a common place

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2716/head
Pranav C 2 years ago
parent
commit
24891ec0c0
  1. 3
      packages/nc-gui-v2/components/cell/Attachment.vue
  2. 5
      packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue
  3. 4
      packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue
  4. 6
      packages/nc-gui-v2/components/virtual-cell/HasMany.vue
  5. 6
      packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue
  6. 5
      packages/nc-gui-v2/components/virtual-cell/components/ListChildItems.vue
  7. 5
      packages/nc-gui-v2/components/virtual-cell/components/ListItems.vue
  8. 5
      packages/nc-gui-v2/composables/useViewData.ts
  9. 1
      packages/nc-gui-v2/lib/constants.ts

3
packages/nc-gui-v2/components/cell/Attachment.vue

@ -4,6 +4,7 @@ import { inject, ref, watchEffect } from '#imports'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
import { ColumnInj, MetaInj } from '~/components' import { ColumnInj, MetaInj } from '~/components'
import useProject from '~/composables/useProject' import useProject from '~/composables/useProject'
import { NOCO } from '~/lib/constants'
import { isImage } from '~/utils/fileUtils' import { isImage } from '~/utils/fileUtils'
import MaterialPlusIcon from '~icons/mdi/plus' import MaterialPlusIcon from '~icons/mdi/plus'
import MaterialArrowExpandIcon from '~icons/mdi/arrow-expand' import MaterialArrowExpandIcon from '~icons/mdi/arrow-expand'
@ -81,7 +82,7 @@ const onFileSelection = async (e) => {
try { try {
const data = await $api.storage.upload( const data = await $api.storage.upload(
{ {
path: ['noco', project.value.title, meta?.value?.title, column?.title].join('/'), path: [NOCO, project.value.title, meta?.value?.title, column?.title].join('/'),
}, },
{ {
files: file, files: file,

5
packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue

@ -1,6 +1,7 @@
<script> <script>
import FileSaver from 'file-saver' import FileSaver from 'file-saver'
import { ExportTypes } from 'nocodb-sdk' import { ExportTypes } from 'nocodb-sdk'
import { NOCO } from '~/lib/constants'
import DropOrSelectFileModal from '~/components/import/DropOrSelectFileModal' import DropOrSelectFileModal from '~/components/import/DropOrSelectFileModal'
import ColumnMappingModal from '~/components/project/spreadsheet/components/importExport/ColumnMappingModal' import ColumnMappingModal from '~/components/project/spreadsheet/components/importExport/ColumnMappingModal'
import CSVTemplateAdapter from '~/components/import/templateParsers/CSVTemplateAdapter' import CSVTemplateAdapter from '~/components/import/templateParsers/CSVTemplateAdapter'
@ -165,7 +166,7 @@ export default {
}) })
} else { } else {
res = await this.$api.dbViewRow.export( res = await this.$api.dbViewRow.export(
'noco', NOCO,
this.projectName, this.projectName,
this.meta.title, this.meta.title,
this.selectedView.title, this.selectedView.title,
@ -226,7 +227,7 @@ export default {
return res return res
}, {}), }, {}),
) )
await this.$api.dbTableRow.bulkCreate('noco', this.projectName, this.meta.title, batchData) await this.$api.dbTableRow.bulkCreate(NOCO, this.projectName, this.meta.title, batchData)
progress += batchData.length progress += batchData.length
this.$store.commit('loader/MutMessage', `Importing data : ${progress}/${data.length}`) this.$store.commit('loader/MutMessage', `Importing data : ${progress}/${data.length}`)
this.$store.commit('loader/MutProgress', Math.round((100 * progress) / data.length)) this.$store.commit('loader/MutProgress', Math.round((100 * progress) / data.length))

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

@ -212,7 +212,7 @@ export default {
// todo: audit // todo: audit
await this.$api.dbTableRow.nestedRemove( await this.$api.dbTableRow.nestedRemove(
'noco', NOCO,
this.projectName, this.projectName,
this.meta.title, this.meta.title,
id, id,
@ -286,7 +286,7 @@ export default {
this.newRecordModal = false this.newRecordModal = false
return return
} }
await this.$api.dbTableRow.nestedAdd('noco', this.projectName, this.meta.title, id, 'bt', this.column.title, pid) await this.$api.dbTableRow.nestedAdd(NOCO, this.projectName, this.meta.title, id, 'bt', this.column.title, pid)
this.pid = pid this.pid = pid

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

@ -252,7 +252,7 @@ export default {
.map((c) => child[c.title]) .map((c) => child[c.title])
.join('___') .join('___')
await this.$api.dbTableRow.nestedRemove( await this.$api.dbTableRow.nestedRemove(
'noco', NOCO,
this.projectName, this.projectName,
this.meta.title, this.meta.title,
this.parentId, this.parentId,
@ -296,7 +296,7 @@ export default {
.map((c) => child[c.title]) .map((c) => child[c.title])
.join('___') .join('___')
this.newRecordModal = false this.newRecordModal = false
await this.$api.dbTableRow.nestedAdd('noco', this.projectName, this.meta.title, this.parentId, 'hm', this.column.title, id) await this.$api.dbTableRow.nestedAdd(NOCO, this.projectName, this.meta.title, this.parentId, 'hm', this.column.title, id)
this.$emit('loadTableData') this.$emit('loadTableData')
if ((this.childListModal || this.isForm) && this.$refs.childList) { if ((this.childListModal || this.isForm) && this.$refs.childList) {
@ -360,7 +360,7 @@ export default {
.map((c) => child[c.title]) .map((c) => child[c.title])
.join('___') .join('___')
await this.$api.dbTableRow.nestedAdd('noco', this.projectName, this.meta.title, pid, 'hm', this.column.title, id) await this.$api.dbTableRow.nestedAdd(NOCO, this.projectName, this.meta.title, pid, 'hm', this.column.title, id)
} else { } else {
await this.addChildToParent(child) await this.addChildToParent(child)
} }

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

@ -234,7 +234,7 @@ export default {
.map((c) => this.row[c.title]) .map((c) => this.row[c.title])
.join('___') .join('___')
await this.$api.dbTableRow.nestedRemove('noco', this.projectName, this.meta.title, pid, 'mm', this.column.title, cid) await this.$api.dbTableRow.nestedRemove(NOCO, this.projectName, this.meta.title, pid, 'mm', this.column.title, cid)
this.$emit('loadTableData') this.$emit('loadTableData')
if ((this.childListModal || this.isForm) && this.$refs.childList) { if ((this.childListModal || this.isForm) && this.$refs.childList) {
@ -321,7 +321,7 @@ export default {
// const vcidCol = this.assocMeta.columns.find(c => c.id === this.column.colOptions.fk_mm_parent_column_id).title // const vcidCol = this.assocMeta.columns.find(c => c.id === this.column.colOptions.fk_mm_parent_column_id).title
// const vpidCol = this.assocMeta.columns.find(c => c.id === this.column.colOptions.fk_mm_child_column_id).title // const vpidCol = this.assocMeta.columns.find(c => c.id === this.column.colOptions.fk_mm_child_column_id).title
await this.$api.dbTableRow.nestedAdd('noco', this.projectName, this.meta.title, pid, 'mm', this.column.title, cid) await this.$api.dbTableRow.nestedAdd(NOCO, this.projectName, this.meta.title, pid, 'mm', this.column.title, cid)
try { try {
this.$emit('loadTableData') this.$emit('loadTableData')
@ -383,7 +383,7 @@ export default {
.map((c) => row[c.title]) .map((c) => row[c.title])
.join('___') .join('___')
await this.$api.dbTableRow.nestedAdd('noco', this.projectName, this.meta.title, pid, 'mm', this.column.title, cid) await this.$api.dbTableRow.nestedAdd(NOCO, this.projectName, this.meta.title, pid, 'mm', this.column.title, cid)
} else { } else {
await this.addChildToParent(child) await this.addChildToParent(child)
} }

5
packages/nc-gui-v2/components/virtual-cell/components/ListChildItems.vue

@ -1,5 +1,6 @@
<script> <script>
import { RelationTypes } from 'nocodb-sdk' import { RelationTypes } from 'nocodb-sdk'
import { NOCO } from '~/lib/constants'
import Pagination from '~/components/project/spreadsheet/components/Pagination' import Pagination from '~/components/project/spreadsheet/components/Pagination'
export default { export default {
@ -86,7 +87,7 @@ export default {
} }
if (this.column && this.column.colOptions) { if (this.column && this.column.colOptions) {
this.data = await this.$api.dbTableRow.nestedList( this.data = await this.$api.dbTableRow.nestedList(
'noco', NOCO,
this.projectName, this.projectName,
this.parentMeta.title, this.parentMeta.title,
this.rowId, this.rowId,
@ -98,7 +99,7 @@ export default {
}, },
) )
} else { } else {
this.data = await this.$api.dbTableRow.list('noco', this.projectName, this.meta.title, { this.data = await this.$api.dbTableRow.list(NOCO, this.projectName, this.meta.title, {
limit: this.size, limit: this.size,
offset: this.size * (this.page - 1), offset: this.size * (this.page - 1),
...this.queryParams, ...this.queryParams,

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

@ -1,5 +1,6 @@
<script> <script>
import Pagination from '~/components/project/spreadsheet/components/Pagination' import Pagination from '~/components/project/spreadsheet/components/Pagination'
import { NOCO } from '~/lib/constants'
export default { export default {
name: 'ListItems', name: 'ListItems',
@ -75,7 +76,7 @@ export default {
if (this.column && this.column.colOptions && this.rowId) { if (this.column && this.column.colOptions && this.rowId) {
this.data = await this.$api.dbTableRow.nestedChildrenExcludedList( this.data = await this.$api.dbTableRow.nestedChildrenExcludedList(
'noco', NOCO,
this.projectName, this.projectName,
this.parentMeta.title, this.parentMeta.title,
this.rowId, this.rowId,
@ -88,7 +89,7 @@ export default {
}, },
) )
} else { } else {
this.data = await this.$api.dbTableRow.list('noco', this.projectName, this.meta.title, { this.data = await this.$api.dbTableRow.list(NOCO, this.projectName, this.meta.title, {
limit: this.size, limit: this.size,
offset: this.size * (this.page - 1), offset: this.size * (this.page - 1),
...this.queryParams, ...this.queryParams,

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

@ -2,6 +2,7 @@ import type { Api, PaginatedType, TableType } from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue' import type { ComputedRef, Ref } from 'vue'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
import useProject from '~/composables/useProject' import useProject from '~/composables/useProject'
import { NOCO } from '~/lib/constants'
const formatData = (list: Array<Record<string, any>>) => const formatData = (list: Array<Record<string, any>>) =>
list.map((row) => ({ list.map((row) => ({
@ -36,7 +37,7 @@ export default (
.join('___') as string .join('___') as string
return $api.dbViewRow.update( return $api.dbViewRow.update(
'noco', NOCO,
project?.value.id as string, project?.value.id as string,
meta?.value.id as string, meta?.value.id as string,
viewMeta?.value?.id as string, viewMeta?.value?.id as string,
@ -77,7 +78,7 @@ export default (
}, {}) }, {})
const insertedData = await $api.dbViewRow.create( const insertedData = await $api.dbViewRow.create(
'noco', NOCO,
project?.value.id as string, project?.value.id as string,
meta?.value.id as string, meta?.value.id as string,
viewMeta?.value?.id as string, viewMeta?.value?.id as string,

1
packages/nc-gui-v2/lib/constants.ts

@ -0,0 +1 @@
export const NOCO = 'noco'
Loading…
Cancel
Save