Files
baserow/web-frontend/modules/database/services/view/grid.js
T

58 lines
1.2 KiB
JavaScript

export default (client) => {
return {
fetchRows({
gridId,
limit = 100,
offset = null,
cancelToken = null,
includeFieldOptions = false,
}) {
const config = {
params: {
limit,
},
}
const include = []
if (offset !== null) {
config.params.offset = offset
}
if (cancelToken !== null) {
config.cancelToken = cancelToken
}
if (includeFieldOptions) {
include.push('field_options')
}
if (include.length > 0) {
config.params.include = include.join(',')
}
return client.get(`/database/views/grid/${gridId}/`, config)
},
fetchCount(gridId) {
const config = {
params: {
count: true,
},
}
return client.get(`/database/views/grid/${gridId}/`, config)
},
filterRows({ gridId, rowIds, fieldIds = null }) {
const data = { row_ids: rowIds }
if (fieldIds !== null) {
data.field_ids = fieldIds
}
return client.post(`/database/views/grid/${gridId}/`, data)
},
update({ gridId, values }) {
return client.patch(`/database/views/grid/${gridId}/`, values)
},
}
}