Skip to content

Commit

Permalink
refactor(Project): extract custom button function (frappe#45116)
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra authored Jan 6, 2025
1 parent 3ca3707 commit 6f5fea6
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions erpnext/projects/doctype/project/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,29 +147,32 @@ 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"),
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();
},
() => frm.events.get_project_status_dialog(frm).show(),
__("Actions")
);
},

get_project_status_dialog: function (frm) {
const dialog = 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, dialog.get_values().status);
dialog.hide();
},
primary_action_label: __("Set Project Status"),
});
return dialog;
},

create_duplicate: function (frm) {
return new Promise((resolve) => {
frappe.prompt("Project Name", (data) => {
Expand Down

0 comments on commit 6f5fea6

Please sign in to comment.