Add Show Calendar button

This commit is contained in:
Faris Ansari 2017-10-23 19:06:59 +05:30
parent 8c291c9b20
commit 1fbc8ff448
2 changed files with 12 additions and 1 deletions

View file

@ -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;

View file

@ -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;
}