Browse Source

refactor: column delete api correction

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1668/head
Pranav C 3 years ago
parent
commit
4e87678831
  1. 2
      packages/nc-gui/components/project/spreadsheet/components/headerCell.vue
  2. 27
      packages/nocodb-sdk/src/lib/Api.ts
  3. 4
      packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts
  4. 20
      scripts/sdk/swagger.json

2
packages/nc-gui/components/project/spreadsheet/components/headerCell.vue

@ -184,7 +184,7 @@ export default {
column.altered = 4 column.altered = 4
const columns = this.meta.columns.slice() const columns = this.meta.columns.slice()
columns[this.columnIndex] = column columns[this.columnIndex] = column
await this.$api.dbTableColumn.delete(this.meta.id, column.id) await this.$api.dbTableColumn.delete(column.id)
this.$emit('colDelete') this.$emit('colDelete')
this.$emit('saved') this.$emit('saved')

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

@ -1494,12 +1494,12 @@ export class Api<
* @tags DB Table column * @tags DB Table column
* @name Read * @name Read
* @summary Column Read * @summary Column Read
* @request GET:/api/v1/db/meta/tables/{tableId}/columns/{columnId} * @request GET:/api/v1/db/meta/columns/{columnId}
* @response `200` `ColumnType` OK * @response `200` `ColumnType` OK
*/ */
read: (tableId: string, columnId: string, params: RequestParams = {}) => read: (columnId: string, params: RequestParams = {}) =>
this.request<ColumnType, any>({ this.request<ColumnType, any>({
path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}`, path: `/api/v1/db/meta/columns/${columnId}`,
method: 'GET', method: 'GET',
format: 'json', format: 'json',
...params, ...params,
@ -1511,17 +1511,16 @@ export class Api<
* @tags DB Table column * @tags DB Table column
* @name Update * @name Update
* @summary Column Update * @summary Column Update
* @request PATCH:/api/v1/db/meta/tables/{tableId}/columns/{columnId} * @request PATCH:/api/v1/db/meta/columns/{columnId}
* @response `200` `ColumnType` OK * @response `200` `ColumnType` OK
*/ */
update: ( update: (
tableId: string,
columnId: string, columnId: string,
data: ColumnReqType, data: ColumnReqType,
params: RequestParams = {} params: RequestParams = {}
) => ) =>
this.request<ColumnType, any>({ this.request<ColumnType, any>({
path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}`, path: `/api/v1/db/meta/columns/${columnId}`,
method: 'PATCH', method: 'PATCH',
body: data, body: data,
type: ContentType.Json, type: ContentType.Json,
@ -1534,12 +1533,12 @@ export class Api<
* *
* @tags DB Table column * @tags DB Table column
* @name Delete * @name Delete
* @request DELETE:/api/v1/db/meta/tables/{tableId}/columns/{columnId} * @request DELETE:/api/v1/db/meta/columns/{columnId}
* @response `200` `void` OK * @response `200` `void` OK
*/ */
delete: (tableId: string, columnId: string, params: RequestParams = {}) => delete: (columnId: string, params: RequestParams = {}) =>
this.request<void, any>({ this.request<void, any>({
path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}`, path: `/api/v1/db/meta/columns/${columnId}`,
method: 'DELETE', method: 'DELETE',
...params, ...params,
}), }),
@ -1549,16 +1548,12 @@ export class Api<
* *
* @tags DB Table column * @tags DB Table column
* @name PrimaryColumnSet * @name PrimaryColumnSet
* @request POST:/api/v1/db/meta/tables/{tableId}/columns/{columnId}/primary * @request POST:/api/v1/db/meta/columns/{columnId}/primary
* @response `200` `void` OK * @response `200` `void` OK
*/ */
primaryColumnSet: ( primaryColumnSet: (columnId: string, params: RequestParams = {}) =>
tableId: string,
columnId: string,
params: RequestParams = {}
) =>
this.request<void, any>({ this.request<void, any>({
path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}/primary`, path: `/api/v1/db/meta/columns/${columnId}/primary`,
method: 'POST', method: 'POST',
...params, ...params,
}), }),

4
packages/nocodb/src/lib/noco/meta/helpers/extractProjectIdAndAuthenticate.ts

@ -8,6 +8,7 @@ import GridViewColumn from '../../../noco-models/GridViewColumn';
import FormViewColumn from '../../../noco-models/FormViewColumn'; import FormViewColumn from '../../../noco-models/FormViewColumn';
import GalleryViewColumn from '../../../noco-models/GalleryViewColumn'; import GalleryViewColumn from '../../../noco-models/GalleryViewColumn';
import Project from '../../../noco-models/Project'; import Project from '../../../noco-models/Project';
import Column from '../../../noco-models/Column';
export default async (req, res, next) => { export default async (req, res, next) => {
try { try {
@ -66,6 +67,9 @@ export default async (req, res, next) => {
params.galleryViewColumnId params.galleryViewColumnId
); );
req.ncProjectId = galleryViewColumn?.project_id; req.ncProjectId = galleryViewColumn?.project_id;
} else if (params.columnId) {
const column = await Column.get({ colId: params.columnId });
req.ncProjectId = column?.project_id;
} }
const user = await new Promise((resolve, _reject) => { const user = await new Promise((resolve, _reject) => {

20
scripts/sdk/swagger.json

@ -1182,16 +1182,8 @@
] ]
} }
}, },
"/api/v1/db/meta/tables/{tableId}/columns/{columnId}": { "/api/v1/db/meta/columns/{columnId}": {
"parameters": [ "parameters": [
{
"schema": {
"type": "string"
},
"name": "tableId",
"in": "path",
"required": true
},
{ {
"schema": { "schema": {
"type": "string" "type": "string"
@ -1262,16 +1254,8 @@
] ]
} }
}, },
"/api/v1/db/meta/tables/{tableId}/columns/{columnId}/primary": { "/api/v1/db/meta/columns/{columnId}/primary": {
"parameters": [ "parameters": [
{
"schema": {
"type": "string"
},
"name": "tableId",
"in": "path",
"required": true
},
{ {
"schema": { "schema": {
"type": "string" "type": "string"

Loading…
Cancel
Save