mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 04:23:19 +00:00
Fix #1623 Can not display empty admin fields list
This commit is contained in:
@@ -189,12 +189,16 @@ define([
|
|||||||
|
|
||||||
// get previous index if exists else next index - 1 as item is being deleted
|
// get previous index if exists else next index - 1 as item is being deleted
|
||||||
var index = previousIndex ? previousIndex : (nextIndex ? nextIndex - 1 : -1);
|
var index = previousIndex ? previousIndex : (nextIndex ? nextIndex - 1 : -1);
|
||||||
|
|
||||||
modalView.render();
|
modalView.render();
|
||||||
modalView.on("modal:confirm", function () {
|
modalView.on("modal:confirm", function () {
|
||||||
AdminFieldApp.fieldsToDelete.push(self.model);
|
AdminFieldApp.fieldsToDelete.push(self.model);
|
||||||
AdminFieldApp.fieldListView.collection.remove(self.model);
|
AdminFieldApp.fieldListView.collection.remove(self.model);
|
||||||
|
// last item is deleted
|
||||||
|
if (index < 0) {
|
||||||
|
self.remove();
|
||||||
|
} else {
|
||||||
self._selectModelView(index);
|
self._selectModelView(index);
|
||||||
|
}
|
||||||
// Enable state button, models is out of sync
|
// Enable state button, models is out of sync
|
||||||
AdminFieldApp.saveView.updateStateButton(false);
|
AdminFieldApp.saveView.updateStateButton(false);
|
||||||
});
|
});
|
||||||
|
@@ -28,7 +28,7 @@ define([
|
|||||||
this.itemViews = [];
|
this.itemViews = [];
|
||||||
|
|
||||||
// force base 1 indexed
|
// force base 1 indexed
|
||||||
if (this.collection.first().get("sorter") === 0) {
|
if (this.collection.length > 0 && this.collection.first().get("sorter") === 0) {
|
||||||
this.collection.each(function (model) {
|
this.collection.each(function (model) {
|
||||||
model.set({'sorter': model.get("sorter") + 1}, {silent: true});
|
model.set({'sorter': model.get("sorter") + 1}, {silent: true});
|
||||||
});
|
});
|
||||||
|
@@ -85,14 +85,25 @@ define([
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
updateStateButton: function (disable) {
|
updateStateButton: function (disable) {
|
||||||
var toDisable = disable || !this._isModelDesync();
|
var toDisable = !this._isModelDesync();
|
||||||
|
if ("undefined" !== typeof disable) {
|
||||||
|
toDisable = disable;
|
||||||
|
}
|
||||||
|
|
||||||
this._disableSaveButton(toDisable);
|
this._disableSaveButton(toDisable);
|
||||||
},
|
},
|
||||||
// check whether model has changed or not
|
// check whether model has changed or not
|
||||||
_isModelDesync: function () {
|
_isModelDesync: function () {
|
||||||
return "undefined" !== typeof AdminFieldApp.fieldsCollection.find(function (model) {
|
var fieldToDelete = false;
|
||||||
|
var fieldToUpdate = false;
|
||||||
|
|
||||||
|
fieldToUpdate = "undefined" !== typeof AdminFieldApp.fieldsCollection.find(function (model) {
|
||||||
return !_.isEmpty(model.previousAttributes());
|
return !_.isEmpty(model.previousAttributes());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fieldToDelete = AdminFieldApp.fieldsToDelete.length > 0;
|
||||||
|
|
||||||
|
return fieldToUpdate || fieldToDelete;
|
||||||
},
|
},
|
||||||
// create a transparent overlay on top of the application
|
// create a transparent overlay on top of the application
|
||||||
_overlay: function (showOrHide) {
|
_overlay: function (showOrHide) {
|
||||||
|
Reference in New Issue
Block a user