forked from 0x2620/pandora
some more improvements to lists
This commit is contained in:
parent
839c9761fd
commit
a16439022c
4 changed files with 88 additions and 42 deletions
|
@ -37,7 +37,6 @@ def parseCondition(condition, user):
|
|||
else:
|
||||
exclude = False
|
||||
if k == 'subscribed':
|
||||
print "FXIME, subscribed needs work"
|
||||
key = 'subscribed_users__username'
|
||||
v = user.username
|
||||
elif isinstance(v, bool): #featured and public flag
|
||||
|
|
|
@ -30,10 +30,10 @@ 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':'position__position', 'operator':'+'}]
|
||||
query['sort'] = [{'key':'user', 'operator':'+'}, {'key':'name', 'operator':'+'}]
|
||||
#query['sort'] = [{'key':'position__position', 'operator':'+'}]
|
||||
query['sort'] = [{'key':'name', 'operator':'+'}]
|
||||
for key in ('keys', 'group', 'list', 'range', 'ids'):
|
||||
for key in ('keys', 'group', 'list', 'range', 'ids', 'sort'):
|
||||
if key in data:
|
||||
query[key] = data[key]
|
||||
query['qs'] = models.List.objects.find(data, user)
|
||||
|
@ -77,10 +77,16 @@ def findLists(request):
|
|||
query = _parse_query(data, request.user)
|
||||
|
||||
#order
|
||||
#FIXME: having to use distinct here seams wrong
|
||||
qs = _order_query(query['qs'].distinct(), query['sort'])
|
||||
#qs = query['qs'].distinct().order_by('position__position')
|
||||
#qs = query['qs']
|
||||
is_section_request = query['sort'] == [{u'operator': u'+', u'key': u'position'}]
|
||||
is_featured = len(filter(lambda x: x['key'] == 'status' and x['value'] == 'featured' and x['operator'] == '=', data['query'].get('conditions', []))) > 0
|
||||
|
||||
if is_section_request:
|
||||
qs = query['qs']
|
||||
if not is_featured:
|
||||
qs = qs.filter(position__in=models.Position.objects.filter(user=request.user))
|
||||
qs = qs.order_by('position__position')
|
||||
else:
|
||||
qs = _order_query(query['qs'], query['sort'])
|
||||
|
||||
#range
|
||||
response = json_response()
|
||||
|
@ -225,6 +231,9 @@ def editList(request):
|
|||
if value not in list._status:
|
||||
value = list._status[0]
|
||||
setattr(list, key, value)
|
||||
if value == 'private':
|
||||
for user in list.subscribed_users.all():
|
||||
list.subscribed_users.remove(user)
|
||||
elif key == 'name':
|
||||
name = data['name']
|
||||
num = 1
|
||||
|
|
|
@ -37,9 +37,7 @@ class UserProfile(models.Model):
|
|||
ui['lists'][''] = site_config['uiDefaults']['list']
|
||||
|
||||
def add(lists, section):
|
||||
print lists, section
|
||||
ids = [l.get_id() for l in lists]
|
||||
in_list = filter(lambda l: l in ui['lists'], ids)
|
||||
ids = []
|
||||
for l in lists:
|
||||
if section == 'featured':
|
||||
pos, created = Position.objects.get_or_create(list=l, section=section)
|
||||
|
@ -49,11 +47,10 @@ class UserProfile(models.Model):
|
|||
pos.position = len(in_list)
|
||||
pos.save()
|
||||
id = l.get_id()
|
||||
if id not in in_list:
|
||||
if id not in ui['lists']:
|
||||
ui['lists'][id] = {}
|
||||
ui['lists'][id].update(ui['lists'][''])
|
||||
in_list.append(id)
|
||||
ui['lists'][id]['position'] = pos.position
|
||||
ids.append(id)
|
||||
return ids
|
||||
|
||||
ids = ['']
|
||||
|
|
|
@ -1097,11 +1097,14 @@ var pandora = new Ox.App({
|
|||
app.$ui.leftPanel.find('.OxTextList').css({
|
||||
width: data + 'px'
|
||||
});
|
||||
app.$ui.leftPanel.find('.OxTextList .OxContent').css({
|
||||
width: data + 'px'
|
||||
});
|
||||
app.$ui.leftPanel.find('.OxItem').css({
|
||||
width: data + 'px'
|
||||
});
|
||||
app.$ui.leftPanel.find('.OxCell.OxColumnName').css({
|
||||
width: (data - 80) + 'px'
|
||||
width: (data - 88) + 'px'
|
||||
});
|
||||
//*/
|
||||
Ox.print('resize', data, data / app.ui.infoRatio + 16);
|
||||
|
@ -2130,6 +2133,17 @@ var pandora = new Ox.App({
|
|||
$sections.push($section);
|
||||
app.$ui.sectionLists[i] = new Ox.TextList({
|
||||
columns: [
|
||||
{
|
||||
id: 'user',
|
||||
format: function() {
|
||||
return $('<img>').attr({
|
||||
src: 'static/oxjs/build/png/ox.ui/icon16.png'
|
||||
});
|
||||
},
|
||||
operator: '+',
|
||||
visible: true,
|
||||
width: 16
|
||||
},
|
||||
{
|
||||
id: 'id',
|
||||
format: function(value) {
|
||||
|
@ -2138,21 +2152,21 @@ var pandora = new Ox.App({
|
|||
operator: '+',
|
||||
unique: true,
|
||||
visible: id == 'public',
|
||||
width: 184
|
||||
width: 168
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
editable: id == 'my' ? true : (id == 'featured' ? function(data) {
|
||||
Ox.print('########', data, app.user.username)
|
||||
return data.id && data.id.split(': ')[0] == app.user.username;
|
||||
} : false),
|
||||
editable: function(data) {
|
||||
return data.user == app.user.username;
|
||||
// return data.id && data.id.split(': ')[0] == app.user.username;
|
||||
},
|
||||
id: 'name',
|
||||
input: {
|
||||
autovalidate: autovalidateListname
|
||||
},
|
||||
operator: '+',
|
||||
visible: id != 'public',
|
||||
width: 184
|
||||
width: 168
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
|
@ -2163,13 +2177,23 @@ var pandora = new Ox.App({
|
|||
},
|
||||
{
|
||||
align: 'left',
|
||||
clickable: function(data) {
|
||||
//alert(JSON.stringify([data.user, data.type]))
|
||||
Ox.print('$$$$$$$$', data.user, data.type)
|
||||
return data.user == app.user.username && data.type == 'smart';
|
||||
},
|
||||
format: function(value) {
|
||||
return $('<img>').attr({
|
||||
src: 'static/oxjs/build/png/ox.ui.modern/symbol' +
|
||||
(value ? 'Find' : 'None') + '.png'
|
||||
// var symbols = {static: 'Click', smart: 'Find'};
|
||||
return $('<img>')
|
||||
.attr({
|
||||
src: 'static/oxjs/build/png/ox.ui.' + Ox.theme() +
|
||||
'/symbolFind.png'
|
||||
})
|
||||
.css({
|
||||
opacity: value == 'static' ? 0.1 : 1
|
||||
});
|
||||
},
|
||||
id: 'query',
|
||||
id: 'type',
|
||||
operator: '+',
|
||||
visible: true,
|
||||
width: 16
|
||||
|
@ -2178,11 +2202,15 @@ var pandora = new Ox.App({
|
|||
align: 'left',
|
||||
clickable: id == 'my',
|
||||
format: function(value) {
|
||||
var symbols = {private: 'None', public: 'Publish', featured: 'Star'};
|
||||
return $('<img>').attr({
|
||||
src: 'static/oxjs/build/png/ox.ui.modern/symbol' +
|
||||
symbols[value] + '.png'
|
||||
});
|
||||
//var symbols = {private: 'Publish', public: 'Publish', featured: 'Star'};
|
||||
return $('<img>')
|
||||
.attr({
|
||||
src: 'static/oxjs/build/png/ox.ui.' + Ox.theme() + '/symbol'
|
||||
+ (value == 'featured' ? 'Star' : 'Publish') + '.png'
|
||||
})
|
||||
.css({
|
||||
opacity: value == 'private' ? 0.1 : 1
|
||||
})
|
||||
},
|
||||
id: 'status',
|
||||
operator: '+',
|
||||
|
@ -2227,8 +2255,28 @@ var pandora = new Ox.App({
|
|||
.bindEvent({
|
||||
click: function(event, data) {
|
||||
var list = app.$ui.sectionLists[i];
|
||||
if (data.key == 'query') {
|
||||
|
||||
if (data.key == 'type') {
|
||||
var $dialog = new Ox.Dialog({
|
||||
buttons: [
|
||||
new Ox.Button({
|
||||
id: 'cancel',
|
||||
title: 'Cancel'
|
||||
}).bindEvent('click', function() {
|
||||
$dialog.close();
|
||||
}),
|
||||
new Ox.Button({
|
||||
id: 'save',
|
||||
title: 'Save'
|
||||
}).bindEvent('click', function() {
|
||||
$dialog.close();
|
||||
})
|
||||
],
|
||||
content: new Ox.Element('div').html('...'),
|
||||
height: 200,
|
||||
keys: {enter: 'save', escape: 'cancel'},
|
||||
title: 'Advanced Find',
|
||||
width: 640
|
||||
}).open();
|
||||
} else if (data.key == 'status') {
|
||||
pandora.api.editList({
|
||||
id: data.id,
|
||||
|
@ -2252,23 +2300,16 @@ var pandora = new Ox.App({
|
|||
app.user.ui.lists[id].position = pos;
|
||||
});
|
||||
*/
|
||||
// fixme: only one of the below
|
||||
// (and then Ox.List can send less event data)
|
||||
pandora.api.editList({
|
||||
id: data.id,
|
||||
position: data.position
|
||||
});
|
||||
/*
|
||||
pandora.api.sortLists({
|
||||
section: id,
|
||||
ids: data.ids
|
||||
});
|
||||
*/
|
||||
},
|
||||
select: function(event, data) {
|
||||
app.$ui.sectionLists.forEach(function($list, i_) {
|
||||
i != i_ && $list.options('selected', []);
|
||||
});
|
||||
URL.set('?find=list:' + data.ids[0]);
|
||||
},
|
||||
submit: function(event, data) {
|
||||
data_ = {id: data.id};
|
||||
|
@ -2775,7 +2816,7 @@ var pandora = new Ox.App({
|
|||
if (app.user.ui.section == 'items') {
|
||||
if (!old.user.ui.item) {
|
||||
if (!app.user.ui.item) {
|
||||
|
||||
app.$ui.mainPanel.replace(1, app.$ui.rightPanel = ui.rightPanel());
|
||||
} else {
|
||||
app.$ui.mainPanel.replace(1, app.$ui.rightPanel = ui.rightPanel());
|
||||
//app.$ui.rightPanel.replace(0, app.$ui.toolbar = ui.toolbar());
|
||||
|
|
Loading…
Reference in a new issue