documents panel: fix 'add', add tooltip, clean up query construction

This commit is contained in:
rolux 2014-01-16 03:56:20 +00:00
parent d2d2636248
commit f4074a15ea

View file

@ -107,7 +107,10 @@ pandora.ui.documentsPanel = function(options) {
$addButton = (isItemView ? Ox.Button({ $addButton = (isItemView ? Ox.Button({
title: 'add', title: 'add',
tooltip: Ox._('Add Documents...'), tooltip: Ox._(
'Add Documents... {0}',
['<span class="OxBright">' + Ox.UI.symbols.control + 'N</span>']
),
type: 'image' type: 'image'
}) : Ox.FileButton({ }) : Ox.FileButton({
image: 'upload', image: 'upload',
@ -118,7 +121,7 @@ pandora.ui.documentsPanel = function(options) {
.bindEvent({ .bindEvent({
click: function(data) { click: function(data) {
if (isItemView) { if (isItemView) {
editDocuments(); openDocumentsDialog();
} else { } else {
uploadDocuments(data); uploadDocuments(data);
} }
@ -435,7 +438,7 @@ pandora.ui.documentsPanel = function(options) {
function editDocuments() { function editDocuments() {
pandora.UI.set('documentsSelection.', $list.options('selected')); pandora.UI.set('documentsSelection.', $list.options('selected'));
pandora.$ui.documentsDialog = pandora.ui.documentsDialog().open(); openDocumentsDialog();
} }
function getOrderButtonTitle() { function getOrderButtonTitle() {
@ -486,6 +489,10 @@ pandora.ui.documentsPanel = function(options) {
} }
} }
function openDocumentsDialog() {
pandora.$ui.documentsDialog = pandora.ui.documentsDialog().open();
}
function replaceDocument(file) { function replaceDocument(file) {
var id = $list.options('selected')[0]; var id = $list.options('selected')[0];
} }
@ -637,7 +644,10 @@ pandora.ui.documentsPanel = function(options) {
size: 128 size: 128
}))) })))
.bindEvent({ .bindEvent({
add: uploadDocuments, add: function() {
// we can't open upload dialog via control+n
isItemView && openDocumentsDialog();
},
closepreview: closeDocuments, closepreview: closeDocuments,
'delete': deleteDocuments, 'delete': deleteDocuments,
init: function(data) { init: function(data) {
@ -711,8 +721,7 @@ pandora.ui.documentsPanel = function(options) {
function selectDocuments() { function selectDocuments() {
var selected = ui.documentsSelection[isItemView ? ui.item : ''] || [], var selected = ui.documentsSelection[isItemView ? ui.item : ''] || [],
string = selected.length < 2 ? 'Document' string = selected.length < 2 ? 'Document' : ' Documents';
: selected.length + ' Documents';
$list.options({selected: selected}); $list.options({selected: selected});
$itemMenu.setItemTitle('open', Ox._('Open ' + string)); $itemMenu.setItemTitle('open', Ox._('Open ' + string));
if (isItemView) { if (isItemView) {
@ -723,7 +732,9 @@ pandora.ui.documentsPanel = function(options) {
'Add ' + string + ' to Current ' 'Add ' + string + ' to Current '
+ pandora.site.itemName.singular + pandora.site.itemName.singular
)) ))
.setItemTitle('delete', Ox._('Delete ' + string + '...')); .setItemTitle('replace', Ox._('Replace ' + string + '...'))
.setItemTitle('delete', Ox._('Delete ' + string + '...'))
[selected.length == 1 ? 'enableItem' : 'disableItem']('replace');
} }
$itemMenu[selected.length ? 'show' : 'hide'](); $itemMenu[selected.length ? 'show' : 'hide']();
$selectButton[selected.length > 1 ? 'show' : 'hide'](); $selectButton[selected.length > 1 ? 'show' : 'hide']();
@ -743,30 +754,32 @@ pandora.ui.documentsPanel = function(options) {
function updateList() { function updateList() {
var key = $findSelect.value(), var key = $findSelect.value(),
value = $findInput.value(), value = $findInput.value(),
query = { itemCondition = isItemView
? {key: 'item', operator: '==', value: ui.item}
: null,
findQuery = {
conditions: [].concat( conditions: [].concat(
isItemView key != 'user'
? [{ key: 'item', value: ui.item, operator: '==' }] ? [{key: 'name', operator: '=', value: value}]
: [], : [],
value key == 'all'
? { ? [
conditions: [].concat( {key: 'extension', operator: '=', value: value},
key != 'user' {key: 'description', operator: '=', value: value}
? [{key: 'name', value: value, operator: '='}] ]
: [], : [],
key == 'all' key != 'name'
? [{key: 'description', value: value, operator: '='}] ? [{key: 'user', operator: '=', value: value}]
: [], : []
key != 'name'
? [{key: 'user', value: value, operator: '='}]
: []
),
operator: '|'
}
: []
), ),
operator: '&' operator: '|'
}; },
query = isItemView
? {
conditions: [itemCondition].concat(findQuery),
operator: '&'
}
: findQuery;
$list.options({query: query}); $list.options({query: query});
} }