refactor: update affected_states list with has_affected_states boolean
This commit is contained in:
parent
9c663fcdf0
commit
1358b10fdf
2 changed files with 6 additions and 6 deletions
|
|
@ -152,15 +152,15 @@ export const useStore = defineStore("workflow-builder-store", () => {
|
|||
function reset_non_submittable_states() {
|
||||
if (is_submittable.value) return;
|
||||
|
||||
let affected_states = [];
|
||||
let has_affected_states = false;
|
||||
workflow.value.elements.forEach((el) => {
|
||||
if (el.type === "state" && el.data.doc_status && el.data.doc_status !== "Draft") {
|
||||
affected_states.push(el.data.state);
|
||||
has_affected_states = true;
|
||||
el.data.doc_status = "Draft";
|
||||
}
|
||||
});
|
||||
|
||||
if (affected_states.length) {
|
||||
if (has_affected_states) {
|
||||
frappe.msgprint({
|
||||
title: __("Doc Status Reset"),
|
||||
message: __(
|
||||
|
|
|
|||
|
|
@ -128,14 +128,14 @@ frappe.ui.form.on("Workflow", {
|
|||
);
|
||||
|
||||
if (!is_submittable) {
|
||||
let affected_states = [];
|
||||
let has_affected_states = false;
|
||||
frm.doc.states.forEach((row) => {
|
||||
if (parseInt(row.doc_status || 0) !== 0) {
|
||||
affected_states.push(row.state);
|
||||
has_affected_states = true;
|
||||
row.doc_status = "0";
|
||||
}
|
||||
});
|
||||
if (affected_states.length) {
|
||||
if (has_affected_states) {
|
||||
frm.refresh_field("states");
|
||||
frappe.msgprint({
|
||||
title: __("Doc Status Reset"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue