Browse Source

Added cookie extension support for the custom view extension

Dustin Utecht 2 years ago
parent
commit
ff311573b3

+ 1 - 1
site/docs/extensions/cookie.md

@@ -180,7 +180,7 @@ toc: true
 
 
    Set this array with the table properties (sortOrder, sortName, sortPriority, pageNumber, pageList, hiddenColumns, searchText, filterControl) that you want to save
    Set this array with the table properties (sortOrder, sortName, sortPriority, pageNumber, pageList, hiddenColumns, searchText, filterControl) that you want to save
 
 
-- **Default:** `['bs.table.sortOrder', 'bs.table.sortName', 'bs.table.sortPriority', 'bs.table.pageNumber', 'bs.table.pageList', 'bs.table.hiddenColumns', 'bs.table.searchText', 'bs.table.filterControl', 'bs.table.cardView']`
+- **Default:** `['bs.table.sortOrder', 'bs.table.sortName', 'bs.table.sortPriority', 'bs.table.pageNumber', 'bs.table.pageList', 'bs.table.hiddenColumns', 'bs.table.searchText', 'bs.table.filterControl', 'bs.table.cardView', 'bs.table.customView']`
 
 
 ## Methods
 ## Methods
 
 

+ 9 - 1
src/extensions/cookie/bootstrap-table-cookie.js

@@ -13,6 +13,7 @@ const UtilsCookie = {
     columns: 'bs.table.columns',
     columns: 'bs.table.columns',
     hiddenColumns: 'bs.table.hiddenColumns',
     hiddenColumns: 'bs.table.hiddenColumns',
     cardView: 'bs.table.cardView',
     cardView: 'bs.table.cardView',
+    customView: 'bs.table.customView',
     searchText: 'bs.table.searchText',
     searchText: 'bs.table.searchText',
     reorderColumns: 'bs.table.reorderColumns',
     reorderColumns: 'bs.table.reorderColumns',
     filterControl: 'bs.table.filterControl',
     filterControl: 'bs.table.filterControl',
@@ -180,7 +181,7 @@ Object.assign($.fn.bootstrapTable.defaults, {
     'bs.table.pageNumber', 'bs.table.pageList',
     'bs.table.pageNumber', 'bs.table.pageList',
     'bs.table.hiddenColumns', 'bs.table.columns', 'bs.table.searchText',
     'bs.table.hiddenColumns', 'bs.table.columns', 'bs.table.searchText',
     'bs.table.filterControl', 'bs.table.filterBy',
     'bs.table.filterControl', 'bs.table.filterBy',
-    'bs.table.reorderColumns', 'bs.table.cardView'
+    'bs.table.reorderColumns', 'bs.table.cardView', 'bs.table.customView'
   ],
   ],
   cookieStorage: 'cookieStorage', // localStorage, sessionStorage, customStorage
   cookieStorage: 'cookieStorage', // localStorage, sessionStorage, customStorage
   cookieCustomStorageGet: null,
   cookieCustomStorageGet: null,
@@ -377,6 +378,11 @@ $.BootstrapTable = class extends $.BootstrapTable {
     UtilsCookie.setCookie(this, UtilsCookie.cookieIds.cardView, this.options.cardView)
     UtilsCookie.setCookie(this, UtilsCookie.cookieIds.cardView, this.options.cardView)
   }
   }
 
 
+  toggleCustomView () {
+    super.toggleCustomView()
+    UtilsCookie.setCookie(this, UtilsCookie.cookieIds.customView, this.customViewDefaultView)
+  }
+
   selectPage (page) {
   selectPage (page) {
     super.selectPage(page)
     super.selectPage(page)
     if (!this.options.cookie) {
     if (!this.options.cookie) {
@@ -433,6 +439,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
     const pageListCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.pageList)
     const pageListCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.pageList)
     const searchTextCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.searchText)
     const searchTextCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.searchText)
     const cardViewCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.cardView)
     const cardViewCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.cardView)
+    const customViewCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.customView)
 
 
     const columnsCookieValue = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.columns)
     const columnsCookieValue = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.columns)
     const hiddenColumnsCookieValue = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.hiddenColumns)
     const hiddenColumnsCookieValue = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.hiddenColumns)
@@ -493,6 +500,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
     if (cardViewCookie !== null) {
     if (cardViewCookie !== null) {
       this.options.cardView = cardViewCookie === 'true' ? cardViewCookie : false
       this.options.cardView = cardViewCookie === 'true' ? cardViewCookie : false
     }
     }
+    this.customViewDefaultView = customViewCookie === 'true'
 
 
     if (hiddenColumnsCookie) {
     if (hiddenColumnsCookie) {
       for (const column of this.columns) {
       for (const column of this.columns) {