From cf10fde5ec4e7112e7fdd58c30a6ad06be7e2f9d Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 29 Apr 2020 14:19:27 +0530 Subject: [PATCH] fix: mark form as dirty when editing or deleting exercise card --- .../doctype/exercise_type/exercise_type.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/erpnext/healthcare/doctype/exercise_type/exercise_type.js b/erpnext/healthcare/doctype/exercise_type/exercise_type.js index f450c9bccb..ff99dc2d72 100644 --- a/erpnext/healthcare/doctype/exercise_type/exercise_type.js +++ b/erpnext/healthcare/doctype/exercise_type/exercise_type.js @@ -24,6 +24,8 @@ erpnext.ExerciseEditor = Class.extend({ this.exercise_cards = $('
').appendTo(this.wrapper); + this.row = $('
').appendTo(this.exercise_cards); + let me = this; this.exercise_toolbar.find(".btn-add") @@ -32,7 +34,7 @@ erpnext.ExerciseEditor = Class.extend({ 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 @@ erpnext.ExerciseEditor = Class.extend({ make_cards: function(frm) { var me = this; $(me.exercise_cards).empty(); - this.row = $('
').appendTo(me.exercise_cards); $.each(frm.doc.steps_table, function(i, step) { $(repl(` @@ -78,6 +79,7 @@ erpnext.ExerciseEditor = Class.extend({ frm.doc.steps_table.pop(id); frm.refresh_field('steps_table'); $('#col-'+id).remove(); + frm.dirty(); }, 300); }); }, @@ -106,7 +108,10 @@ erpnext.ExerciseEditor = Class.extend({ ], 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(`
@@ -165,9 +170,10 @@ erpnext.ExerciseEditor = Class.extend({ 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({