more app.config.itemKeys, more Ox.Filter

This commit is contained in:
rlx 2011-01-24 04:08:45 +00:00
parent a9f68c0337
commit 3439c30fbd
2 changed files with 323 additions and 226 deletions

View file

@ -32,341 +32,378 @@
{"id": "keyword", "title": "Keyword"} {"id": "keyword", "title": "Keyword"}
], ],
"itemKeys": [ "itemKeys": [
{ {
"id": "title", "id": "title",
"title": "Title", "title": "Title",
"type": "string", "type": "string",
"find": {"autocomplete": true, "autocompleteSortKey": "votes"}, "autocomplete": true,
"sort": {"removable": false, "type": "title", "width": 180} "autocompleteSortKey": "votes",
"columnRequired": true,
"columnWidth": 180,
"find": true,
"sort": "title"
}, },
{ {
"id": "director", "id": "director",
"title": "Director", "title": "Director",
"type": ["string"], "type": ["string"],
"find": {"autocomplete": true}, "autocomplete": true,
"sort": {"removable": false, "type": "person", "width": 180}, "columnRequired": true,
"group": true "columnWidth": 180,
"find": true,
"group": true,
"sort": "person"
}, },
{ {
"id": "country", "id": "country",
"title": "Country", "title": "Country",
"type": ["string"], "type": ["string"],
"find": {"autocomplete": true}, "autocomplete": true,
"sort": {"type": "string", "width": 120}, "columnWidth": 120,
"find": true,
"group": true "group": true
}, },
{ {
"id": "year", "id": "year",
"title": "Year", "title": "Year",
"type": "year", "type": "year",
"find": {"autocomplete": true}, "autocomplete": true,
"sort": {"type": "year", "width": 60}, "columnWidth": 60,
"find": true,
"group": true "group": true
}, },
{ {
"id": "language", "id": "language",
"title": "Language", "title": "Language",
"type": ["string"], "type": ["string"],
"find": {"autocomplete": true}, "autocomplete": true,
"sort": {"type": "string", "width": 120}, "columnWidth": 120,
"find": true,
"group": true "group": true
}, },
{ {
"id": "runtime", "id": "runtime",
"title": "Runtime", "title": "Runtime",
"type": "integer", "type": "integer",
"sort": {"type": "integer", "width": 60}, "columnWidth": 60,
"format": {"type": "duration", "args": [0, "medium"]} "format": {"type": "duration", "args": [0, "medium"]}
}, },
{ {
"id": "writer", "id": "writer",
"title": "Writer", "title": "Writer",
"type": ["string"], "type": ["string"],
"find": {"autocomplete": true}, "autocomplete": true,
"sort": {"type": "person", "width": 180}, "columnWidth": 180,
"group": true "find": true,
"group": true,
"sort": "person"
}, },
{ {
"id": "producer", "id": "producer",
"type": ["string"],
"title": "Producer", "title": "Producer",
"find": {"autocomplete": true}, "type": ["string"],
"sort": {"type": "person", "width": 180}, "autocomplete": true,
"group": true "columnWidth": 180,
"find": true,
"group": true,
"sort": "person"
}, },
{ {
"id": "cinematographer", "id": "cinematographer",
"title": "Cinematographer", "title": "Cinematographer",
"type": ["string"], "type": ["string"],
"find": {"autocomplete": true}, "autocomplete": true,
"sort": {"type": "person", "width": 180}, "columnWidth": 180,
"group": true "find": true,
"group": true,
"sort": "person"
}, },
{ {
"id": "editor", "id": "editor",
"title": "Editor", "title": "Editor",
"type": ["string"], "type": ["string"],
"find": {"autocomplete": true}, "autocomplete": true,
"sort": {"type": "person", "width": 180}, "columnWidth": 180,
"group": true "find": true,
"group": true,
"sort": "person"
}, },
{ {
"id": "actor", "id": "actor",
"title": "Actor", "title": "Actor",
"type": ["string"], "type": ["string"],
"find": {"autocomplete": true}, "autocomplete": true,
"group": true "find": true,
"group": true,
"sort": "person"
}, },
{ {
"id": "numberofactors", "id": "numberofactors",
"title": "Number of Actors", "title": "Number of Actors",
"sort": {"type": "integer", "width": 60}, "type": "integer",
"value": {"key": "actor", "type": "length"}, "columnWidth": 60,
"type": "integer" "value": {"key": "actor", "type": "length"}
}, },
{ {
"id": "character", "id": "character",
"title": "Character", "title": "Character",
"type": ["string"], "type": ["string"],
"find": {"autocomplete": true} "autocomplete": true,
"find": true,
"sort": "person"
}, },
{ {
"id": "name", "id": "name",
"title": "Name", "title": "Name",
"type": ["string"], "type": ["string"],
"find": {"autocomplete": true} "autocomplete": true,
"find": true
}, },
{ {
"id": "genre", "id": "genre",
"title": "Genre", "title": "Genre",
"type": ["string"], "type": ["string"],
"find": {"autocomplete": true}, "autocomplete": true,
"sort": {"type": "string", "width": 120}, "columnWidth": 120,
"find": true,
"group": true "group": true
}, },
{ {
"id": "keyword", "id": "keyword",
"title": "Keyword", "title": "Keyword",
"type": ["string"], "type": ["string"],
"find": {"autocomplete": true}, "autocomplete": true,
"find": true,
"group": true "group": true
}, },
{ {
"id": "numberofkeywords", "id": "numberofkeywords",
"title": "Number of Keyword", "title": "Number of Keywords",
"type": "integer", "type": "integer",
"sort": {"type": "integer", "width": 60}, "columnWidth": 60,
"value": {"key": "keyword", "type": "length"} "value": {"key": "keyword", "type": "length"}
}, },
{ {
"id": "summary", "id": "summary",
"title": "Summary", "title": "Summary",
"type": "text", "type": "text",
"group": false, "find": true
"find": {}
}, },
{ {
"id": "wordsinsummary", "id": "wordsinsummary",
"title": "Words in Summary", "title": "Words in Summary",
"sort": {"type": "integer", "width": 60},
"type": "integer", "type": "integer",
"columnWidth": 60,
"value": {"key": "summary", "type": "words"} "value": {"key": "summary", "type": "words"}
}, },
{
"id": "trivia",
"title": "Trivia",
"type": ["text"]
},
{ {
"id": "wordsintrivia", "id": "wordsintrivia",
"title": "Words in Trivia", "title": "Words in Trivia",
"type": "integer", "type": "integer",
"sort": {"type": "integer", "width": 60}, "columnWidth": 60,
"value": {"key": "trivia", "type": "words"} "value": {"key": "trivia", "type": "words"}
}, },
{ {
"id": "releasedate", "id": "releasedate",
"title": "Release Date", "title": "Release Date",
"sort": {"type": "date", "width": 120},
"type": "date", "type": "date",
"columnWidth": 120,
"format": {"type": "date", "args": ["%a, %b %e, %Y"]} "format": {"type": "date", "args": ["%a, %b %e, %Y"]}
}, },
{ {
"id": "budget", "id": "budget",
"title": "Budget", "title": "Budget",
"sort": {"type": "integer", "width": 90},
"type": "integer", "type": "integer",
"columnWidth": 90,
"format": {"type": "currency", "args": ["$", 0]} "format": {"type": "currency", "args": ["$", 0]}
}, },
{ {
"id": "gross", "id": "gross",
"title": "Gross", "title": "Gross",
"sort": {"type": "integer", "width": 90},
"type": "integer", "type": "integer",
"columnWidth": 90,
"format": {"type": "currency", "args": ["$", 0]} "format": {"type": "currency", "args": ["$", 0]}
}, },
{ {
"id": "profit", "id": "profit",
"title": "Profit", "title": "Profit",
"sort": {"type": "integer", "width": 90},
"type": "integer", "type": "integer",
"columnWidth": 90,
"format": {"type": "currency", "args": ["$", 0]} "format": {"type": "currency", "args": ["$", 0]}
}, },
{ {
"id": "rating", "id": "rating",
"title": "Rating", "title": "Rating",
"sort": {"type": "float", "width": 60},
"type": "float", "type": "float",
"columnWidth": 60,
"format": {"type": "percent", "args": [10, 2]} "format": {"type": "percent", "args": [10, 2]}
}, },
{ {
"id": "votes", "id": "votes",
"title": "Votes", "title": "Votes",
"sort": {"type": "integer", "width": 60},
"type": "integer", "type": "integer",
"format": {"type": "percent", "args": [403824, 2]} "columnWidth": 60,
"format": {"type": "percent", "args": ["auto", 2]}
}, },
{ {
"id": "id", "id": "id",
"title": "ID", "title": "ID",
"sort": {"type": "string", "width": 90}, "type": "string",
"type": "string" "columnWidth": 90
}, },
{ {
"id": "dialog", "id": "subtitles",
"title": "Dialog", "title": "Subtitles",
"type": "text", "type": "layer",
"group": false, "find": true
"find": {}
},
{
"id": "aspectratio",
"title": "Aspect Ratio",
"sort": {"type": "float", "width": 90},
"type": "float"
}, },
{ {
"id": "duration", "id": "duration",
"title": "Duration", "title": "Duration",
"sort": {"type": "float", "width": 90}, "type": "float",
"type": "float" "columnWidth": 90,
}, "format": {"type": "duration", "args": [0, "short"]}
{
"id": "color",
"title": "Color",
"sort": {"type": "float", "width": 90},
"type": "float"
},
{
"id": "saturation",
"title": "Saturation",
"sort": {"type": "float", "width": 60},
"type": "float"
},
{
"id": "brightness",
"title": "Brightness",
"sort": {"type": "float", "width": 60},
"type": "float"
},
{
"id": "volume",
"title": "Volume",
"sort": {"type": "float", "width": 60},
"type": "float"
},
{
"id": "clips",
"title": "Clips",
"sort": {"type": "integer", "width": 60},
"type": "integer"
},
{
"id": "cuts",
"title": "Cuts",
"sort": {"type": "integer", "width": 60},
"type": "integer"
},
{
"id": "cutsperminute",
"title": "Cuts per Minute",
"sort": {"type": "float", "width": 60},
"type": "float"
},
{
"id": "words",
"title": "Words",
"sort": {"type": "integer", "width": 60},
"type": "integer"
},
{
"id": "wordsperminute",
"title": "Words per Minute",
"sort": {"type": "float", "width": 60},
"type": "float"
}, },
{ {
"id": "resolution", "id": "resolution",
"title": "Resolution", "title": "Resolution",
"sort": {"type": "integer", "width": 90}, "type": ["integer"],
"type": "integer" "columnWidth": 90
},
{
"id": "aspectratio",
"title": "Aspect Ratio",
"type": "float",
"columnWidth": 90,
"format": {"type": "unit", "args": [":1"]}
}, },
{ {
"id": "pixels", "id": "pixels",
"title": "Pixels", "title": "Pixels",
"type": "integer", "type": "integer",
"group": false, "columnWidth": 90,
"sort": {"type": "integer", "width": 60}, "format": {"type": "value", "args": ["px"]}
"auto": true },
{
"id": "hue",
"title": "Hue",
"type": "hue",
"columnWidth": 90,
"format": {"type": "color", "args": ["hue"]}
},
{
"id": "saturation",
"title": "Saturation",
"type": "float",
"columnWidth": 90,
"format": {"type": "color", "args": ["greyscale"]}
},
{
"id": "lightness",
"title": "Lightness",
"type": "float",
"columnWidth": 90,
"format": {"type": "color", "args": ["greyscale"]}
},
{
"id": "volume",
"title": "Volume",
"type": "float",
"columnWidth": 60
},
{
"id": "numberofcuts",
"title": "Number of Cuts",
"type": "integer",
"columnWidth": 60,
"value": {"key": "cuts", "type": "length"}
},
{
"id": "cutsperminute",
"title": "Cuts per Minute",
"type": "float",
"columnWidth": 60,
"value": {"key": "cuts", "type": "lengthperminute"}
},
{
"id": "words",
"title": "Words",
"type": "integer",
"columnWidth": 60,
"value": {"layer": "subtitles", "type": "words"}
},
{
"id": "wordsperminute",
"title": "Words per Minute",
"type": "float",
"columnWidth": 60,
"value": {"layer": "subtitles", "type": "wordsperminute"}
}, },
{ {
"id": "size", "id": "size",
"title": "Size", "title": "Size",
"sort": {"type": "integer", "width": 60}, "type": "integer",
"type": "integer" "columnWidth": 60,
"format": {"type": "value", "args": ["B"]},
"rightsLevel": 1
}, },
{ {
"id": "bitrate", "id": "bitrate",
"title": "Bitrate", "title": "Bitrate",
"sort": {"type": "integer", "width": 60}, "type": "integer",
"type": "integer" "columnWidth": 60,
"format": {"type": "unit", "args": ["kbps"]}
}, },
{ {
"id": "files", "id": "numberoffiles",
"title": "Files", "title": "Number of Files",
"sort": {"type": "integer", "width": 60}, "type": "integer",
"type": "integer" "columnWidth": 60,
"value": {"key": "files", "type": "length"},
"rightsLevel": 1
}, },
{ {
"id": "filename", "id": "filename",
"title": "Filename", "title": "Filename",
"sort": {"type": "string", "width": 180}, "type": ["string"],
"type": "string" "find": true,
"rightsLevel": 1
}, },
{ {
"id": "published", "id": "published",
"title": "Date Published", "title": "Date Published",
"sort": {"type": "date", "width": 90}, "type": "date",
"type": "date" "columnWidth": 90
}, },
{ {
"id": "modified", "id": "modified",
"title": "Date Modified", "title": "Date Modified",
"sort": {"type": "date", "width": 90}, "type": "date",
"type": "date" "columnWidth": 90
}, },
{ {
"id": "accessed", "id": "accessed",
"title": "Date Accessed", "title": "Date Accessed",
"sort": {"type": "date", "width": 90}, "type": "date",
"type": "date" "columnWidth": 90
}, },
{ {
"id": "viewed", "id": "viewed",
"title": "Date Viewed", "title": "Date Viewed",
"sort": {"type": "date", "width": 90}, "type": "date",
"type": "date" "columnWidth": 90
}, },
{ {
"id": "popularity", "id": "popularity",
"title": "Popularity", "title": "Popularity",
"sort": {"type": "float", "width": 60}, "type": "integer",
"type": "float" "columnWidth": 60,
"format": {"type": "percent", "args": ["auto", 2]}
} }
], ],
"itemName": { "itemName": {
@ -384,8 +421,29 @@
{"id": "files", "title": "Files", "admin": true} {"id": "files", "title": "Files", "admin": true}
], ],
"layers": [ "layers": [
{"id": "privatenotes", "title": "Private Notes", "type": "text", "private": true}, {
{"id": "publicnotes", "title": "Public Notes", "type": "text"} "id": "privatenotes",
"title": "Private Notes",
"type": "text",
"overlap": true,
"private": true
},
{
"id": "publicnotes",
"title": "Public Notes",
"overlap": true,
"type": "text"
},
{
"id": "subtitles",
"title": "Subtitles",
"type": "text",
"overlay": true,
"sort": [
{"id": "words", "title": "Words", "type": "words"},
{"id": "wordsperminute", "title": "Words per Minute", "type": "wordsperminute"}
]
}
], ],
"listViews": [ "listViews": [
{"id": "list", "title": "as List"}, {"id": "list", "title": "as List"},
@ -499,7 +557,7 @@
"listQuery": {"conditions": [], "operator": ""}, "listQuery": {"conditions": [], "operator": ""},
"lists": { "lists": {
"": { "": {
"columns": ["id", "title", "director", "country", "year", "language", "runtime", "genre"], "columns": ["title", "director", "country", "year", "language", "runtime", "genre"],
"columnWidth": {}, "columnWidth": {},
"listView": "icons", "listView": "icons",
"selected": [], "selected": [],
@ -535,5 +593,6 @@
"videoSize": "small" "videoSize": "small"
}, },
"username": "" "username": ""
} },
"userLevels": ["guest", "member", "staff", "admin"]
} }

View file

@ -9,6 +9,10 @@ var pandora = new Ox.App({
//Ox.print('data', data); //Ox.print('data', data);
// fixme: never set ui.videoPosition to 0 ... set to null a.k.a. delete
// fixme: sort=-director doesn't work
// fixme: don't reload full right panel on sortSelect
var app = { var app = {
$ui: { $ui: {
body: $('body'), body: $('body'),
@ -21,10 +25,7 @@ var pandora = new Ox.App({
requests: {}, requests: {},
ui: { ui: {
findKeys: $.map(data.config.itemKeys, function(key, i) { findKeys: $.map(data.config.itemKeys, function(key, i) {
return 'find' in key ? $.extend({ return key.find ? key : null;
id: key.id,
title: key.title
}, key.find) : null;
}), }),
infoRatio: 16 / 9, infoRatio: 16 / 9,
scrollbarSize: $.browser.mozilla ? 16 : 12, scrollbarSize: $.browser.mozilla ? 16 : 12,
@ -55,10 +56,7 @@ var pandora = new Ox.App({
}, },
selectedMovies: [], selectedMovies: [],
sortKeys: $.map(data.config.itemKeys, function(key, i) { sortKeys: $.map(data.config.itemKeys, function(key, i) {
return 'sort' in key ? $.extend({ return key.columnWidth ? key : null;
id: key.id,
title: key.title
}, key.sort) : null;
}) })
}, },
user: data.user user: data.user
@ -660,6 +658,62 @@ var pandora = new Ox.App({
}) })
return that; return that;
}, },
filter: function() {
var that = new Ox.Filter({
findKeys: $.map(app.config.itemKeys, function(key) {
return {
autocomplete: key.autocomplete,
autocompleteSortKey: key.autocompleteSortKey,
format: key.format,
id: key.id,
title: key.title,
type: key.type
};
}),
sortKeys: app.ui.sortKeys,
viewKeys: app.config.listViews
});
return that;
},
filterDialog: function() {
var that = new Ox.Dialog({
buttons: [
new Ox.Button({
id: 'debug',
title: 'Debug',
})
.bindEvent({
click: function() {
alert(JSON.stringify(app.$ui.filter.options('query')));
}
}),
new Ox.Button({
id: 'cancel',
title: 'Cancel'
})
.bindEvent({
click: function() {
app.$ui.filterDialog.close();
}
}),
new Ox.Button({
id: 'save',
title: 'Save'
})
.bindEvent({
click: function() {
app.$ui.filterDialog.close();
}
})
],
content: app.$ui.filter = new ui.filter(),
height: 264,
keys: {enter: 'save', escape: 'cancel'},
title: 'Advanced Find',
width: 616 + app.ui.scrollbarSize
});
return that;
},
findElement: function() { findElement: function() {
var findKey = '', var findKey = '',
findValue = ''; findValue = '';
@ -688,29 +742,35 @@ var pandora = new Ox.App({
] : [], [ ] : [], [
app.$ui.findSelect = new Ox.Select({ app.$ui.findSelect = new Ox.Select({
id: 'select', id: 'select',
items: $.map(app.ui.findKeys, function(key, i) { items: $.merge($.map(app.ui.findKeys, function(key, i) {
return { return {
id: key.id, id: key.id,
checked: key.id == findKey, checked: key.id == findKey,
title: 'Find: ' + key.title title: 'Find: ' + key.title
}; };
}), }), [{}, {
id: 'advanced',
title: 'Find: Advanced'
}]),
overlap: 'right', overlap: 'right',
width: 112 width: 112
}) })
.bindEvent({ .bindEvent({
change: function(event, data) { change: function(event, data) {
var key = data.selected[0].id; var key = data.selected[0].id;
if (!app.user.ui.findQuery.conditions.length) { // fixme: can this case happen at all? if (key == 'advanced') {
app.user.ui.findQuery.conditions = [{key: key, value: '', operator: ''}]; app.$ui.filterDialog = ui.filterDialog().open();
} else { } else {
app.user.ui.findQuery.conditions[0].key = key; if (!app.user.ui.findQuery.conditions.length) { // fixme: can this case happen at all?
app.user.ui.findQuery.conditions = [{key: key, value: '', operator: ''}];
} else {
app.user.ui.findQuery.conditions[0].key = key;
}
app.$ui.mainMenu.checkItem('findMenu_find_' + key);
app.$ui.findInput.options({
autocomplete: autocompleteFunction()
}).focus();
} }
app.$ui.mainMenu.checkItem('findMenu_find_' + key);
app.$ui.findInput.options({
autocomplete: autocompleteFunction()
}).focus();
//Ox.print(app.$ui.findInput.options('autocomplete').toString())
} }
}), }),
app.$ui.findInput = new Ox.Input({ app.$ui.findInput = new Ox.Input({
@ -1139,31 +1199,7 @@ var pandora = new Ox.App({
click: function(event, data) { click: function(event, data) {
var $list = app.$ui.folderList[id]; var $list = app.$ui.folderList[id];
if (data.key == 'type') { if (data.key == 'type') {
var $dialog = new Ox.Dialog({ app.$ui.filterDialog = ui.filterDialog().open();
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.Filter({
keys: $.map(app.config.sortKeys, function(key) {
return {id: key.id, title: key.title, type: 'string'}
})
}),
height: 200,
keys: {enter: 'save', escape: 'cancel'},
title: 'Advanced Find',
width: 616 + app.ui.scrollbarSize
}).open();
} else if (data.key == 'status') { } else if (data.key == 'status') {
pandora.api.editList({ pandora.api.editList({
id: data.id, id: data.id,
@ -1869,16 +1905,22 @@ var pandora = new Ox.App({
that = new Ox.TextList({ that = new Ox.TextList({
columns: $.map(app.ui.sortKeys, function(key, i) { columns: $.map(app.ui.sortKeys, function(key, i) {
var position = app.user.ui.lists[app.user.ui.list].columns.indexOf(key.id); 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 {
return $.extend($.extend({}, key), { align: ['string', 'text'].indexOf(
align: getAlignment(key.id), Ox.isArray(key.type) ? key.type[0]: key.type
defaultWidth: key.width, ) > -1 ? 'left' : 'right',
defaultWidth: key.columnWidth,
format: key.format,
id: key.id,
operator: getSortOperator(key.id), operator: getSortOperator(key.id),
position: position, position: position,
removable: !key.columnRequired,
title: key.title,
type: key.type,
unique: key.id == 'id', unique: key.id == 'id',
visible: position > -1, visible: position > -1,
width: app.user.ui.lists[app.user.ui.list].columnWidth[key.id] || key.width width: app.user.ui.lists[app.user.ui.list].columnWidth[key.id] || key.columnWidth
}); };
}), }),
columnsMovable: true, columnsMovable: true,
columnsRemovable: true, columnsRemovable: true,
@ -3206,12 +3248,6 @@ var pandora = new Ox.App({
app.user.ui.showMovies && app.$ui.contentPanel.size(0, 112 + app.ui.scrollbarSize); app.user.ui.showMovies && app.$ui.contentPanel.size(0, 112 + app.ui.scrollbarSize);
} }
function getAlignment(key) { // fixme: make static
return ['person', 'string', 'text', 'title'].indexOf(
Ox.getObjectById(app.ui.sortKeys, key).type
) > -1 ? 'left' : 'right';
}
function getListData() { function getListData() {
var data = {}; var data = {};
if (app.user.ui.list) { if (app.user.ui.list) {
@ -3261,9 +3297,10 @@ var pandora = new Ox.App({
} }
function getSortOperator(key) { // fixme: make static function getSortOperator(key) { // fixme: make static
return ['person', 'string', 'text', 'title'].indexOf( var type = Ox.getObjectById(app.config.itemKeys, key).type;
Ox.getObjectById(app.ui.sortKeys, key).type return ['hue', 'string', 'text'].indexOf(
) > -1 ? '' : '-'; Ox.isArray(type) ? type[0] : type
) > -1 ? '+' : '-';
} }
function reloadGroups(i) { function reloadGroups(i) {
@ -3560,7 +3597,7 @@ var pandora = new Ox.App({
UI.set(['lists', app.user.ui.list, 'sort'].join('|'), $.map(query.sort.split(','), function(v, i) { UI.set(['lists', app.user.ui.list, 'sort'].join('|'), $.map(query.sort.split(','), function(v, i) {
var hasOperator = '+-'.indexOf(v[0]) > -1, var hasOperator = '+-'.indexOf(v[0]) > -1,
key = hasOperator ? query.sort.substr(1) : query.sort, key = hasOperator ? query.sort.substr(1) : query.sort,
operator = hasOperator ? v[0].replace('+', '') : getSortOperator(key); operator = hasOperator ? v[0]/*.replace('+', '')*/ : getSortOperator(key);
return { return {
key: key, key: key,
operator: operator operator: operator
@ -3596,10 +3633,12 @@ var pandora = new Ox.App({
toString: function() { toString: function() {
//Ox.print('tS', app.user.ui.find) //Ox.print('tS', app.user.ui.find)
var sort = app.user.ui.lists[app.user.ui.list].sort[0];
key = sort.key,
operator = sort.operator;
return '?' + Ox.serialize({ return '?' + Ox.serialize({
find: constructFind(Query.toObject()), find: constructFind(Query.toObject()),
sort: app.user.ui.lists[app.user.ui.list].sort[0].operator + sort: (operator == getSortOperator(key) ? '' : operator) + key,
app.user.ui.lists[app.user.ui.list].sort[0].key,
view: app.user.ui.lists[app.user.ui.list].listView view: app.user.ui.lists[app.user.ui.list].listView
}); });
} }
@ -3612,28 +3651,27 @@ var pandora = new Ox.App({
return { return {
set: function(obj) { set: function(obj) {
if (arguments.length == 2) { if (arguments.length == 2) {
// translate (key, value) to {key: value}
var obj_ = {}; var obj_ = {};
obj_[arguments[0]] = arguments[1]; obj_[arguments[0]] = arguments[1];
obj = obj_; obj = obj_;
} }
$.each(obj, function(key, val) { $.each(obj, function(key, val) {
Ox.print('key', key, 'val', val) Ox.print('key', key, 'val', val)
keys = key.split('|'); var i = 0,
if (keys.length == 1) { keys = key.split('|'),
app.user.ui[keys[0]] = val; old = app.user.ui;
} else if (keys.length == 2) { while (i < keys.length - 1) {
app.user.ui[keys[0]][keys[1]] = val; old = old[keys[i]];
} else if (keys.length == 3) { i++;
app.user.ui[keys[0]][keys[1]][keys[2]] = val; }
} else if (keys.length == 4) { if (old[keys[i]] !== val) {
app.user.ui[keys[0]][keys[1]][keys[2]][keys[3]] = val; old[keys[i]] = val;
} else if (keys.length == 5) { } else {
app.user.ui[keys[0]][keys[1]][keys[2]][keys[3]][keys[4]] = val; delete obj[key];
} else if (keys.length == 6) {
app.user.ui[keys[0]][keys[1]][keys[2]][keys[3]][keys[4]][keys[5]] = val;
} }
}); });
pandora.api.setUI(obj); Ox.length(obj) && pandora.api.setUI(obj);
//alert('set ' + JSON.stringify(obj)) //alert('set ' + JSON.stringify(obj))
} }
} }