Skip to content

Commit

Permalink
see #623 fix caching issue, also we are now doing a single ajax call …
Browse files Browse the repository at this point in the history
…to update all the priorities
  • Loading branch information
ernestob committed Sep 6, 2019
1 parent fa368a9 commit 0f387f4
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions design/admin/javascript/admin2pp_dragndrop_children.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,33 @@ admin2ppDragNDropChildren.prototype = {
var start = +inputs.first().text();
var increments = admin2ppDragNDropChildren.PRIORITY_OFFSET * this.sortOrder;
var instance = this;
var recordPriorityIDs = [];
var recordPriorities = [];
inputs.each(function() {
jQuery( this ).text( start );
var recordId = jQuery( this ).closest('tr').attr('id');
var record = subItemsTable.getRecordSet().getRecord(recordId);
instance.updatePriority(record, start);
recordPriorityIDs.push(record.getData('node_id'));
recordPriorities.push(start);
record.setData('priority', start);
start = start + increments;
});
instance.updatePriority(recordPriorityIDs, recordPriorities);
},

updatePriority: function(record, priority) {
var sortedBy = subItemsTable.get('sortedBy'),
paginator = subItemsTable.get('paginator')
;
record.setData('priority', priority);

jQuery.ez('ezjscnode::updatepriority', {
ContentNodeID: record.getData('parent_node_id'),
ContentObjectID: record.getData('contentobject_id'),
PriorityID: [record.getData('node_id')],
Priority: [priority]
}, onSuccess);
updatePriority: function(recordPriorityIDs, recordPriorities) {

var onSuccess = function(data) {
record.setData('priority', priority);
// Clear JS cache
subItemsTable.getDataSource().flushCache();
}

jQuery.ez('ezjscnode::updatepriority', {
ContentNodeID: $('input[name="ContentNodeID"]').val(),
ContentObjectID: $('input[name="ContentObjectID"]').val(),
PriorityID: recordPriorityIDs,
Priority: recordPriorities
}, onSuccess);
},

fixBackgrounds:function() {
Expand Down

0 comments on commit 0f387f4

Please sign in to comment.