fix manage files to load again and handle upper case extensions

This commit is contained in:
j 2013-04-28 17:57:24 +00:00
parent 70271b4649
commit 001e85eea7
3 changed files with 27 additions and 23 deletions

View file

@ -186,16 +186,6 @@ pandora.ui.filesDialog = function() {
} }
}), }),
$itemLabel = Ox.Label({
textAlign: 'center',
title: 'No file selected',
width: getLabelWidth()
})
.css({
float: 'left',
margin: '4px'
}),
$closeButton = Ox.Button({ $closeButton = Ox.Button({
title: 'close', title: 'close',
tooltip: 'Close', tooltip: 'Close',
@ -293,6 +283,16 @@ pandora.ui.filesDialog = function() {
orientation: 'horizontal' orientation: 'horizontal'
}), }),
$itemLabel = Ox.Label({
textAlign: 'center',
title: 'No file selected',
width: getLabelWidth()
})
.css({
float: 'left',
margin: '4px'
}),
that = Ox.Dialog({ that = Ox.Dialog({
buttons: [ buttons: [
Ox.Button({ Ox.Button({
@ -521,17 +521,17 @@ pandora.ui.filesDialog = function() {
pandora.ui.uploadFileDialog(data.files[0], function(file) { pandora.ui.uploadFileDialog(data.files[0], function(file) {
Ox.Request.clearCache('findFiles'); Ox.Request.clearCache('findFiles');
pandora.api.findFiles({ pandora.api.findFiles({
ids: [file.id], positions: [file.id],
query: $list.options.query, query: $list.options('query'),
sort: $list.options.sort, sort: $list.options('sort'),
}, function(data) { }, function(data) {
$list.bindEventOnce({ $list.bindEventOnce({
load: function() { load: function() {
list.options({selected: [file.id]}); $list.options({selected: [file.id]});
// selectFile(file.id); // selectFile(file.id);
} }
}); });
if (data.positions[file.id] > -1) { if (data.data.positions[file.id] > -1) {
$list.reloadList(); $list.reloadList();
} else { } else {
$list.options({ $list.options({

View file

@ -7,6 +7,11 @@ pandora.ui.uploadFileDialog = function(file, callback) {
extensions = ['gif', 'jpg', 'jpeg', 'pdf', 'png'], extensions = ['gif', 'jpg', 'jpeg', 'pdf', 'png'],
filename = file.name.split('.').slice(0, -1).join('.') + '.'
+ (extension == 'jpeg' ? 'jpg' : extension),
id = pandora.user.username + ':' + filename,
upload, upload,
$errorDialog, $errorDialog,
@ -40,7 +45,9 @@ pandora.ui.uploadFileDialog = function(file, callback) {
if (title == 'Cancel Upload') { if (title == 'Cancel Upload') {
upload.abort(); upload.abort();
} else if (title == 'Done') { } else if (title == 'Done') {
callback(); callback({
id: id
});
} }
} }
}) })
@ -55,9 +62,7 @@ pandora.ui.uploadFileDialog = function(file, callback) {
open: function() { open: function() {
upload = pandora.chunkupload({ upload = pandora.chunkupload({
data: { data: {
filename: extension == 'jpeg' filename: filename
? file.name.split('.').slice(0, -1).join('.') + '.jpg'
: file.name
}, },
file: file, file: file,
url: '/api/upload/file/', url: '/api/upload/file/',
@ -93,11 +98,10 @@ pandora.ui.uploadFileDialog = function(file, callback) {
range: [0, 1], range: [0, 1],
sort: [{key: 'name', operator: '+'}] sort: [{key: 'name', operator: '+'}]
}, function(result) { }, function(result) {
var id = pandora.user.name + ':' + file.name;
if (result.data.items.length) { if (result.data.items.length) {
errorDialog( errorDialog(
'The file ' + id + ' already exists' + ( 'The file ' + id + ' already exists' + (
file.name == result.data.items[0].id filename == result.data.items[0].id
? '' ? ''
: ' as ' + result.data.items[0].id : ' as ' + result.data.items[0].id
) + '.' ) + '.'