Browse Source

refactor: shared form view api corrections

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1668/head
Pranav C 3 years ago
parent
commit
55248ec80e
  1. 75
      packages/nc-gui/components/project/spreadsheet/public/xcForm.vue
  2. 2
      packages/nc-gui/components/project/spreadsheet/public/xcTable.vue
  3. 13
      packages/nocodb-sdk/src/lib/Api.ts
  4. 2
      packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts
  5. 36
      scripts/sdk/swagger.json

75
packages/nc-gui/components/project/spreadsheet/public/xcForm.vue

@ -298,7 +298,7 @@ export default {
this.loading = true this.loading = true
try { try {
this.viewMeta = (await this.$api.public.sharedViewMetaGet(this.$route.params.id, { this.viewMeta = (await this.$api.public.sharedViewMetaGet(this.$route.params.id, {
password: this.password headers: { 'xc-password': this.password }
})) }))
this.view = this.viewMeta.view this.view = this.viewMeta.view
@ -306,66 +306,6 @@ export default {
this.metas = this.viewMeta.relatedMetas this.metas = this.viewMeta.relatedMetas
this.columns = this.meta.columns.filter(c => c.show) this.columns = this.meta.columns.filter(c => c.show)
this.client = this.viewMeta.client this.client = this.viewMeta.client
// try {
// // eslint-disable-next-line camelcase
// const {
// meta,
// // model_name,
// client,
// query_params: qp,
// db_alias: dbAlias,
// relatedTableMetas
// } = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'sharedViewGet', {
// view_id: this.$route.params.id,
// password: this.password
// }])
// this.client = client
// this.meta = meta
// this.query_params = qp
// this.dbAlias = dbAlias
// this.metas = relatedTableMetas
//
// const showFields = this.query_params.showFields || {}
// let fields = this.query_params.fieldsOrder || []
// if (!fields.length) {
// fields = Object.keys(showFields)
// }
// // eslint-disable-next-line camelcase
//
// let columns = this.meta.columns
// if (this.meta && this.meta.v) {
// columns = [...columns, ...this.meta.v.map(v => ({ ...v, virtual: 1 }))]
// }
//
// {
// const _ref = {}
// columns.forEach((c) => {
// if (c.virtual && c.bt) {
// c.prop = `${c.bt.rtn}Read`
// }
// if (c.virtual && c.mm) {
// c.prop = `${c.mm.rtn}MMList`
// }
// if (c.virtual && c.hm) {
// c.prop = `${c.hm.table_name}List`
// }
//
// // if (c.virtual && c.lk) {
// // c.alias = `${c.lk._lcn} (from ${c.lk._ltn})`
// // } else {
// c.alias = c.title
// // }
// if (c.alias in _ref) {
// c.alias += _ref[c.alias]++
// } else {
// _ref[c.alias] = 1
// }
// })
// }
// // this.modelName = model_name
// this.columns = columns.filter(c => showFields[c.alias]).sort((a, b) => fields.indexOf(a.alias) - fields.indexOf(b.alias))
//
// this.localParams = (this.query_params.extraViewParams && this.query_params.extraViewParams.formParams) || {}
} catch (e) { } catch (e) {
if (e.response && e.response.status === 404) { if (e.response && e.response.status === 404) {
this.notFound = true this.notFound = true
@ -385,16 +325,6 @@ export default {
} }
this.submitting = true this.submitting = true
// const id = this.meta.columns.filter(c => c.pk).map(c => this.localState[c.title]).join('___')
// const updatedObj = Object.keys(this.changedColumns).reduce((obj, col) => {
// obj[col] = this.localState[col]
// return obj
// }, {})
// if (this.isNew) {
// const formData = new FormData()
const data = { ...this.localState, ...this.virtual } const data = { ...this.localState, ...this.virtual }
const attachment = {} const attachment = {}
@ -407,8 +337,9 @@ export default {
await this.$api.public.dataCreate(this.$route.params.id, { await this.$api.public.dataCreate(this.$route.params.id, {
data, data,
password: this.password,
...attachment ...attachment
}, {
headers: { 'xc-password': this.password }
}) })
this.virtual = {} this.virtual = {}

2
packages/nc-gui/components/project/spreadsheet/public/xcTable.vue

@ -430,7 +430,7 @@ export default {
filterArrJson: JSON.stringify(this.filters), filterArrJson: JSON.stringify(this.filters),
...this.queryParams ...this.queryParams
}, { }, {
headers: { password: this.password } headers: { 'xc-password': this.password }
} }
)) ))

13
packages/nocodb-sdk/src/lib/Api.ts

@ -2821,7 +2821,6 @@ export class Api<
*/ */
dataList: ( dataList: (
sharedViewUuid: string, sharedViewUuid: string,
data: { password?: string; sorts?: SortType[]; filters?: FilterType[] },
query?: { limit?: string; offset?: string }, query?: { limit?: string; offset?: string },
params: RequestParams = {} params: RequestParams = {}
) => ) =>
@ -2829,8 +2828,6 @@ export class Api<
path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows`, path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows`,
method: 'GET', method: 'GET',
query: query, query: query,
body: data,
type: ContentType.Json,
format: 'json', format: 'json',
...params, ...params,
}), }),
@ -2839,14 +2836,20 @@ export class Api<
* No description * No description
* *
* @tags Public * @tags Public
* @name SharedViewCreate * @name DataCreate
* @request POST:/api/v1/db/public/shared-view/{sharedViewUuid}/rows * @request POST:/api/v1/db/public/shared-view/{sharedViewUuid}/rows
* @response `200` `any` OK * @response `200` `any` OK
*/ */
sharedViewCreate: (sharedViewUuid: string, params: RequestParams = {}) => dataCreate: (
sharedViewUuid: string,
data: any,
params: RequestParams = {}
) =>
this.request<any, any>({ this.request<any, any>({
path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows`, path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows`,
method: 'POST', method: 'POST',
body: data,
type: ContentType.Json,
format: 'json', format: 'json',
...params, ...params,
}), }),

2
packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataApis.ts

@ -324,7 +324,7 @@ router.post(
catchError(relDataList) catchError(relDataList)
); );
router.post( router.post(
'/api/v1/db/public/shared-view/:sharedViewUuid/create', '/api/v1/db/public/shared-view/:sharedViewUuid/rows',
multer({ multer({
storage: multer.diskStorage({}) storage: multer.diskStorage({})
}).any(), }).any(),

36
scripts/sdk/swagger.json

@ -3421,33 +3421,6 @@
"tags": [ "tags": [
"Public" "Public"
], ],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"password": {
"type": "string"
},
"sorts": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Sort"
}
},
"filters": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Filter"
}
}
}
}
}
},
"description": ""
},
"parameters": [ "parameters": [
{ {
"schema": { "schema": {
@ -3467,7 +3440,7 @@
}, },
"post": { "post": {
"summary": "", "summary": "",
"operationId": "public-shared-view-create", "operationId": "public-data-create",
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
@ -3478,6 +3451,13 @@
} }
} }
}, },
"requestBody": {
"content": {
"application/json": {
"schema": {}
}
}
},
"tags": [ "tags": [
"Public" "Public"
], ],

Loading…
Cancel
Save