diff --git a/js/actions/loan_contract_actions.js b/js/actions/loan_contract_actions.js
index 95c52d93..54405810 100644
--- a/js/actions/loan_contract_actions.js
+++ b/js/actions/loan_contract_actions.js
@@ -19,13 +19,15 @@ class LoanContractActions {
if (contracts && contracts.length > 0) {
this.actions.updateLoanContract({
contractKey: contracts[0].s3Key,
- contractUrl: contracts[0].s3Url
+ contractUrl: contracts[0].s3Url,
+ contractEmail: email
});
}
else {
this.actions.updateLoanContract({
contractKey: null,
- contractUrl: null
+ contractUrl: null,
+ contractEmail: null
});
}
})
@@ -33,7 +35,8 @@ class LoanContractActions {
console.error(err);
this.actions.updateLoanContract({
contractKey: null,
- contractUrl: null
+ contractUrl: null,
+ contractEmail: null
});
});
} else {
diff --git a/js/components/ascribe_buttons/acl_button.js b/js/components/ascribe_buttons/acl_button.js
index c479174c..053320f5 100644
--- a/js/components/ascribe_buttons/acl_button.js
+++ b/js/components/ascribe_buttons/acl_button.js
@@ -79,7 +79,7 @@ let AclButton = React.createClass({
form: (
+ url={this.isPiece() ? apiUrls.ownership_loans_pieces : apiUrls.ownership_loans_editions}/>
),
handleSuccess: this.showNotification
};
diff --git a/js/components/ascribe_forms/form_loan_new.js b/js/components/ascribe_forms/form_loan_new.js
index c25ef78a..f28aa28f 100644
--- a/js/components/ascribe_forms/form_loan_new.js
+++ b/js/components/ascribe_forms/form_loan_new.js
@@ -14,7 +14,9 @@ import LoanContractStore from '../../stores/loan_contract_store';
import LoanContractActions from '../../actions/loan_contract_actions';
import AppConstants from '../../constants/application_constants';
-import { getLangText } from '../../utils/lang_utils.js';
+
+import { mergeOptions } from '../../utils/general_utils';
+import { getLangText } from '../../utils/lang_utils';
let LoanForm = React.createClass({
@@ -54,13 +56,14 @@ let LoanForm = React.createClass({
if(this.state.contractKey && this.state.contractUrl) {
return (
+ name="terms"
+ className="ascribe-settings-property-collapsible-toggle"
+ style={{paddingBottom: 0}}>
{getLangText('I agree to the')}
- {getLangText('terms of')} {this.refs.loaneeEmail.getDomNode().value}
+ {getLangText('terms of')} {this.state.contractEmail}
@@ -69,6 +72,20 @@ let LoanForm = React.createClass({
}
},
+ onRequestHide() {
+ // Since the modal can be opened without sending it to the server
+ // and therefore clearing the store,
+ // we'll need to make sure to flush the store once the
+ // modal unmounts
+ LoanContractActions.updateLoanContract({
+ contractUrl: null,
+ contractEmail: null,
+ contractKey: null
+ });
+
+ this.props.onRequestHide();
+ },
+
render() {
return (
@@ -86,7 +103,7 @@ let LoanForm = React.createClass({
+ onClick={this.onRequestHide}>{getLangText('CLOSE')}
}
spinner={
@@ -107,9 +124,8 @@ let LoanForm = React.createClass({
label={getLangText('Gallery/exhibition (optional)')}
onBlur={this.handleOnBlur}>
+ type="text"
+ placeholder={getLangText('Gallery/exhibition (optional)')}/>
- {this.getContractCheckbox()}
+
@@ -143,7 +159,7 @@ let LoanForm = React.createClass({
placeholder={getLangText('Enter your password')}
required/>
-
+ {this.getContractCheckbox()}
);
}
diff --git a/js/components/ascribe_forms/input_date.js b/js/components/ascribe_forms/input_date.js
index 56af046e..3097bdd1 100644
--- a/js/components/ascribe_forms/input_date.js
+++ b/js/components/ascribe_forms/input_date.js
@@ -2,7 +2,6 @@
import React from 'react';
-import AlertMixin from '../../mixins/alert_mixin';
import DatePicker from 'react-datepicker/dist/react-datepicker';
let InputDate = React.createClass({
@@ -11,31 +10,33 @@ let InputDate = React.createClass({
placeholderText: React.PropTypes.string
},
- mixins: [AlertMixin],
-
getInitialState() {
return {
- value: null,
- value_formatted: null,
- alerts: null // needed in AlertMixin
+ value: null
};
},
handleChange(date) {
+ let formattedDate = date.format('YYYY-MM-DD');
this.setState({
- value: date,
- value_formatted: date.format('YYYY-MM-DD')});
+ value: formattedDate,
+ value_moment: date
+ });
+
+ this.props.onChange({
+ target: {
+ value: formattedDate
+ }
+ });
},
render: function () {
- let alerts = (this.props.submitted) ? null : this.state.alerts;
+ console.log(this.state.value);
return (
- {alerts}
diff --git a/js/components/ascribe_forms/property.js b/js/components/ascribe_forms/property.js
index 9f12a624..897f2064 100644
--- a/js/components/ascribe_forms/property.js
+++ b/js/components/ascribe_forms/property.js
@@ -82,7 +82,7 @@ let Property = React.createClass({
this.props.onChange(event);
}
- this.setState({value: true});
+ this.setState({value: event.target.value});
},
handleFocus() {
diff --git a/js/constants/api_urls.js b/js/constants/api_urls.js
index b404441b..b1fc9e71 100644
--- a/js/constants/api_urls.js
+++ b/js/constants/api_urls.js
@@ -24,7 +24,8 @@ let apiUrls = {
'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/',
'ownership_consigns_confirm': AppConstants.apiEndpoint + 'ownership/consigns/confirm/',
'ownership_consigns_deny': AppConstants.apiEndpoint + 'ownership/consigns/deny/',
- 'ownership_loans': AppConstants.apiEndpoint + 'ownership/loans/',
+ 'ownership_loans_pieces': AppConstants.apiEndpoint + 'ownership/loans/pieces/',
+ 'ownership_loans_editions': AppConstants.apiEndpoint + 'ownership/loans/editions/',
'ownership_loans_confirm': AppConstants.apiEndpoint + 'ownership/loans/confirm/',
'ownership_loans_deny': AppConstants.apiEndpoint + 'ownership/loans/deny/',
'ownership_loans_contract': AppConstants.apiEndpoint + 'ownership/loans/editions/contract/',
diff --git a/js/fetchers/ownership_fetcher.js b/js/fetchers/ownership_fetcher.js
index b84884e8..111e3a9a 100644
--- a/js/fetchers/ownership_fetcher.js
+++ b/js/fetchers/ownership_fetcher.js
@@ -1,8 +1,8 @@
'use strict';
import requests from '../utils/requests';
-import AppConstants from '../constants/application_constants';
+import ApiUrls from '../constants/api_urls';
let OwnershipFetcher = {
/**
@@ -10,7 +10,7 @@ let OwnershipFetcher = {
* If no arg is supplied, load the current user
*/
fetchLoanContract(email) {
- return requests.get(AppConstants.apiEndpoint + 'ownership/loans/contract/?loanee=' + email);
+ return requests.get(ApiUrls.ownership_loans_contract + '?loanee=' + email);
}
};
diff --git a/js/stores/loan_contract_store.js b/js/stores/loan_contract_store.js
index a69a051a..107b34bb 100644
--- a/js/stores/loan_contract_store.js
+++ b/js/stores/loan_contract_store.js
@@ -8,12 +8,14 @@ class LoanContractStore {
constructor() {
this.contractKey = null;
this.contractUrl = null;
+ this.contractEmail = null;
this.bindActions(LoanContractActions);
}
- onUpdateLoanContract({contractKey, contractUrl}) {
+ onUpdateLoanContract({contractKey, contractUrl, contractEmail}) {
this.contractKey = contractKey;
this.contractUrl = contractUrl;
+ this.contractEmail = contractEmail;
}
}