mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
Merge remote-tracking branch 'origin/AD-419-decouple-piece-registration-from-' into AD-419-decouple-piece-registration-from-
This commit is contained in:
commit
7a699d7cb8
@ -184,8 +184,8 @@ function bundle(watch) {
|
|||||||
.on('error', notify.onError('Error: <%= error.message %>'))
|
.on('error', notify.onError('Error: <%= error.message %>'))
|
||||||
.pipe(gulpif(!argv.production, sourcemaps.write())) // writes .map file
|
.pipe(gulpif(!argv.production, sourcemaps.write())) // writes .map file
|
||||||
.on('error', notify.onError('Error: <%= error.message %>'))
|
.on('error', notify.onError('Error: <%= error.message %>'))
|
||||||
//.pipe(gulpif(argv.production, uglify()))
|
.pipe(gulpif(argv.production, uglify()))
|
||||||
//.on('error', notify.onError('Error: <%= error.message %>'))
|
.on('error', notify.onError('Error: <%= error.message %>'))
|
||||||
.pipe(gulp.dest('./build/js'))
|
.pipe(gulp.dest('./build/js'))
|
||||||
.on('error', notify.onError('Error: <%= error.message %>'))
|
.on('error', notify.onError('Error: <%= error.message %>'))
|
||||||
.pipe(browserSync.stream())
|
.pipe(browserSync.stream())
|
||||||
|
@ -59,6 +59,7 @@ let Form = React.createClass({
|
|||||||
for (let ref in this.refs){
|
for (let ref in this.refs){
|
||||||
data[this.refs[ref].props.name] = this.refs[ref].state.value;
|
data[this.refs[ref].props.name] = this.refs[ref].state.value;
|
||||||
}
|
}
|
||||||
|
console.log(data);
|
||||||
if ('getFormData' in this.props){
|
if ('getFormData' in this.props){
|
||||||
data = mergeOptionsWithDuplicates(data, this.props.getFormData());
|
data = mergeOptionsWithDuplicates(data, this.props.getFormData());
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import ReactAddons from 'react/addons';
|
||||||
|
|
||||||
import CollapsibleMixin from 'react-bootstrap/lib/CollapsibleMixin';
|
import CollapsibleMixin from 'react-bootstrap/lib/CollapsibleMixin';
|
||||||
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
|
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
|
||||||
@ -39,15 +40,17 @@ let PropertyCollapsile = React.createClass({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleChange(event) {
|
||||||
|
this.setState({value: event.target.value});
|
||||||
|
},
|
||||||
|
|
||||||
renderChildren() {
|
renderChildren() {
|
||||||
if(this.state.show) {
|
if(this.state.show) {
|
||||||
return (<div
|
return ReactAddons.Children.map(this.props.children, (child) => {
|
||||||
className={classNames(this.getCollapsibleClassSet()) + ' ascribe-settings-property'}
|
return ReactAddons.addons.cloneWithProps(child, {
|
||||||
ref="panel">
|
onChange: this.handleChange
|
||||||
{this.props.children}
|
});
|
||||||
</div>);
|
});
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -75,14 +78,19 @@ let PropertyCollapsile = React.createClass({
|
|||||||
onClick={this.handleFocus}
|
onClick={this.handleFocus}
|
||||||
onFocus={this.handleFocus}>
|
onFocus={this.handleFocus}>
|
||||||
<input
|
<input
|
||||||
|
onChange={this.handleChange}
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
ref="checkboxCollapsible"/>
|
ref="checkboxCollapsible"/>
|
||||||
{/* PLEASE LEAVE THE SPACE BETWEEN LABEL and this.props.label */}
|
{/* PLEASE LEAVE THE SPACE BETWEEN LABEL and this.props.label */}
|
||||||
<span className="checkbox"> {this.props.checkboxLabel}</span>
|
<span className="checkbox"> {this.props.checkboxLabel}</span>
|
||||||
</div>
|
</div>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
|
<div
|
||||||
|
className={classNames(this.getCollapsibleClassSet()) + ' ascribe-settings-property'}
|
||||||
|
ref="panel">
|
||||||
{this.renderChildren()}
|
{this.renderChildren()}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2,11 +2,6 @@
|
|||||||
|
|
||||||
import React from 'react/addons';
|
import React from 'react/addons';
|
||||||
|
|
||||||
import promise from 'es6-promise';
|
|
||||||
promise.polyfill();
|
|
||||||
|
|
||||||
import fetch from 'isomorphic-fetch';
|
|
||||||
|
|
||||||
import { getCookie } from '../../utils/fetch_api_utils';
|
import { getCookie } from '../../utils/fetch_api_utils';
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
|
||||||
@ -96,7 +91,8 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
setIsUploadReady: React.PropTypes.func,
|
setIsUploadReady: React.PropTypes.func,
|
||||||
isReadyForFormSubmission: React.PropTypes.func,
|
isReadyForFormSubmission: React.PropTypes.func,
|
||||||
areAssetsDownloadable: React.PropTypes.bool,
|
areAssetsDownloadable: React.PropTypes.bool,
|
||||||
areAssetsEditable: React.PropTypes.bool
|
areAssetsEditable: React.PropTypes.bool,
|
||||||
|
defaultErrorMessage: React.PropTypes.string
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
@ -141,7 +137,8 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
},
|
},
|
||||||
multiple: false
|
multiple: false,
|
||||||
|
defaultErrorMessage: 'Unexpected error. Please contact us if this happens repeatedly.'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -188,24 +185,21 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
multiple: this.props.multiple,
|
multiple: this.props.multiple,
|
||||||
retry: this.props.retry,
|
retry: this.props.retry,
|
||||||
callbacks: {
|
callbacks: {
|
||||||
onSubmit: this.onSubmit,
|
|
||||||
onComplete: this.onComplete,
|
onComplete: this.onComplete,
|
||||||
onCancel: this.onCancel,
|
onCancel: this.onCancel,
|
||||||
onDelete: this.onDelete,
|
|
||||||
onProgress: this.onProgress,
|
onProgress: this.onProgress,
|
||||||
onRetry: this.onRetry,
|
|
||||||
onAutoRetry: this.onAutoRetry,
|
|
||||||
onManualRetry: this.onManualRetry,
|
|
||||||
onDeleteComplete: this.onDeleteComplete,
|
onDeleteComplete: this.onDeleteComplete,
|
||||||
onSessionRequestComplete: this.onSessionRequestComplete
|
onSessionRequestComplete: this.onSessionRequestComplete,
|
||||||
|
onError: this.onError
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
requestKey(fileId) {
|
requestKey(fileId) {
|
||||||
|
let defer = new fineUploader.Promise();
|
||||||
let filename = this.state.uploader.getName(fileId);
|
let filename = this.state.uploader.getName(fileId);
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
fetch(this.props.keyRoutine.url, {
|
window.fetch(this.props.keyRoutine.url, {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
@ -223,21 +217,55 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
return res.json();
|
return res.json();
|
||||||
})
|
})
|
||||||
.then((res) =>{
|
.then((res) =>{
|
||||||
resolve(res.key);
|
defer.success(res.key);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
defer.failure(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
return defer;
|
||||||
|
},
|
||||||
|
|
||||||
|
createBlob(file) {
|
||||||
|
let defer = new fineUploader.Promise();
|
||||||
|
window.fetch(this.props.createBlobRoutine.url, {
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
},
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify({
|
||||||
|
'filename': file.name,
|
||||||
|
'key': file.key,
|
||||||
|
'piece_id': this.props.createBlobRoutine.pieceId
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
return res.json();
|
||||||
|
})
|
||||||
|
.then((res) =>{
|
||||||
|
if(res.otherdata) {
|
||||||
|
file.s3Url = res.otherdata.url_safe;
|
||||||
|
file.s3UrlSafe = res.otherdata.url_safe;
|
||||||
|
} else if(res.digitalwork) {
|
||||||
|
file.s3Url = res.digitalwork.url_safe;
|
||||||
|
file.s3UrlSafe = res.digitalwork.url_safe;
|
||||||
|
} else {
|
||||||
|
throw new Error('Could not find a url to download.');
|
||||||
|
}
|
||||||
|
defer.success(res.key);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
defer.failure(err);
|
||||||
console.error(err);
|
console.error(err);
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
return defer;
|
||||||
},
|
},
|
||||||
|
|
||||||
/* FineUploader specific callback function handlers */
|
/* FineUploader specific callback function handlers */
|
||||||
|
|
||||||
onSubmit() {
|
|
||||||
console.log('submit');
|
|
||||||
},
|
|
||||||
|
|
||||||
onComplete(id) {
|
onComplete(id) {
|
||||||
let files = this.state.filesToUpload;
|
let files = this.state.filesToUpload;
|
||||||
files[id].status = 'upload successful';
|
files[id].status = 'upload successful';
|
||||||
@ -272,57 +300,9 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createBlob(file) {
|
onError() {
|
||||||
let defer = new fineUploader.Promise();
|
let notification = new GlobalNotificationModel(this.props.defaultErrorMessage, 'danger', 5000);
|
||||||
fetch(this.props.createBlobRoutine.url, {
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
method: 'post',
|
|
||||||
headers: {
|
|
||||||
'Accept': 'application/json',
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
|
||||||
},
|
|
||||||
credentials: 'include',
|
|
||||||
body: JSON.stringify({
|
|
||||||
'filename': file.name,
|
|
||||||
'key': file.key,
|
|
||||||
'piece_id': this.props.createBlobRoutine.pieceId
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
return res.json();
|
|
||||||
})
|
|
||||||
.then((res) =>{
|
|
||||||
if(res.otherdata) {
|
|
||||||
file.s3Url = res.otherdata.url_safe;
|
|
||||||
file.s3UrlSafe = res.otherdata.url_safe;
|
|
||||||
} else if(res.digitalwork) {
|
|
||||||
file.s3Url = res.digitalwork.url_safe;
|
|
||||||
file.s3UrlSafe = res.digitalwork.url_safe;
|
|
||||||
} else {
|
|
||||||
throw new Error('Could not find a url to download.');
|
|
||||||
}
|
|
||||||
defer.success(res.key);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
});
|
|
||||||
return defer;
|
|
||||||
},
|
|
||||||
|
|
||||||
onRetry() {
|
|
||||||
console.log('retry');
|
|
||||||
},
|
|
||||||
|
|
||||||
onAutoRetry() {
|
|
||||||
console.log('autoretry');
|
|
||||||
},
|
|
||||||
|
|
||||||
onManualRetry() {
|
|
||||||
console.log('manualretry');
|
|
||||||
},
|
|
||||||
|
|
||||||
onDelete() {
|
|
||||||
console.log('delete');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancel(id) {
|
onCancel(id) {
|
||||||
|
@ -139,6 +139,7 @@ let RegisterPiece = React.createClass( {
|
|||||||
if (this.props.canSpecifyEditions) {
|
if (this.props.canSpecifyEditions) {
|
||||||
return (
|
return (
|
||||||
<PropertyCollapsible
|
<PropertyCollapsible
|
||||||
|
name="num_editions"
|
||||||
checkboxLabel={getLangText('Specify editions')}>
|
checkboxLabel={getLangText('Specify editions')}>
|
||||||
<span>{getLangText('Editions')}</span>
|
<span>{getLangText('Editions')}</span>
|
||||||
<input
|
<input
|
||||||
|
Loading…
Reference in New Issue
Block a user