update metadata dialog

This commit is contained in:
rolux 2013-02-25 16:36:38 +00:00
parent ac6ad162ba
commit 94009e1622

View file

@ -4,12 +4,12 @@ pandora.ui.metadataDialog = function(data) {
var keys = [ var keys = [
'title', 'alternativeTitles', 'title', 'alternativeTitles',
'director', 'country', 'year', 'language', 'runtime', 'director',
// 'productionCompany', 'country', 'year', 'language', 'runtime', 'color', 'sound',
'productionCompany',
'producer', 'writer', 'cinematographer', 'editor', 'actor', 'producer', 'writer', 'cinematographer', 'editor', 'actor',
'genre', 'keyword', 'genre', 'keyword',
'summary' 'summary'
// color, sound
], ],
updateKeys, updateKeys,
dialogHeight = Math.round((window.innerHeight - 48) * 0.9), dialogHeight = Math.round((window.innerHeight - 48) * 0.9),
@ -75,7 +75,6 @@ pandora.ui.metadataDialog = function(data) {
that.close(); that.close();
} }
}), }),
{},
Ox.Button({ Ox.Button({
disabled: true, disabled: true,
id: 'update', id: 'update',
@ -177,7 +176,7 @@ pandora.ui.metadataDialog = function(data) {
keys.forEach(function(key, index) { keys.forEach(function(key, index) {
var isEqual = Ox.isEqual(data[key], imdb[key]), var isEqual = Ox.isEqual(data[key], imdb[key]),
checked = isEqual ? [true, true] checked = isEqual ? [true, true]
: !Ox.isUndefined(data) && Ox.isUndefined(imdb[key]) ? [true, false] : !Ox.isUndefined(data[key]) && Ox.isUndefined(imdb[key]) ? [true, false]
: [false, true]; : [false, true];
if (index > 0) { if (index > 0) {
$('<div>') $('<div>')
@ -243,9 +242,11 @@ pandora.ui.metadataDialog = function(data) {
} }
function formatValue(key, value) { function formatValue(key, value) {
return key == 'alternativeTitles' ? value.map(function(v) { return !value ? ''
: key == 'alternativeTitles' ? value.map(function(v) {
return v[0]; return v[0];
}).join('; ') }).join('; ')
: key == 'runtime' ? Ox.formatDuration(value, 0, 'short')
: Ox.isArray( : Ox.isArray(
Ox.getObjectById(pandora.site.itemKeys, key).type Ox.getObjectById(pandora.site.itemKeys, key).type
) ? value.join(', ') ) ? value.join(', ')
@ -263,14 +264,10 @@ pandora.ui.metadataDialog = function(data) {
function getUpdateKeys() { function getUpdateKeys() {
return keys.filter(function(key) { return keys.filter(function(key) {
return $input[key][0].options('value')[0] === false; return $input[key][0].options('inputs')[0].options('value') === false;
}); });
} }
function parseValue(value, type) {
return Ox.isArray(type) ? ', '.split(value) : value;
}
function setSize(data) { function setSize(data) {
dialogHeight = data.height; dialogHeight = data.height;
dialogWidth = data.width; dialogWidth = data.width;
@ -288,9 +285,12 @@ pandora.ui.metadataDialog = function(data) {
} }
function updateMetadata() { function updateMetadata() {
var edit = {id: data.id}; var edit = {id: data.id},
type = Ox.getObjectById(pandora.site.itemKeys, key).type;
updateKeys.forEach(function(key) { updateKeys.forEach(function(key) {
edit[key] = imdb[key]; edit[key] = imdb[key] || (
Ox.isArray(type) ? [] : ''
);
}); });
that.disableButtons(); that.disableButtons();
pandora.api.edit(edit, function(result) { pandora.api.edit(edit, function(result) {