Browse Source

Update bootstrap-table-filter-control.js

The collectBootstrapCookies funtion check only if cookie exist, but I'm using localstorage to store variable of the cookie plugin.
I've added to check localstorage.
manukieli 6 years ago
parent
commit
c7eca189cf
1 changed files with 14 additions and 1 deletions
  1. 14 1
      src/extensions/filter-control/bootstrap-table-filter-control.js

+ 14 - 1
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -178,6 +178,7 @@ const UtilsFilterControl = {
   collectBootstrapCookies () {
     const cookies = []
     const foundCookies = document.cookie.match(/(?:bs.table.)(\w*)/g)
+    const foundLocalStorage = localStorage
 
     if (foundCookies) {
       $.each(foundCookies, (i, _cookie) => {
@@ -190,8 +191,20 @@ const UtilsFilterControl = {
           cookies.push(cookie)
         }
       })
-      return cookies
     }
+    if (foundLocalStorage){
+      for(var i = 0; i < foundLocalStorage.length; i++) {
+        let cookie = foundLocalStorage.key(i)
+        if (/./.test(cookie)) {
+          cookie = cookie.split('.').pop()
+        }
+
+        if ($.inArray(cookie, cookies) === -1) {
+          cookies.push(cookie)
+        }
+      }
+    }
+    return cookies
   },
   escapeID (id) {
     // eslint-disable-next-line no-useless-escape