From 6e7037e5f2ddfc25d8b6b7d2efcffb5b174db0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Mon, 15 Jun 2015 09:29:34 +0200 Subject: [PATCH] Finish implementing refactor for open and close for edition lists --- js/actions/edition_list_actions.js | 1 + .../accordion_list_item_table_editions.js | 13 +++++++++---- .../ascribe_buttons/delete_button.js | 3 ++- js/components/ascribe_forms/form_loan.js | 11 ++++++----- .../piece_list_bulk_modal.js | 1 + js/components/header.js | 2 +- js/stores/edition_list_store.js | 19 ++++++++++++------- 7 files changed, 32 insertions(+), 18 deletions(-) diff --git a/js/actions/edition_list_actions.js b/js/actions/edition_list_actions.js index e36ae1b0..c54bc6fd 100644 --- a/js/actions/edition_list_actions.js +++ b/js/actions/edition_list_actions.js @@ -10,6 +10,7 @@ class EditionListActions { 'updateEditionList', 'selectEdition', 'clearAllEditionSelections', + 'closeAllEditionLists', 'toggleEditionList' ); } diff --git a/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js b/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js index ea5d9d94..ed717c57 100644 --- a/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js +++ b/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js @@ -59,8 +59,13 @@ let AccordionListItemTableEditions = React.createClass({ }, toggleTable() { - // This is triggered everytime show all editions is clicked, which is wrong - EditionListActions.fetchEditionList(this.props.parentId); + let isEditionListOpen = this.state.isEditionListOpenForPieceId[this.props.parentId] ? this.state.isEditionListOpenForPieceId[this.props.parentId].show : false; + if(isEditionListOpen) { + EditionListActions.toggleEditionList(this.props.parentId); + } else { + EditionListActions.toggleEditionList(this.props.parentId); + EditionListActions.fetchEditionList(this.props.parentId); + } }, changeEditionListOrder(orderBy, orderAsc) { @@ -84,8 +89,8 @@ let AccordionListItemTableEditions = React.createClass({ orderAsc = this.state.editionList[this.props.parentId].orderAsc; } - if(this.props.parentId in this.state.editionOpenList) { - show = this.state.editionOpenList[this.props.parentId].show; + if(this.props.parentId in this.state.isEditionListOpenForPieceId) { + show = this.state.isEditionListOpenForPieceId[this.props.parentId].show; } let transition = new TransitionModel('edition', 'editionId', 'bitcoin_id'); diff --git a/js/components/ascribe_buttons/delete_button.js b/js/components/ascribe_buttons/delete_button.js index e52ff119..1b2a7748 100644 --- a/js/components/ascribe_buttons/delete_button.js +++ b/js/components/ascribe_buttons/delete_button.js @@ -23,12 +23,13 @@ let DeleteButton = React.createClass({ mixins: [Router.Navigation], - showNotification(response){ + showNotification(response) { this.props.editions .forEach((edition) => { EditionListActions.fetchEditionList(edition.parent); }); EditionListActions.clearAllEditionSelections(); + EditionListActions.closeAllEditionLists(); this.transitionTo('pieces'); let notification = new GlobalNotificationModel(response.notification, 'success'); GlobalNotificationActions.appendGlobalNotification(notification); diff --git a/js/components/ascribe_forms/form_loan.js b/js/components/ascribe_forms/form_loan.js index 2623c8bb..ae4ca49e 100644 --- a/js/components/ascribe_forms/form_loan.js +++ b/js/components/ascribe_forms/form_loan.js @@ -52,7 +52,7 @@ let LoanForm = React.createClass({ loaneeHasContract: true }); } - else{ + else { this.resetLoanContract(); } }) @@ -63,10 +63,11 @@ let LoanForm = React.createClass({ }, resetLoanContract(){ - this.setState({contract_key: null, - contract_url: null, - loaneeHasContract: false - }); + this.setState({ + contract_key: null, + contract_url: null, + loaneeHasContract: false + }); }, renderForm() { diff --git a/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js b/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js index d3e7f127..c50c09fd 100644 --- a/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js +++ b/js/components/ascribe_piece_list_bulk_modal/piece_list_bulk_modal.js @@ -65,6 +65,7 @@ let PieceListBulkModal = React.createClass({ clearAllSelections() { EditionListActions.clearAllEditionSelections(); + EditionListActions.closeAllEditionLists(); }, handleSuccess() { diff --git a/js/components/header.js b/js/components/header.js index 140aeead..2ad26657 100644 --- a/js/components/header.js +++ b/js/components/header.js @@ -38,7 +38,7 @@ let Header = React.createClass({ return (