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

View file

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

View file

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