mirror of
https://github.com/ascribe/onion.git
synced 2025-01-05 11:25:09 +01:00
Filter the collection to only show the consignable items by default
This commit is contained in:
parent
799ccb9b8d
commit
318a0bf4b2
@ -6,12 +6,6 @@ import { mergeOptions } from '../../utils/general_utils';
|
|||||||
|
|
||||||
import EditionListActions from '../../actions/edition_list_actions';
|
import EditionListActions from '../../actions/edition_list_actions';
|
||||||
|
|
||||||
import UserStore from '../../stores/user_store';
|
|
||||||
import UserActions from '../../actions/user_actions';
|
|
||||||
|
|
||||||
import PieceListStore from '../../stores/piece_list_store';
|
|
||||||
import PieceListActions from '../../actions/piece_list_actions';
|
|
||||||
|
|
||||||
import PieceListBulkModalSelectedEditionsWidget from './piece_list_bulk_modal_selected_editions_widget';
|
import PieceListBulkModalSelectedEditionsWidget from './piece_list_bulk_modal_selected_editions_widget';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils.js';
|
import { getLangText } from '../../utils/lang_utils.js';
|
||||||
@ -30,31 +24,6 @@ let PieceListBulkModal = React.createClass({
|
|||||||
])
|
])
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
|
||||||
return mergeOptions(
|
|
||||||
UserStore.getState(),
|
|
||||||
PieceListStore.getState()
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
UserStore.listen(this.onChange);
|
|
||||||
PieceListStore.listen(this.onChange);
|
|
||||||
|
|
||||||
UserActions.fetchCurrentUser();
|
|
||||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
|
||||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
|
||||||
},
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
PieceListStore.unlisten(this.onChange);
|
|
||||||
UserStore.unlisten(this.onChange);
|
|
||||||
},
|
|
||||||
|
|
||||||
onChange(state) {
|
|
||||||
this.setState(state);
|
|
||||||
},
|
|
||||||
|
|
||||||
clearAllSelections() {
|
clearAllSelections() {
|
||||||
EditionListActions.clearAllEditionSelections();
|
EditionListActions.clearAllEditionSelections();
|
||||||
EditionListActions.closeAllEditionLists();
|
EditionListActions.closeAllEditionLists();
|
||||||
|
@ -28,7 +28,7 @@ let PieceListToolbarFilterWidget = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
generateFilterByStatement(param) {
|
generateFilterByStatement(param) {
|
||||||
let filterBy = this.props.filterBy;
|
const { filterBy } = this.props;
|
||||||
|
|
||||||
if(filterBy) {
|
if(filterBy) {
|
||||||
// we need hasOwnProperty since the values are all booleans
|
// we need hasOwnProperty since the values are all booleans
|
||||||
@ -56,13 +56,13 @@ let PieceListToolbarFilterWidget = React.createClass({
|
|||||||
*/
|
*/
|
||||||
filterBy(param) {
|
filterBy(param) {
|
||||||
return () => {
|
return () => {
|
||||||
let filterBy = this.generateFilterByStatement(param);
|
const filterBy = this.generateFilterByStatement(param);
|
||||||
this.props.applyFilterBy(filterBy);
|
this.props.applyFilterBy(filterBy);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
isFilterActive() {
|
isFilterActive() {
|
||||||
let trueValuesOnly = Object.keys(this.props.filterBy).filter((acl) => acl);
|
const trueValuesOnly = Object.keys(this.props.filterBy).filter((acl) => acl);
|
||||||
|
|
||||||
// We're hiding the star in that complicated matter so that,
|
// We're hiding the star in that complicated matter so that,
|
||||||
// the surrounding button is not resized up on appearance
|
// the surrounding button is not resized up on appearance
|
||||||
@ -74,7 +74,7 @@ let PieceListToolbarFilterWidget = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let filterIcon = (
|
const filterIcon = (
|
||||||
<span>
|
<span>
|
||||||
<span className="ascribe-icon icon-ascribe-filter" aria-hidden="true"></span>
|
<span className="ascribe-icon icon-ascribe-filter" aria-hidden="true"></span>
|
||||||
<span style={this.isFilterActive()}>*</span>
|
<span style={this.isFilterActive()}>*</span>
|
||||||
|
@ -60,11 +60,17 @@ let PieceList = React.createClass({
|
|||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return mergeOptions(
|
const stores = mergeOptions(
|
||||||
PieceListStore.getState(),
|
PieceListStore.getState(),
|
||||||
EditionListStore.getState()
|
EditionListStore.getState()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Use the default filters but use the stores' settings if they're available
|
||||||
|
stores.filterBy = Object.assign(this.getDefaultFilterBy(), stores.filterBy);
|
||||||
|
|
||||||
|
return stores;
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -96,6 +102,21 @@ let PieceList = React.createClass({
|
|||||||
this.setState(state);
|
this.setState(state);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getDefaultFilterBy() {
|
||||||
|
const { filterParams } = this.props;
|
||||||
|
const defaultFilterBy = {};
|
||||||
|
|
||||||
|
filterParams.forEach(({ label, items }) => {
|
||||||
|
items.forEach((item) => {
|
||||||
|
if (typeof item === 'object' && item.defaultValue) {
|
||||||
|
defaultFilterBy[item.key] = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return defaultFilterBy;
|
||||||
|
},
|
||||||
|
|
||||||
paginationGoToPage(page) {
|
paginationGoToPage(page) {
|
||||||
return () => {
|
return () => {
|
||||||
// if the users clicks a pager of the pagination,
|
// if the users clicks a pager of the pagination,
|
||||||
|
@ -25,7 +25,8 @@ let LumenusPieceList = React.createClass({
|
|||||||
label: getLangText('Show works I can'),
|
label: getLangText('Show works I can'),
|
||||||
items: [{
|
items: [{
|
||||||
key: 'acl_consign',
|
key: 'acl_consign',
|
||||||
label: getLangText('consign to Lumenus')
|
label: getLangText('consign to Lumenus'),
|
||||||
|
defaultValue: true
|
||||||
}]
|
}]
|
||||||
}]}
|
}]}
|
||||||
location={this.props.location}/>
|
location={this.props.location}/>
|
||||||
|
Loading…
Reference in New Issue
Block a user