2011-11-06 08:28:10 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
pandora.ui.filterForm = function(list) {
|
2011-11-10 22:48:32 +00:00
|
|
|
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(
|
2011-11-11 15:48:25 +00:00
|
|
|
that.$filter = Ox.Filter({
|
2012-05-24 08:22:56 +00:00
|
|
|
findKeys: pandora.site.itemKeys.map(function(itemKey) {
|
2013-03-03 12:02:51 +00:00
|
|
|
var key = Ox.clone(itemKey, true);
|
2013-05-09 10:13:58 +00:00
|
|
|
key.title = Ox._(key.title);
|
2011-11-10 22:48:32 +00:00
|
|
|
key.type = key.type == 'layer'
|
|
|
|
? Ox.getObjectById(pandora.site.layers, key.id).type
|
|
|
|
: key.type;
|
2013-03-03 12:02:51 +00:00
|
|
|
if (key.format && key.format.type == 'ColorPercent') {
|
|
|
|
key.format.type = 'percent';
|
|
|
|
}
|
2011-11-10 22:48:32 +00:00
|
|
|
return key;
|
2012-05-24 08:22:56 +00:00
|
|
|
}).concat([{
|
2011-11-10 22:48:32 +00:00
|
|
|
id: 'list',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('List'),
|
2011-11-10 22:48:32 +00:00
|
|
|
type: 'list',
|
|
|
|
values: result.data.items.map(function(item) {
|
|
|
|
return item.id;
|
|
|
|
})
|
2012-05-24 08:22:56 +00:00
|
|
|
}]),
|
2011-11-10 22:48:32 +00:00
|
|
|
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) {
|
2013-03-03 11:15:28 +00:00
|
|
|
if (pandora.user.ui.updateAdvancedFindResults) {
|
2013-03-03 10:15:38 +00:00
|
|
|
that.updateResults(data.query);
|
|
|
|
}
|
2011-11-06 08:28:10 +00:00
|
|
|
});
|
2013-03-03 11:15:28 +00:00
|
|
|
} else if (pandora.user.ui.updateAdvancedFindResults) {
|
2013-03-03 10:15:38 +00:00
|
|
|
that.updateResults();
|
2011-11-10 22:48:32 +00:00
|
|
|
}
|
2013-03-03 10:15:38 +00:00
|
|
|
that.triggerEvent('change', data);
|
2011-11-06 08:28:10 +00:00
|
|
|
}
|
2011-11-10 22:48:32 +00:00
|
|
|
})
|
|
|
|
);
|
2013-03-03 10:15:38 +00:00
|
|
|
that.getList = that.$filter.getList;
|
2011-11-10 22:48:32 +00:00
|
|
|
});
|
2013-03-03 10:15:38 +00:00
|
|
|
that.updateResults = function(query) {
|
|
|
|
if (list) {
|
|
|
|
Ox.Request.clearCache(list.id);
|
|
|
|
pandora.$ui.list
|
|
|
|
.bindEventOnce({
|
|
|
|
init: function(data) {
|
|
|
|
pandora.$ui.folderList[
|
|
|
|
pandora.getListData().folder
|
|
|
|
].value(list.id, 'query', query);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.reloadList();
|
|
|
|
pandora.$ui.filters.forEach(function($filter) {
|
|
|
|
$filter.reloadList();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
pandora.UI.set({find: Ox.clone(that.$filter.options('query'), true)});
|
|
|
|
pandora.$ui.findElement.updateElement();
|
|
|
|
}
|
|
|
|
};
|
2011-11-06 08:28:10 +00:00
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|