Fix error handling new task modal and completed task duplication[SCI-7722][SCI-7730]

This commit is contained in:
Anton 2023-01-16 10:46:48 +01:00
parent 78b4e71d3e
commit 3eb18a7cf4
4 changed files with 19 additions and 4 deletions

View file

@ -11,10 +11,18 @@
// Modal's submit handler function
$(experimentWrapper)
.on('ajax:success', newMyModuleModal, function() {
$(this).find('sci-input-container').removeClass('error');
$(newMyModuleModal).modal('hide');
})
.on('ajax:error', newMyModuleModal, function(ev, data) {
$(this).renderFormErrors('my_module', data.responseJSON);
let errors = data.responseJSON;
$(this).find('sci-input-container').removeClass('error');
if (errors.name) {
$(this).find('#my_module_name')
.parent()
.addClass('error')
.attr('data-error-text', errors.name.join(', '));
}
})
.on('submit', newMyModuleModal, function() {
// To submit correct assigned user ids to new modal

View file

@ -81,6 +81,10 @@
&.error {
padding-bottom: 6px;
label {
color: $brand-danger;
}
.sci-input-field {
border: $border-danger;
}

View file

@ -474,6 +474,7 @@ class ExperimentsController < ApplicationController
created_by: current_user,
due_date: nil,
started_on: nil,
state: 'uncompleted',
completed_on: nil
}.merge(new_my_module.get_new_position)
)

View file

@ -10,9 +10,11 @@
<div class="modal-body">
<%= f.hidden_field :view_mode, value: view_mode%>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 sci-input-container form-group">
<label><%= t('experiments.canvas.new_my_module_modal.name') %></label>
<%= text_field_tag 'my_module[name]', '', placeholder: t('experiments.canvas.new_my_module_modal.name_placeholder'), class: "sci-input-field" %>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="sci-input-container form-group">
<label><%= t('experiments.canvas.new_my_module_modal.name') %></label>
<%= text_field_tag 'my_module[name]', '', placeholder: t('experiments.canvas.new_my_module_modal.name_placeholder'), class: "sci-input-field" %>
</div>
</div>
</div>
<div class="row">