initial documents view

This commit is contained in:
j 2013-05-27 12:29:43 +00:00
parent 71846d5461
commit 85bb82f683
3 changed files with 190 additions and 0 deletions

View file

@ -641,6 +641,7 @@
"itemRequiresVideo": false, "itemRequiresVideo": false,
"itemViews": [ "itemViews": [
{"id": "info", "title": "Info"}, {"id": "info", "title": "Info"},
{"id": "documents", "title": "Documents"},
{"id": "player", "title": "Player"}, {"id": "player", "title": "Player"},
{"id": "editor", "title": "Editor"}, {"id": "editor", "title": "Editor"},
{"id": "timeline", "title": "Timeline"}, {"id": "timeline", "title": "Timeline"},

View file

@ -0,0 +1,180 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict';
pandora.ui.documentsView = function(options, self) {
var self = self || {},
that = Ox.Element({}, self)
.defaults({
id: ''
})
.options(options || {});
self.selected = null;
self.$toolbar = Ox.Bar({
size: 24
});
self.$preview = Ox.Element();
self.$documentsList = Ox.TableList({
columns: [
{
align: 'left',
id: 'index',
operator: '+',
title: Ox._('Index'),
visible: false,
width: 60
},
{
align: 'left',
id: 'id',
operator: '+',
title: Ox._('ID'),
visible: false,
width: 60
},
{
align: 'left',
id: 'user',
operator: '+',
title: Ox._('User'),
visible: false,
width: 60
},
{
align: 'left',
id: 'name',
operator: '+',
title: Ox._('Name'),
visible: true,
width: 360
},
{
id: 'extension',
operator: '+',
title: Ox._('Extension'),
visible: false,
width: 60
},
{
editable: true,
id: 'description',
operator: '+',
title: Ox._('Description'),
visible: true,
width: 240
}
],
columnsMovable: true,
columnsRemovable: true,
columnsResizable: true,
columnsVisible: true,
items: options.documents,
scrollbarVisible: true,
sort: [{key: 'index', operator: '+'}],
sortable: true,
unique: 'id'
})
.bindEvent({
add: function(data) {
pandora.$ui.documentsDialog = pandora.ui.documentsDialog().open();
},
'delete': function(data) {
if (data.ids.length > 0 && options.editable) {
pandora.api.removeDocument({
ids: data.ids,
item: pandora.user.ui.item
}, function(result) {
Ox.Request.clearCache();
//fixme just upload list here
//self.$documentsList.reloadList();
pandora.$ui.contentPanel.replaceElement(1,
pandora.$ui.item = pandora.ui.item());
});
}
},
move: function(data) {
Ox.Request.clearCache();
pandora.api.sortDocuments({
item: pandora.user.ui.item,
ids: data.ids
})
},
select: selectDocument,
submit: function(data) {
var value = self.$documentsList.value(data.id, data.key);
if (data.value != value && !(data.value === '' && value === null)) {
self.$documentsList.value(data.id, data.key, data.value || null);
data.key == 'description' && pandora.api.editDocument({
description: data.value,
id: data.id,
item: pandora.user.ui.item
}, function(result) {
//if description is empty, fall back to global description
self.$documentsList.value(data.id, data.key, result.data.description);
renderPreview();
});
}
}
});
function renderPreview() {
var isImage = Ox.contains(['jpg', 'png'], self.selected.split('.').pop()),
size = {width: 256, height: 256},
src = '/documents/' + self.selected + (isImage ? '' : '.jpg');
self.$preview.empty();
self.selected && self.$preview
.append(Ox.ImageElement({
height: size.height,
src: src,
width: size.width
}))
.append(Ox.Element()
.html(self.$documentsList.value(self.selected, 'description')
));
}
function selectDocument(data) {
if (data.ids[0] != self.selected) {
self.selected = data.ids[0];
renderPreview();
}
}
that.setElement(Ox.SplitPanel({
elements: [
{
element: Ox.SplitPanel({
elements: [
{
element: self.$toolbar,
size: 24
},
{
element: self.$documentsList
},
],
orientation: 'vertical'
})
},
{
collapsible: true,
element: self.$preview,
size: 256
}
],
orientation: 'horizontal'
})
);
that.reload = function() {
self.$documentsList.reloadList();
}
return that;
};

View file

@ -16,6 +16,9 @@ pandora.ui.item = function() {
'cuts', 'director', 'duration', 'editable', 'layers', 'cuts', 'director', 'duration', 'editable', 'layers',
'parts', 'posterFrame', 'rendered', 'rightslevel', 'parts', 'posterFrame', 'rendered', 'rightslevel',
'size', 'title', 'videoRatio', 'year' 'size', 'title', 'videoRatio', 'year'
] : pandora.user.ui.itemView == 'documents' ? [
'director', 'documents', 'duration', 'editable',
'rightslevel', 'size', 'title', 'videoRatio', 'year'
] : [] ] : []
}, pandora.user.ui.itemView == 'info' && pandora.site.capabilities.canEditMetadata[pandora.user.level] ? 0 : -1, function(result) { }, pandora.user.ui.itemView == 'info' && pandora.site.capabilities.canEditMetadata[pandora.user.level] ? 0 : -1, function(result) {
@ -69,6 +72,12 @@ pandora.ui.item = function() {
} }
}) })
); );
} else if (pandora.user.ui.itemView == 'documents') {
pandora.$ui.contentPanel.replaceElement(1,
pandora.$ui.documentsView = pandora.ui.documentsView(result.data)
);
} else if (pandora.user.ui.itemView == 'player') { } else if (pandora.user.ui.itemView == 'player') {