From 2e4f687d31749f456e741132f2fe2cc9ee2508d2 Mon Sep 17 00:00:00 2001 From: aignatov-bio <47317017+aignatov-bio@users.noreply.github.com> Date: Tue, 25 Jan 2022 12:27:23 +0100 Subject: [PATCH] Add experiment move error handling to project show [SCI-6398] (#3776) Co-authored-by: Anton --- app/assets/javascripts/projects/show.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/assets/javascripts/projects/show.js b/app/assets/javascripts/projects/show.js index 17d8adbaa..59dd02284 100644 --- a/app/assets/javascripts/projects/show.js +++ b/app/assets/javascripts/projects/show.js @@ -236,6 +236,22 @@ modal.on('hidden.bs.modal', function() { $(this).remove(); }); + validateMoveModal(modal) + } + + function validateMoveModal(modal) { + if (modal[0].id.match(/move-experiment-modal-[0-9]*/)) { + let form = $(modal).find('form'); + form.on('ajax:success', function(e, data) { + animateSpinner(form, true); + window.location.replace(data.path); + }).on('ajax:error', function(e, error) { + animateSpinner(form, false); + form.clearFormErrors(); + let msg = JSON.parse(error.responseText); + renderFormError(e, form.find('#experiment_project_id'), msg.message.toString()); + }); + } }