Fixing bulk deletion.
This commit is contained in:
parent
6b40f15318
commit
6685ebaa7b
|
@ -74,9 +74,8 @@
|
|||
}
|
||||
|
||||
const deleteRows = async () => {
|
||||
await api.post(`/api/${tableId}/rows`, {
|
||||
await api.delete(`/api/${tableId}/rows`, {
|
||||
rows: selectedRows,
|
||||
type: "delete",
|
||||
})
|
||||
data = data.filter(row => !selectedRows.includes(row))
|
||||
notifications.success(`Successfully deleted ${selectedRows.length} rows`)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
async function confirmDeletion() {
|
||||
await deleteRows()
|
||||
modal.hide()
|
||||
modal?.hide()
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -142,8 +142,7 @@ exports.fetchView = async (ctx) => {
|
|||
// if this is a table view being looked for just transfer to that
|
||||
if (viewName.startsWith(TABLE_VIEW_BEGINS_WITH)) {
|
||||
ctx.params.tableId = viewName.substring(4)
|
||||
await exports.fetchTableRows(ctx)
|
||||
return
|
||||
return exports.fetchTableRows(ctx)
|
||||
}
|
||||
|
||||
const db = new CouchDB(appId)
|
||||
|
@ -228,7 +227,8 @@ exports.find = async (ctx) => {
|
|||
exports.destroy = async function (ctx) {
|
||||
const appId = ctx.appId
|
||||
const db = new CouchDB(appId)
|
||||
const row = await db.get(ctx.params.rowId)
|
||||
const { rowId, revId } = ctx.request.body
|
||||
const row = await db.get(rowId)
|
||||
|
||||
if (row.tableId !== ctx.params.tableId) {
|
||||
throw "Supplied tableId doesn't match the row's tableId"
|
||||
|
@ -241,12 +241,12 @@ exports.destroy = async function (ctx) {
|
|||
})
|
||||
if (ctx.params.tableId === InternalTables.USER_METADATA) {
|
||||
ctx.params = {
|
||||
id: ctx.params.rowId,
|
||||
id: rowId,
|
||||
}
|
||||
await userController.destroyMetadata(ctx)
|
||||
return { response: ctx.body, row }
|
||||
} else {
|
||||
const response = await db.remove(ctx.params.rowId, ctx.params.revId)
|
||||
const response = await db.remove(rowId, revId)
|
||||
return { response, row }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ router
|
|||
rowController.validate
|
||||
)
|
||||
.delete(
|
||||
"/api/:tableId/rows/:rowId/:revId",
|
||||
paramSubResource("tableId", "rowId"),
|
||||
"/api/:tableId/rows",
|
||||
paramResource("tableId"),
|
||||
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
||||
usage,
|
||||
rowController.destroy
|
||||
|
|
|
@ -62,8 +62,12 @@ module.exports.run = async function ({ inputs, appId, apiKey, emitter }) {
|
|||
let ctx = {
|
||||
params: {
|
||||
tableId: inputs.tableId,
|
||||
rowId: inputs.id,
|
||||
revId: inputs.revision,
|
||||
},
|
||||
request: {
|
||||
body: {
|
||||
rowId: inputs.id,
|
||||
revId: inputs.revision,
|
||||
},
|
||||
},
|
||||
appId,
|
||||
eventEmitter: emitter,
|
||||
|
|
Loading…
Reference in New Issue