From 9e130c4277f8c03d04f802b3cd1379d763bc2332 Mon Sep 17 00:00:00 2001 From: Dustin Utecht <13292481+UtechtDustin@users.noreply.github.com> Date: Sun, 1 Oct 2023 21:09:06 +0200 Subject: [PATCH] Added cookie extension support for the custom view extension --- site/docs/extensions/cookie.md | 2 +- src/extensions/cookie/bootstrap-table-cookie.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/site/docs/extensions/cookie.md b/site/docs/extensions/cookie.md index e9fdf0d4f3..1b14037a93 100644 --- a/site/docs/extensions/cookie.md +++ b/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 -- **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 diff --git a/src/extensions/cookie/bootstrap-table-cookie.js b/src/extensions/cookie/bootstrap-table-cookie.js index e00cdb7e51..6d0b715c5f 100644 --- a/src/extensions/cookie/bootstrap-table-cookie.js +++ b/src/extensions/cookie/bootstrap-table-cookie.js @@ -13,6 +13,7 @@ const UtilsCookie = { columns: 'bs.table.columns', hiddenColumns: 'bs.table.hiddenColumns', cardView: 'bs.table.cardView', + customView: 'bs.table.customView', searchText: 'bs.table.searchText', reorderColumns: 'bs.table.reorderColumns', filterControl: 'bs.table.filterControl', @@ -180,7 +181,7 @@ Object.assign($.fn.bootstrapTable.defaults, { 'bs.table.pageNumber', 'bs.table.pageList', 'bs.table.hiddenColumns', 'bs.table.columns', 'bs.table.searchText', '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 cookieCustomStorageGet: null, @@ -377,6 +378,11 @@ $.BootstrapTable = class extends $.BootstrapTable { UtilsCookie.setCookie(this, UtilsCookie.cookieIds.cardView, this.options.cardView) } + toggleCustomView () { + super.toggleCustomView() + UtilsCookie.setCookie(this, UtilsCookie.cookieIds.customView, this.customViewDefaultView) + } + selectPage (page) { super.selectPage(page) if (!this.options.cookie) { @@ -433,6 +439,7 @@ $.BootstrapTable = class extends $.BootstrapTable { const pageListCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.pageList) const searchTextCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.searchText) 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 hiddenColumnsCookieValue = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.hiddenColumns) @@ -491,6 +498,7 @@ $.BootstrapTable = class extends $.BootstrapTable { } // cardView this.options.cardView = cardViewCookie === 'true' ? cardViewCookie : false + this.customViewDefaultView = customViewCookie === 'true' if (hiddenColumnsCookie) { for (const column of this.columns) {