From 71f94768d911860cf668077daa26e9f8637554f0 Mon Sep 17 00:00:00 2001 From: diminator Date: Tue, 15 Sep 2015 13:22:52 +0200 Subject: [PATCH] fix PR comments --- js/actions/contract_agreement_list_actions.js | 4 ++-- js/components/acl_proxy.js | 2 +- js/components/ascribe_forms/form_loan.js | 11 ++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/js/actions/contract_agreement_list_actions.js b/js/actions/contract_agreement_list_actions.js index 94f292c5..86988f47 100644 --- a/js/actions/contract_agreement_list_actions.js +++ b/js/actions/contract_agreement_list_actions.js @@ -37,11 +37,11 @@ class ContractAgreementListActions { fetchAvailableContractAgreementList(issuer){ return Q.Promise((resolve, reject) => { - this.actions.fetchContractAgreementList(issuer, 'True', null) + this.actions.fetchContractAgreementList(issuer, true, null) .then((contractAgreementListAccepted) => { if (!contractAgreementListAccepted) { // fetch pending agreements if no accepted ones - return this.actions.fetchContractAgreementList(issuer, null, 'True'); + return this.actions.fetchContractAgreementList(issuer, null, true); } else { resolve(contractAgreementListAccepted); diff --git a/js/components/acl_proxy.js b/js/components/acl_proxy.js index 10a7516e..4fc90a9b 100644 --- a/js/components/acl_proxy.js +++ b/js/components/acl_proxy.js @@ -21,7 +21,7 @@ let AclProxy = React.createClass({ }, getChildren() { - if (this.props.children.length && this.props.children.length > 1){ + if (React.Children.count(this.props.children) > 1){ /* This might ruin styles for header items in the navbar etc */ diff --git a/js/components/ascribe_forms/form_loan.js b/js/components/ascribe_forms/form_loan.js index 8e83ca34..180ee9ea 100644 --- a/js/components/ascribe_forms/form_loan.js +++ b/js/components/ascribe_forms/form_loan.js @@ -57,6 +57,15 @@ let LoanForm = React.createClass({ this.getContractAgreementsOrCreatePublic(this.props.email); }, + componentWillReceiveProps(nextProps) { + // however, it can also be that at the time the component is mounting, + // the email is not defined (because it's asynchronously fetched from the server). + // Then we need to update it as soon as it is included into LoanForm's props. + if(nextProps && nextProps.email) { + this.getContractAgreementsOrCreatePublic(nextProps.email); + } + }, + componentWillUnmount() { ContractAgreementListStore.unlisten(this.onChange); }, @@ -70,7 +79,7 @@ let LoanForm = React.createClass({ ContractAgreementListActions.fetchAvailableContractAgreementList(email).then( (contractAgreementList) => { if (!contractAgreementList) { - ContractAgreementListActions.createContractAgreementFromPublicContract.defer(email); + ContractAgreementListActions.createContractAgreementFromPublicContract(email); } } );