Add id to each individual action
This commit is contained in:
parent
65d7656097
commit
3bcbb57baa
|
@ -90,7 +90,12 @@ describe("/rowsActions", () => {
|
||||||
expect(res).toEqual({
|
expect(res).toEqual({
|
||||||
_id: `${tableId}_row_actions`,
|
_id: `${tableId}_row_actions`,
|
||||||
_rev: expect.stringMatching(/^1-\w+/),
|
_rev: expect.stringMatching(/^1-\w+/),
|
||||||
actions: [{ name: rowAction.name }],
|
actions: [
|
||||||
|
{
|
||||||
|
id: expect.any(String),
|
||||||
|
name: rowAction.name,
|
||||||
|
},
|
||||||
|
],
|
||||||
tableId: tableId,
|
tableId: tableId,
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
|
@ -107,7 +112,10 @@ describe("/rowsActions", () => {
|
||||||
expect(res).toEqual({
|
expect(res).toEqual({
|
||||||
_id: `${tableId}_row_actions`,
|
_id: `${tableId}_row_actions`,
|
||||||
_rev: expect.stringMatching(/^3-\w+/),
|
_rev: expect.stringMatching(/^3-\w+/),
|
||||||
actions: rowActions,
|
actions: rowActions.map(a => ({
|
||||||
|
id: expect.any(String),
|
||||||
|
...a,
|
||||||
|
})),
|
||||||
tableId: tableId,
|
tableId: tableId,
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
|
@ -129,7 +137,12 @@ describe("/rowsActions", () => {
|
||||||
expect(res1).toEqual({
|
expect(res1).toEqual({
|
||||||
_id: `${tableId}_row_actions`,
|
_id: `${tableId}_row_actions`,
|
||||||
_rev: expect.stringMatching(/^1-\w+/),
|
_rev: expect.stringMatching(/^1-\w+/),
|
||||||
actions: [rowAction1],
|
actions: [
|
||||||
|
{
|
||||||
|
id: expect.any(String),
|
||||||
|
...rowAction1,
|
||||||
|
},
|
||||||
|
],
|
||||||
tableId: tableId,
|
tableId: tableId,
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
|
@ -138,7 +151,12 @@ describe("/rowsActions", () => {
|
||||||
expect(res2).toEqual({
|
expect(res2).toEqual({
|
||||||
_id: `${otherTableId}_row_actions`,
|
_id: `${otherTableId}_row_actions`,
|
||||||
_rev: expect.stringMatching(/^1-\w+/),
|
_rev: expect.stringMatching(/^1-\w+/),
|
||||||
actions: [rowAction2],
|
actions: [
|
||||||
|
{
|
||||||
|
id: expect.any(String),
|
||||||
|
...rowAction2,
|
||||||
|
},
|
||||||
|
],
|
||||||
tableId: otherTableId,
|
tableId: otherTableId,
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
|
@ -178,7 +196,10 @@ describe("/rowsActions", () => {
|
||||||
expect(response).toEqual(
|
expect(response).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
tableId,
|
tableId,
|
||||||
actions: rowActions,
|
actions: rowActions.map(a => ({
|
||||||
|
id: expect.any(String),
|
||||||
|
...a,
|
||||||
|
})),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { context } from "@budibase/backend-core"
|
import { context, utils } from "@budibase/backend-core"
|
||||||
|
|
||||||
import { generateRowActionsID } from "../../db/utils"
|
import { generateRowActionsID } from "../../db/utils"
|
||||||
import { TableRowActions } from "@budibase/types"
|
import { TableRowActions } from "@budibase/types"
|
||||||
|
@ -17,7 +17,10 @@ export async function create(tableId: string, rowAction: { name: string }) {
|
||||||
doc = { _id: rowActionsId, actions: [] }
|
doc = { _id: rowActionsId, actions: [] }
|
||||||
}
|
}
|
||||||
|
|
||||||
doc.actions.push(rowAction)
|
doc.actions.push({
|
||||||
|
id: utils.newid(),
|
||||||
|
...rowAction,
|
||||||
|
})
|
||||||
await db.put(doc)
|
await db.put(doc)
|
||||||
|
|
||||||
return await get(tableId)
|
return await get(tableId)
|
||||||
|
|
|
@ -5,6 +5,7 @@ export interface CreateRowActionRequest {
|
||||||
export interface RowActionsResponse {
|
export interface RowActionsResponse {
|
||||||
tableId: string
|
tableId: string
|
||||||
actions: {
|
actions: {
|
||||||
|
id: string
|
||||||
name: string
|
name: string
|
||||||
}[]
|
}[]
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { Document } from "../document"
|
||||||
export interface TableRowActions extends Document {
|
export interface TableRowActions extends Document {
|
||||||
_id: string
|
_id: string
|
||||||
actions: {
|
actions: {
|
||||||
|
id: string
|
||||||
name: string
|
name: string
|
||||||
}[]
|
}[]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue