From a6d6de6c4f8a7ba676294bc94cf122d7a82f020c Mon Sep 17 00:00:00 2001 From: Anupam Date: Fri, 24 Dec 2021 15:34:24 +0530 Subject: [PATCH 1/3] fix: grouping project form custom buttons --- erpnext/projects/doctype/project/project.js | 44 +++++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js index 31460f66ea..dc7cf81c76 100644 --- a/erpnext/projects/doctype/project/project.js +++ b/erpnext/projects/doctype/project/project.js @@ -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); - }); - - frm.add_custom_button(__('Completed'), () => { - frm.events.set_status(frm, 'Completed'); - }, __('Set Status')); + }, __("Actions")); - 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() + }); }); }, From 9c0f6d1306ac352bbc7314f1d03b662f7f0b785d Mon Sep 17 00:00:00 2001 From: Anupam Date: Fri, 24 Dec 2021 16:51:50 +0530 Subject: [PATCH 2/3] fix: sider issue --- erpnext/projects/doctype/project/project.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js index dc7cf81c76..6399a50f48 100644 --- a/erpnext/projects/doctype/project/project.js +++ b/erpnext/projects/doctype/project/project.js @@ -133,9 +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(() => { - frm.reload_doc() - }); + {project: frm.doc.name, status: status}).then(() => { + frm.reload_doc(); + }); }); }, From 077e2c646721e24eccdf7937715f5250cc6c22ca Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Tue, 28 Dec 2021 11:08:13 +0530 Subject: [PATCH 3/3] Update erpnext/projects/doctype/project/project.js --- erpnext/projects/doctype/project/project.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js index 6399a50f48..4f19bbd516 100644 --- a/erpnext/projects/doctype/project/project.js +++ b/erpnext/projects/doctype/project/project.js @@ -95,7 +95,7 @@ frappe.ui.form.on("Project", { set_project_status_button: function(frm) { frm.add_custom_button(__('Set Project Status'), () => { let d = new frappe.ui.Dialog({ - "title": "Set Project Status", + "title": __("Set Project Status"), "fields": [ { "fieldname": "status",