update advanced find

This commit is contained in:
rolux 2011-11-10 22:48:32 +00:00
parent 72c0917d2c
commit 2d7d0414f9
3 changed files with 66 additions and 64 deletions

View file

@ -3,24 +3,13 @@
pandora.ui.filterDialog = function(list) { pandora.ui.filterDialog = function(list) {
var that = Ox.Dialog({ var that = Ox.Dialog({
buttons: [ buttons: [
/*
Ox.Button({
id: 'cancel',
title: 'Cancel'
})
.bindEvent({
click: function() {
pandora.$ui.filterDialog.close();
}
}),
*/
Ox.Button({ Ox.Button({
id: 'done', id: 'done',
title: 'Done' title: 'Done'
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
pandora.$ui.filterDialog.close(); that.close();
} }
}) })
], ],
@ -30,6 +19,7 @@ pandora.ui.filterDialog = function(list) {
minWidth: 648 + Ox.UI.SCROLLBAR_SIZE, minWidth: 648 + Ox.UI.SCROLLBAR_SIZE,
height: 264, height: 264,
// keys: {enter: 'save', escape: 'cancel'}, // keys: {enter: 'save', escape: 'cancel'},
removeOnClose: true,
title: list ? 'Smart List - ' + list.name : 'Advanced Find', title: list ? 'Smart List - ' + list.name : 'Advanced Find',
width: 648 + Ox.UI.SCROLLBAR_SIZE width: 648 + Ox.UI.SCROLLBAR_SIZE
}); });

View file

@ -3,54 +3,70 @@
'use strict'; 'use strict';
pandora.ui.filterForm = function(list) { pandora.ui.filterForm = function(list) {
var that = Ox.Filter({ var that = Ox.Element();
findKeys: Ox.merge(Ox.map(pandora.site.itemKeys, function(itemKey) { pandora.api.findLists({
var key = Ox.clone(itemKey); query: {
key.type = key.type == 'layer' conditions: [{key: 'type', value: 'static', operator: '='}],
? Ox.getObjectById(pandora.site.layers, key.id).type operator: '&'
: key.type; },
return key; keys: ['id'],
}), { range: [0, 1000],
id: 'list', sort: [{key: 'user', operator: '+'}, {key: 'name', operator: '+'}]
title: 'List', }, function(result) {
type: 'string' that.append(
}), Ox.Filter({
list: list ? null : { findKeys: Ox.merge(Ox.map(pandora.site.itemKeys, function(itemKey) {
sort: pandora.user.ui.listSort, var key = Ox.clone(itemKey);
view: pandora.user.ui.listView key.type = key.type == 'layer'
}, ? Ox.getObjectById(pandora.site.layers, key.id).type
query: Ox.clone(list ? list.query : pandora.user.ui.find, true), : key.type;
sortKeys: pandora.site.sortKeys, return key;
viewKeys: pandora.site.listViews }), {
}) id: 'list',
.css({padding: '16px'}) title: 'List',
.bindEvent({ type: 'list',
change: function(data) { values: result.data.items.map(function(item) {
if (list) { return item.id;
pandora.api.editList({ })
id: list.id, }),
query: data.query list: list ? null : {
}, function(result) { sort: pandora.user.ui.listSort,
Ox.Request.clearCache(list.id); view: pandora.user.ui.listView
pandora.$ui.list },
.bindEventOnce({ query: Ox.clone(list ? list.query : pandora.user.ui.find, true),
init: function(data) { sortKeys: pandora.site.sortKeys,
pandora.$ui.folderList[ viewKeys: pandora.site.listViews
pandora.getListData().folder })
].value(list.id, 'items', data.items); .css({padding: '16px'})
} .bindEvent({
}) change: function(data) {
.reloadList(); if (list) {
pandora.$ui.filters.forEach(function($filter) { pandora.api.editList({
$filter.reloadList(); id: list.id,
query: data.query
}, function(result) {
Ox.Request.clearCache(list.id);
pandora.$ui.list
.bindEventOnce({
init: function(data) {
pandora.$ui.folderList[
pandora.getListData().folder
].value(list.id, 'items', data.items);
}
})
.reloadList();
pandora.$ui.filters.forEach(function($filter) {
$filter.reloadList();
});
}); });
}); } else {
} else { Ox.Log('FIND', 'change form', data.query, pandora.user.ui.find)
Ox.Log('FIND', 'change form', data.query, pandora.user.ui.find) pandora.UI.set({find: Ox.clone(data.query, true)});
pandora.UI.set({find: Ox.clone(data.query, true)}); }
} }
} })
}); );
});
return that; return that;
}; };

View file

@ -52,9 +52,7 @@ pandora.ui.findElement = function() {
placeholder: 'Edit Query...', placeholder: 'Edit Query...',
value: '' value: ''
}); });
(pandora.$ui.filterDialog || ( pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
pandora.$ui.filterDialog = pandora.ui.filterDialog()
)).open();
} else { } else {
Ox.Log('FIND', pandora.$ui.findInput.value()) Ox.Log('FIND', pandora.$ui.findInput.value())
pandora.$ui.findInput.options({ pandora.$ui.findInput.options({
@ -80,9 +78,7 @@ pandora.ui.findElement = function() {
focus: function(data) { focus: function(data) {
if (pandora.$ui.findSelect.value() == 'advanced') { if (pandora.$ui.findSelect.value() == 'advanced') {
pandora.$ui.findInput.blurInput(); pandora.$ui.findInput.blurInput();
(pandora.$ui.filterDialog || ( pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
pandora.$ui.filterDialog = pandora.ui.filterDialog()
)).open();
} }
}, },
submit: function(data) { submit: function(data) {