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', 'name': 'title',
}.get(e['key'], e['key']) }.get(e['key'], e['key'])
if key == 'resolution': if key == 'resolution':
order_by.append('%swidth'%operator) order_by.append('%swidth' % operator)
order_by.append('%sheight'%operator) order_by.append('%sheight' % operator)
else: else:
if '__' not in key: if '__' not in key and key not in ('created', 'modified'):
key = "%s%s" % (prefix, key) key = "%s%s" % (prefix, key)
order = '%s%s' % (operator, key) order = '%s%s' % (operator, key)
order_by.append(order) order_by.append(order)
@ -202,10 +202,11 @@ def get_item(query):
def parse_query(data, user): def parse_query(data, user):
query = {} query = {}
query['range'] = [0, 100] 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'): for key in ('keys', 'group', 'file', 'range', 'position', 'positions', 'sort'):
if key in data: if key in data:
query[key] = data[key] query[key] = data[key]
print(query.get('sort'), data.get('sort'))
query['qs'] = models.Document.objects.find(data, user) query['qs'] = models.Document.objects.find(data, user)
query['item'] = get_item(data.get('query', {})) query['item'] = get_item(data.get('query', {}))
return query return query

View file

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

View file

@ -56,6 +56,29 @@ pandora.ui.collection = function() {
columnsVisible: true, columnsVisible: true,
scrollbarVisible: 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') { } else if (view == 'grid') {
that = Ox.IconList({ that = Ox.IconList({
borderRadius: 0, borderRadius: 0,

View file

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