Skip to content

Commit 73076fa

Browse files
scmmishrasahil28297
andcommitted
feat: allow toggle sidebar to be persistent using local storage
Co-authored-by: Sahil Khan <sahilkhan28297@gmail.com>
1 parent 9f453c3 commit 73076fa

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

frappe/public/js/frappe/list/base_list.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ frappe.provide('frappe.views');
33
frappe.views.BaseList = class BaseList {
44
constructor(opts) {
55
Object.assign(this, opts);
6+
this.show_sidebar = JSON.parse(localStorage.show_sidebar || 'true');
67
}
78

89
show() {
@@ -200,13 +201,26 @@ frappe.views.BaseList = class BaseList {
200201
}
201202

202203
toggle_side_bar() {
203-
this.list_sidebar.parent.toggleClass('hide');
204-
this.page.current_view.find('.layout-main-section-wrapper').toggleClass('col-md-10 col-md-12');
204+
this.show_sidebar = !this.show_sidebar
205+
localStorage.show_sidebar = this.show_sidebar;
206+
this.list_sidebar.parent.toggle(this.show_sidebar);
207+
this.set_list_width()
208+
}
209+
210+
set_list_width() {
211+
if (!this.show_sidebar) {
212+
cur_list.page.current_view.find('.layout-main-section-wrapper').removeClass('col-md-10')
213+
cur_list.page.current_view.find('.layout-main-section-wrapper').addClass('col-md-12')
214+
} else {
215+
cur_list.page.current_view.find('.layout-main-section-wrapper').removeClass('col-md-12')
216+
cur_list.page.current_view.find('.layout-main-section-wrapper').addClass('col-md-10')
217+
}
205218
}
206219

207220
setup_main_section() {
208221
return frappe.run_serially([
209222
this.setup_list_wrapper,
223+
this.set_list_width,
210224
this.setup_filter_area,
211225
this.setup_sort_selector,
212226
this.setup_result_area,

frappe/public/js/frappe/list/list_sidebar.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ frappe.views.ListSidebar = class ListSidebar {
2323
this.sidebar = $('<div class="list-sidebar overlay-sidebar hidden-xs hidden-sm"></div>')
2424
.html(sidebar_content)
2525
.appendTo(this.page.sidebar.empty());
26+
let show_sidebar = JSON.parse(localStorage.show_sidebar || 'true');
27+
this.sidebar.toggle(show_sidebar)
2628

2729
this.setup_reports();
2830
this.setup_list_filter();

0 commit comments

Comments
 (0)