From 429c595e0455baea02e272e0b72f816b708d9178 Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Mon, 22 May 2023 11:59:26 +0200 Subject: [PATCH] Reload Button --- public/js/components/filter/Filter.js | 54 +++++++++++++++++++-------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/public/js/components/filter/Filter.js b/public/js/components/filter/Filter.js index ae2ab9e7a..7fbeb84bc 100644 --- a/public/js/components/filter/Filter.js +++ b/public/js/components/filter/Filter.js @@ -55,6 +55,7 @@ export const CoreFilterCmpt = { tabulatorOptions: Object, tabulatorEvents: Array, tableOnly: Boolean, + reload: Boolean, download: { type: [Boolean, String, Function, Array, Object], default: false @@ -73,6 +74,7 @@ export const CoreFilterCmpt = { filterFields: null, availableFilters: null, + selectedFilter: null, // FetchCmpt binded properties fetchCmptRefresh: false, @@ -160,6 +162,12 @@ export const CoreFilterCmpt = { } }, methods: { + reloadTable() { + if (this.tableOnly) + this.tabulator.reload(); + else + this.getFilter(); + }, initTabulator() { // Define a default tabulator options in case it was not provided let tabulatorOptions = {...{ @@ -211,8 +219,16 @@ export const CoreFilterCmpt = { * */ getFilter: function() { - // - this.startFetchCmpt(CoreFilterAPIs.getFilter, null, this.render); + if (this.selectedFilter === null) + this.startFetchCmpt(CoreFilterAPIs.getFilter, null, this.render); + else + this.startFetchCmpt( + CoreFilterAPIs.getFilterById, + { + filterId: this.selectedFilter + }, + this.render + ); }, /** * @@ -381,6 +397,7 @@ export const CoreFilterCmpt = { * */ handlerSaveCustomFilter: function(customFilterName) { + this.selectedFilter = null; // this.startFetchCmpt( CoreFilterAPIs.saveCustomFilter, @@ -394,11 +411,14 @@ export const CoreFilterCmpt = { * */ handlerRemoveCustomFilter: function(event) { + filterId = event.currentTarget.getAttribute("href").substring(1); + if (filterId === this.selectedFilter) + this.selectedFilter = null; // this.startFetchCmpt( CoreFilterAPIs.removeCustomFilter, { - filterId: event.currentTarget.getAttribute("href").substring(1) + filterId: filterId }, this.getFilter ); @@ -427,16 +447,11 @@ export const CoreFilterCmpt = { this.switchFilter(filterId); }, switchFilter(filterId) { - // Ajax call - this.startFetchCmpt( - CoreFilterAPIs.getFilterById, - { - filterId - }, - this.render - ); + this.selectedFilter = filterId; + this.getFilter(); }, applyFilterConfig(filterFields) { + this.selectedFilter = null; this.startFetchCmpt( CoreFilterAPIs.applyFilterFields, { @@ -480,11 +495,18 @@ export const CoreFilterCmpt = {
-
- [ {{ filterName }} ] - - - +
+
+ [ {{ filterName }} ] + + + +
+
+ +