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

@ -163,10 +163,10 @@ def _order_query(qs, sort, item=None):
'name': 'title',
}.get(e['key'], e['key'])
if key == 'resolution':
order_by.append('%swidth'%operator)
order_by.append('%sheight'%operator)
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)
@ -202,10 +202,11 @@ def get_item(query):
def parse_query(data, user):
query = {}
query['range'] = [0, 100]
query['sort'] = [{'key':'user', 'operator':'+'}, {'key':'name', 'operator':'+'}]
query['sort'] = [{'key': 'user', 'operator': '+'}, {'key': 'name', 'operator': '+'}]
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

@ -49,7 +49,7 @@ def _order_query(qs, sort):
def parse_query(data, user):
query = {}
query['range'] = [0, 100]
query['sort'] = [{'key':'user', 'operator':'+'}, {'key':'name', 'operator':'+'}]
query['sort'] = [{'key': 'user', 'operator': '+'}, {'key': 'name', 'operator': '+'}]
for key in ('keys', 'group', 'collection', 'range', 'position', 'positions', 'sort'):
if key in data:
query[key] = data[key]

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({