From 72fdc8ed4d5af9f43f9637c59af4ac82952c6bba Mon Sep 17 00:00:00 2001 From: j Date: Thu, 2 Mar 2017 12:37:53 +0100 Subject: [PATCH] fix sort in collection list view --- pandora/document/views.py | 9 +++++---- pandora/documentcollection/views.py | 2 +- static/js/collection.js | 23 +++++++++++++++++++++++ static/js/documentsPanel.js | 2 +- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/pandora/document/views.py b/pandora/document/views.py index d8d356da..41d6ffea 100644 --- a/pandora/document/views.py +++ b/pandora/document/views.py @@ -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 diff --git a/pandora/documentcollection/views.py b/pandora/documentcollection/views.py index f31f50ba..09aff734 100644 --- a/pandora/documentcollection/views.py +++ b/pandora/documentcollection/views.py @@ -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] diff --git a/static/js/collection.js b/static/js/collection.js index c8a8c280..26a39560 100644 --- a/static/js/collection.js +++ b/static/js/collection.js @@ -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, diff --git a/static/js/documentsPanel.js b/static/js/documentsPanel.js index e7104a29..24d84ff2 100644 --- a/static/js/documentsPanel.js +++ b/static/js/documentsPanel.js @@ -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({