fix: mark form as dirty when editing or deleting exercise card
diff --git a/erpnext/healthcare/doctype/exercise_type/exercise_type.js b/erpnext/healthcare/doctype/exercise_type/exercise_type.js
index f450c9b..ff99dc2 100644
--- a/erpnext/healthcare/doctype/exercise_type/exercise_type.js
+++ b/erpnext/healthcare/doctype/exercise_type/exercise_type.js
@@ -24,6 +24,8 @@
this.exercise_cards = $('<div class="exercise-cards"></div>').appendTo(this.wrapper);
+ this.row = $('<div class="exercise-row"></div>').appendTo(this.exercise_cards);
+
let me = this;
this.exercise_toolbar.find(".btn-add")
@@ -32,7 +34,7 @@
me.show_add_card_dialog(frm);
});
- if (frm.doc.steps_table.length > 0) {
+ if (frm.doc.steps_table && frm.doc.steps_table.length > 0) {
this.make_cards(frm);
this.make_buttons(frm);
}
@@ -41,7 +43,6 @@
make_cards: function(frm) {
var me = this;
$(me.exercise_cards).empty();
- this.row = $('<div class="exercise-row"></div>').appendTo(me.exercise_cards);
$.each(frm.doc.steps_table, function(i, step) {
$(repl(`
@@ -78,6 +79,7 @@
frm.doc.steps_table.pop(id);
frm.refresh_field('steps_table');
$('#col-'+id).remove();
+ frm.dirty();
}, 300);
});
},
@@ -106,7 +108,10 @@
],
primary_action: function() {
let data = d.get_values();
- let i = frm.doc.steps_table.length;
+ let i = 0;
+ if (frm.doc.steps_table) {
+ i = frm.doc.steps_table.length;
+ }
$(repl(`
<div class="exercise-col col-sm-4" id="%(col_id)s">
<div class="card h-100 exercise-card" id="%(card_id)s">
@@ -165,9 +170,10 @@
frm.doc.steps_table[id].image = data.image;
frm.doc.steps_table[id].description = data.step_description;
refresh_field('steps_table');
+ frm.dirty();
new_dialog.hide();
},
- primary_action_label: __("Save"),
+ primary_action_label: __("Edit"),
});
new_dialog.set_values({