Compare commits

..

No commits in common. "4e79d2af0b3d050e3b7b111672d515d1fd29059d" and "0d40c14c000491d669a77aea74f2a87ae57ff2a0" have entirely different histories.

2 changed files with 73 additions and 86 deletions

View file

@ -25,7 +25,6 @@
"canAddItems": {"member": true, "staff": true, "admin": true}, "canAddItems": {"member": true, "staff": true, "admin": true},
"canAddDocuments": {"member": true, "staff": true, "admin": true}, "canAddDocuments": {"member": true, "staff": true, "admin": true},
"canDownloadVideo": {"guest": 0, "member": 0, "staff": 4, "admin": 4}, "canDownloadVideo": {"guest": 0, "member": 0, "staff": 4, "admin": 4},
"canDownloadSource": {"guest": 0, "member": 0, "staff": 4, "admin": 4},
"canEditAnnotations": {"staff": true, "admin": true}, "canEditAnnotations": {"staff": true, "admin": true},
"canEditDocuments": {"staff": true, "admin": true}, "canEditDocuments": {"staff": true, "admin": true},
"canEditEntities": {"staff": true, "admin": true}, "canEditEntities": {"staff": true, "admin": true},
@ -912,9 +911,9 @@
"documentFilters": [ "documentFilters": [
{"id": "author", "sort": [{"key": "items", "operator": "-"}]}, {"id": "author", "sort": [{"key": "items", "operator": "-"}]},
{"id": "place", "sort": [{"key": "items", "operator": "-"}]}, {"id": "place", "sort": [{"key": "items", "operator": "-"}]},
{"id": "language", "sort": [{"key": "items", "operator": "-"}]}, {"id": "date", "sort": [{"key": "name", "operator": "-"}]},
{"id": "publisher", "sort": [{"key": "items", "operator": "-"}]}, {"id": "publisher", "sort": [{"key": "items", "operator": "-"}]},
{"id": "extensions", "sort": [{"key": "items", "operator": "-"}]} {"id": "language", "sort": [{"key": "items", "operator": "-"}]}
], ],
"edit": "", "edit": "",
"edits": {}, "edits": {},

View file

@ -1,12 +1,10 @@
'use strict'; 'use strict';
pandora.ui.infoView = function(data, isMixed) { pandora.ui.infoView = function(data) {
isMixed = isMixed || {};
var ui = pandora.user.ui, var ui = pandora.user.ui,
isMultiple = arguments.length == 2, canEdit = pandora.site.capabilities.canEditMetadata[pandora.user.level] || data.editable,
canEdit = pandora.hasCapability('canEditMetadata') || isMultiple || data.editable, canRemove = pandora.site.capabilities.canRemoveItems[pandora.user.level] || data.editable,
canRemove = pandora.hasCapability('canRemoveItems'),
css = { css = {
marginTop: '4px', marginTop: '4px',
textAlign: 'justify' textAlign: 'justify'
@ -14,11 +12,10 @@ pandora.ui.infoView = function(data, isMixed) {
descriptions = [], descriptions = [],
html, html,
iconRatio = ui.icons == 'posters' ? data.posterRatio : 1, iconRatio = ui.icons == 'posters' ? data.posterRatio : 1,
iconSize = isMultiple ? 0 : ui.infoIconSize, iconSize = ui.infoIconSize,
iconWidth = isMultiple ? 0 : iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio), iconWidth = iconRatio > 1 ? iconSize : Math.round(iconSize * iconRatio),
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio), iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
iconLeft = isMultiple ? 0 : iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0, iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8, borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8,
margin = 16, margin = 16,
nameKeys = pandora.site.itemKeys.filter(function(key) { nameKeys = pandora.site.itemKeys.filter(function(key) {
@ -100,7 +97,7 @@ pandora.ui.infoView = function(data, isMixed) {
that = Ox.SplitPanel({ that = Ox.SplitPanel({
elements: [ elements: [
{element: $bar, size: isMultiple ? 0 : 16}, {element: $bar, size: 16},
{element: $info} {element: $info}
], ],
orientation: 'vertical' orientation: 'vertical'
@ -110,10 +107,9 @@ pandora.ui.infoView = function(data, isMixed) {
.css({ .css({
position: 'absolute' position: 'absolute'
}) })
.appendTo($info); .appendTo($info),
if (!isMultiple) { $icon = Ox.Element({
var $icon = Ox.Element({
element: '<img>', element: '<img>',
tooltip: 'Switch to ' + Ox.getObjectById( tooltip: 'Switch to ' + Ox.getObjectById(
pandora.site.itemViews, pandora.site.itemViews,
@ -176,8 +172,7 @@ pandora.ui.infoView = function(data, isMixed) {
}) })
.appendTo($reflection), .appendTo($reflection),
} $data = $('<div>')
var $data = $('<div>')
.addClass('OxTextPage') .addClass('OxTextPage')
.css({ .css({
position: 'absolute', position: 'absolute',
@ -185,7 +180,7 @@ pandora.ui.infoView = function(data, isMixed) {
top: margin + iconHeight + margin + 'px', top: margin + iconHeight + margin + 'px',
width: iconSize + 'px', width: iconSize + 'px',
}) })
.appendTo($left) .appendTo($left),
$text = Ox.Element() $text = Ox.Element()
.addClass('OxTextPage') .addClass('OxTextPage')
@ -341,7 +336,7 @@ pandora.ui.infoView = function(data, isMixed) {
); );
}, },
maxHeight: Infinity, maxHeight: Infinity,
placeholder: formatLight(Ox._( isMixed.summary ? 'Mixed Summary' : 'No Summary')), placeholder: formatLight(Ox._('No Summary')),
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
type: 'textarea', type: 'textarea',
value: data.summary || '' value: data.summary || ''
@ -372,50 +367,49 @@ pandora.ui.infoView = function(data, isMixed) {
.appendTo($text); .appendTo($text);
// Duration, Aspect Ratio -------------------------------------------------- // Duration, Aspect Ratio --------------------------------------------------
if (!isMultiple) {
['duration', 'aspectratio'].forEach(function(key) {
var itemKey = Ox.getObjectById(pandora.site.itemKeys, key),
value = data[key] || 0;
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey(itemKey.title, 'statistics'))
.append(
Ox.Theme.formatColor(null, 'gradient')
.css({textAlign: 'right'})
.html(
Ox['format' + Ox.toTitleCase(itemKey.format.type)]
.apply(null, [value].concat(itemKey.format.args))
)
)
.appendTo($statistics);
});
// Hue, Saturation, Lightness, Volume --------------------------------------
['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) {
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey(key, 'statistics'))
.append(
Ox.Theme.formatColor(
data[key] || 0, key == 'volume' ? 'lightness' : key
).css({textAlign: 'right'})
)
.appendTo($statistics);
});
// Cuts per Minute ---------------------------------------------------------
['duration', 'aspectratio'].forEach(function(key) {
var itemKey = Ox.getObjectById(pandora.site.itemKeys, key),
value = data[key] || 0;
$('<div>') $('<div>')
.css({marginBottom: '4px'}) .css({marginBottom: '4px'})
.append(formatKey('cuts per minute', 'statistics')) .append(formatKey(itemKey.title, 'statistics'))
.append( .append(
Ox.Theme.formatColor(null, 'gradient') Ox.Theme.formatColor(null, 'gradient')
.css({textAlign: 'right'}) .css({textAlign: 'right'})
.html(Ox.formatNumber(data['cutsperminute'] || 0, 3)) .html(
Ox['format' + Ox.toTitleCase(itemKey.format.type)]
.apply(null, [value].concat(itemKey.format.args))
)
) )
.appendTo($statistics); .appendTo($statistics);
} });
// Hue, Saturation, Lightness, Volume --------------------------------------
['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) {
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey(key, 'statistics'))
.append(
Ox.Theme.formatColor(
data[key] || 0, key == 'volume' ? 'lightness' : key
).css({textAlign: 'right'})
)
.appendTo($statistics);
});
// Cuts per Minute ---------------------------------------------------------
$('<div>')
.css({marginBottom: '4px'})
.append(formatKey('cuts per minute', 'statistics'))
.append(
Ox.Theme.formatColor(null, 'gradient')
.css({textAlign: 'right'})
.html(Ox.formatNumber(data['cutsperminute'] || 0, 3))
)
.appendTo($statistics);
// Rights Level ------------------------------------------------------------ // Rights Level ------------------------------------------------------------
@ -485,7 +479,7 @@ pandora.ui.infoView = function(data, isMixed) {
.append( .append(
Ox.EditableContent({ Ox.EditableContent({
height: 128, height: 128,
placeholder: formatLight(Ox._(isMixed ? 'Mixed notes' : 'No notes')), placeholder: formatLight(Ox._('No notes')),
tooltip: pandora.getEditTooltip(), tooltip: pandora.getEditTooltip(),
type: 'textarea', type: 'textarea',
value: data.notes || '', value: data.notes || '',
@ -504,7 +498,7 @@ pandora.ui.infoView = function(data, isMixed) {
function editMetadata(key, value) { function editMetadata(key, value) {
if (value != data[key]) { if (value != data[key]) {
var edit = {id: isMultiple ? ui.listSelection : data.id}; var edit = {id: data.id};
if (key == 'title') { if (key == 'title') {
edit[key] = value; edit[key] = value;
} else if (listKeys.indexOf(key) >= 0) { } else if (listKeys.indexOf(key) >= 0) {
@ -513,28 +507,26 @@ pandora.ui.infoView = function(data, isMixed) {
edit[key] = value ? value : null; edit[key] = value ? value : null;
} }
pandora.api.edit(edit, function(result) { pandora.api.edit(edit, function(result) {
if (!isMultiple) { data[key] = result.data[key];
data[key] = result.data[key]; descriptions[key] && descriptions[key].options({
descriptions[key] && descriptions[key].options({ value: result.data[key + 'description']
value: result.data[key + 'description'] });
}); Ox.Request.clearCache(); // fixme: too much? can change filter/list etc
Ox.Request.clearCache(); // fixme: too much? can change filter/list etc if (result.data.id != data.id) {
if (result.data.id != data.id) { pandora.UI.set({item: result.data.id});
pandora.UI.set({item: result.data.id}); pandora.$ui.browser.value(data.id, 'id', result.data.id);
pandora.$ui.browser.value(data.id, 'id', result.data.id);
}
pandora.updateItemContext();
pandora.$ui.browser.value(result.data.id, key, result.data[key]);
pandora.$ui.itemTitle
.options({
title: '<b>' + result.data.title
+ (Ox.len(result.data.director)
? ' (' + result.data.director.join(', ') + ')'
: '')
+ (result.data.year ? ' ' + result.data.year : '') + '</b>'
});
//pandora.$ui.contentPanel.replaceElement(0, pandora.$ui.browser = pandora.ui.browser());
} }
pandora.updateItemContext();
pandora.$ui.browser.value(result.data.id, key, result.data[key]);
pandora.$ui.itemTitle
.options({
title: '<b>' + result.data.title
+ (Ox.len(result.data.director)
? ' (' + result.data.director.join(', ') + ')'
: '')
+ (result.data.year ? ' ' + result.data.year : '') + '</b>'
});
//pandora.$ui.contentPanel.replaceElement(0, pandora.$ui.browser = pandora.ui.browser());
}); });
} }
} }
@ -695,7 +687,7 @@ pandora.ui.infoView = function(data, isMixed) {
format: function(value) { format: function(value) {
return formatValue(key, value); return formatValue(key, value);
}, },
placeholder: formatLight(Ox._( isMixed[key] ? 'mixed' : 'unknown')), placeholder: formatLight(Ox._('unknown')),
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
value: getValue(key, data[key]) value: getValue(key, data[key])
}) })
@ -737,12 +729,8 @@ pandora.ui.infoView = function(data, isMixed) {
.css({background: $rightsLevelElement.css('background')}) .css({background: $rightsLevelElement.css('background')})
.data({OxColor: $rightsLevelElement.data('OxColor')}) .data({OxColor: $rightsLevelElement.data('OxColor')})
renderCapabilities(rightsLevel); renderCapabilities(rightsLevel);
var edit = { pandora.api.edit({id: data.id, rightslevel: rightsLevel}, function(result) {
id: isMultiple ? ui.listSelection : data.id, // ...
rightslevel: rightsLevel
};
pandora.api.edit(edit, function(result) {
that.triggerEvent('change', Ox.extend({}, 'rightslevel', rightsLevel));
}); });
} }
}) })