From 21884b658713f8d4a38da88e589a94cfa3c162b1 Mon Sep 17 00:00:00 2001 From: sanj Date: Wed, 12 Jan 2011 02:02:18 +0530 Subject: [PATCH] search / loading --- itf/app/models.py | 7 ++++--- itf/bestpractices/models.py | 4 +++- itf/static/js/itf/itf.js | 22 +++++++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/itf/app/models.py b/itf/app/models.py index 8e9acbb..978b074 100644 --- a/itf/app/models.py +++ b/itf/app/models.py @@ -87,11 +87,12 @@ class ItfModel(models.Model): search = options['search'] if search != '': qset = kls.fts(qset, search) - ''' + sort = options['sort'] if sort != []: - qset = qset.order_by(sort[0]) #FIXME: Do Sort! - ''' + for s in sort: + sort = s['operator'] + s['key'] + qset = qset.order_by(sort) r0 = options['range'][0] r1 = options['range'][1] results = qset[r0:r1] diff --git a/itf/bestpractices/models.py b/itf/bestpractices/models.py index a03fbfb..f4edcc1 100644 --- a/itf/bestpractices/models.py +++ b/itf/bestpractices/models.py @@ -12,7 +12,9 @@ class BestPractice(ItfModel): quick_howto = models.TextField(blank=True) tags = TagField(blank=True, help_text="Enter as many tags as you like, separated by commas.") category = models.ForeignKey("BestPracticeCategory") - + added = models.DateTimeField(auto_now_add=True, null=True) + modified = models.DateTimeField(auto_now=True, null=True) + fts_fields = ['title', 'story', 'guideline', 'law', 'theatre', 'quick_howto'] fk_filters = ['category'] sort_fields = ['title'] diff --git a/itf/static/js/itf/itf.js b/itf/static/js/itf/itf.js index 6174770..f020985 100644 --- a/itf/static/js/itf/itf.js +++ b/itf/static/js/itf/itf.js @@ -722,13 +722,15 @@ Ox.ItfBox = function(options, self) { .appendTo(that) .hide() .bindEvent("submit", function(value) { + app.$ui[options.boxId].$loading.start(); $list.options("request", function(data, callback) { - return app.api.find(getQueryParams(data), callback) + app.$ui[options.boxId].$loading.stop(); + return app.api.find(getQueryParams(data), callback); }); }); - var $buttons = new Ox.Element().appendTo($title).css({'position': 'absolute', 'top': '1px', 'right': '1px'}); + var $buttons = new Ox.Element().appendTo($title).css({'position': 'absolute', 'top': '1px', 'right': '16px'}); that.$loading = new Ox.LoadingIcon().appendTo($buttons); var $infoBtn = new Ox.Button({ @@ -841,13 +843,19 @@ Ox.ItfBox = function(options, self) { unique: true } ], - 'sort': [{ - key: 'title', - operator: '-' - }] + 'sort': [ + { + key: 'added', + operator: '-' + }, + { + key: 'id', + operator: '-' + } + ] }); - var $list = new Ox.ItfList(listOptions) + var $list = that.$list = new Ox.ItfList(listOptions) .appendTo($listContainer); return that;