better mapping between find query string and lists, find input, groups
This commit is contained in:
parent
16b998f760
commit
a8b30f5a48
9 changed files with 347 additions and 329 deletions
|
|
@ -1,20 +1,21 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
pandora.ui.browser = function() {
|
||||
var that;
|
||||
var sizes, that;
|
||||
if (!pandora.user.ui.item) {
|
||||
pandora.user.ui.groupsSizes = pandora.getGroupsSizes();
|
||||
pandora.$ui.groups = pandora.ui.groups();
|
||||
that = Ox.SplitPanel({
|
||||
elements: [
|
||||
{
|
||||
element: pandora.$ui.groups[0],
|
||||
size: pandora.user.queryGroups[0].size
|
||||
size: pandora.user.ui.groupsSizes[0]
|
||||
},
|
||||
{
|
||||
element: pandora.$ui.groupsInnerPanel = pandora.ui.groupsInnerPanel()
|
||||
},
|
||||
{
|
||||
element: pandora.$ui.groups[4],
|
||||
size: pandora.user.queryGroups[4].size
|
||||
size: pandora.user.ui.groupsSizes[4]
|
||||
},
|
||||
],
|
||||
id: 'browser',
|
||||
|
|
|
|||
|
|
@ -1,17 +1,14 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
pandora.ui.findElement = function() {
|
||||
var findKey = '',
|
||||
findValue = '';
|
||||
if (pandora.user.ui.findQuery.conditions.length == 1) {
|
||||
findKey = pandora.user.ui.findQuery.conditions[0].key;
|
||||
findValue = pandora.user.ui.findQuery.conditions[0].value;
|
||||
}
|
||||
var findIndex = pandora.user.ui.find.index,
|
||||
findKey = pandora.user.ui.find.key,
|
||||
findValue = pandora.user.ui.find.value;
|
||||
var that = Ox.FormElementGroup({
|
||||
elements: $.merge(pandora.user.ui.list ? [
|
||||
pandora.$ui.findListSelect = Ox.Select({
|
||||
items: [
|
||||
{id: 'all', title: 'Find: All ' + pandora.site.itemName.plural},
|
||||
{id: 'list', title: 'Find: This List'}
|
||||
{id: 'list', title: 'Find: This List', checked: true}
|
||||
],
|
||||
overlap: 'right',
|
||||
type: 'image'
|
||||
|
|
@ -27,17 +24,20 @@ pandora.ui.findElement = function() {
|
|||
] : [], [
|
||||
pandora.$ui.findSelect = Ox.Select({
|
||||
id: 'select',
|
||||
items: $.merge($.map(pandora.site.findKeys,
|
||||
function(key, i) {
|
||||
return {
|
||||
id: key.id,
|
||||
checked: key.id == findKey,
|
||||
title: 'Find: ' + key.title
|
||||
};
|
||||
}), [{}, {
|
||||
id: 'advanced',
|
||||
title: 'Find: Advanced'
|
||||
}]),
|
||||
items: Ox.merge(
|
||||
pandora.site.findKeys.map(function(key, i) {
|
||||
return {
|
||||
id: key.id,
|
||||
title: 'Find: ' + key.title,
|
||||
checked: findKey == key.id
|
||||
};
|
||||
}),
|
||||
[{}, {
|
||||
id: 'advanced',
|
||||
title: 'Find: Advanced',
|
||||
checked: findKey == 'advanced'
|
||||
}]
|
||||
),
|
||||
overlap: 'right',
|
||||
width: 112
|
||||
})
|
||||
|
|
@ -47,11 +47,6 @@ pandora.ui.findElement = function() {
|
|||
if (key == 'advanced') {
|
||||
pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
|
||||
} else {
|
||||
if (!pandora.user.ui.findQuery.conditions.length) { // fixme: can this case happen at all?
|
||||
pandora.user.ui.findQuery.conditions = [{key: key, value: '', operator: ''}];
|
||||
} else {
|
||||
pandora.user.ui.findQuery.conditions[0].key = key;
|
||||
}
|
||||
pandora.$ui.mainMenu.checkItem('findMenu_find_' + key);
|
||||
pandora.$ui.findInput.options({
|
||||
autocomplete: autocompleteFunction()
|
||||
|
|
@ -66,25 +61,47 @@ pandora.ui.findElement = function() {
|
|||
autocompleteSelectSubmit: true,
|
||||
clear: true,
|
||||
id: 'input',
|
||||
placeholder: findKey == 'advanced' ? 'Edit...' : '',
|
||||
value: findValue,
|
||||
width: 192
|
||||
})
|
||||
.bindEvent({
|
||||
submit: function(event, data) {
|
||||
var key = pandora.user.ui.findQuery.conditions.length ?
|
||||
pandora.user.ui.findQuery.conditions[0].key : '';
|
||||
if (pandora.user.ui.list && that.value()[0].id == 'all') {
|
||||
$.each(pandora.$ui.folderList, function(k, $list) {
|
||||
$list.options({selected: []});
|
||||
});
|
||||
pandora.UI.set({list: ''});
|
||||
pandora.user.ui.listQuery = {conditions: [], operator: ''};
|
||||
focus: function(data) {
|
||||
if (findKey == 'advanced') {
|
||||
pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
|
||||
}
|
||||
},
|
||||
submit: function(data) {
|
||||
var findInList = pandora.user.ui.list
|
||||
&& pandora.$ui.findListSelect.value() == 'list',
|
||||
key = pandora.$ui.findSelect.value(),
|
||||
condition = {
|
||||
key: key == 'all' ? '' : key,
|
||||
value: data.value,
|
||||
operator: ''
|
||||
};
|
||||
if (findInList) {
|
||||
pandora.user.ui.query = {
|
||||
conditions: [{
|
||||
key: 'list',
|
||||
value: pandora.user.ui.list,
|
||||
operator: ''
|
||||
}, condition],
|
||||
operator: '&'
|
||||
}
|
||||
findIndex == 0 && pandora.user.ui.query.conditions.reverse();
|
||||
} else {
|
||||
if (pandora.user.ui.list) {
|
||||
Ox.forEach(pandora.$ui.folderList, function($list) {
|
||||
$list.options({selected: []});
|
||||
});
|
||||
pandora.UI.set({list: ''});
|
||||
}
|
||||
pandora.user.ui.query = {
|
||||
conditions: [condition],
|
||||
operator: ''
|
||||
}
|
||||
}
|
||||
pandora.user.ui.findQuery.conditions = [{
|
||||
key: key == 'all' ? '' : key,
|
||||
value: data.value,
|
||||
operator: ''
|
||||
}];
|
||||
pandora.URL.set(pandora.Query.toString());
|
||||
}
|
||||
})
|
||||
|
|
@ -96,7 +113,7 @@ pandora.ui.findElement = function() {
|
|||
margin: '4px'
|
||||
});
|
||||
function autocompleteFunction() {
|
||||
return pandora.user.ui.findQuery.conditions.length ? function(value, callback) {
|
||||
return pandora.user.ui.query.conditions.length ? function(value, callback) {
|
||||
var elementValue = that.value(),
|
||||
key = elementValue[pandora.user.ui.list ? 1 : 0],
|
||||
findKey = Ox.getObjectById(pandora.site.findKeys, key);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,9 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
pandora.ui.group = function(id, query) {
|
||||
//Ox.print('group', id, query);
|
||||
/*
|
||||
query && query.conditions.length && alert($.map(query.conditions, function(v) {
|
||||
return v.value;
|
||||
}));
|
||||
*/
|
||||
//alert(id + ' ' + JSON.stringify(pandora.Query.toObject(id)))
|
||||
pandora.ui.group = function(id) {
|
||||
var i = pandora.user.ui.groups.indexOf(id),
|
||||
panelWidth = pandora.$ui.document.width() - (pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize) - 1,
|
||||
title = Ox.getObjectById(pandora.site.groups, id).title,
|
||||
width = pandora.getGroupWidth(i, panelWidth),
|
||||
//width = pandora.getGroupWidth(i, panelWidth),
|
||||
that = Ox.TextList({
|
||||
columns: [
|
||||
{
|
||||
|
|
@ -20,7 +13,7 @@ pandora.ui.group = function(id, query) {
|
|||
title: title,
|
||||
unique: true,
|
||||
visible: true,
|
||||
width: width.column
|
||||
width: pandora.user.ui.groupsSizes[i] - 40 - Ox.UI.SCROLLBAR_SIZE
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
|
|
@ -36,40 +29,61 @@ pandora.ui.group = function(id, query) {
|
|||
items: function(data, callback) {
|
||||
//if (pandora.user.ui.showGroups) {
|
||||
delete data.keys;
|
||||
//alert(id + " pandora.Query.toObject " + JSON.stringify(pandora.Query.toObject(id)) + ' ' + JSON.stringify(data))
|
||||
return pandora.api.find($.extend(data, {
|
||||
group: id,
|
||||
query: pandora.Query.toObject(id)
|
||||
query: pandora.user.ui.groupsData[i].query
|
||||
}), callback);
|
||||
//} else {
|
||||
// callback({data: {items: data.keys ? [] : 0}});
|
||||
//}
|
||||
},
|
||||
scrollbarVisible: true,
|
||||
selected: query ? $.map(query.conditions, function(v) {
|
||||
return v.value;
|
||||
}) : [],
|
||||
sort: [
|
||||
{
|
||||
key: id == 'year' ? 'name' : 'items',
|
||||
operator: '-'
|
||||
}
|
||||
]
|
||||
selected: pandora.user.ui.groupsData[i].selected,
|
||||
sort: [{
|
||||
key: id == 'year' ? 'name' : 'items',
|
||||
operator: '-'
|
||||
}]
|
||||
})
|
||||
.bindEvent({
|
||||
paste: function(event, data) {
|
||||
pandora.$ui.list.triggerEvent('paste', data);
|
||||
},
|
||||
select: function(event, data) {
|
||||
var group = pandora.user.queryGroups[i],
|
||||
query;
|
||||
pandora.user.queryGroups[i].query.conditions = $.map(data.ids, function(v) {
|
||||
return {
|
||||
key: id,
|
||||
value: v,
|
||||
operator: '='
|
||||
};
|
||||
});
|
||||
var conditions = data.ids.map(function(value) {
|
||||
return {
|
||||
key: id,
|
||||
value: value,
|
||||
operator: '='
|
||||
};
|
||||
}),
|
||||
index = pandora.user.ui.groupsData[i].index;
|
||||
if (Ox.isArray(index)) {
|
||||
pandora.user.ui.query = {
|
||||
conditions: conditions,
|
||||
operator: conditions.length > 1 ? '|' : ''
|
||||
}
|
||||
} else {
|
||||
if (index == -1) {
|
||||
index = pandora.user.ui.query.conditions.length;
|
||||
pandora.user.ui.query.operator = '&'
|
||||
}
|
||||
if (conditions.length == 0) {
|
||||
pandora.user.ui.query.conditions.splice(index, 1);
|
||||
if (pandora.user.ui.query.conditions.length == 1) {
|
||||
pandora.user.ui.query.operator = '';
|
||||
}
|
||||
} else if (conditions.length == 1) {
|
||||
pandora.user.ui.query.conditions[index] = conditions[0];
|
||||
} else {
|
||||
pandora.user.ui.query.conditions[index].conditions = conditions;
|
||||
pandora.user.ui.query.conditions[index].operator = '|';
|
||||
delete pandora.user.ui.query.conditions[index].key;
|
||||
delete pandora.user.ui.query.conditions[index].value;
|
||||
}
|
||||
}
|
||||
pandora.Query.updateGroups();
|
||||
Ox.print('---------', pandora.user.ui.query, pandora.user.ui.groupsData)
|
||||
pandora.URL.push(pandora.Query.toString());
|
||||
pandora.reloadGroups(i);
|
||||
}
|
||||
});
|
||||
|
|
@ -156,14 +170,14 @@ pandora.ui.groupsInnerPanel = function() {
|
|||
elements: [
|
||||
{
|
||||
element: pandora.$ui.groups[1],
|
||||
size: pandora.user.queryGroups[1].size
|
||||
size: pandora.user.ui.groupsSizes[1]
|
||||
},
|
||||
{
|
||||
element: pandora.$ui.groups[2],
|
||||
},
|
||||
{
|
||||
element: pandora.$ui.groups[3],
|
||||
size: pandora.user.queryGroups[3].size
|
||||
size: pandora.user.ui.groupsSizes[3]
|
||||
}
|
||||
],
|
||||
orientation: 'horizontal'
|
||||
|
|
|
|||
|
|
@ -89,20 +89,20 @@ pandora.ui.list = function() { // fixme: remove view argument
|
|||
ratio = icons == 'posters' ? data.posterRatio : 1;
|
||||
size = size || 128;
|
||||
return {
|
||||
height: ratio <= 1 ? size : size / ratio,
|
||||
height: Math.round(ratio <= 1 ? size : size / ratio),
|
||||
id: data.id,
|
||||
info: data[['title', 'director'].indexOf(sort[0].key) > -1 ? 'year' : sort[0].key],
|
||||
title: data.title + (data.director.length ? ' (' + data.director.join(', ') + ')' : ''),
|
||||
url: icons == 'posters'
|
||||
? '/' + data.id + '/poster' + size + '.jpg'
|
||||
: '/' + data.id + '/icon' + size + '.jpg',
|
||||
width: ratio >= 1 ? size : size * ratio
|
||||
width: Math.round(ratio >= 1 ? size : size * ratio)
|
||||
};
|
||||
},
|
||||
items: function(data, callback) {
|
||||
//Ox.print('data, pandora.Query.toObject', data, pandora.Query.toObject())
|
||||
pandora.api.find($.extend(data, {
|
||||
query: pandora.Query.toObject()
|
||||
query: pandora.user.ui.query
|
||||
}), callback);
|
||||
},
|
||||
keys: ['director', 'id', 'posterRatio', 'title', 'year'],
|
||||
|
|
|
|||
|
|
@ -120,11 +120,11 @@ pandora.ui.mainMenu = function() {
|
|||
{ id: 'findMenu', title: 'Find', items: [
|
||||
{ id: 'find', title: 'Find', items: [
|
||||
{ group: 'find', min: 1, max: 1, items: pandora.site.findKeys.map(function(key, i) {
|
||||
var index = pandora.user.ui.find.index;
|
||||
return Ox.extend({
|
||||
checked: pandora.user.ui.findQuery.conditions.length ? (
|
||||
pandora.user.ui.findQuery.conditions[0].key == key.id ||
|
||||
(pandora.user.ui.findQuery.conditions[0].key === '' && key.id == 'all')
|
||||
) : key.id == 'all',
|
||||
checked: index > -1 && pandora.user.ui.query.conditions[index].key
|
||||
? pandora.user.ui.query.conditions[index].key == key.id
|
||||
: key.id == 'all'
|
||||
}, key);
|
||||
}) }
|
||||
] },
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ pandora.ui.rightPanel = function() {
|
|||
.bindEvent({
|
||||
resize: function(event, data) {
|
||||
if (!pandora.user.ui.item) {
|
||||
pandora.resizeGroups(data);
|
||||
pandora.resizeGroups();
|
||||
pandora.$ui.list.size();
|
||||
if (pandora.user.ui.lists[pandora.user.ui.list].listView == 'timelines') {
|
||||
pandora.$ui.list.options({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue