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 { ColumnInj, MetaInj } from '~/components'
import useProject from '~/composables/useProject'
import { NOCO } from '~/lib/constants'
import { isImage } from '~/utils/fileUtils'
import MaterialPlusIcon from '~icons/mdi/plus'
import MaterialArrowExpandIcon from '~icons/mdi/arrow-expand'
@ -81,7 +82,7 @@ const onFileSelection = async (e) => {
try {
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,

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

@ -1,6 +1,7 @@
<script>
import FileSaver from 'file-saver'
import { ExportTypes } from 'nocodb-sdk'
import { NOCO } from '~/lib/constants'
import DropOrSelectFileModal from '~/components/import/DropOrSelectFileModal'
import ColumnMappingModal from '~/components/project/spreadsheet/components/importExport/ColumnMappingModal'
import CSVTemplateAdapter from '~/components/import/templateParsers/CSVTemplateAdapter'
@ -165,7 +166,7 @@ export default {
})
} else {
res = await this.$api.dbViewRow.export(
'noco',
NOCO,
this.projectName,
this.meta.title,
this.selectedView.title,
@ -226,7 +227,7 @@ export default {
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
this.$store.commit('loader/MutMessage', `Importing data : ${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
await this.$api.dbTableRow.nestedRemove(
'noco',
NOCO,
this.projectName,
this.meta.title,
id,
@ -286,7 +286,7 @@ export default {
this.newRecordModal = false
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

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

@ -252,7 +252,7 @@ export default {
.map((c) => child[c.title])
.join('___')
await this.$api.dbTableRow.nestedRemove(
'noco',
NOCO,
this.projectName,
this.meta.title,
this.parentId,
@ -296,7 +296,7 @@ export default {
.map((c) => child[c.title])
.join('___')
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')
if ((this.childListModal || this.isForm) && this.$refs.childList) {
@ -360,7 +360,7 @@ export default {
.map((c) => child[c.title])
.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 {
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])
.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')
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 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 {
this.$emit('loadTableData')
@ -383,7 +383,7 @@ export default {
.map((c) => row[c.title])
.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 {
await this.addChildToParent(child)
}

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

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

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

@ -1,5 +1,6 @@
<script>
import Pagination from '~/components/project/spreadsheet/components/Pagination'
import { NOCO } from '~/lib/constants'
export default {
name: 'ListItems',
@ -75,7 +76,7 @@ export default {
if (this.column && this.column.colOptions && this.rowId) {
this.data = await this.$api.dbTableRow.nestedChildrenExcludedList(
'noco',
NOCO,
this.projectName,
this.parentMeta.title,
this.rowId,
@ -88,7 +89,7 @@ export default {
},
)
} 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,
offset: this.size * (this.page - 1),
...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 { useNuxtApp } from '#app'
import useProject from '~/composables/useProject'
import { NOCO } from '~/lib/constants'
const formatData = (list: Array<Record<string, any>>) =>
list.map((row) => ({
@ -36,7 +37,7 @@ export default (
.join('___') as string
return $api.dbViewRow.update(
'noco',
NOCO,
project?.value.id as string,
meta?.value.id as string,
viewMeta?.value?.id as string,
@ -77,7 +78,7 @@ export default (
}, {})
const insertedData = await $api.dbViewRow.create(
'noco',
NOCO,
project?.value.id as string,
meta?.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