fix adding video to current item
This commit is contained in:
parent
19141fe96d
commit
896b57810a
2 changed files with 104 additions and 57 deletions
|
@ -100,37 +100,69 @@ pandora.ui.addFilesDialog = function(options) {
|
|||
width: 640
|
||||
});
|
||||
|
||||
var $select = Ox.Select({
|
||||
items: [
|
||||
{
|
||||
var selectItems = [];
|
||||
if (!pandora.site.itemRequiresVideo && pandora.user.ui.item) {
|
||||
selectItems.push({
|
||||
id: 'add',
|
||||
title: Ox._(
|
||||
'Add to current {0}',
|
||||
[pandora.site.itemName.singular.toLowerCase()]
|
||||
)
|
||||
});
|
||||
selectItems.push({
|
||||
id: 'one',
|
||||
title: Ox._(
|
||||
options.items.length > 1 ? 'Create new {0} with multiple parts' : 'Create new {0}',
|
||||
[pandora.site.itemName.singular.toLowerCase()]
|
||||
)
|
||||
});
|
||||
} else {
|
||||
selectItems.push({
|
||||
id: 'one',
|
||||
title: Ox._(
|
||||
'Create one {0} with multiple parts',
|
||||
[pandora.site.itemName.singular.toLowerCase()]
|
||||
)
|
||||
},
|
||||
{
|
||||
});
|
||||
}
|
||||
if (options.items.length > 1) {
|
||||
selectItems.push({
|
||||
id: 'multiple',
|
||||
title: Ox._(
|
||||
'Create multiple {0}',
|
||||
[pandora.site.itemName.plural.toLowerCase()]
|
||||
)
|
||||
});
|
||||
}
|
||||
],
|
||||
var $select = Ox.Select({
|
||||
items: selectItems,
|
||||
width: 256
|
||||
}).css({
|
||||
display: options.items.length > 1 ? 'block' : 'none',
|
||||
display: selectItems.length > 1 ? 'block' : 'none',
|
||||
margin: '4px'
|
||||
});
|
||||
$($select.find('.OxButton')[0]).css({margin: '-1px'});
|
||||
$button.parent().parent().append($select);
|
||||
|
||||
function importVideos(callback) {
|
||||
var id;
|
||||
var id, title;
|
||||
($select.value() == 'add' ? pandora.api.get : Ox.noop)({
|
||||
id: pandora.user.ui.item,
|
||||
keys: ['title']
|
||||
}, function(result) {
|
||||
if ($select.value() == 'add') {
|
||||
title = result.data.title;
|
||||
}
|
||||
Ox.serialForEach(options.items, function(item, index, items, callback) {
|
||||
var isNewItem = index == 0 || $select.value() == 'multiple';
|
||||
if ($select.value() == 'add') {
|
||||
id = pandora.user.ui.item;
|
||||
isNewItem = false;
|
||||
} else {
|
||||
title = items[$select.value() == 'one' ? 0 : index].title;
|
||||
}
|
||||
(isNewItem ? pandora.api.add : Ox.noop)({
|
||||
title: item.title
|
||||
title: title
|
||||
}, function(result) {
|
||||
if (isNewItem) {
|
||||
id = result.data.id;
|
||||
|
@ -149,13 +181,26 @@ pandora.ui.addFilesDialog = function(options) {
|
|||
});
|
||||
});
|
||||
}, callback);
|
||||
});
|
||||
}
|
||||
|
||||
function uploadVideos(callback) {
|
||||
var id;
|
||||
var id, title;
|
||||
($select.value() == 'add' ? pandora.api.get : Ox.noop)({
|
||||
id: pandora.user.ui.item,
|
||||
keys: ['title']
|
||||
}, function(result) {
|
||||
if ($select.value() == 'add') {
|
||||
title = result.data.title;
|
||||
}
|
||||
Ox.serialForEach(options.items, function(item, index, items, callback) {
|
||||
var isNewItem = index == 0 || $select.value() == 'multiple';
|
||||
var title = items[$select.value() == 'one' ? 0 : index].title;
|
||||
if ($select.value() == 'add') {
|
||||
id = pandora.user.ui.item;
|
||||
isNewItem = false;
|
||||
} else {
|
||||
title = items[$select.value() == 'one' ? 0 : index].title;
|
||||
}
|
||||
(isNewItem ? pandora.api.add : Ox.noop)({
|
||||
title: title
|
||||
}, function(result) {
|
||||
|
@ -169,8 +214,9 @@ pandora.ui.addFilesDialog = function(options) {
|
|||
}
|
||||
}));
|
||||
callback();
|
||||
});
|
||||
})
|
||||
}, callback);
|
||||
});
|
||||
}
|
||||
|
||||
return that;
|
||||
|
|
|
@ -5,7 +5,8 @@ pandora.ui.addItemDialog = function(options) {
|
|||
|
||||
var input = '';
|
||||
|
||||
var selected = options.selected ? options.selected : 'upload';
|
||||
var selected = options.selected ? options.selected
|
||||
: !pandora.site.itemRequiresVideo && !pandora.user.ui.item ? 'add' : 'upload';
|
||||
|
||||
var $button;
|
||||
|
||||
|
|
Loading…
Reference in a new issue