1
0
mirror of https://gitlab.com/bramw/baserow.git synced 2024-11-21 23:37:55 +00:00
bramw_baserow/web-frontend/modules/builder/services/element.js
2023-08-08 14:55:52 +00:00

36 lines
1016 B
JavaScript

export default (client) => {
return {
fetchAll(pageId) {
return client.get(`builder/page/${pageId}/elements/`)
},
create(pageId, elementType, beforeId = null, configuration = null) {
const payload = {
type: elementType,
...configuration,
}
if (beforeId !== null) {
payload.before_id = beforeId
}
return client.post(`builder/page/${pageId}/elements/`, payload)
},
update(elementId, values) {
return client.patch(`builder/element/${elementId}/`, values)
},
delete(elementId) {
return client.delete(`builder/element/${elementId}/`)
},
move(elementId, beforeId, parentElementId, placeInContainer) {
return client.patch(`builder/element/${elementId}/move/`, {
before_id: beforeId,
parent_element_id: parentElementId,
place_in_container: placeInContainer,
})
},
duplicate(elementId) {
return client.post(`builder/element/${elementId}/duplicate/`)
},
}
}