move reloadMetadata from toolbar to doubleclick on title or director

This commit is contained in:
rolux 2011-10-30 15:15:27 +00:00
parent 64bf2a3a71
commit 7edf7ac0db
3 changed files with 27 additions and 34 deletions

View file

@ -20,7 +20,6 @@
"canEditUsers": {"admin": true}, "canEditUsers": {"admin": true},
"canPlayClips": {"guest": 2, "member": 2, "friend": 4, "staff": 4, "admin": 4}, "canPlayClips": {"guest": 2, "member": 2, "friend": 4, "staff": 4, "admin": 4},
"canPlayVideo": {"guest": 1, "member": 1, "friend": 4, "staff": 4, "admin": 4}, "canPlayVideo": {"guest": 1, "member": 1, "friend": 4, "staff": 4, "admin": 4},
"canReloadMetadata": {"staff": true, "admin": true},
"canSeeDebugMenu": {"staff": true, "admin": true}, "canSeeDebugMenu": {"staff": true, "admin": true},
"canSeeFiles": {"staff": true, "admin": true}, "canSeeFiles": {"staff": true, "admin": true},
"canSeeItem": {"guest": 3, "member": 3, "friend": 4, "staff": 4, "admin": 4}, "canSeeItem": {"guest": 3, "member": 3, "friend": 4, "staff": 4, "admin": 4},

View file

@ -141,7 +141,8 @@ pandora.ui.infoView = function(data) {
format: function(value) { format: function(value) {
return formatTitle(value); return formatTitle(value);
}, },
tooltip: isEditable ? 'Doubleclick to edit' : '', tooltip: isEditable ? 'Doubleclick to edit'
: canEdit ? 'Doubleclick to reload metadata' : '',
value: data.title value: data.title
}) })
.css({ .css({
@ -151,11 +152,13 @@ pandora.ui.infoView = function(data) {
MozUserSelect: 'text', MozUserSelect: 'text',
WebkitUserSelect: 'text' WebkitUserSelect: 'text'
}) })
.bindEvent({ .bindEvent(Ox.extend({
submit: function(event) { submit: function(event) {
editMetadata('title', event.value); editMetadata('title', event.value);
} }
}) }, !isEditable && canEdit ? {
doubleclick: reloadMetadata
} : {}))
.appendTo($text) .appendTo($text)
) )
.appendTo($text); .appendTo($text);
@ -176,7 +179,8 @@ pandora.ui.infoView = function(data) {
? formatValue(value.split(', '), 'name') ? formatValue(value.split(', '), 'name')
: formatLight('Unknown Director'); : formatLight('Unknown Director');
}, },
tooltip: isEditable ? 'Doubleclick to edit' : '', tooltip: isEditable ? 'Doubleclick to edit'
: canEdit ? 'Doubleclick to reload metadata' : '',
value: data.director ? data.director.join(', ') : 'Unknown Director' value: data.director ? data.director.join(', ') : 'Unknown Director'
}) })
.css({ .css({
@ -186,11 +190,13 @@ pandora.ui.infoView = function(data) {
MozUserSelect: 'text', MozUserSelect: 'text',
WebkitUserSelect: 'text' WebkitUserSelect: 'text'
}) })
.bindEvent({ .bindEvent(Ox.extend({
submit: function(event) { submit: function(event) {
editMetadata('director', event.value); editMetadata('director', event.value);
} }
}) }, !isEditable && canEdit ? {
doubleclick: reloadMetadata
} : {}))
) )
.appendTo($text); .appendTo($text);
} }
@ -564,6 +570,21 @@ pandora.ui.infoView = function(data) {
return data; return data;
} }
function reloadMetadata() {
var item = ui.item;
// fixme: maybe there's a better method name for this?
pandora.api.updateExternalData({
id: ui.item
}, function(result) {
Ox.Request.clearCache(item);
if (ui.item == item && ui.itemView == 'info') {
pandora.$ui.contentPanel.replaceElement(
1, pandora.$ui.item = pandora.ui.item()
);
}
});
}
function renderCapabilities(rightsLevel) { function renderCapabilities(rightsLevel) {
var capabilities = Ox.merge( var capabilities = Ox.merge(
canEdit ? [{name: 'canSeeItem', symbol: 'Find'}] : [], canEdit ? [{name: 'canSeeItem', symbol: 'Find'}] : [],

View file

@ -23,33 +23,6 @@ pandora.ui.toolbar = function() {
pandora.$ui.orderButton = pandora.ui.orderButton() pandora.$ui.orderButton = pandora.ui.orderButton()
); );
} }
if (
ui.item && ui.itemView == 'info'
&& pandora.site.capabilities.canReloadMetadata[pandora.user.level]
) {
that.append(
Ox.Button({
title: 'Reload Metadata'
})
.css({float: 'left', margin: '4px'})
.bindEvent({
click: function() {
var item = ui.item;
// fixme: maybe there's a better method name for this?
pandora.api.updateExternalData({
id: ui.item
}, function(result) {
Ox.Request.clearCache(item);
if (ui.item == item && ui.itemView == 'info') {
pandora.$ui.contentPanel.replaceElement(
1, pandora.$ui.item = pandora.ui.item()
);
}
});
}
})
);
}
that.append( that.append(
pandora.$ui.findElement = pandora.ui.findElement() pandora.$ui.findElement = pandora.ui.findElement()
); );