add lists to menu
This commit is contained in:
parent
7576482b37
commit
494a022f82
4 changed files with 72 additions and 24 deletions
|
@ -51,6 +51,7 @@ Ox.load({
|
||||||
site: data.site,
|
site: data.site,
|
||||||
user: data.user.level == 'guest' ? Ox.clone(data.site.user) : data.user
|
user: data.user.level == 'guest' ? Ox.clone(data.site.user) : data.user
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
// ---- fixme: remove, server sends wrong data
|
// ---- fixme: remove, server sends wrong data
|
||||||
pandora.site.user.ui.lists = {
|
pandora.site.user.ui.lists = {
|
||||||
"": {
|
"": {
|
||||||
|
@ -71,6 +72,7 @@ Ox.load({
|
||||||
{"id": "genre", "sort": [{"key": "items", "operator": "-"}]}
|
{"id": "genre", "sort": [{"key": "items", "operator": "-"}]}
|
||||||
];
|
];
|
||||||
// ----
|
// ----
|
||||||
|
*/
|
||||||
Ox.print("USER.UI.LISTS", data.user.ui.lists, "SITE.USER.UI.LISTS", data.site.user.ui.lists)
|
Ox.print("USER.UI.LISTS", data.user.ui.lists, "SITE.USER.UI.LISTS", data.site.user.ui.lists)
|
||||||
Ox.extend(pandora.site, {
|
Ox.extend(pandora.site, {
|
||||||
findKeys: Ox.map(data.site.itemKeys, function(key) {
|
findKeys: Ox.map(data.site.itemKeys, function(key) {
|
||||||
|
|
|
@ -322,6 +322,32 @@ pandora.getListData = function() {
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pandora.getListMenu = function(lists) {
|
||||||
|
return { id: 'listMenu', title: 'List', items: [
|
||||||
|
{ id: 'history', title: 'History', items: [
|
||||||
|
{ id: 'allmovies', title: 'All ' + pandora.site.itemName.plural }
|
||||||
|
] },
|
||||||
|
{ id: 'viewlist', title: 'View List', items: lists ? ['personal', 'favorite', 'featured'].map(function(folder) {
|
||||||
|
return { id: folder + 'lists', title: Ox.toTitleCase(folder) + ' Lists', items: [
|
||||||
|
{ group: folder + 'lists', min: 0, max: 1, items: lists[folder].map(function(list) {
|
||||||
|
return { id: 'viewlist' + list.id, title: (folder == 'favorite' ? list.user + ': ' : '') + list.name, checked: list.id == pandora.user.ui.list };
|
||||||
|
}) }
|
||||||
|
] };
|
||||||
|
}) : [
|
||||||
|
{ id: 'loading', title: 'Loading...', disabled: true }
|
||||||
|
] },
|
||||||
|
{},
|
||||||
|
{ id: 'newlist', title: 'New List...', keyboard: 'control n' },
|
||||||
|
{ id: 'newlistfromselection', title: 'New List from Selection...', disabled: true, keyboard: 'shift control n' },
|
||||||
|
{ id: 'newsmartlist', title: 'New Smart List...', keyboard: 'alt control n' },
|
||||||
|
{ id: 'newsmartlistfromresults', title: 'New Smart List from Results...', keyboard: 'shift alt control n' },
|
||||||
|
{},
|
||||||
|
{ id: 'addmovietolist', title: ['Add Selected ' + pandora.site.itemName.singular + ' to List...', 'Add Selected ' + pandora.site.itemName.plural + ' to List...'], disabled: true },
|
||||||
|
{},
|
||||||
|
{ id: 'setposterframe', title: 'Set Poster Frame', disabled: true }
|
||||||
|
] };
|
||||||
|
};
|
||||||
|
|
||||||
pandora.getSortMenu = function() {
|
pandora.getSortMenu = function() {
|
||||||
var list = pandora.user.ui.lists[pandora.user.ui.list],
|
var list = pandora.user.ui.lists[pandora.user.ui.list],
|
||||||
isClipView = pandora.isClipView(list.listView);
|
isClipView = pandora.isClipView(list.listView);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||||
|
// fixme: the filename should be folderList.js
|
||||||
pandora.ui.folderList = function(id) {
|
pandora.ui.folderList = function(id) {
|
||||||
var i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id),
|
var i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id),
|
||||||
that;
|
that;
|
||||||
|
@ -119,7 +120,9 @@ pandora.ui.folderList = function(id) {
|
||||||
{key: 'status', value: 'featured', operator: '!'},
|
{key: 'status', value: 'featured', operator: '!'},
|
||||||
], operator: '&'};
|
], operator: '&'};
|
||||||
} else if (id == 'featured') {
|
} else if (id == 'featured') {
|
||||||
query = {conditions: [{key: 'status', value: 'featured', operator: '='}], operator: '&'};
|
query = {conditions: [
|
||||||
|
{key: 'status', value: 'featured', operator: '='}
|
||||||
|
], operator: '&'};
|
||||||
}
|
}
|
||||||
return pandora.api.findLists(Ox.extend(data, {
|
return pandora.api.findLists(Ox.extend(data, {
|
||||||
query: query
|
query: query
|
||||||
|
|
|
@ -32,27 +32,7 @@ pandora.ui.mainMenu = function() {
|
||||||
{ id: 'signup', title: 'Sign Up...', disabled: !isGuest },
|
{ id: 'signup', title: 'Sign Up...', disabled: !isGuest },
|
||||||
{ id: 'signinsignout', title: isGuest ? 'Sign In...' : 'Sign Out...' }
|
{ id: 'signinsignout', title: isGuest ? 'Sign In...' : 'Sign Out...' }
|
||||||
] },
|
] },
|
||||||
{ id: 'listMenu', title: 'List', items: [
|
pandora.getListMenu(),
|
||||||
{ id: 'history', title: 'History', items: [
|
|
||||||
{ id: 'allmovies', title: 'All ' + pandora.site.itemName.plural }
|
|
||||||
] },
|
|
||||||
{ id: 'lists', title: 'View List', items: [
|
|
||||||
{ id: 'favorites', title: 'Favorites' }
|
|
||||||
] },
|
|
||||||
{ id: 'features', title: 'View Feature', items: [
|
|
||||||
{ id: 'situationistfilm', title: 'Situationist Film' },
|
|
||||||
{ id: 'timelines', title: 'Timelines' }
|
|
||||||
] },
|
|
||||||
{},
|
|
||||||
{ id: 'newlist', title: 'New List...', keyboard: 'control n' },
|
|
||||||
{ id: 'newlistfromselection', title: 'New List from Selection...', disabled: true, keyboard: 'shift control n' },
|
|
||||||
{ id: 'newsmartlist', title: 'New Smart List...', keyboard: 'alt control n' },
|
|
||||||
{ id: 'newsmartlistfromresults', title: 'New Smart List from Results...', keyboard: 'shift alt control n' },
|
|
||||||
{},
|
|
||||||
{ id: 'addmovietolist', title: ['Add Selected ' + pandora.site.itemName.singular + ' to List...', 'Add Selected ' + pandora.site.itemName.plural + ' to List...'], disabled: true },
|
|
||||||
{},
|
|
||||||
{ id: 'setposterframe', title: 'Set Poster Frame', disabled: true }
|
|
||||||
]},
|
|
||||||
{ id: 'editMenu', title: 'Edit', items: [
|
{ id: 'editMenu', title: 'Edit', items: [
|
||||||
{ id: 'undo', title: 'Undo', disabled: true, keyboard: 'control z' },
|
{ id: 'undo', title: 'Undo', disabled: true, keyboard: 'control z' },
|
||||||
{ id: 'redo', title: 'Redo', disabled: true, keyboard: 'shift control z' },
|
{ id: 'redo', title: 'Redo', disabled: true, keyboard: 'shift control z' },
|
||||||
|
@ -167,7 +147,7 @@ pandora.ui.mainMenu = function() {
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
change: function(data) {
|
change: function(data) {
|
||||||
var value = data.checked[0].id;
|
var value = data.checked[0] ? data.checked[0].id : null;
|
||||||
if (data.id == 'find') {
|
if (data.id == 'find') {
|
||||||
pandora.$ui.findSelect.options({value: value});
|
pandora.$ui.findSelect.options({value: value});
|
||||||
} else if (data.id == 'movieview') {
|
} else if (data.id == 'movieview') {
|
||||||
|
@ -204,7 +184,6 @@ pandora.ui.mainMenu = function() {
|
||||||
var groups = Ox.clone(pandora.user.ui.groups),
|
var groups = Ox.clone(pandora.user.ui.groups),
|
||||||
id = data.id.replace('sortgroup', ''),
|
id = data.id.replace('sortgroup', ''),
|
||||||
position = Ox.getPositionById(groups, id),
|
position = Ox.getPositionById(groups, id),
|
||||||
// fixme: the backend mysteriously omits type
|
|
||||||
type = Ox.getObjectById(pandora.site.groups, id).type,
|
type = Ox.getObjectById(pandora.site.groups, id).type,
|
||||||
key = value,
|
key = value,
|
||||||
operator = key == 'name' && type == 'string' ? '+' : '-';
|
operator = key == 'name' && type == 'string' ? '+' : '-';
|
||||||
|
@ -252,6 +231,10 @@ pandora.ui.mainMenu = function() {
|
||||||
pandora.$ui.viewSelect.options({value: value});
|
pandora.$ui.viewSelect.options({value: value});
|
||||||
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list());
|
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list());
|
||||||
pandora.URL.push('/' + value + '/' + document.location.search);
|
pandora.URL.push('/' + value + '/' + document.location.search);
|
||||||
|
} else if (['personallists', 'favoritelists', 'featuredlists'].indexOf(data.id) > -1) {
|
||||||
|
pandora.URL.set(
|
||||||
|
data.checked[0] ? '?find=list:' + data.checked[0].id.substr(8) : ''
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
click: function(data) {
|
click: function(data) {
|
||||||
|
@ -590,6 +573,40 @@ pandora.ui.mainMenu = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// fixme: the sidebar makes the same requests.
|
||||||
|
// is it ok to make them twice, or should the sidebar trigger the menu replace?
|
||||||
|
|
||||||
|
var counter = 0,
|
||||||
|
lists = {},
|
||||||
|
queries = {
|
||||||
|
// fixme: duplicated
|
||||||
|
personal: {conditions: [
|
||||||
|
{key: 'user', value: pandora.user.username, operator: '='},
|
||||||
|
{key: 'status', value: 'featured', operator: '!'}
|
||||||
|
], operator: '&'},
|
||||||
|
favorite: {conditions: [
|
||||||
|
{key: 'subscribed', value: true, operator: '='},
|
||||||
|
{key: 'status', value: 'featured', operator: '!'},
|
||||||
|
], operator: '&'},
|
||||||
|
featured: {conditions: [
|
||||||
|
{key: 'status', value: 'featured', operator: '='}
|
||||||
|
], operator: '&'}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ox.forEach(queries, function(query, folder) {
|
||||||
|
pandora.api.findLists({
|
||||||
|
query: query,
|
||||||
|
keys: ['id', 'name', 'user']
|
||||||
|
}, function(result) {
|
||||||
|
lists[folder] = result.data.items;
|
||||||
|
if (++counter == 3) {
|
||||||
|
Ox.print('--------------------------------------------', lists)
|
||||||
|
pandora.$ui.mainMenu.replaceMenu('listMenu', pandora.getListMenu(lists));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue