search / loading

This commit is contained in:
sanj 2011-01-12 02:02:18 +05:30
parent e685fb4ef4
commit 21884b6587
3 changed files with 22 additions and 11 deletions

View File

@ -87,11 +87,12 @@ class ItfModel(models.Model):
search = options['search'] search = options['search']
if search != '': if search != '':
qset = kls.fts(qset, search) qset = kls.fts(qset, search)
'''
sort = options['sort'] sort = options['sort']
if 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] r0 = options['range'][0]
r1 = options['range'][1] r1 = options['range'][1]
results = qset[r0:r1] results = qset[r0:r1]

View File

@ -12,7 +12,9 @@ class BestPractice(ItfModel):
quick_howto = models.TextField(blank=True) quick_howto = models.TextField(blank=True)
tags = TagField(blank=True, help_text="Enter as many tags as you like, separated by commas.") tags = TagField(blank=True, help_text="Enter as many tags as you like, separated by commas.")
category = models.ForeignKey("BestPracticeCategory") 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'] fts_fields = ['title', 'story', 'guideline', 'law', 'theatre', 'quick_howto']
fk_filters = ['category'] fk_filters = ['category']
sort_fields = ['title'] sort_fields = ['title']

View File

@ -722,13 +722,15 @@ Ox.ItfBox = function(options, self) {
.appendTo(that) .appendTo(that)
.hide() .hide()
.bindEvent("submit", function(value) { .bindEvent("submit", function(value) {
app.$ui[options.boxId].$loading.start();
$list.options("request", function(data, callback) { $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); that.$loading = new Ox.LoadingIcon().appendTo($buttons);
var $infoBtn = new Ox.Button({ var $infoBtn = new Ox.Button({
@ -841,13 +843,19 @@ Ox.ItfBox = function(options, self) {
unique: true unique: true
} }
], ],
'sort': [{ 'sort': [
key: 'title', {
operator: '-' key: 'added',
}] operator: '-'
},
{
key: 'id',
operator: '-'
}
]
}); });
var $list = new Ox.ItfList(listOptions) var $list = that.$list = new Ox.ItfList(listOptions)
.appendTo($listContainer); .appendTo($listContainer);
return that; return that;