Skip to content

Commit

Permalink
Added advance errors reporting inside handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
execut committed Mar 11, 2019
1 parent ed0ec78 commit ebb9cd6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
36 changes: 27 additions & 9 deletions widgets/assets/HandlersButton.js
Expand Up @@ -34,19 +34,30 @@
}

$.get(url, function (r) {
var resultError = [];
for (var modelName in r) {
for (var attribute in r[modelName]) {
for (var errorKey in r[modelName][attribute]) {
var error = r[modelName][attribute][errorKey];
resultError[resultError.length] = modelName + ': ' + error;
var content = '';
if (typeof r === 'string') {
content = r;
} else {
var resultError = [];
for (var modelName in r) {
for (var attribute in r[modelName]) {
for (var errorKey in r[modelName][attribute]) {
var error = r[modelName][attribute][errorKey];
resultError[resultError.length] = modelName + ': ' + error;
}
}
}

content = resultError.join('<br>');
}

t._setModalContent(content)
}).fail(function (r) {
if (r.status == 302 || r.status == 301) {
return;
}

t._modalEl.find('.modal-body').html(resultError.join('<br>'));
t._modalEl.modal('show');
el.attr('disabled', false);
t._setModalContent('Произошла ошибка №' + r.status + ': ' + r.responseText);
});
} else {
el.attr('disabled', false);
Expand All @@ -58,6 +69,13 @@
el = t.element;

return t.options.confirmMessage.replace('#', totalCount);
},
_setModalContent: function (content) {
var t = this,
el = t.element;
t._modalEl.find('.modal-body').html(content);
t._modalEl.modal('show');
el.attr('disabled', false);
}
})
})();
2 changes: 1 addition & 1 deletion widgets/assets/HandlersButton.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ebb9cd6

Please sign in to comment.