mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
implement submission for autofill firefox and chrome
This commit is contained in:
parent
ea88e87355
commit
bf2a766e84
@ -69,7 +69,7 @@ gulp.task('js:build', function() {
|
||||
bundle(false);
|
||||
});
|
||||
|
||||
gulp.task('serve', ['browser-sync', 'run-server', 'lint:watch', 'sass:build', 'sass:watch', 'copy'], function() {
|
||||
gulp.task('serve', ['browser-sync', 'run-server', 'sass:build', 'sass:watch', 'copy'], function() {
|
||||
bundle(true);
|
||||
});
|
||||
|
||||
|
@ -137,9 +137,12 @@ let Form = React.createClass({
|
||||
});
|
||||
},
|
||||
render() {
|
||||
|
||||
return (
|
||||
<form role="form" className="ascribe-form" onSubmit={this.submit} autoComplete="on">
|
||||
<form
|
||||
role="form"
|
||||
className="ascribe-form"
|
||||
onSubmit={this.submit}
|
||||
autoComplete="on">
|
||||
{this.getErrors()}
|
||||
{this.renderChildren()}
|
||||
{this.getButtons()}
|
||||
|
@ -118,7 +118,7 @@ var ReactS3FineUploader = React.createClass({
|
||||
},
|
||||
|
||||
getCookie(name) {
|
||||
console.log(document.cookie);
|
||||
//console.log(document);
|
||||
let value = '; ' + document.cookie;
|
||||
let parts = value.split('; ' + name + '=');
|
||||
if (parts.length === 2) {
|
||||
@ -126,31 +126,33 @@ var ReactS3FineUploader = React.createClass({
|
||||
}
|
||||
},
|
||||
requestKey(fileId) {
|
||||
//console.log(this.getCookie('csrftoken'));
|
||||
let filename = this.state.uploader.getName(fileId);
|
||||
let defer = new fineUploader.Promise();
|
||||
fetch(this.props.keyRoutine.url, {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': this.getCookie('csrftoken')
|
||||
},
|
||||
credentials: 'include',
|
||||
body: JSON.stringify({
|
||||
'filename': filename,
|
||||
'file_class': 'digitalwork'
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(this.props.keyRoutine.url, {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': this.getCookie('csrftoken')
|
||||
},
|
||||
credentials: 'include',
|
||||
body: JSON.stringify({
|
||||
'filename': filename,
|
||||
'file_class': 'digitalwork'
|
||||
})
|
||||
})
|
||||
})
|
||||
.then((res) => {
|
||||
return res.json();
|
||||
})
|
||||
.then((res) =>{
|
||||
defer.success(res.key);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
.then((res) => {
|
||||
return res.json();
|
||||
})
|
||||
.then((res) =>{
|
||||
resolve(res.key);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
return defer;
|
||||
},
|
||||
|
||||
/* FineUploader specific callback function handlers */
|
||||
|
@ -37,16 +37,27 @@ let LoginForm = React.createClass({
|
||||
handleSuccess(){
|
||||
let notification = new GlobalNotificationModel('Login successsful', 'success', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
this.transitionTo('pieces');
|
||||
|
||||
/*Taken from http://stackoverflow.com/a/14916411 */
|
||||
/*
|
||||
We actually have to trick the Browser into showing the "save password" dialog
|
||||
as Chrome expects the login page to be reloaded after the login.
|
||||
Users on Stack Overflow claim this is a bug in chrome and should be fixed in the future.
|
||||
Until then, we redirect the HARD way, but reloading the whole page using window.location
|
||||
*/
|
||||
window.location = '/collection';
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Form
|
||||
ref="loginForm"
|
||||
url={apiUrls.users_login}
|
||||
handleSuccess={this.handleSuccess}
|
||||
buttons={
|
||||
<button type="submit" className="btn ascribe-btn ascribe-btn-login">
|
||||
<button
|
||||
type="submit"
|
||||
className="btn ascribe-btn ascribe-btn-login">
|
||||
Log in to ascribe
|
||||
</button>}
|
||||
spinner={
|
||||
@ -61,6 +72,7 @@ let LoginForm = React.createClass({
|
||||
type="email"
|
||||
placeholder="Enter your email"
|
||||
autoComplete="on"
|
||||
name="username"
|
||||
required/>
|
||||
</Property>
|
||||
<Property
|
||||
@ -70,6 +82,7 @@ let LoginForm = React.createClass({
|
||||
type="password"
|
||||
placeholder="Enter your password"
|
||||
autoComplete="on"
|
||||
name="password"
|
||||
required/>
|
||||
</Property>
|
||||
<hr />
|
||||
|
@ -40,7 +40,7 @@ let RegisterPiece = React.createClass( {
|
||||
return data;
|
||||
},
|
||||
handleChange(){
|
||||
this.setState({digital_work_key: this.refs.uploader.refs.fineuploader.state.filesToUpload[0].key})
|
||||
this.setState({digital_work_key: this.refs.uploader.refs.fineuploader.state.filesToUpload[0].key});
|
||||
},
|
||||
|
||||
render() {
|
||||
|
Loading…
Reference in New Issue
Block a user