v1.18.x
Baris Usakli 7 years ago
parent 852396e60d
commit 8276e20254

@ -75,8 +75,7 @@ define('admin/extend/widgets', ['jqueryui'], function () {
$('#save').on('click', saveWidgets);
function saveWidgets() {
var total = $('#widgets [data-template][data-location]').length;
var saveData = [];
$('#widgets [data-template][data-location]').each(function (i, el) {
el = $(el);
@ -112,26 +111,24 @@ define('admin/extend/widgets', ['jqueryui'], function () {
});
});
socket.emit('admin.widgets.set', {
saveData.push({
template: template,
location: location,
widgets: widgets,
}, function (err) {
total -= 1;
});
});
if (err) {
app.alertError(err.message);
}
socket.emit('admin.widgets.set', saveData, function (err) {
if (err) {
app.alertError(err.message);
}
if (total === 0) {
app.alert({
alert_id: 'admin:widgets',
type: 'success',
title: '[[admin/extend/widgets:alert.updated]]',
message: '[[admin/extend/widgets:alert.update-success]]',
timeout: 2500,
});
}
app.alert({
alert_id: 'admin:widgets',
type: 'success',
title: '[[admin/extend/widgets:alert.updated]]',
message: '[[admin/extend/widgets:alert.update-success]]',
timeout: 2500,
});
});
}

@ -149,11 +149,11 @@ SocketAdmin.plugins.upgrade = function (socket, data, callback) {
};
SocketAdmin.widgets.set = function (socket, data, callback) {
if (!data) {
if (!Array.isArray(data)) {
return callback(new Error('[[error:invalid-data]]'));
}
widgets.setArea(data, callback);
async.eachSeries(data, widgets.setArea, callback);
};
SocketAdmin.config.set = function (socket, data, callback) {

Loading…
Cancel
Save