diff --git a/frappe/public/js/frappe/list/list_renderer.js b/frappe/public/js/frappe/list/list_renderer.js
index cd844f6238..9c5e74fbab 100644
--- a/frappe/public/js/frappe/list/list_renderer.js
+++ b/frappe/public/js/frappe/list/list_renderer.js
@@ -74,6 +74,13 @@ frappe.views.ListRenderer = Class.extend({
should_refresh: function() {
return this.list_view.current_view !== this.list_view.last_view;
},
+ load_last_view: function() {
+ // this function should handle loading the last view of your list_renderer,
+ // If you have a last view (for e.g last kanban board in Kanban View),
+ // load it using frappe.set_route and return true
+ // else return false
+ return false;
+ },
set_wrapper: function () {
this.wrapper = this.list_view.wrapper && this.list_view.wrapper.find('.result-list');
},
diff --git a/frappe/public/js/frappe/list/list_sidebar.js b/frappe/public/js/frappe/list/list_sidebar.js
index 68f250da9d..3cdd21a227 100644
--- a/frappe/public/js/frappe/list/list_sidebar.js
+++ b/frappe/public/js/frappe/list/list_sidebar.js
@@ -288,7 +288,7 @@ frappe.views.ListSidebar = Class.extend({
let default_link = '';
if (frappe.views.calendar[this.doctype]) {
// has standard calendar view
- default_link = `
${ __("Default") }`
+ default_link = `${ __("Default") }`
}
const other_links = calendar_views.map(
calendar_view => `
@@ -307,7 +307,7 @@ frappe.views.ListSidebar = Class.extend({
`;
-
+ $link_calendar.removeClass('hide');
$link_calendar.html(dropdown_html);
});
},
diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js
index 42f2bd3aa2..533ca903c4 100644
--- a/frappe/public/js/frappe/list/list_view.js
+++ b/frappe/public/js/frappe/list/list_view.js
@@ -399,6 +399,13 @@ frappe.views.ListView = frappe.ui.BaseList.extend({
if (this.list_renderer.should_refresh()) {
this.setup_list_renderer();
+
+ if (this.list_renderer.load_last_view && this.list_renderer.load_last_view()) {
+ // let the list_renderer load the last view for the current view
+ // for e.g last kanban board for kanban view
+ return;
+ }
+
this.refresh_surroundings();
this.dirty = true;
}
diff --git a/frappe/public/js/frappe/views/calendar/calendar.js b/frappe/public/js/frappe/views/calendar/calendar.js
index 9126c4b0e3..024d2dbbde 100644
--- a/frappe/public/js/frappe/views/calendar/calendar.js
+++ b/frappe/public/js/frappe/views/calendar/calendar.js
@@ -13,6 +13,21 @@ frappe.views.CalendarView = frappe.views.ListRenderer.extend({
this.calendar = new frappe.views.Calendar(options);
});
},
+ load_last_view: function() {
+ const route = frappe.get_route();
+
+ if (!route[3]) {
+ // routed to Calendar view, check last calendar_view
+ let calendar_view = this.user_settings.last_calendar_view;
+
+ if (calendar_view) {
+ frappe.set_route('List', this.doctype, 'Calendar', calendar_view);
+ return true;
+ }
+ }
+
+ return false;
+ },
set_defaults: function() {
this._super();
this.page_title = this.page_title + ' ' + __('Calendar');
@@ -23,12 +38,22 @@ frappe.views.CalendarView = frappe.views.ListRenderer.extend({
get_header_html: function() {
return null;
},
- get_calendar_options: function() {
- let calendar_view = this.user_settings.last_calendar_view;
-
- if (!calendar_view) {
- calendar_view = frappe.get_route()[3] || 'Default';
+ should_refresh: function() {
+ var should_refresh = this._super();
+ if(!should_refresh) {
+ this.last_calendar_view = this.current_calendar_view || '';
+ this.current_calendar_view = this.get_calendar_view();
+ this.page_title = __(this.get_calendar_view());
+
+ should_refresh = this.current_calendar_view !== this.last_calendar_view;
}
+ return should_refresh;
+ },
+ get_calendar_view: function() {
+ return frappe.get_route()[3];
+ },
+ get_calendar_options: function() {
+ const calendar_view = frappe.get_route()[3] || 'Default';
// save in user_settings
frappe.model.user_settings.save(this.doctype, 'Calendar', {
@@ -164,7 +189,6 @@ frappe.views.Calendar = Class.extend({
args: me.get_args(start, end),
callback: function(r) {
var events = r.message;
- console.log(events);
events = me.prepare_events(events);
callback(events);
}