Browse Source

fix(gui): on delete failure from child list show error message

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3569/head
Pranav C 2 years ago
parent
commit
7da60b4885
  1. 17
      packages/nc-gui/composables/useLTARStore.ts
  2. 5
      packages/nocodb-sdk/src/lib/Api.ts
  3. 7
      scripts/sdk/swagger.json

17
packages/nc-gui/composables/useLTARStore.ts

@ -193,7 +193,22 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
onOk: async () => {
const id = getRelatedTableRowId(row)
try {
$api.dbTableRow.delete(NOCO, projectId, relatedTableMeta.value.id as string, id as string)
const res: { message?: string[] } = await $api.dbTableRow.delete(
NOCO,
projectId,
relatedTableMeta.value.id as string,
id as string,
)
if (res.message) {
message.info(
`Row delete failed: ${`Unable to delete row with ID ${id} because of the following:
\n${res.message.join('\n')}.\n
Clear the data first & try again`})}`,
)
return false
}
reloadData?.()
/** reload child list if not a new row */

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

@ -2395,7 +2395,7 @@ export class Api<
* @name Delete
* @summary Table row delete
* @request DELETE:/api/v1/db/data/{orgs}/{projectName}/{tableName}/{rowId}
* @response `200` `void` OK
* @response `200` `any` OK
*/
delete: (
orgs: string,
@ -2404,9 +2404,10 @@ export class Api<
rowId: string,
params: RequestParams = {}
) =>
this.request<void, any>({
this.request<any, any>({
path: `/api/v1/db/data/${orgs}/${projectName}/${tableName}/${rowId}`,
method: 'DELETE',
format: 'json',
...params,
}),

7
scripts/sdk/swagger.json

@ -3393,7 +3393,12 @@
"operationId": "db-table-row-delete",
"responses": {
"200": {
"description": "OK"
"description": "OK",
"content": {
"application/json": {
"schema": {}
}
}
}
},
"tags": [

Loading…
Cancel
Save