make more ui settings sticky
This commit is contained in:
parent
631bd145b4
commit
9044cdf9c2
3 changed files with 102 additions and 23 deletions
|
@ -124,16 +124,6 @@
|
||||||
{"id": "size", "admin": true},
|
{"id": "size", "admin": true},
|
||||||
{"id": "pixels"}
|
{"id": "pixels"}
|
||||||
],
|
],
|
||||||
"uiDefaults": {
|
|
||||||
"list": {
|
|
||||||
"columns": ["id", "title", "director", "country", "year", "language", "runtime", "genre"],
|
|
||||||
"listView": "icons",
|
|
||||||
"selected": [],
|
|
||||||
"sort": [
|
|
||||||
{"key": "director", "operator": ""}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"user": {
|
"user": {
|
||||||
"group": "guest",
|
"group": "guest",
|
||||||
"lists": {
|
"lists": {
|
||||||
|
@ -169,6 +159,7 @@
|
||||||
"lists": {
|
"lists": {
|
||||||
"": {
|
"": {
|
||||||
"columns": ["id", "title", "director", "country", "year", "language", "runtime", "genre"],
|
"columns": ["id", "title", "director", "country", "year", "language", "runtime", "genre"],
|
||||||
|
"columnWidth": {},
|
||||||
"listView": "icons",
|
"listView": "icons",
|
||||||
"selected": [],
|
"selected": [],
|
||||||
"sort": [
|
"sort": [
|
||||||
|
|
|
@ -402,6 +402,24 @@ def setPreferences(request):
|
||||||
actions.register(setPreferences, cache=False)
|
actions.register(setPreferences, cache=False)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required_json
|
||||||
|
def resetUI(request):
|
||||||
|
'''
|
||||||
|
reset user ui settings to defaults
|
||||||
|
param data {
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
'status': {'code': int, 'text': string}
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
profile = request.user.get_profile()
|
||||||
|
profile.ui = {}
|
||||||
|
profile.save()
|
||||||
|
response = json_response()
|
||||||
|
return render_to_json_response(response)
|
||||||
|
actions.register(resetUI, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def setUI(request):
|
def setUI(request):
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -33,7 +33,7 @@ var pandora = new Ox.App({
|
||||||
pandora.app = app; // remove later
|
pandora.app = app; // remove later
|
||||||
|
|
||||||
if (app.user.group == 'guest') {
|
if (app.user.group == 'guest') {
|
||||||
app.user = data.config.user;
|
app.user = $.extend({}, app.config.user);
|
||||||
$.browser.safari && Ox.theme('modern');
|
$.browser.safari && Ox.theme('modern');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1138,18 +1138,31 @@ var pandora = new Ox.App({
|
||||||
return that;
|
return that;
|
||||||
},
|
},
|
||||||
list: function(view) { // fixme: remove view argument
|
list: function(view) { // fixme: remove view argument
|
||||||
var that, $map,
|
var that, $map;
|
||||||
keys = ['director', 'id', 'poster', 'title', 'year'];
|
|
||||||
//Ox.print('constructList', view);
|
//Ox.print('constructList', view);
|
||||||
if (view == 'list') {
|
if (view == 'list') {
|
||||||
|
/*
|
||||||
|
keys = Ox.unique($.merge(
|
||||||
|
$.map(app.user.ui.lists[app.user.ui.list].columns, function(id) {
|
||||||
|
return Ox.getObjectById(app.config.sortKeys, id);
|
||||||
|
}),
|
||||||
|
app.config.sortKeys
|
||||||
|
));
|
||||||
|
Ox.print('$$$$', keys)
|
||||||
|
*/
|
||||||
that = new Ox.TextList({
|
that = new Ox.TextList({
|
||||||
columns: $.map(app.config.sortKeys, function(key, i) {
|
columns: $.map(app.config.sortKeys, function(key, i) {
|
||||||
return $.extend({
|
var position = app.user.ui.lists[app.user.ui.list].columns.indexOf(key.id);
|
||||||
|
Ox.print(position, '++++', key.id, app.user.ui.lists[app.user.ui.list].columnWidth[key.id], key.width, '||:', app.user.ui.lists[app.user.ui.list].columnWidth[key.id] || key.width)
|
||||||
|
return $.extend($.extend({}, key), {
|
||||||
align: getAlignment(key.id),
|
align: getAlignment(key.id),
|
||||||
|
defaultWidth: key.width,
|
||||||
operator: getSortOperator(key.id),
|
operator: getSortOperator(key.id),
|
||||||
|
position: position,
|
||||||
unique: key.id == 'id',
|
unique: key.id == 'id',
|
||||||
visible: $.inArray(key.id, app.user.ui.lists[app.user.ui.list].columns) > -1
|
visible: position > -1,
|
||||||
}, key);
|
width: app.user.ui.lists[app.user.ui.list].columnWidth[key.id] || key.width
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
columnsMovable: true,
|
columnsMovable: true,
|
||||||
columnsRemovable: true,
|
columnsRemovable: true,
|
||||||
|
@ -1166,8 +1179,26 @@ var pandora = new Ox.App({
|
||||||
sort: app.user.ui.lists[app.user.ui.list].sort
|
sort: app.user.ui.lists[app.user.ui.list].sort
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
resize: function(event, data) {
|
columnchange: function(event, data) {
|
||||||
|
var columnWidth = {}
|
||||||
|
UI.set(['lists', app.user.ui.list, 'columns'].join('|'), data.ids);
|
||||||
|
/*
|
||||||
|
data.ids.forEach(function(id) {
|
||||||
|
columnWidth[id] =
|
||||||
|
app.user.ui.lists[app.user.ui.list].columnWidth[id] ||
|
||||||
|
Ox.getObjectById(app.config.sortKeys, id).width
|
||||||
|
});
|
||||||
|
UI.set(['lists', app.user.ui.list, 'columnWidth'].join('|'), columnWidth);
|
||||||
|
*/
|
||||||
|
},
|
||||||
|
columnresize: function(event, data) {
|
||||||
|
UI.set(['lists', app.user.ui.list, 'columnWidth', data.id].join('|'), data.width);
|
||||||
|
},
|
||||||
|
resize: function(event, data) { // this is the resize event of the split panel
|
||||||
that.size();
|
that.size();
|
||||||
|
},
|
||||||
|
sort: function(event, data) {
|
||||||
|
UI.set(['lists', app.user.ui.list, 'sort'].join('|'), [data]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (view == 'icons') {
|
} else if (view == 'icons') {
|
||||||
|
@ -1185,7 +1216,7 @@ var pandora = new Ox.App({
|
||||||
width: ratio >= 1 ? size : size * ratio
|
width: ratio >= 1 ? size : size * ratio
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
keys: keys,
|
keys: ['director', 'id', 'poster', 'title', 'year'],
|
||||||
request: function(data, callback) {
|
request: function(data, callback) {
|
||||||
//Ox.print('data, Query.toObject', data, Query.toObject())
|
//Ox.print('data, Query.toObject', data, Query.toObject())
|
||||||
pandora.api.find($.extend(data, {
|
pandora.api.find($.extend(data, {
|
||||||
|
@ -1745,6 +1776,7 @@ var pandora = new Ox.App({
|
||||||
UI.set({list: data.ids[0]});
|
UI.set({list: data.ids[0]});
|
||||||
URL.set('?find=list:' + data.ids[0]);
|
URL.set('?find=list:' + data.ids[0]);
|
||||||
} else {
|
} else {
|
||||||
|
UI.set({list: ''});
|
||||||
URL.set('');
|
URL.set('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1755,6 +1787,7 @@ var pandora = new Ox.App({
|
||||||
var isGuest = app.user.group == 'guest',
|
var isGuest = app.user.group == 'guest',
|
||||||
that = new Ox.MainMenu({
|
that = new Ox.MainMenu({
|
||||||
extras: [
|
extras: [
|
||||||
|
$('<div>').html('beta').css({marginRight: '4px'}),
|
||||||
app.$ui.loadingIcon = new Ox.LoadingIcon({
|
app.$ui.loadingIcon = new Ox.LoadingIcon({
|
||||||
size: 'medium'
|
size: 'medium'
|
||||||
})
|
})
|
||||||
|
@ -1904,7 +1937,8 @@ var pandora = new Ox.App({
|
||||||
{ id: 'help', title: app.config.site.name + ' Help', keyboard: 'shift ?' }
|
{ id: 'help', title: app.config.site.name + ' Help', keyboard: 'shift ?' }
|
||||||
] },
|
] },
|
||||||
{ id: 'debugMenu', title: 'Debug', items: [
|
{ id: 'debugMenu', title: 'Debug', items: [
|
||||||
{ id: 'query', title: 'Show Query' }
|
{ id: 'query', title: 'Show Query' },
|
||||||
|
{ id: 'resetui', title: 'Reset UI Settings'}
|
||||||
] },
|
] },
|
||||||
{ id: 'testMenu', title: 'Test', items: [
|
{ id: 'testMenu', title: 'Test', items: [
|
||||||
{ group: 'foogroup', items: [
|
{ group: 'foogroup', items: [
|
||||||
|
@ -2254,7 +2288,31 @@ var pandora = new Ox.App({
|
||||||
overflow: 'hidden'
|
overflow: 'hidden'
|
||||||
}).append($manage).open();
|
}).append($manage).open();
|
||||||
} else if (data.id == 'query') {
|
} else if (data.id == 'query') {
|
||||||
alert(JSON.stringify(Query.toObject()));
|
var $dialog = new Ox.Dialog({
|
||||||
|
buttons: [
|
||||||
|
new Ox.Button({
|
||||||
|
id: 'close',
|
||||||
|
title: 'Close'
|
||||||
|
}).bindEvent({
|
||||||
|
click: function() {
|
||||||
|
$dialog.close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
],
|
||||||
|
content: new Ox.Element()
|
||||||
|
.html([
|
||||||
|
'Query: ' + JSON.stringify(Query.toObject()),
|
||||||
|
'findQuery: ' + JSON.stringify(app.user.ui.findQuery),
|
||||||
|
'listQuery: ' + JSON.stringify(app.user.ui.listQuery)
|
||||||
|
].join('<br/><br/>')),
|
||||||
|
height: 200,
|
||||||
|
keys: {enter: 'close', escape: 'close'},
|
||||||
|
width: 400
|
||||||
|
}).open();
|
||||||
|
} else if (data.id == 'resetui') {
|
||||||
|
pandora.api.resetUI({}, function() {
|
||||||
|
app.$ui.appPanel.reload();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2652,7 +2710,7 @@ var pandora = new Ox.App({
|
||||||
type: data.id == 'new' ? 'static' : 'smart'
|
type: data.id == 'new' ? 'static' : 'smart'
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
id = result.data.id;
|
id = result.data.id;
|
||||||
UI.set(['lists', id].join('|'), app.config.uiDefaults.list);
|
UI.set(['lists', id].join('|'), app.config.user.ui.lists['']);
|
||||||
URL.set('?find=list:' + id)
|
URL.set('?find=list:' + id)
|
||||||
Ox.Request.emptyCache(); // fixme: remove
|
Ox.Request.emptyCache(); // fixme: remove
|
||||||
$list.reloadList().bindEvent({load: load});
|
$list.reloadList().bindEvent({load: load});
|
||||||
|
@ -3215,10 +3273,21 @@ var pandora = new Ox.App({
|
||||||
return {
|
return {
|
||||||
|
|
||||||
fromString: function(str) {
|
fromString: function(str) {
|
||||||
var query = Ox.unserialize(str.substr(1)),
|
var list = '',
|
||||||
|
query = Ox.unserialize(str.substr(1)),
|
||||||
sort = [];
|
sort = [];
|
||||||
if ('find' in query) {
|
if ('find' in query) {
|
||||||
|
app.user.ui.listQuery = {conditions: [], operator: ''}; // fixme: hackish
|
||||||
app.user.ui.findQuery = parseFind(query.find);
|
app.user.ui.findQuery = parseFind(query.find);
|
||||||
|
if (app.user.ui.listsQuery) {
|
||||||
|
list = app.user.ui.listsQuery.conditions[0].value;
|
||||||
|
UI.set({
|
||||||
|
list: list
|
||||||
|
});
|
||||||
|
!app.user.ui.lists[list] && UI.set(
|
||||||
|
'lists.' + list, app.config.user.ui.list
|
||||||
|
);
|
||||||
|
}
|
||||||
//Ox.print('user.ui.findQuery', app.user.ui.findQuery)
|
//Ox.print('user.ui.findQuery', app.user.ui.findQuery)
|
||||||
}
|
}
|
||||||
if ('sort' in query) {
|
if ('sort' in query) {
|
||||||
|
@ -3340,7 +3409,7 @@ var pandora = new Ox.App({
|
||||||
});
|
});
|
||||||
UI.set(['lists', app.user.ui.list, 'listView'].join('|'), url);
|
UI.set(['lists', app.user.ui.list, 'listView'].join('|'), url);
|
||||||
},
|
},
|
||||||
'^[0-9A-Z]': function() {
|
'^[0-9A-Z]': function(url) {
|
||||||
var split = url.split('/'),
|
var split = url.split('/'),
|
||||||
item = split[0],
|
item = split[0],
|
||||||
view = new RegExp(
|
view = new RegExp(
|
||||||
|
@ -3380,6 +3449,7 @@ var pandora = new Ox.App({
|
||||||
//Ox.print(url, 're', re)
|
//Ox.print(url, 're', re)
|
||||||
re = new RegExp(re);
|
re = new RegExp(re);
|
||||||
if (re(url)) {
|
if (re(url)) {
|
||||||
|
Ox.print('URL re ' + re)
|
||||||
fn(url);
|
fn(url);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue