diff --git a/app/assets/javascripts/experiments/dropdown_actions.js b/app/assets/javascripts/experiments/dropdown_actions.js index f6956737e..29a3f4990 100644 --- a/app/assets/javascripts/experiments/dropdown_actions.js +++ b/app/assets/javascripts/experiments/dropdown_actions.js @@ -3,8 +3,6 @@ // Create ajax hook on given 'element', which should return modal with 'id' => // show that modal function initializeModal(element, id){ - - // Initializev new experiment modal listner $(element) .on("ajax:beforeSend", function(){ animateSpinner(); @@ -16,7 +14,6 @@ keyboard: false, }); validateMoveModal(id); - validateExperimentForm($(id)); }) .on("ajax:error", function() { animateSpinner(null, false); @@ -61,42 +58,11 @@ var msg = JSON.parse(error.responseText); renderFormError(e, form.find("#experiment_project_id"), - msg.message.toString(), - true); + msg.message.toString()); }) + .clearFormErrors(); } } - // Setup front-end validations for experiment form - function validateExperimentForm(element){ - if ( element ) { - var form = element.find("form"); - form - .on('ajax:success' , function(){ - animateSpinner(form, true); - location.reload(); - }) - .on('ajax:error', function(e, error){ - var msg = JSON.parse(error.responseText); - if ( 'name' in msg ) { - renderFormError(e, - element.find("#experiment-name"), - msg.name.toString(), - true); - } else if ( 'description' in msg ) { - renderFormError(e, - element.find("#experiment-description"), - msg.description.toString(), - true); - } else { - renderFormError(e, - element.find("#experiment-name"), - error.statusText, - true); - } - }) - } - } - // Initialize no description edit link function initEditNoDescription(){ var modal = "#edit-experiment-modal-"; diff --git a/app/assets/javascripts/step_comments.js b/app/assets/javascripts/step_comments.js index 4260a274f..f29dbaaf7 100644 --- a/app/assets/javascripts/step_comments.js +++ b/app/assets/javascripts/step_comments.js @@ -1,7 +1,3 @@ -// Place all the behaviors and hooks related to the matching controller here. -// All this logic will automatically be available in application.js. - - (function(){ function initializeComments(){ @@ -10,53 +6,57 @@ var that = $(this); var link = that.attr("data-href"); - $.ajax({ - method: 'GET', - url: link, - beforeSend: animateSpinner(that, true), - success: function(data){ - $(that.children()[0]).html(data.html); - commentFormOnSubmitAction(); + $.ajax({ method: 'GET', + url: link, + beforeSend: animateSpinner(that, true) }) + .done(function(data){ + // $(that.children()[0]).html(data.html); + debugger; + updateCommentHTML(that, data); animateSpinner(that, false); - }, - complete: animateSpinner(that, false) - }); + }) + .always(animateSpinner(that, false)); }); } function refreshComments(child){ var parent = child.closest(".step-comment"); var link = parent.attr("data-href"); - $.ajax({ - method: 'GET', - url: link, - beforeSend: animateSpinner(parent, true), - success: function(data){ + $.ajax({ method: 'GET', + url: link, + beforeSend: animateSpinner(parent, true) }) + .done(function(data){ updateCommentHTML(parent, data); animateSpinner(parent, false); - }, - complete: animateSpinner(parent, false) - }); + }) + .always(animateSpinner(parent, false)); + } function commentFormOnSubmitAction(){ + debugger; $(".comment-form") .each(function() { - bindCommentAjax($(this)); + bindCommentAjax($(this).attr("id")); }); } function bindCommentAjax(form){ - form - .ajaxSuccess( function(){ - refreshComments(form); + debugger; + $(document) + .on('ajax:success', function () { + debugger + refreshComments($(form)); + }) + .on('ajax:error', function () { + refreshComments(form); }); } function updateCommentHTML(parent, data) { - var comment_form = $(parent.find(".comment-form")); $(parent.children()[0]).html(data.html); - bindCommentAjax(comment_form); + var id = $(parent.find(".comment-form")).attr("id") + bindCommentAjax(id); } initializeComments(); diff --git a/app/assets/stylesheets/my_modules.scss b/app/assets/stylesheets/my_modules.scss index 89909c313..b4bcb3395 100644 --- a/app/assets/stylesheets/my_modules.scss +++ b/app/assets/stylesheets/my_modules.scss @@ -18,17 +18,7 @@ background-color: transparent !important; } -.step-comment { - border: 1px solid $color-gallery; -} - -.equal { - display: flex; - flex-wrap: wrap; - width: 100%; - - & > div[class*='col-'] { - display: flex; - flex-direction: column; - } +.step-container .row { + margin-left: 0; + margin-right: 0; } diff --git a/app/views/step_comments/_index.html.erb b/app/views/step_comments/_index.html.erb index b78a306d5..1b8dc1397 100644 --- a/app/views/step_comments/_index.html.erb +++ b/app/views/step_comments/_index.html.erb @@ -1,6 +1,4 @@ -