Return allowed run from table

This commit is contained in:
Adria Navarro 2024-10-04 13:21:21 +02:00
parent b6aebd67a8
commit 349637733e
2 changed files with 15 additions and 12 deletions

View File

@ -63,13 +63,15 @@
$: rowActions.refreshRowActions(id)
const makeRowActionButtons = actions => {
return (actions || []).map(action => ({
text: action.name,
onClick: async row => {
await rowActions.trigger(id, action.id, row._id)
notifications.success("Row action triggered successfully")
},
}))
return (actions || [])
.filter(action => action.allowedSources?.includes(id))
.map(action => ({
text: action.name,
onClick: async row => {
await rowActions.trigger(id, action.id, row._id)
notifications.success("Row action triggered successfully")
},
}))
}
const relationshipSupport = datasource => {

View File

@ -131,11 +131,12 @@ const derivedStore = derived(store, $store => {
Object.keys($store || {}).forEach(tableId => {
map[tableId] = $store[tableId]
for (let action of $store[tableId]) {
for (let viewId of action.allowedSources || []) {
if (!map[viewId]) {
map[viewId] = []
}
map[viewId].push(action)
const otherSources = (action.allowedSources || []).filter(
sourceId => sourceId !== tableId
)
for (let source of otherSources) {
map[source] ??= []
map[source].push(action)
}
}
})