diff --git a/js/components/acl_proxy.js b/js/components/acl_proxy.js index a04e499d..be0d8466 100644 --- a/js/components/acl_proxy.js +++ b/js/components/acl_proxy.js @@ -36,9 +36,9 @@ let AclProxy = React.createClass({ ); } else { - if(typeof this.props.aclObject[this.props.aclName] === 'undefined') { + /* if(typeof this.props.aclObject[this.props.aclName] === 'undefined') { console.warn('The aclName you\'re filtering for was not present (or undefined) in the aclObject.'); - } + } */ return null; } } diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index 25e8a97c..3aabc9e2 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -89,7 +89,7 @@ let Edition = React.createClass({ PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc, this.state.filterBy); - EditionListActions.refreshEditionList(this.props.edition.parent); + EditionListActions.refreshEditionList({pieceId: this.props.edition.parent}); EditionListActions.closeAllEditionLists(); EditionListActions.clearAllEditionSelections(); 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 3642a667..452a9bd8 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 @@ -81,7 +81,7 @@ let PieceListBulkModal = React.createClass({ this.fetchSelectedPieceEditionList() .forEach((pieceId) => { - EditionListActions.refreshEditionList(pieceId); + EditionListActions.refreshEditionList({pieceId, filterBy: {}}); }); EditionListActions.clearAllEditionSelections(); }, diff --git a/js/components/ascribe_piece_list_toolbar/piece_list_toolbar_filter_widget.js b/js/components/ascribe_piece_list_toolbar/piece_list_toolbar_filter_widget.js index 13bfd9a0..2520c499 100644 --- a/js/components/ascribe_piece_list_toolbar/piece_list_toolbar_filter_widget.js +++ b/js/components/ascribe_piece_list_toolbar/piece_list_toolbar_filter_widget.js @@ -80,7 +80,7 @@ let PieceListToolbarFilterWidgetFilter = React.createClass({ title={filterIcon} className="ascribe-piece-list-toolbar-filter-widget">
  • - {getLangText('Show works that')}: + {getLangText('Show works I can')}:
  • {this.props.filterParams.map((param, i) => { let label; @@ -100,7 +100,7 @@ let PieceListToolbarFilterWidgetFilter = React.createClass({ className="filter-widget-item">
    - {getLangText('I can') + ' ' + getLangText(label)} + {getLangText(label)} PieceListActions.fetchPieceRequestActions()); } }, @@ -49,6 +59,7 @@ let PieceList = React.createClass({ componentWillUnmount() { PieceListStore.unlisten(this.onChange); + EditionListStore.unlisten(this.onChange); }, onChange(state) { @@ -56,13 +67,14 @@ let PieceList = React.createClass({ }, paginationGoToPage(page) { - // if the users clicks a pager of the pagination, - // the site should go to the top - document.body.scrollTop = document.documentElement.scrollTop = 0; - - return () => PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, + return () => { + // if the users clicks a pager of the pagination, + // the site should go to the top + document.body.scrollTop = document.documentElement.scrollTop = 0; + PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc, this.state.filterBy); + }; }, getPagination() { @@ -86,8 +98,24 @@ let PieceList = React.createClass({ }, applyFilterBy(filterBy) { + // first we need to apply the filter on the piece list PieceListActions.fetchPieceList(1, this.state.pageSize, this.state.search, - this.state.orderBy, this.state.orderAsc, filterBy); + this.state.orderBy, this.state.orderAsc, filterBy) + .then(() => { + // but also, we need to filter all the open edition lists + this.state.pieceList + .forEach((piece) => { + // but only if they're actually open + if(this.state.isEditionListOpenForPieceId[piece.id].show) { + EditionListActions.refreshEditionList({ + pieceId: piece.id, + filterBy + }); + } + + }); + }); + // we have to redirect the user always to page one as it could be that there is no page two // for filtered pieces this.transitionTo(this.getPathname(), {page: 1}); @@ -100,7 +128,6 @@ let PieceList = React.createClass({ render() { let loadingElement = (); - return (
    { // reset back to the normal pageSize and page this.editionList[pieceId].page = prevEditionListPage; @@ -125,9 +133,21 @@ class EditionListStore { } onToggleEditionList(pieceId) { + this.isEditionListOpenForPieceId[pieceId] = { show: this.isEditionListOpenForPieceId[pieceId] ? !this.isEditionListOpenForPieceId[pieceId].show : true }; + + // When loading all editions of a piece, closing the table and then applying the filter + // the merge fails, as the edition list is not refreshed when closed. + // Therefore in the case of a filter application when closed, we need to reload the + // edition list + if(!this.isEditionListOpenForPieceId[pieceId].show) { + // to clear an array, david walsh recommends to just set it's length to zero + // http://davidwalsh.name/empty-array + + this.editionList[pieceId].length = 0; + } } onCloseAllEditionLists() {