fix: grouping project form custom buttons
This commit is contained in:
parent
7987a46509
commit
a6d6de6c4f
@ -59,22 +59,16 @@ frappe.ui.form.on("Project", {
|
||||
|
||||
frm.trigger('show_dashboard');
|
||||
}
|
||||
frm.events.set_buttons(frm);
|
||||
frm.trigger("set_custom_buttons");
|
||||
},
|
||||
|
||||
set_buttons: function(frm) {
|
||||
set_custom_buttons: function(frm) {
|
||||
if (!frm.is_new()) {
|
||||
frm.add_custom_button(__('Duplicate Project with Tasks'), () => {
|
||||
frm.events.create_duplicate(frm);
|
||||
});
|
||||
}, __("Actions"));
|
||||
|
||||
frm.add_custom_button(__('Completed'), () => {
|
||||
frm.events.set_status(frm, 'Completed');
|
||||
}, __('Set Status'));
|
||||
|
||||
frm.add_custom_button(__('Cancelled'), () => {
|
||||
frm.events.set_status(frm, 'Cancelled');
|
||||
}, __('Set Status'));
|
||||
frm.trigger("set_project_status_button");
|
||||
|
||||
|
||||
if (frappe.model.can_read("Task")) {
|
||||
@ -83,7 +77,7 @@ frappe.ui.form.on("Project", {
|
||||
"project": frm.doc.name
|
||||
};
|
||||
frappe.set_route("List", "Task", "Gantt");
|
||||
});
|
||||
}, __("View"));
|
||||
|
||||
frm.add_custom_button(__("Kanban Board"), () => {
|
||||
frappe.call('erpnext.projects.doctype.project.project.create_kanban_board_if_not_exists', {
|
||||
@ -91,13 +85,35 @@ frappe.ui.form.on("Project", {
|
||||
}).then(() => {
|
||||
frappe.set_route('List', 'Task', 'Kanban', frm.doc.project_name);
|
||||
});
|
||||
});
|
||||
}, __("View"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
set_project_status_button: function(frm) {
|
||||
frm.add_custom_button(__('Set Project Status'), () => {
|
||||
let d = new frappe.ui.Dialog({
|
||||
"title": "Set Project Status",
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"label": "Status",
|
||||
"reqd": 1,
|
||||
"options": "Completed\nCancelled",
|
||||
},
|
||||
],
|
||||
primary_action: function() {
|
||||
frm.events.set_status(frm, d.get_values().status);
|
||||
d.hide();
|
||||
},
|
||||
primary_action_label: __("Set Project Status")
|
||||
}).show();
|
||||
}, __("Actions"));
|
||||
},
|
||||
|
||||
create_duplicate: function(frm) {
|
||||
return new Promise(resolve => {
|
||||
frappe.prompt('Project Name', (data) => {
|
||||
@ -117,7 +133,9 @@ frappe.ui.form.on("Project", {
|
||||
set_status: function(frm, status) {
|
||||
frappe.confirm(__('Set Project and all Tasks to status {0}?', [status.bold()]), () => {
|
||||
frappe.xcall('erpnext.projects.doctype.project.project.set_project_status',
|
||||
{project: frm.doc.name, status: status}).then(() => { /* page will auto reload */ });
|
||||
{project: frm.doc.name, status: status}).then(() => {
|
||||
frm.reload_doc()
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user