2011-04-23 16:45:50 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=js
|
2011-04-22 22:03:10 +00:00
|
|
|
// fixme: this is not necessarily part of OxUI
|
|
|
|
|
|
|
|
/*
|
|
|
|
============================================================================
|
|
|
|
Pan.do/ra
|
|
|
|
============================================================================
|
|
|
|
*/
|
|
|
|
|
2011-06-03 23:09:18 +00:00
|
|
|
// fixme: this doesn't belong here
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
Ox.FilesView = function(options, self) {
|
|
|
|
|
|
|
|
var self = self || {},
|
2011-04-29 12:40:51 +00:00
|
|
|
that = new Ox.Element({}, self)
|
2011-04-22 22:03:10 +00:00
|
|
|
.defaults({
|
|
|
|
id: ''
|
|
|
|
})
|
|
|
|
.options(options || {});
|
|
|
|
|
2011-06-04 01:41:47 +00:00
|
|
|
self.selected = [];
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
self.$toolbar = new Ox.Bar({
|
|
|
|
size: 24
|
|
|
|
});
|
|
|
|
|
|
|
|
self.$orderButton = new Ox.Button({
|
|
|
|
title: 'Change Order of Users...'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
margin: '4px'
|
|
|
|
})
|
|
|
|
.appendTo(self.$toolbar);
|
|
|
|
|
|
|
|
self.$moveButton = new Ox.Button({
|
|
|
|
disabled: 'true',
|
|
|
|
title: 'Move Selected Files...'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
float: 'right',
|
|
|
|
margin: '4px'
|
|
|
|
})
|
|
|
|
.appendTo(self.$toolbar);
|
|
|
|
|
|
|
|
self.$filesList = new Ox.TextList({
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
align: 'left',
|
|
|
|
id: 'users',
|
|
|
|
operator: '+',
|
|
|
|
title: 'Users',
|
|
|
|
visible: true,
|
|
|
|
width: 120
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'left',
|
|
|
|
id: 'folder',
|
|
|
|
operator: '+',
|
|
|
|
title: 'Folder',
|
|
|
|
visible: true,
|
|
|
|
width: 180
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'left',
|
|
|
|
id: 'name',
|
|
|
|
operator: '+',
|
|
|
|
title: 'Name',
|
|
|
|
visible: true,
|
|
|
|
width: 360
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'left',
|
|
|
|
id: 'type',
|
|
|
|
operator: '+',
|
|
|
|
title: 'Type',
|
|
|
|
visible: true,
|
|
|
|
width: 60
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
id: 'part',
|
|
|
|
operator: '+',
|
|
|
|
title: 'Part',
|
|
|
|
visible: true,
|
|
|
|
width: 60
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
format: {type: 'value', args: ['B']},
|
|
|
|
id: 'size',
|
|
|
|
operator: '-',
|
|
|
|
title: 'Size',
|
|
|
|
visible: true,
|
|
|
|
width: 90
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
format: {type: 'resolution', args: ['px']},
|
|
|
|
id: 'resolution',
|
|
|
|
operator: '-',
|
|
|
|
title: 'Resolution',
|
|
|
|
visible: true,
|
|
|
|
width: 90
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
format: {type: 'duration', args: [0, 'short']},
|
|
|
|
id: 'duration',
|
|
|
|
operator: '-',
|
|
|
|
title: 'Duration',
|
|
|
|
visible: true,
|
|
|
|
width: 90
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'left',
|
|
|
|
id: 'oshash',
|
|
|
|
operator: '+',
|
|
|
|
title: 'Hash',
|
|
|
|
unique: true,
|
|
|
|
visible: false,
|
|
|
|
width: 120
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'left',
|
|
|
|
id: 'instances',
|
|
|
|
operator: '+',
|
|
|
|
title: 'Instances',
|
|
|
|
visible: false,
|
|
|
|
width: 120
|
|
|
|
}
|
|
|
|
],
|
|
|
|
columnsMovable: true,
|
|
|
|
columnsRemovable: true,
|
|
|
|
columnsResizable: true,
|
|
|
|
columnsVisible: true,
|
|
|
|
id: 'files',
|
|
|
|
items: function(data, callback) {
|
|
|
|
pandora.api.findFiles($.extend(data, {
|
|
|
|
query: {
|
|
|
|
conditions: [{
|
|
|
|
key: 'id',
|
|
|
|
value: self.options.id,
|
|
|
|
operator: '='
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
}), callback);
|
|
|
|
},
|
|
|
|
scrollbarVisible: true,
|
2011-06-04 02:32:42 +00:00
|
|
|
sort: [{key: 'name', operator: '+'}]
|
2011-04-22 22:03:10 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
open: openFiles,
|
|
|
|
select: selectFiles
|
|
|
|
});
|
|
|
|
|
2011-06-04 02:32:42 +00:00
|
|
|
self.$instancesList = Ox.TextList({
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
align: 'left',
|
|
|
|
id: 'user',
|
|
|
|
operator: '+',
|
|
|
|
title: 'User',
|
|
|
|
visible: true,
|
|
|
|
width: 120
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'left',
|
|
|
|
id: 'volume',
|
|
|
|
operator: '+',
|
|
|
|
title: 'Volume',
|
|
|
|
visible: true,
|
|
|
|
width: 120
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'left',
|
|
|
|
id: 'folder',
|
|
|
|
operator: '+',
|
|
|
|
title: 'Folder',
|
|
|
|
visible: true,
|
|
|
|
width: 180
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'left',
|
|
|
|
id: 'name',
|
|
|
|
operator: '+',
|
|
|
|
title: 'Name',
|
|
|
|
visible: true,
|
|
|
|
width: 360
|
|
|
|
},
|
|
|
|
],
|
|
|
|
columnsMovable: true,
|
|
|
|
columnsRemovable: true,
|
|
|
|
columnsResizable: true,
|
|
|
|
columnsVisible: true,
|
|
|
|
id: 'files',
|
|
|
|
items: [],
|
|
|
|
scrollbarVisible: true,
|
|
|
|
sort: [{key: 'user', operator: '+'}]
|
|
|
|
});
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-06-04 01:41:47 +00:00
|
|
|
self.$movieLabel = Ox.Label({
|
|
|
|
textAlign: 'center',
|
|
|
|
title: 'Move Selected Files to Another Movie',
|
|
|
|
width: 240
|
|
|
|
})
|
|
|
|
.css({margin: '8px'});
|
|
|
|
|
|
|
|
['title', 'director', 'year', 'id'].forEach(function(key) {
|
|
|
|
self['$' + key + 'Input'] = Ox.Input({
|
|
|
|
clear: true,
|
|
|
|
id: key,
|
|
|
|
label: key == 'id' ? 'ID' : Ox.toTitleCase(key),
|
|
|
|
labelWidth: 64,
|
|
|
|
width: 240
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
var conditions;
|
|
|
|
if (data.value.length) {
|
|
|
|
if (key == 'id') {
|
|
|
|
conditions = [{key: 'id', value: data.value, operator: '='}]
|
|
|
|
} else {
|
|
|
|
conditions = Ox.map(['title', 'director', 'year'], function(key) {
|
|
|
|
var value = self['$' + key + 'Input'].options('value')
|
|
|
|
return value.length ? {key: key, value: value, operator: '='} : null;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
pandora.api.find({
|
|
|
|
keys: ['title', 'director', 'year', 'id'],
|
|
|
|
query: {
|
|
|
|
conditions: conditions,
|
|
|
|
operator: '&'
|
|
|
|
},
|
|
|
|
range: [0, 2]
|
|
|
|
}, function(result) {
|
|
|
|
var length = result.data.items.length;
|
|
|
|
if (length == 0) {
|
|
|
|
if (key != 'id') {
|
|
|
|
self.$idInput.options({value: ''});
|
|
|
|
}
|
|
|
|
} else if (result.data.items.length == 1) {
|
|
|
|
['title', 'director', 'year', 'id'].forEach(function(key) {
|
|
|
|
self['$' + key + 'Input'].options({
|
|
|
|
value: key == 'director'
|
|
|
|
? result.data.items[0][key].join(', ')
|
|
|
|
: result.data.items[0][key]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
self.$idInput.options({value: ''});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
self.$checkbox = Ox.Checkbox({
|
|
|
|
checked: false,
|
|
|
|
id: 'go',
|
|
|
|
title: 'Go to this movie after moving files', // fixme: wrong, can be 'Go to video' etc
|
|
|
|
width: 240
|
|
|
|
});
|
|
|
|
|
|
|
|
self.$movieForm = Ox.Form({
|
|
|
|
items: [
|
|
|
|
self.$titleInput,
|
|
|
|
self.$directorInput,
|
|
|
|
self.$yearInput,
|
|
|
|
self.$idInput,
|
|
|
|
self.$checkbox
|
|
|
|
],
|
|
|
|
width: 240
|
|
|
|
})
|
|
|
|
.css({margin: '8px'});
|
|
|
|
|
|
|
|
self.$clearButton = Ox.Button({
|
2011-06-04 02:32:42 +00:00
|
|
|
title: 'Clear Form',
|
2011-06-04 01:41:47 +00:00
|
|
|
width: 116
|
|
|
|
})
|
|
|
|
.css({margin: '0 4px 4px 8px'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
['title', 'director', 'year', 'id'].forEach(function(key) {
|
|
|
|
self['$' + key + 'Input'].options({value: ''})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
self.$moveButton = Ox.Button({
|
|
|
|
disabled: true,
|
2011-06-04 02:32:42 +00:00
|
|
|
title: 'Move Files',
|
2011-06-04 01:41:47 +00:00
|
|
|
width: 116
|
|
|
|
})
|
|
|
|
.css({margin: '0 4px 4px 4px'});
|
|
|
|
|
|
|
|
self.$moviePanel = Ox.Element()
|
|
|
|
.append(self.$movieLabel)
|
|
|
|
.append(self.$movieForm)
|
|
|
|
.append(self.$clearButton)
|
|
|
|
.append(self.$moveButton);
|
|
|
|
|
|
|
|
that.$element = Ox.SplitPanel({
|
2011-04-22 22:03:10 +00:00
|
|
|
elements: [
|
|
|
|
{
|
2011-06-04 01:41:47 +00:00
|
|
|
element: Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: self.$toolbar,
|
|
|
|
size: 24
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: self.$filesList
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: self.$instancesList,
|
|
|
|
size: 80
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
})
|
2011-04-22 22:03:10 +00:00
|
|
|
},
|
|
|
|
{
|
2011-06-04 01:41:47 +00:00
|
|
|
collapsible: true,
|
|
|
|
element: self.$moviePanel,
|
|
|
|
size: 256
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
],
|
2011-06-04 01:41:47 +00:00
|
|
|
orientation: 'horizontal'
|
2011-04-22 22:03:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function openFiles(event, data) {
|
2011-06-04 01:41:47 +00:00
|
|
|
Ox.print('........', JSON.stringify(self.$filesList.value(data.ids[0], 'instances')))
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
|
2011-06-04 01:41:47 +00:00
|
|
|
function selectFiles(data) {
|
2011-06-04 02:32:42 +00:00
|
|
|
Ox.print('........', JSON.stringify(self.$filesList.value(data.ids[0], 'instances')))
|
2011-06-04 01:41:47 +00:00
|
|
|
self.selected = data.ids;
|
2011-06-04 02:32:42 +00:00
|
|
|
self.$instancesList.options({
|
|
|
|
items: data.ids.length == 1
|
|
|
|
? self.$filesList.value(data.ids[0], 'instances') : []
|
|
|
|
});
|
2011-06-04 01:41:47 +00:00
|
|
|
updateForm();
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateForm() {
|
|
|
|
self.$moveButton.options({
|
|
|
|
disabled: self.selected.length === 0
|
|
|
|
});
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|