Fix #1267 List is not renumbered after delete & Fix #1264 Can not add field, if there is no field in database

This commit is contained in:
Nicolas Le Goff
2013-07-10 19:24:19 +02:00
parent 14949cb619
commit 68ebcfddb5
8 changed files with 73 additions and 50 deletions

View File

@@ -37,24 +37,41 @@ define([
if (this._isModelDesync()) {
this._loadingState(true);
AdminFieldApp.fieldsCollection.save({
success: function(fields) {
// reset collection with new one
AdminFieldApp.fieldsCollection.reset(fields);
$.when.apply($, _.map(AdminFieldApp.fieldsToDelete, function(m){
return m.destroy({
success: function(model, response) {
AdminFieldApp.fieldsToDelete = _.filter(AdminFieldApp.fieldsToDelete, function(m){
return model.get("id") !== m.get("id");
});
},
error: function(xhr, textStatus, errorThrown) {
new AlertView({
alert: "error", message: '' !== xhr.responseText ? xhr.responseText : i18n.t("something_wrong")
}).render();
}
});
})).done(
function() {
AdminFieldApp.fieldsCollection.save({
success: function(fields) {
// reset collection with new one
AdminFieldApp.fieldsCollection.reset(fields);
new AlertView({
alert: "success",
message: i18n.t("fields_save")
}).render();
},
error: function(xhr, textStatus, errorThrown) {
new AlertView({
alert: "error", message: '' !== xhr.responseText ? xhr.responseText : i18n.t("something_wrong")
}).render();
new AlertView({
alert: "success",
message: i18n.t("fields_save")
}).render();
},
error: function(xhr, textStatus, errorThrown) {
new AlertView({
alert: "error", message: '' !== xhr.responseText ? xhr.responseText : i18n.t("something_wrong")
}).render();
}
}).done(function() {
self._loadingState(false);
});
}
}).done(function() {
self._loadingState(false);
});
);
}
return this;