fix sort in collection list view

This commit is contained in:
j 2017-03-02 12:37:53 +01:00
parent 812e8a8345
commit 72fdc8ed4d
4 changed files with 30 additions and 6 deletions

View file

@ -166,7 +166,7 @@ def _order_query(qs, sort, item=None):
order_by.append('%swidth' % operator)
order_by.append('%sheight' % operator)
else:
if '__' not in key:
if '__' not in key and key not in ('created', 'modified'):
key = "%s%s" % (prefix, key)
order = '%s%s' % (operator, key)
order_by.append(order)
@ -206,6 +206,7 @@ def parse_query(data, user):
for key in ('keys', 'group', 'file', 'range', 'position', 'positions', 'sort'):
if key in data:
query[key] = data[key]
print(query.get('sort'), data.get('sort'))
query['qs'] = models.Document.objects.find(data, user)
query['item'] = get_item(data.get('query', {}))
return query

View file

@ -56,6 +56,29 @@ pandora.ui.collection = function() {
columnsVisible: true,
scrollbarVisible: true,
})
.bindEvent({
columnchange: function(data) {
var columnWidth = {};
pandora.UI.set({collectionColumns: data.ids});
/*
data.ids.forEach(function(id) {
columnWidth[id] =
ui.collections[ui.collection].columnWidth[id]
|| Ox.getObjectById(pandora.site.sortKeys, id).width
});
pandora.UI.set({collectionColumnWidth: columnWidth});
*/
},
columnresize: function(data) {
pandora.UI.set('collectionColumnWidth.' + data.id, data.width);
},
sort: function(data) {
pandora.UI.set({
collectionSort: [{key: data.key, operator: data.operator}]
});
}
});
} else if (view == 'grid') {
that = Ox.IconList({
borderRadius: 0,

View file

@ -943,7 +943,7 @@ pandora.ui.documentsPanel = function(options) {
ui.part.documents && pandora.UI.set('part.documents', data.ids[0]);
},
sort: function(data) {
pandora.UI.set({documentsSort: [data]});
pandora.UI.set({collectionSort: [data]});
}
})
.bindEventOnce({