WIP: Aureplop/kpsul js refactor #501
2 changed files with 11 additions and 15 deletions
|
@ -177,12 +177,12 @@ function isValidTrigramme(trigramme) {
|
|||
|
||||
class UserDialog {
|
||||
|
||||
static get default_data() {
|
||||
return {'title': '', 'content': '', 'callback_as_dict': false};
|
||||
static get defaults() {
|
||||
return {'title': '', 'content': ''};
|
||||
}
|
||||
|
||||
constructor(data) {
|
||||
$.extend(this, this.constructor.default_data, data);
|
||||
$.extend(this, this.constructor.defaults, data);
|
||||
}
|
||||
|
||||
open(callback, errors, next_focus) {
|
||||
|
@ -195,18 +195,14 @@ class UserDialog {
|
|||
closeAnimation:'bottom',
|
||||
keyboardEnabled: true,
|
||||
confirm: function() {
|
||||
if (that.callback_as_dict) {
|
||||
var inputs = {};
|
||||
this.$content.find('input').each(function () {
|
||||
inputs[$(this).attr('name')] = $(this).val();
|
||||
});
|
||||
var inputs = {};
|
||||
this.$content.find('input').each(function () {
|
||||
inputs[$(this).attr('name')] = $(this).val();
|
||||
});
|
||||
if (Object.keys(inputs).length > 1)
|
||||
return callback(inputs);
|
||||
} else {
|
||||
var input_values = this.$content.find('input').map(function () {
|
||||
return $(this).val();
|
||||
}).get();
|
||||
return callback.apply(null, input_values);
|
||||
}
|
||||
else
|
||||
return callback(inputs[Object.keys(inputs)[0]]);
|
||||
},
|
||||
onOpen: function() {
|
||||
var that = this
|
||||
|
|
|
@ -243,7 +243,7 @@ $(document).ready(function() {
|
|||
if ('need_comment' in data['errors'])
|
||||
askComment(performOperations);
|
||||
else
|
||||
displayErrors(data);
|
||||
displayErrors(getErrorsHtml(data));
|
||||
},
|
||||
next_focus: articleSelect,
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue