mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 20:13:28 +00:00
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:
@@ -970,8 +970,9 @@ class databox_field implements cache_cacheableInterface
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
if ($row)
|
||||
$sorter = (int) $row['sorter'];
|
||||
if ($row) {
|
||||
$sorter = max(1, (int) $row['sorter']);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO metadatas_structure
|
||||
(`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`,
|
||||
|
@@ -4,7 +4,7 @@
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="save_template">
|
||||
<button type="button" class="btn btn-large btn-success save-all">
|
||||
<button type="button" class="btn btn-success save-all">
|
||||
<i class="icon-hdd icon-white"></i> {% trans %}Save all changes{% endtrans %}
|
||||
</button>
|
||||
</script>
|
||||
@@ -248,7 +248,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="position">
|
||||
<%= position + 1 %>
|
||||
<%= position %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@@ -30,6 +30,7 @@ define([
|
||||
$bottom : $(".row-bottom", this.$scope),
|
||||
$leftBlock : $(".left-block", this.$bottom),
|
||||
$rightBlock : $(".right-block", this.$bottom),
|
||||
fieldsToDelete : [],
|
||||
resizeListBlock: function () {
|
||||
var listBlock = $(".list-block", AdminFieldApp.$leftBlock);
|
||||
listBlock.height(AdminFieldApp.$window.height() - listBlock.offset().top - 10);
|
||||
@@ -92,8 +93,10 @@ define([
|
||||
AdminFieldApp.$window.trigger("resize");
|
||||
|
||||
// click on first item list
|
||||
if (AdminFieldApp.fieldListView.itemViews.length > 0 ) {
|
||||
_.first(AdminFieldApp.fieldListView.itemViews).clickAction().animate();
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
@@ -122,10 +122,7 @@ define([
|
||||
"label_fr" : $("#new-label_fr", this.$el).val(),
|
||||
"label_de" : $("#new-label_de", this.$el).val(),
|
||||
"label_nl" : $("#new-label_nl", this.$el).val(),
|
||||
"multi": $("#new-multivalued", this.$el).is(":checked"),
|
||||
"sorter": AdminFieldApp.fieldsCollection.max(function(model) {
|
||||
return model.get("sorter");
|
||||
}).get("sorter") + 1
|
||||
"multi": $("#new-multivalued", this.$el).is(":checked")
|
||||
});
|
||||
|
||||
field.save(null, {
|
||||
|
@@ -183,23 +183,10 @@ define([
|
||||
|
||||
modalView.render();
|
||||
modalView.on("modal:confirm", function() {
|
||||
self.model.destroy({
|
||||
success: function(model, response) {
|
||||
AdminFieldApp.fieldsToDelete.push(self.model);
|
||||
AdminFieldApp.fieldListView.collection.remove(self.model);
|
||||
self._selectModelView(index);
|
||||
|
||||
new AlertView({alert: "info", message: i18n.t("deleted_success", {
|
||||
postProcess: "sprintf",
|
||||
sprintf: [model.get("name")]
|
||||
})
|
||||
}).render();
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
new AlertView({
|
||||
alert: "error", message: '' !== xhr.responseText ? xhr.responseText : i18n.t("something_wrong")
|
||||
}).render();
|
||||
}
|
||||
});
|
||||
AdminFieldApp.saveView.updateStateButton();
|
||||
});
|
||||
|
||||
return this;
|
||||
|
@@ -30,6 +30,7 @@ define([
|
||||
// rerender whenever there is a change on the collection
|
||||
this.collection.bind("reset", this.render, this);
|
||||
this.collection.bind("add", this.render, this);
|
||||
this.collection.bind("remove", this._onRemove, this);
|
||||
this.collection.bind("remove", this.render, this);
|
||||
|
||||
AdminFieldApp.errorManager.on('add-error', function(error) {
|
||||
@@ -112,15 +113,27 @@ define([
|
||||
|
||||
return this;
|
||||
},
|
||||
_onRemove : function (model) {
|
||||
var models = [];
|
||||
this.collection.each(function(m) {
|
||||
if (m.get("sorter") > model.get("sorter")) {
|
||||
m.set("sorter", m.get("sorter") - 1);
|
||||
}
|
||||
|
||||
models.push(m);
|
||||
});
|
||||
|
||||
this.collection.reset(models);
|
||||
},
|
||||
updateSortAction: function(event, model, ui) {
|
||||
var newPosition = ui.item.index();
|
||||
this.collection.remove(model, {silent: true});
|
||||
this.collection.each(function (model, index) {
|
||||
var ordinal = index;
|
||||
if (index >= newPosition) ordinal += 1;
|
||||
if (index >= newPosition) ordinal += 2; else ordinal += 1;
|
||||
model.set({'sorter': ordinal}, {silent: true});
|
||||
});
|
||||
model.set({'sorter': newPosition}, {silent: true});
|
||||
model.set({'sorter': newPosition + 1}, {silent: true});
|
||||
this.collection.add(model, {at: newPosition});
|
||||
|
||||
this.itemViews[0].animate(Math.abs(ui.firstItemPosition));
|
||||
|
@@ -37,6 +37,21 @@ define([
|
||||
|
||||
if (this._isModelDesync()) {
|
||||
this._loadingState(true);
|
||||
$.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
|
||||
@@ -56,6 +71,8 @@ define([
|
||||
self._loadingState(false);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@@ -53,6 +53,7 @@
|
||||
#admin-field-app #collection-fields li table {
|
||||
table-layout: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#admin-field-app #collection-fields li .field-name {
|
||||
@@ -221,6 +222,10 @@
|
||||
font-weight: bold
|
||||
}
|
||||
|
||||
#admin-field-app .save-all{
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
#admin-field-app .overlay {
|
||||
zoom: 1;
|
||||
filter: alpha(opacity=50);
|
||||
|
Reference in New Issue
Block a user