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() {
|
function getSortMenu() {
|
||||||
var ui = pandora.user.ui,
|
var ui = pandora.user.ui,
|
||||||
isClipView = pandora.isClipView(ui.listView);
|
isClipView = pandora.isClipView(ui.listView),
|
||||||
return { id: 'sortMenu', title: 'Sort', items: [
|
items = isClipView ? pandora.site.clipKeys.map(function(key) {
|
||||||
{ 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), {
|
return Ox.extend(Ox.clone(key), {
|
||||||
checked: ui.listSort[0].key == key.id,
|
checked: ui.listSort[0].key == key.id,
|
||||||
title: 'Clip ' + key.title
|
title: 'Clip ' + key.title
|
||||||
});
|
});
|
||||||
}) : [],
|
}) : [];
|
||||||
!ui.item ? pandora.site.sortKeys.map(function(key) {
|
return { id: 'sortMenu', title: 'Sort', items: [
|
||||||
return Ox.extend({
|
{ id: 'sortitems', title: 'Sort ' + (isClipView || ui.item ? 'Clips' : pandora.site.itemName.plural) + ' by', items: [
|
||||||
|
{ group: 'listsort', min: 1, max: 1, 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({
|
||||||
checked: ui.listSort[0].key == key.id
|
checked: ui.listSort[0].key == key.id
|
||||||
}, key);
|
}, key) : null;
|
||||||
}) : []
|
})
|
||||||
) }
|
) }
|
||||||
] },
|
] },
|
||||||
{ id: 'orderitems', title: 'Order ' + (isClipView ? 'Clips' : pandora.site.itemName.plural), items: [
|
{ id: 'orderitems', title: 'Order ' + (isClipView ? 'Clips' : pandora.site.itemName.plural), items: [
|
||||||
|
|
|
@ -4,26 +4,26 @@
|
||||||
|
|
||||||
pandora.ui.sortSelect = function(isNavigationView) {
|
pandora.ui.sortSelect = function(isNavigationView) {
|
||||||
var isClipView = pandora.isClipView(),
|
var isClipView = pandora.isClipView(),
|
||||||
items = [],
|
items = isClipView ? pandora.site.clipKeys.map(function(key) {
|
||||||
sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort',
|
|
||||||
that;
|
|
||||||
if (isClipView) {
|
|
||||||
items = pandora.site.clipKeys.map(function(key) {
|
|
||||||
return Ox.extend(Ox.clone(key), {
|
return Ox.extend(Ox.clone(key), {
|
||||||
title: 'Sort by ' + (!pandora.user.ui.item ? 'Clip ' : '') + key.title
|
title: 'Sort by ' + (!pandora.user.ui.item ? 'Clip ' : '') + key.title
|
||||||
});
|
});
|
||||||
});
|
}) : [],
|
||||||
// fixme: a separator would be good
|
// 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) {
|
if (!pandora.user.ui.item) {
|
||||||
items = Ox.merge(items, Ox.map(pandora.site.sortKeys, function(key) {
|
items = Ox.merge(
|
||||||
return Ox.getIndexById(items, key.id) == -1
|
items,
|
||||||
? Ox.extend(Ox.clone(key), {
|
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
|
title: 'Sort by ' + key.title
|
||||||
|
}) : null;
|
||||||
})
|
})
|
||||||
: null;
|
);
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
that = Ox.Select({
|
that = Ox.Select({
|
||||||
id: 'sortSelect',
|
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']),
|
: (pandora.site.itemName[data.items == 1 ? 'singular' : 'plural']),
|
||||||
parts = [];
|
parts = [];
|
||||||
parts.push(Ox.formatNumber(data.items) + ' '+ itemName);
|
parts.push(Ox.formatNumber(data.items) + ' '+ itemName);
|
||||||
if (data.runtime)
|
if (data.runtime) {
|
||||||
parts.push(Ox.formatDuration(data.runtime, 'short'));
|
parts.push(Ox.formatDuration(data.runtime, 'short'));
|
||||||
if (data.files)
|
} else if (data.duration) {
|
||||||
parts.push(data.files + ' file' + (data.files == 1 ? '' : 's'));
|
|
||||||
if (!data.runtime && data.duration)
|
|
||||||
parts.push(Ox.formatDuration(data.duration, 'short'));
|
parts.push(Ox.formatDuration(data.duration, 'short'));
|
||||||
else if (data.duration)
|
}
|
||||||
parts.push(Ox.formatDuration(data.duration));
|
if (pandora.site.capabilities.canSeeFiles[pandora.user.level]) {
|
||||||
if (data.size)
|
data.files && parts.push(data.files + ' file' + (data.files == 1 ? '' : 's'));
|
||||||
parts.push(Ox.formatValue(data.size, 'B'));
|
data.duration && parts.push(Ox.formatDuration(data.duration));
|
||||||
if (data.pixels)
|
data.size && parts.push(Ox.formatValue(data.size, 'B'));
|
||||||
parts.push(Ox.formatValue(data.pixels, 'px'));
|
data.pixels && parts.push(Ox.formatValue(data.pixels, 'px'));
|
||||||
|
}
|
||||||
return parts.join(', ');
|
return parts.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue