better mapping between find query string and lists, find input, groups
This commit is contained in:
parent
3ff1d186c0
commit
1238ad2370
9 changed files with 347 additions and 329 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue