From 16ae00782a6620934e5c7e6b88c926ef5149e5f0 Mon Sep 17 00:00:00 2001 From: aignatov-bio <47317017+aignatov-bio@users.noreply.github.com> Date: Mon, 9 Sep 2019 10:43:38 +0200 Subject: [PATCH] Fix new step button on empty task [SCI-3826] (#2026) * Fix new step button on empty task * Fix markup --- app/assets/javascripts/protocols/steps.js.erb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/protocols/steps.js.erb b/app/assets/javascripts/protocols/steps.js.erb index ae0a3a6dc..2cc5cf49b 100644 --- a/app/assets/javascripts/protocols/steps.js.erb +++ b/app/assets/javascripts/protocols/steps.js.erb @@ -107,7 +107,6 @@ $("[data-action='cancel-edit']") .on("ajax:success", function(e, data) { var $form = $(this).closest("form"); - $form.after(data.html); var $new_step = $(this).next(); $(this).remove(); @@ -139,7 +138,6 @@ var $edit_step = $step.after(data.html); var $form = $step.next(); $step.remove(); - formCallback($form); initEditableHandsOnTable($form); applyCancelCallBack(); @@ -268,8 +266,9 @@ function toggleButtons(show) { if (show) { - $("[data-action='new-step']").show(); + $("[data-action='new-step']:first").show(); $("[data-action='edit-step']").show(); + if ($('#steps .step').length > 0) $("[data-action='new-step']:last").show(); } else { $("[data-action='new-step']").hide(); $("[data-action='edit-step']").hide(); @@ -361,7 +360,6 @@ event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation(); - var $form = $(this).closest("form"); $form.parent().remove().promise().done(function() { newStepHandler();