Skip to content

Commit b5cfd08

Browse files
author
oko-x
committed
feat(tabulator): allow POST method for tabulator data fetch
1 parent bf46699 commit b5cfd08

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-smartbase-admin"
3-
version = "0.2.15"
3+
version = "0.2.16"
44
description = ""
55
authors = ["SmartBase <[email protected]>"]
66
readme = "README.md"

src/django_smartbase_admin/actions/admin_action_list.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ def __init__(
4545
) -> None:
4646
super().__init__(view, request)
4747
if all_params is None:
48-
self.all_params = json.loads(
49-
request.request_data.request_get.get(BASE_PARAMS_NAME, "{}")
50-
)
48+
if request.request_data.request_method == "GET":
49+
self.all_params = json.loads(
50+
request.request_data.request_get.get(BASE_PARAMS_NAME, "{}")
51+
)
52+
if request.request_data.request_method == "POST":
53+
self.all_params = json.loads(request.body)
5154
else:
5255
self.all_params = all_params
5356
if not self.all_params:

src/django_smartbase_admin/static/sb_admin/src/js/table.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ class SBAdminTable {
199199
ajaxUrlGenerator(url, config, params) {
200200
this.lastTableParams = params
201201
this.updateUrlState()
202+
if (this.tabulatorOptions['ajaxConfig']['method'] === 'POST') {
203+
return this.tableAjaxUrl
204+
}
202205
return this.tableAjaxUrl + this.getUrlParamsString()
203206
}
204207

@@ -237,13 +240,23 @@ class SBAdminTable {
237240
ajaxURLGenerator: (url, config, params) => {
238241
return this.ajaxUrlGenerator(url, config, params)
239242
},
243+
ajaxParams: () => {
244+
if (this.tabulatorOptions['ajaxConfig']['method'] === 'POST') {
245+
return this.getAllUrlParams()
246+
}
247+
return {}
248+
},
240249
dataSendParams: {
241250
"size": this.constants.TABLE_PARAMS_SIZE_NAME,
242251
"page": this.constants.TABLE_PARAMS_PAGE_NAME,
243252
"sort": this.constants.TABLE_PARAMS_SORT_NAME,
244253
},
245254
...this.tabulatorOptions
246255
}
256+
if (tabulatorOptions['ajaxConfig']['method'] === 'POST'){
257+
this.tableHistoryEnabled = false
258+
}
259+
tabulatorOptions['ajaxConfig']['headers']['X-CSRFToken'] = window.csrf_token
247260
tabulatorOptions = this.callModuleAction('modifyTabulatorOptions', tabulatorOptions)
248261
this.tabulator = new Tabulator(this.tableElSelector, tabulatorOptions)
249262
document.addEventListener("SBAdminReloadTableData", function () {

0 commit comments

Comments
 (0)