- {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() {