diff --git a/js/actions/loan_contract_actions.js b/js/actions/loan_contract_actions.js index 07ce0966..cc7e5a5b 100644 --- a/js/actions/loan_contract_actions.js +++ b/js/actions/loan_contract_actions.js @@ -7,7 +7,8 @@ import OwnershipFetcher from '../fetchers/ownership_fetcher'; class LoanContractActions { constructor() { this.generateActions( - 'updateLoanContract' + 'updateLoanContract', + 'flushLoanContract' ); } diff --git a/js/components/ascribe_accordion_list/accordion_list_item_edition_widget.js b/js/components/ascribe_accordion_list/accordion_list_item_edition_widget.js index 1616f183..9fb72b06 100644 --- a/js/components/ascribe_accordion_list/accordion_list_item_edition_widget.js +++ b/js/components/ascribe_accordion_list/accordion_list_item_edition_widget.js @@ -6,8 +6,6 @@ import classNames from 'classnames'; import EditionListActions from '../../actions/edition_list_actions'; import EditionListStore from '../../stores/edition_list_store'; -import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'; -import Tooltip from 'react-bootstrap/lib/Tooltip'; import Button from 'react-bootstrap/lib/Button'; import CreateEditionsButton from '../ascribe_buttons/create_editions_button'; diff --git a/js/components/ascribe_detail/piece.js b/js/components/ascribe_detail/piece.js index e73984a9..7dff529f 100644 --- a/js/components/ascribe_detail/piece.js +++ b/js/components/ascribe_detail/piece.js @@ -113,11 +113,19 @@ let Piece = React.createClass({ }, handlePollingSuccess(pieceId, numEditions) { + + // we need to refresh the num_editions property of the actual piece we're looking at PieceActions.updateProperty({ key: 'num_editions', value: numEditions }); + // as well as its representation in the collection + // btw.: It's not sufficient to just set num_editions to numEditions, since a single accordion + // list item also uses the firstEdition property which we can only get from the server in that case. + // Therefore we need to at least refetch the changed piece from the server or on our case simply all + PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc); + let notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); }, diff --git a/js/components/ascribe_forms/form_loan.js b/js/components/ascribe_forms/form_loan.js index 5730cca3..b261d749 100644 --- a/js/components/ascribe_forms/form_loan.js +++ b/js/components/ascribe_forms/form_loan.js @@ -36,6 +36,7 @@ let LoanForm = React.createClass({ }, componentWillUnmount() { + LoanContractActions.flushLoanContract(); LoanContractStore.unlisten(this.onChange); }, @@ -53,13 +54,16 @@ let LoanForm = React.createClass({ getContractCheckbox() { if(this.state.contractKey && this.state.contractUrl) { + // we need to define a key on the InputCheckboxes as otherwise + // react is not rerendering them on a store switch and is keeping + // the default value of the component (which is in that case true) return ( {getLangText('I agree to the')}  @@ -77,7 +81,7 @@ let LoanForm = React.createClass({ style={{paddingBottom: 0}} hidden={true}> ); diff --git a/js/stores/loan_contract_store.js b/js/stores/loan_contract_store.js index 107b34bb..3d0c0592 100644 --- a/js/stores/loan_contract_store.js +++ b/js/stores/loan_contract_store.js @@ -17,6 +17,12 @@ class LoanContractStore { this.contractUrl = contractUrl; this.contractEmail = contractEmail; } + + onFlushLoanContract() { + this.contractKey = null; + this.contractUrl = null; + this.contractEmail = null; + } } export default alt.createStore(LoanContractStore, 'LoanContractStore'); diff --git a/js/stores/piece_list_store.js b/js/stores/piece_list_store.js index 22d8d5d6..a8b73e44 100644 --- a/js/stores/piece_list_store.js +++ b/js/stores/piece_list_store.js @@ -80,7 +80,6 @@ class PieceListStore { let piece = filteredPieceList[0]; piece[key] = value; - } else { throw new Error('Could not find a matching piece in piece list since its either not there or piecelist contains duplicates.'); }