Only show Find: Entity if config defines entites

Followup to 9a4c24
This commit is contained in:
j 2016-03-05 14:49:51 +05:30
parent 0c98cd080e
commit 42ac4a88b8

View file

@ -9,6 +9,9 @@ pandora.ui.documentsPanel = function(options) {
hasListSelection = ui.section == 'items' && !ui.item && ui.listSelection.length, hasListSelection = ui.section == 'items' && !ui.item && ui.listSelection.length,
isItemView = options.isItemView, isItemView = options.isItemView,
listLoaded = false, listLoaded = false,
allFindKeys = ['user', 'name', 'entity', 'extension', 'description'].filter(function(key) {
return key != 'entity' || pandora.site.entities.length;
}),
columns = [ columns = [
{ {
@ -166,16 +169,19 @@ pandora.ui.documentsPanel = function(options) {
.appendTo($listBar), .appendTo($listBar),
$findSelect = Ox.Select({ $findSelect = Ox.Select({
items: isItemView ? [ items: [
{id: 'all', title: Ox._('Find: All')},
{id: 'name', title: Ox._('Find: Name')},
{id: 'entity', title: Ox._('Find: Entity')}
] : [
{id: 'all', title: Ox._('Find: All')}, {id: 'all', title: Ox._('Find: All')},
{id: 'name', title: Ox._('Find: Name')}, {id: 'name', title: Ox._('Find: Name')},
{id: 'user', title: Ox._('Find: User')}, {id: 'user', title: Ox._('Find: User')},
{id: 'entity', title: Ox._('Find: Entity')} {id: 'entity', title: Ox._('Find: Entity')}
], ].filter(function(item) {
if (item.id == 'user') {
return !isItemView;
} else if (item.id == 'entity') {
return pandora.site.entities.length;
}
return true;
}),
overlap: 'right', overlap: 'right',
type: 'image' type: 'image'
}) })
@ -1011,15 +1017,13 @@ pandora.ui.documentsPanel = function(options) {
); );
} }
var allKeys = ['user', 'name', 'entity', 'extension', 'description'];
function updateList() { function updateList() {
var key = $findSelect.value(), var key = $findSelect.value(),
value = $findInput.value(), value = $findInput.value(),
itemCondition = isItemView itemCondition = isItemView
? {key: 'item', operator: '==', value: ui.item} ? {key: 'item', operator: '==', value: ui.item}
: null, : null,
findKeys = key == 'all' ? allKeys : [key], findKeys = key == 'all' ? allFindKeys : [key],
findQuery = { findQuery = {
conditions: findKeys.map(function(k) { conditions: findKeys.map(function(k) {
return {key: k, operator: '=', value: value}; return {key: k, operator: '=', value: value};