fix error message when editing custom column on locked task

This commit is contained in:
Mojca Lorber 2017-03-15 14:09:44 +01:00
parent 7a4e3201e7
commit 4792bd87b9
2 changed files with 50 additions and 28 deletions

View file

@ -1193,8 +1193,14 @@ function changeToEditMode() {
cancelEditMode(); cancelEditMode();
var self = $(this); var li = $(this).closest('li');
var li = self.closest('li'); var url = li.attr('data-edit-url') + "/electronic_sign_edit";
ajaxCallEvent();
function ajaxCallEvent(){
$.ajax({
url: url,
success: function() {
var text = li.find('.text'); var text = li.find('.text');
if ($(text).find('.modal-tooltiptext').length > 0) { if ($(text).find('.modal-tooltiptext').length > 0) {
text = $(text).find('.modal-tooltiptext'); text = $(text).find('.modal-tooltiptext');
@ -1221,6 +1227,22 @@ function changeToEditMode() {
}); });
// Focus input // Focus input
textEdit.focus(); textEdit.focus();
},
error: function(e) {
$(li).clearFormErrors();
var msg = $.parseJSON(e.responseText);
renderFormError(undefined,
$(li).find('.text-edit'),
Object.keys(msg)[0] + ' ' + msg.name.toString());
var verticalHeight = $(li).offset().top;
dropdownList.scrollTo(verticalHeight,0);
setTimeout(function() {
$(li).clearFormErrors();
}, 5000);
}
});
}
}); });
// On hiding dropdown, cancel edit mode throughout dropdown // On hiding dropdown, cancel edit mode throughout dropdown

View file

@ -1,7 +1,7 @@
class CustomFieldsController < ApplicationController class CustomFieldsController < ApplicationController
include InputSanitizeHelper include InputSanitizeHelper
before_action :load_vars, only: [:update, :destroy, :destroy_html] before_action :load_vars, except: :create
before_action :load_vars_nested, only: [:create, :destroy_html] before_action :load_vars_nested, only: [:create, :destroy_html]
before_action :check_create_permissions, only: :create before_action :check_create_permissions, only: :create
before_action :check_update_permissions, only: :update before_action :check_update_permissions, only: :update