Browse Source

refactor: use view data apis in gridview and formview

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1668/head
Pranav C 3 years ago
parent
commit
bfdec7f967
  1. 27
      packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue
  2. 23
      packages/nc-gui/components/project/spreadsheet/views/formView.vue
  3. 133
      scripts/sdk/swagger.json

27
packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue

@ -1013,11 +1013,12 @@ export default {
}, {})
// const insertedData = await this.api.insert(insertObj)
const insertedData = (await this.$api.dbTableRow.create(
const insertedData = await this.$api.dbViewRow.create(
'noco',
this.projectName,
this.meta.title, insertObj
))
this.meta.title,
this.selectedView.title, insertObj
)
this.data.splice(row, 1, {
row: insertedData,
@ -1054,7 +1055,9 @@ export default {
return
}
const { row: rowObj, rowMeta, oldRow, saving, lastSave } = this.data[row]
if (!lastSave) { this.$set(this.data[row], 'lastSave', rowObj[column.title]) }
if (!lastSave) {
this.$set(this.data[row], 'lastSave', rowObj[column.title])
}
if (rowMeta.new) {
// return if there is no change
if ((column && oldRow[column.title] === rowObj[column.title]) || saving) {
@ -1070,7 +1073,9 @@ export default {
if (!column || (oldRow[column.title] === rowObj[column.title] && ((lastSave || rowObj[column.title]) === rowObj[column.title]))) {
return
}
if (saved) { this.$set(this.data[row], 'lastSave', oldRow[column.title]) }
if (saved) {
this.$set(this.data[row], 'lastSave', oldRow[column.title])
}
const id = this.meta.columns.filter(c => c.pk).map(c => rowObj[c.title]).join('___')
if (!id) {
@ -1079,10 +1084,12 @@ export default {
this.$set(this.data[row], 'saving', true)
// eslint-disable-next-line promise/param-names
const newData = (await this.$api.dbTableRow.update(
const newData = (await this.$api.dbViewRow.update(
'noco',
this.projectName,
this.meta.title, id, {
this.meta.title,
this.selectedView.title,
id, {
[column.title]: rowObj[column.title]
}, {
query: { ignoreWebhook: !saved }
@ -1279,7 +1286,11 @@ export default {
const {
list,
pageInfo
} = (await this.$api.dbViewRow.list('noco', this.projectName, this.meta.title, this.selectedView.title,
} = (await this.$api.dbViewRow.list(
'noco',
this.projectName,
this.meta.title,
this.selectedView.title,
{
...this.queryParams,
...(this._isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(this.sortList) }),

23
packages/nc-gui/components/project/spreadsheet/views/formView.vue

@ -715,20 +715,6 @@ export default {
})
).sort((a, b) => a.order - b.order)
},
// async loadFormColumns() {
// this.formColumns = (await this.$api.meta.viewColumnList(this.viewId))
// let order = 1
// const fieldById = this.formColumns.reduce((o, f) => ({ ...o, [f.fk_column_id]: f }), {})
// this.fields = this.meta.columns.map(c => ({
// _cn: c.title,
// uidt: c.uidt,
// alias: c.title,
// fk_column_id: c.id,
// ...(fieldById[c.id] ? fieldById[c.id] : {}),
// order: (fieldById[c.id] && fieldById[c.id].order) || order++
// })
// ).sort((a, b) => a.order - b.order)
// },
hideColumn(i) {
if (this.isDbRequired(this.columns[i])) {
this.$toast.info('Required field can\'t be removed').goAway(3000)
@ -854,15 +840,14 @@ export default {
this.loading = true
// todo: add params option in GraphQL
// let data = await this.api.insert(this.localState, { params: { form: this.$route.query.view } })
let data = await this.$api.dbTableRow.create(
let data = await this.$api.dbViewRow.create(
'noco',
this.projectName,
this.meta.title,
this.localState,
{ query: { form: this.$route.query.view } }
this.selectedView.title,
this.localState
)
data = { ...this.localState, ...data }
// save hasmany and manytomany relations from local state

133
scripts/sdk/swagger.json

@ -1137,29 +1137,6 @@
"required": true
}
],
"get": {
"summary": "Column List",
"operationId": "db-table-column-list",
"responses": {
"200": {
"$ref": "#/components/responses/ColumnList"
},
"201": {
"description": "Created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Column"
}
}
}
}
},
"description": "Read project details",
"tags": [
"DB Table column"
]
},
"post": {
"summary": "Column create",
"operationId": "db-table-column-create",
@ -1193,26 +1170,6 @@
"required": true
}
],
"get": {
"summary": "Column Read",
"operationId": "db-table-column-read",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Column"
}
}
}
}
},
"description": "Read project details",
"tags": [
"DB Table column"
]
},
"patch": {
"summary": "Column Update",
"operationId": "db-table-column-update",
@ -1610,23 +1567,6 @@
"required": true
}
],
"get": {
"summary": "",
"operationId": "db-view-column-read",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {}
}
}
}
},
"tags": [
"DB View Column"
]
},
"patch": {
"summary": "",
"operationId": "db-view-column-update",
@ -3546,79 +3486,6 @@
]
}
},
"/api/v1/db/public/shared-view/{sharedViewUuid}/rows/{rowId}/{relationType}/{columnName}/exclude": {
"parameters": [
{
"schema": {
"type": "string"
},
"name": "sharedViewUuid",
"in": "path",
"required": true
},
{
"schema": {
"type": "string"
},
"name": "rowId",
"in": "path",
"required": true
},
{
"schema": {
"type": "string",
"enum": [
"mm",
"hm"
]
},
"name": "relationType",
"in": "path",
"required": true
},
{
"schema": {
"type": "string"
},
"name": "columnName",
"in": "path",
"required": true
}
],
"get": {
"summary": "",
"operationId": "public-data-nested-excluded-list",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {}
}
}
}
},
"tags": [
"Public"
],
"parameters": [
{
"schema": {
"type": "string"
},
"in": "query",
"name": "limit"
},
{
"schema": {
"type": "string"
},
"in": "query",
"name": "offset"
}
]
}
},
"/api/v1/db/public/shared-view/{sharedViewUuid}/rows/export/{type}": {
"parameters": [
{

Loading…
Cancel
Save