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
const columns = this.meta.columns.slice()
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('saved')

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

@ -1494,12 +1494,12 @@ export class Api<
* @tags DB Table column
* @name 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
*/
read: (tableId: string, columnId: string, params: RequestParams = {}) =>
read: (columnId: string, params: RequestParams = {}) =>
this.request<ColumnType, any>({
path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}`,
path: `/api/v1/db/meta/columns/${columnId}`,
method: 'GET',
format: 'json',
...params,
@ -1511,17 +1511,16 @@ export class Api<
* @tags DB Table column
* @name 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
*/
update: (
tableId: string,
columnId: string,
data: ColumnReqType,
params: RequestParams = {}
) =>
this.request<ColumnType, any>({
path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}`,
path: `/api/v1/db/meta/columns/${columnId}`,
method: 'PATCH',
body: data,
type: ContentType.Json,
@ -1534,12 +1533,12 @@ export class Api<
*
* @tags DB Table column
* @name Delete
* @request DELETE:/api/v1/db/meta/tables/{tableId}/columns/{columnId}
* @request DELETE:/api/v1/db/meta/columns/{columnId}
* @response `200` `void` OK
*/
delete: (tableId: string, columnId: string, params: RequestParams = {}) =>
delete: (columnId: string, params: RequestParams = {}) =>
this.request<void, any>({
path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}`,
path: `/api/v1/db/meta/columns/${columnId}`,
method: 'DELETE',
...params,
}),
@ -1549,16 +1548,12 @@ export class Api<
*
* @tags DB Table column
* @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
*/
primaryColumnSet: (
tableId: string,
columnId: string,
params: RequestParams = {}
) =>
primaryColumnSet: (columnId: string, params: RequestParams = {}) =>
this.request<void, any>({
path: `/api/v1/db/meta/tables/${tableId}/columns/${columnId}/primary`,
path: `/api/v1/db/meta/columns/${columnId}/primary`,
method: 'POST',
...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 GalleryViewColumn from '../../../noco-models/GalleryViewColumn';
import Project from '../../../noco-models/Project';
import Column from '../../../noco-models/Column';
export default async (req, res, next) => {
try {
@ -66,6 +67,9 @@ export default async (req, res, next) => {
params.galleryViewColumnId
);
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) => {

20
scripts/sdk/swagger.json

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

Loading…
Cancel
Save