make sure users without 'canSeeFiles' don't get files info in status bar; honor capability property of sort keys (fixes #251)
This commit is contained in:
parent
11b0a06107
commit
e2c0669860
4 changed files with 38 additions and 60 deletions
|
@ -520,21 +520,25 @@ pandora.ui.mainMenu = function() {
|
|||
|
||||
function getSortMenu() {
|
||||
var ui = pandora.user.ui,
|
||||
isClipView = pandora.isClipView(ui.listView);
|
||||
isClipView = pandora.isClipView(ui.listView),
|
||||
items = isClipView ? pandora.site.clipKeys.map(function(key) {
|
||||
return Ox.extend(Ox.clone(key), {
|
||||
checked: ui.listSort[0].key == key.id,
|
||||
title: 'Clip ' + key.title
|
||||
});
|
||||
}) : [];
|
||||
return { id: 'sortMenu', title: 'Sort', items: [
|
||||
{ id: 'sortitems', title: 'Sort ' + (isClipView || ui.item ? 'Clips' : pandora.site.itemName.plural) + ' by', items: [
|
||||
{ group: 'listsort', min: 1, max: 1, items: Ox.merge(
|
||||
isClipView ? pandora.site.clipKeys.map(function(key) {
|
||||
return Ox.extend(Ox.clone(key), {
|
||||
checked: ui.listSort[0].key == key.id,
|
||||
title: 'Clip ' + key.title
|
||||
});
|
||||
}) : [],
|
||||
!ui.item ? pandora.site.sortKeys.map(function(key) {
|
||||
return Ox.extend({
|
||||
items,
|
||||
Ox.map(pandora.site.sortKeys, function(key) {
|
||||
return Ox.getIndexById(items, key.id) == -1 && (
|
||||
!key.capability
|
||||
|| pandora.site.capabilities[key.capability][pandora.user.level]
|
||||
) ? Ox.extend({
|
||||
checked: ui.listSort[0].key == key.id
|
||||
}, key);
|
||||
}) : []
|
||||
}, key) : null;
|
||||
})
|
||||
) }
|
||||
] },
|
||||
{ id: 'orderitems', title: 'Order ' + (isClipView ? 'Clips' : pandora.site.itemName.plural), items: [
|
||||
|
|
|
@ -4,26 +4,26 @@
|
|||
|
||||
pandora.ui.sortSelect = function(isNavigationView) {
|
||||
var isClipView = pandora.isClipView(),
|
||||
items = [],
|
||||
sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort',
|
||||
that;
|
||||
if (isClipView) {
|
||||
items = pandora.site.clipKeys.map(function(key) {
|
||||
items = isClipView ? pandora.site.clipKeys.map(function(key) {
|
||||
return Ox.extend(Ox.clone(key), {
|
||||
title: 'Sort by ' + (!pandora.user.ui.item ? 'Clip ' : '') + key.title
|
||||
});
|
||||
});
|
||||
}) : [],
|
||||
// fixme: a separator would be good
|
||||
// !pandora.user.ui.item && items.push({});
|
||||
}
|
||||
sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort',
|
||||
that;
|
||||
if (!pandora.user.ui.item) {
|
||||
items = Ox.merge(items, Ox.map(pandora.site.sortKeys, function(key) {
|
||||
return Ox.getIndexById(items, key.id) == -1
|
||||
? Ox.extend(Ox.clone(key), {
|
||||
items = Ox.merge(
|
||||
items,
|
||||
Ox.map(pandora.site.sortKeys, function(key) {
|
||||
return Ox.getIndexById(items, key.id) == -1 && (
|
||||
!key.capability
|
||||
|| pandora.site.capabilities[key.capability][pandora.user.level]
|
||||
) ? Ox.extend(Ox.clone(key), {
|
||||
title: 'Sort by ' + key.title
|
||||
})
|
||||
: null;
|
||||
}));
|
||||
}) : null;
|
||||
})
|
||||
);
|
||||
}
|
||||
that = Ox.Select({
|
||||
id: 'sortSelect',
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
'use strict';
|
||||
pandora.ui.status = function(key, data) {
|
||||
var itemName = data.items != 1 ? pandora.site.itemName.plural : pandora.site.itemName.singular,
|
||||
segments = [],
|
||||
that = Ox.toTitleCase(key) + ': ';
|
||||
if (!pandora.user.ui.item && pandora.user.ui.listView == 'clip') {
|
||||
itemName = data.items != 1 ? 'Clips' : 'Clip';
|
||||
}
|
||||
segments.push(Ox.formatNumber(data.items) + ' '+ itemName);
|
||||
if (data.runtime)
|
||||
segments.push(Ox.formatDuration(data.runtime, 'short'));
|
||||
if (data.files)
|
||||
segments.push(data.files + ' file' + (data.files != 1 ? 's' : ''));
|
||||
if (!data.runtime && data.duration)
|
||||
segments.push(Ox.formatDuration(data.duration, 'short'));
|
||||
else if (data.duration)
|
||||
segments.push(Ox.formatDuration(data.duration));
|
||||
if (data.size)
|
||||
segments.push(Ox.formatValue(data.size, 'B'));
|
||||
if (data.pixels)
|
||||
segments.push(Ox.formatValue(data.pixels, 'px'));
|
||||
return that + segments.join(', ');
|
||||
};
|
||||
|
|
@ -36,18 +36,17 @@ pandora.ui.statusbar = function() {
|
|||
: (pandora.site.itemName[data.items == 1 ? 'singular' : 'plural']),
|
||||
parts = [];
|
||||
parts.push(Ox.formatNumber(data.items) + ' '+ itemName);
|
||||
if (data.runtime)
|
||||
if (data.runtime) {
|
||||
parts.push(Ox.formatDuration(data.runtime, 'short'));
|
||||
if (data.files)
|
||||
parts.push(data.files + ' file' + (data.files == 1 ? '' : 's'));
|
||||
if (!data.runtime && data.duration)
|
||||
} else if (data.duration) {
|
||||
parts.push(Ox.formatDuration(data.duration, 'short'));
|
||||
else if (data.duration)
|
||||
parts.push(Ox.formatDuration(data.duration));
|
||||
if (data.size)
|
||||
parts.push(Ox.formatValue(data.size, 'B'));
|
||||
if (data.pixels)
|
||||
parts.push(Ox.formatValue(data.pixels, 'px'));
|
||||
}
|
||||
if (pandora.site.capabilities.canSeeFiles[pandora.user.level]) {
|
||||
data.files && parts.push(data.files + ' file' + (data.files == 1 ? '' : 's'));
|
||||
data.duration && parts.push(Ox.formatDuration(data.duration));
|
||||
data.size && parts.push(Ox.formatValue(data.size, 'B'));
|
||||
data.pixels && parts.push(Ox.formatValue(data.pixels, 'px'));
|
||||
}
|
||||
return parts.join(', ');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue