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