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']
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]

View File

@ -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']

View File

@ -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;