From 1fbc8ff448c138d220ae2d97a314dd2e7a1b4ab8 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 23 Oct 2017 19:06:59 +0530 Subject: [PATCH] Add Show Calendar button --- frappe/desk/doctype/calendar_view/calendar_view.js | 6 ++++++ frappe/public/js/frappe/views/calendar/calendar.js | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/frappe/desk/doctype/calendar_view/calendar_view.js b/frappe/desk/doctype/calendar_view/calendar_view.js index 2087932643..e93473f61e 100644 --- a/frappe/desk/doctype/calendar_view/calendar_view.js +++ b/frappe/desk/doctype/calendar_view/calendar_view.js @@ -5,6 +5,12 @@ frappe.ui.form.on('Calendar View', { onload: function(frm) { frm.trigger('reference_doctype'); }, + refresh: function(frm) { + if (!frm.is_new()) { + frm.add_custom_button(__('Show Calendar'), + () => frappe.set_route('List', frm.doc.reference_doctype, 'Calendar', frm.doc.name)) + } + }, reference_doctype: function(frm) { const { reference_doctype } = frm.doc; if (!reference_doctype) return; diff --git a/frappe/public/js/frappe/views/calendar/calendar.js b/frappe/public/js/frappe/views/calendar/calendar.js index 024d2dbbde..54d2bb2b6c 100644 --- a/frappe/public/js/frappe/views/calendar/calendar.js +++ b/frappe/public/js/frappe/views/calendar/calendar.js @@ -43,7 +43,12 @@ frappe.views.CalendarView = frappe.views.ListRenderer.extend({ 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()); + + if (this.current_calendar_view !== 'Default') { + this.page_title = __(this.current_calendar_view); + } else { + this.page_title = this.doctype + ' ' + __('Calendar'); + } should_refresh = this.current_calendar_view !== this.last_calendar_view; }