fix: Override primary_action from list_settings
Show Email Composer as primary action in Communication List
This commit is contained in:
parent
93720a911d
commit
65e0fe19cc
3 changed files with 17 additions and 24 deletions
|
|
@ -19,16 +19,7 @@ frappe.listview_settings['Communication'] = {
|
|||
});
|
||||
},
|
||||
|
||||
set_primary_action: function(list_view) {
|
||||
var me = this;
|
||||
if (list_view.new_doctype) {
|
||||
list_view.page.set_primary_action(
|
||||
__("New"),
|
||||
function() { new frappe.views.CommunicationComposer({ doc: {} }) },
|
||||
"octicon octicon-plus"
|
||||
);
|
||||
} else {
|
||||
list_view.page.clear_primary_action();
|
||||
}
|
||||
primary_action: function() {
|
||||
new frappe.views.CommunicationComposer({ doc: {} })
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -168,7 +168,11 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
set_primary_action() {
|
||||
if (this.can_create) {
|
||||
this.page.set_primary_action(__('New'), () => {
|
||||
this.make_new_doc();
|
||||
if (this.settings.primary_action) {
|
||||
this.settings.primary_action();
|
||||
} else {
|
||||
this.make_new_doc();
|
||||
}
|
||||
}, 'octicon octicon-plus');
|
||||
} else {
|
||||
this.page.clear_primary_action();
|
||||
|
|
|
|||
|
|
@ -509,7 +509,12 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
|
||||
delete_saved_draft() {
|
||||
if (this.dialog) {
|
||||
localStorage.removeItem(this.frm.doctype + this.frm.docname);
|
||||
try {
|
||||
localStorage.removeItem(this.frm.doctype + this.frm.docname);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.warn('[Communication] Cannot delete localStorage item');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -574,16 +579,6 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
cur_frm.reload_doc();
|
||||
}
|
||||
|
||||
if (localStorage.getItem(this.frm.doctype + this.frm.docname)) {
|
||||
try {
|
||||
localStorage.removeItem(this.frm.doctype + this.frm.docname);
|
||||
} catch (e) {
|
||||
// silently fail
|
||||
console.log(e);
|
||||
console.warn('[Communication] Failed to delete draft.');
|
||||
}
|
||||
}
|
||||
|
||||
// try the success callback if it exists
|
||||
if (me.success) {
|
||||
try {
|
||||
|
|
@ -635,7 +630,10 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
this.message = this.txt + (this.message ? ("<br><br>" + this.message) : "");
|
||||
} else {
|
||||
// saved draft in localStorage
|
||||
this.message = localStorage.getItem(this.frm.doctype + this.frm.docname) || '';
|
||||
const { doctype, docname } = this.frm || {};
|
||||
if (doctype && docname) {
|
||||
this.message = localStorage.getItem(doctype + docname) || '';
|
||||
}
|
||||
}
|
||||
|
||||
if(this.real_name) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue