mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 10:25:08 +01:00
Merge branch 'AD-777-fineuploader-needs-to-support-mul' into AD-613-cyland-white-label-page
This commit is contained in:
commit
6a0a1b1e35
@ -57,7 +57,13 @@ let FileDragAndDropDialog = React.createClass({
|
|||||||
if(this.props.multipleFiles) {
|
if(this.props.multipleFiles) {
|
||||||
return (
|
return (
|
||||||
<span className="file-drag-and-drop-dialog">
|
<span className="file-drag-and-drop-dialog">
|
||||||
{getLangText('Click or drag to add files')}
|
<p>{getLangText('Drag files here')}</p>
|
||||||
|
<p>{getLangText('or')}</p>
|
||||||
|
<span
|
||||||
|
className="btn btn-default"
|
||||||
|
onClick={this.props.onClick}>
|
||||||
|
{getLangText('choose files to upload')}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -160,7 +160,7 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
},
|
},
|
||||||
multiple: false,
|
multiple: true,
|
||||||
defaultErrorMessage: getLangText('Unexpected error. Please contact us if this happens repeatedly.')
|
defaultErrorMessage: getLangText('Unexpected error. Please contact us if this happens repeatedly.')
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -435,7 +435,9 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onCancel(id) {
|
onCancel(id) {
|
||||||
this.removeFileWithIdFromFilesToUpload(id);
|
|
||||||
|
// when a upload is canceled, we need to update this components file array
|
||||||
|
this.setStatusOfFile(id, 'canceled');
|
||||||
|
|
||||||
let notification = new GlobalNotificationModel(getLangText('File upload canceled'), 'success', 5000);
|
let notification = new GlobalNotificationModel(getLangText('File upload canceled'), 'success', 5000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
@ -455,6 +457,7 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onProgress(id, name, uploadedBytes, totalBytes) {
|
onProgress(id, name, uploadedBytes, totalBytes) {
|
||||||
|
|
||||||
let newState = React.addons.update(this.state, {
|
let newState = React.addons.update(this.state, {
|
||||||
filesToUpload: { [id]: {
|
filesToUpload: { [id]: {
|
||||||
progress: { $set: (uploadedBytes / totalBytes) * 100} }
|
progress: { $set: (uploadedBytes / totalBytes) * 100} }
|
||||||
@ -498,7 +501,9 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
let notification = new GlobalNotificationModel(getLangText('Couldn\'t delete file'), 'danger', 10000);
|
let notification = new GlobalNotificationModel(getLangText('Couldn\'t delete file'), 'danger', 10000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
} else {
|
} else {
|
||||||
this.removeFileWithIdFromFilesToUpload(id);
|
|
||||||
|
// To hide the file in this component, we need to set it's status to "deleted"
|
||||||
|
this.setStatusOfFile(id, 'deleted');
|
||||||
|
|
||||||
let notification = new GlobalNotificationModel(getLangText('File deleted'), 'success', 5000);
|
let notification = new GlobalNotificationModel(getLangText('File deleted'), 'success', 5000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
@ -521,7 +526,8 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleDeleteFile(fileId) {
|
handleDeleteFile(fileId) {
|
||||||
// In some instances (when the file was already uploaded and is just displayed to the user)
|
// In some instances (when the file was already uploaded and is just displayed to the user
|
||||||
|
// - for example in the loan contract or additional files dialog)
|
||||||
// fineuploader does not register an id on the file (we do, don't be confused by this!).
|
// fineuploader does not register an id on the file (we do, don't be confused by this!).
|
||||||
// Since you can only delete a file by its id, we have to implement this method ourselves
|
// Since you can only delete a file by its id, we have to implement this method ourselves
|
||||||
//
|
//
|
||||||
@ -532,7 +538,7 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
if(this.state.filesToUpload[fileId].status !== 'online') {
|
if(this.state.filesToUpload[fileId].status !== 'online') {
|
||||||
// delete file from server
|
// delete file from server
|
||||||
this.state.uploader.deleteFile(fileId);
|
this.state.uploader.deleteFile(fileId);
|
||||||
// this is being continues in onDeleteFile, as
|
// this is being continued in onDeleteFile, as
|
||||||
// fineuploaders deleteFile does not return a correct callback or
|
// fineuploaders deleteFile does not return a correct callback or
|
||||||
// promise
|
// promise
|
||||||
} else {
|
} else {
|
||||||
@ -739,31 +745,23 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
this.setState(newState);
|
this.setState(newState);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeFileWithIdFromFilesToUpload(fileId) {
|
|
||||||
// also, sync files from state with the ones from fineuploader
|
|
||||||
let filesToUpload = JSON.parse(JSON.stringify(this.state.filesToUpload));
|
|
||||||
|
|
||||||
// splice because I can
|
|
||||||
filesToUpload.splice(fileId, 1);
|
|
||||||
|
|
||||||
// set state
|
|
||||||
let newState = React.addons.update(this.state, {
|
|
||||||
filesToUpload: { $set: filesToUpload }
|
|
||||||
});
|
|
||||||
this.setState(newState);
|
|
||||||
},
|
|
||||||
|
|
||||||
setStatusOfFile(fileId, status) {
|
setStatusOfFile(fileId, status) {
|
||||||
// also, sync files from state with the ones from fineuploader
|
// also, sync files from state with the ones from fineuploader
|
||||||
let filesToUpload = JSON.parse(JSON.stringify(this.state.filesToUpload));
|
let filesToUpload = JSON.parse(JSON.stringify(this.state.filesToUpload));
|
||||||
|
|
||||||
// splice because I can
|
|
||||||
filesToUpload[fileId].status = status;
|
filesToUpload[fileId].status = status;
|
||||||
|
|
||||||
|
// is status is set to deleted or canceled, we also need to reset the progress
|
||||||
|
// back to zero
|
||||||
|
if(status === 'deleted' || status === 'canceled') {
|
||||||
|
filesToUpload[fileId].progress = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// set state
|
// set state
|
||||||
let newState = React.addons.update(this.state, {
|
let newState = React.addons.update(this.state, {
|
||||||
filesToUpload: { $set: filesToUpload }
|
filesToUpload: { $set: filesToUpload }
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setState(newState);
|
this.setState(newState);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -41,6 +41,9 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
||||||
|
margin-left: .7em;
|
||||||
|
margin-right: .7em;
|
||||||
|
|
||||||
.delete-file {
|
.delete-file {
|
||||||
display: block;
|
display: block;
|
||||||
background-color: black;
|
background-color: black;
|
||||||
|
Loading…
Reference in New Issue
Block a user