mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 10:25:08 +01:00
Finalize InputContractAgreementCheckbox
This commit is contained in:
parent
0b79a55175
commit
3335032609
@ -131,7 +131,6 @@ let Form = React.createClass({
|
|||||||
// An input can also provide an `Object` as a value
|
// An input can also provide an `Object` as a value
|
||||||
// which we're going to merge with `data` (overwrites)
|
// which we're going to merge with `data` (overwrites)
|
||||||
if(ref.state.value.constructor === Object) {
|
if(ref.state.value.constructor === Object) {
|
||||||
console.log(ref.state.value);
|
|
||||||
Object.assign(data, ref.state.value);
|
Object.assign(data, ref.state.value);
|
||||||
} else {
|
} else {
|
||||||
data[ref.props.name] = ref.state.value;
|
data[ref.props.name] = ref.state.value;
|
||||||
|
@ -74,7 +74,21 @@ const InputContractAgreementCheckbox = React.createClass({
|
|||||||
|
|
||||||
state = mergeOptions(state, {
|
state = mergeOptions(state, {
|
||||||
value: {
|
value: {
|
||||||
|
// If `email` is defined in this component, `getContractAgreementsOrCreatePublic`
|
||||||
|
// is either:
|
||||||
|
//
|
||||||
|
// - fetching a already existing contract agreement; or
|
||||||
|
// - trying to create a contract agreement
|
||||||
|
//
|
||||||
|
// If both attempts result in `contractAgreement` being not defined,
|
||||||
|
// it means that the receiver hasn't defined a contract, which means
|
||||||
|
// a contract agreement cannot be created, which means we don't have to
|
||||||
|
// specify `contract_agreement_id` when sending a request to the server.
|
||||||
contract_agreement_id: contractAgreement ? contractAgreement.id : null,
|
contract_agreement_id: contractAgreement ? contractAgreement.id : null,
|
||||||
|
// If the receiver hasn't set a contract or the contract was
|
||||||
|
// previously accepted, we set the terms to `true`
|
||||||
|
// as we always need to at least give a boolean value for `terms`
|
||||||
|
// to the API endpoint
|
||||||
terms: !contractAgreement || !!contractAgreement.datetime_accepted
|
terms: !contractAgreement || !!contractAgreement.datetime_accepted
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -91,7 +105,7 @@ const InputContractAgreementCheckbox = React.createClass({
|
|||||||
this.props.onChange(event);
|
this.props.onChange(event);
|
||||||
},
|
},
|
||||||
|
|
||||||
getContractAgreement(contractAgreementList) {
|
getContractAgreement(contractAgreementList = this.state.contractAgreementList) {
|
||||||
if (contractAgreementList && contractAgreementList.length > 0) {
|
if (contractAgreementList && contractAgreementList.length > 0) {
|
||||||
return contractAgreementList[0];
|
return contractAgreementList[0];
|
||||||
}
|
}
|
||||||
@ -107,30 +121,22 @@ const InputContractAgreementCheckbox = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getAppendix() {
|
getAppendix() {
|
||||||
const { contractAgreementList } = this.state;
|
const contractAgreement = this.getContractAgreement();
|
||||||
|
|
||||||
if (contractAgreementList && contractAgreementList.length > 0) {
|
if (contractAgreement &&
|
||||||
const appendix = contractAgreementList[0].appendix;
|
contractAgreement.appendix &&
|
||||||
if (appendix && appendix.default) {
|
contractAgreement.appendix.default) {
|
||||||
return (
|
return (
|
||||||
<pre className="ascribe-pre">{appendix.default}</pre>
|
<div className="ascribe-property contract-appendix-form">
|
||||||
|
<p><span>{getLangText('Appendix')}</span></p>
|
||||||
|
<pre className="ascribe-pre">{contractAgreement.appendix.default}</pre>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getContractCheckbox() {
|
getContractCheckbox() {
|
||||||
const { name,
|
const contractAgreement = this.getContractAgreement();
|
||||||
disabled,
|
|
||||||
style } = this.props;
|
|
||||||
const { contractAgreementList } = this.state;
|
|
||||||
const contractAgreement = this.getContractAgreement(contractAgreementList);
|
|
||||||
const inputCheckboxProps = {
|
|
||||||
name,
|
|
||||||
disabled,
|
|
||||||
style,
|
|
||||||
onChange: this.onChange
|
|
||||||
};
|
|
||||||
|
|
||||||
if(contractAgreement) {
|
if(contractAgreement) {
|
||||||
const {
|
const {
|
||||||
@ -145,7 +151,7 @@ const InputContractAgreementCheckbox = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<div className="notification-contract-pdf">
|
<div className="notification-contract-pdf">
|
||||||
<embed
|
<embed
|
||||||
className="loan-form"
|
className="embed-form"
|
||||||
src={contractUrl}
|
src={contractUrl}
|
||||||
alt="pdf"
|
alt="pdf"
|
||||||
pluginspage="http://www.adobe.com/products/acrobat/readstep2.html"/>
|
pluginspage="http://www.adobe.com/products/acrobat/readstep2.html"/>
|
||||||
@ -155,9 +161,17 @@ const InputContractAgreementCheckbox = React.createClass({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
const {
|
||||||
|
name,
|
||||||
|
disabled,
|
||||||
|
style } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InputCheckbox
|
<InputCheckbox
|
||||||
{...inputCheckboxProps}
|
name={name}
|
||||||
|
disabled={disabled}
|
||||||
|
style={style}
|
||||||
|
onChange={this.onChange}
|
||||||
key="terms_explicitly"
|
key="terms_explicitly"
|
||||||
defaultChecked={false}>
|
defaultChecked={false}>
|
||||||
<span>
|
<span>
|
||||||
|
@ -42,7 +42,8 @@ const Property = React.createClass({
|
|||||||
]),
|
]),
|
||||||
style: object,
|
style: object,
|
||||||
expanded: bool,
|
expanded: bool,
|
||||||
checkboxLabel: string
|
checkboxLabel: string,
|
||||||
|
autoFocus: bool
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
@ -75,6 +76,12 @@ const Property = React.createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
if(this.props.autoFocus) {
|
||||||
|
this.handleFocus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
let childInput = this.refs.input;
|
let childInput = this.refs.input;
|
||||||
|
|
||||||
@ -86,7 +93,7 @@ const Property = React.createClass({
|
|||||||
// set from the outside as a prop then(!!!))
|
// set from the outside as a prop then(!!!))
|
||||||
//
|
//
|
||||||
// This handles case 1. and 3.
|
// This handles case 1. and 3.
|
||||||
if(typeof nextProps.expanded === this.props.expanded && nextProps.expanded !== this.state.expanded && !this.props.checkboxLabel) {
|
if(nextProps.expanded !== this.props.expanded && nextProps.expanded !== this.state.expanded && !this.props.checkboxLabel) {
|
||||||
this.setState({ expanded: nextProps.expanded });
|
this.setState({ expanded: nextProps.expanded });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,18 +31,11 @@
|
|||||||
margin-top: .5em;
|
margin-top: .5em;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
|
|
||||||
.consign-form,
|
&.embed-form {
|
||||||
.loan-form {
|
|
||||||
margin-top: .5em;
|
|
||||||
height: 45vh;
|
height: 45vh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.consign-form,
|
|
||||||
.loan-form {
|
|
||||||
height: 40vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.notification-contract-pdf-download {
|
.notification-contract-pdf-download {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
@ -72,3 +65,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ascribe-property.contract-appendix-form {
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user