mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 10:25:08 +01:00
put show state of item list in store to fix bug
This commit is contained in:
parent
713dd72b2b
commit
53a01115f2
@ -6,7 +6,8 @@ import PieceListFetcher from '../fetchers/piece_list_fetcher';
|
|||||||
class PieceListActions {
|
class PieceListActions {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.generateActions(
|
this.generateActions(
|
||||||
'updatePieceList'
|
'updatePieceList',
|
||||||
|
'showEditionList'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,30 +6,17 @@ import TableItem from '../ascribe_table/table_item';
|
|||||||
import TableColumnContentModel from '../../models/table_column_content_model';
|
import TableColumnContentModel from '../../models/table_column_content_model';
|
||||||
|
|
||||||
let AccordionListItemTable = React.createClass({
|
let AccordionListItemTable = React.createClass({
|
||||||
getInitialState() {
|
|
||||||
return {
|
|
||||||
'show': false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
className: React.PropTypes.string,
|
className: React.PropTypes.string,
|
||||||
parentId: React.PropTypes.number,
|
parentId: React.PropTypes.number,
|
||||||
fetchData: React.PropTypes.func,
|
|
||||||
itemList: React.PropTypes.array,
|
itemList: React.PropTypes.array,
|
||||||
columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnContentModel)),
|
columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnContentModel)),
|
||||||
numOfTableItems: React.PropTypes.number
|
numOfTableItems: React.PropTypes.number,
|
||||||
},
|
show: React.PropTypes.bool
|
||||||
|
|
||||||
toggleTable() {
|
|
||||||
this.props.fetchData();
|
|
||||||
this.setState({
|
|
||||||
'show': !this.state.show
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if(this.props.itemList && this.state.show) {
|
if(this.props.show && this.props.itemList) {
|
||||||
return (
|
return (
|
||||||
<div className={this.props.className}>
|
<div className={this.props.className}>
|
||||||
<Table
|
<Table
|
||||||
@ -44,44 +31,17 @@ let AccordionListItemTable = React.createClass({
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Table>
|
</Table>
|
||||||
<AccordionListItemTableToggle
|
{this.props.children}
|
||||||
className="ascribe-accordion-list-table-toggle"
|
|
||||||
onClick={this.toggleTable}
|
|
||||||
show={this.state.show}
|
|
||||||
numOfTableItems={this.props.numOfTableItems} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<div className={this.props.className}>
|
<div className={this.props.className}>
|
||||||
<AccordionListItemTableToggle
|
{this.props.children}
|
||||||
className="ascribe-accordion-list-table-toggle"
|
|
||||||
onClick={this.toggleTable}
|
|
||||||
show={this.state.show}
|
|
||||||
numOfTableItems={this.props.numOfTableItems} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let AccordionListItemTableToggle = React.createClass({
|
|
||||||
propTypes: {
|
|
||||||
className: React.PropTypes.string,
|
|
||||||
onClick: React.PropTypes.func,
|
|
||||||
show: React.PropTypes.bool,
|
|
||||||
numOfTableItems: React.PropTypes.number
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<span
|
|
||||||
className={this.props.className}
|
|
||||||
onClick={this.props.onClick}>
|
|
||||||
{this.props.show ? 'Hide all ' + this.props.numOfTableItems + ' Editions' : 'Show all ' + this.props.numOfTableItems + ' Editions'}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default AccordionListItemTable;
|
export default AccordionListItemTable;
|
@ -2,8 +2,11 @@ import React from 'react';
|
|||||||
|
|
||||||
import EditionListStore from '../../stores/edition_list_store';
|
import EditionListStore from '../../stores/edition_list_store';
|
||||||
import EditionListActions from '../../actions/edition_list_actions';
|
import EditionListActions from '../../actions/edition_list_actions';
|
||||||
|
import PieceListStore from '../../stores/piece_list_store';
|
||||||
|
import PieceListActions from '../../actions/piece_list_actions';
|
||||||
|
|
||||||
import AccordionListItemTable from './accordion_list_item_table';
|
import AccordionListItemTable from './accordion_list_item_table';
|
||||||
|
import AccordionListItemTableToggle from './accordion_list_item_table_toggle';
|
||||||
|
|
||||||
import TableColumnContentModel from '../../models/table_column_content_model';
|
import TableColumnContentModel from '../../models/table_column_content_model';
|
||||||
|
|
||||||
@ -17,7 +20,8 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
propTypes: {
|
propTypes: {
|
||||||
className: React.PropTypes.string,
|
className: React.PropTypes.string,
|
||||||
parentId: React.PropTypes.number,
|
parentId: React.PropTypes.number,
|
||||||
numOfEditions: React.PropTypes.number
|
numOfEditions: React.PropTypes.number,
|
||||||
|
show: React.PropTypes.bool
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
@ -36,14 +40,15 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
EditionListStore.unlisten(this.onChange);
|
EditionListStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
getEditionList() {
|
|
||||||
EditionListActions.fetchEditionList(this.props.parentId);
|
|
||||||
},
|
|
||||||
|
|
||||||
selectItem(pieceId, editionId) {
|
selectItem(pieceId, editionId) {
|
||||||
EditionListActions.selectEdition({pieceId, editionId});
|
EditionListActions.selectEdition({pieceId, editionId});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleTable() {
|
||||||
|
PieceListActions.showEditionList(this.props.parentId);
|
||||||
|
EditionListActions.fetchEditionList(this.props.parentId);
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let columnList = [
|
let columnList = [
|
||||||
new TableColumnContentModel((item) => { return { 'editionId': item.id, 'pieceId': this.props.parentId, 'selectItem': this.selectItem, 'selected': item.selected }}, '', '', TableItemCheckbox, 1, false),
|
new TableColumnContentModel((item) => { return { 'editionId': item.id, 'pieceId': this.props.parentId, 'selectItem': this.selectItem, 'selected': item.selected }}, '', '', TableItemCheckbox, 1, false),
|
||||||
@ -53,13 +58,22 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AccordionListItemTable
|
<div>
|
||||||
className={this.props.className}
|
<AccordionListItemTable
|
||||||
parentId={this.props.parentId}
|
className={this.props.className}
|
||||||
fetchData={this.getEditionList}
|
parentId={this.props.parentId}
|
||||||
itemList={this.state.editionList[this.props.parentId]}
|
itemList={this.state.editionList[this.props.parentId]}
|
||||||
columnList={columnList}
|
columnList={columnList}
|
||||||
numOfTableItems={this.props.numOfEditions} />
|
numOfTableItems={this.props.numOfEditions}
|
||||||
|
show={this.props.show}>
|
||||||
|
<AccordionListItemTableToggle
|
||||||
|
className="ascribe-accordion-list-table-toggle"
|
||||||
|
onClick={this.toggleTable}
|
||||||
|
show={this.props.show}
|
||||||
|
numOfTableItems={this.props.numOfEditions} />
|
||||||
|
</AccordionListItemTable>
|
||||||
|
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
let AccordionListItemTableToggle = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
className: React.PropTypes.string,
|
||||||
|
onClick: React.PropTypes.func,
|
||||||
|
show: React.PropTypes.bool,
|
||||||
|
numOfTableItems: React.PropTypes.number
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={this.props.className}
|
||||||
|
onClick={this.props.onClick}>
|
||||||
|
{this.props.show ? 'Hide all ' + this.props.numOfTableItems + ' Editions' : 'Show all ' + this.props.numOfTableItems + ' Editions'}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default AccordionListItemTableToggle;
|
@ -71,6 +71,7 @@ let PieceList = React.createClass({
|
|||||||
<AccordionListItemTableEditions
|
<AccordionListItemTableEditions
|
||||||
className="ascribe-accordion-list-item-table col-xs-6 col-sm-6 col-md-6 col-lg-6 col-xs-offset-3 col-sm-offset-3 col-md-offset-3 col-lg-offset-3"
|
className="ascribe-accordion-list-item-table col-xs-6 col-sm-6 col-md-6 col-lg-6 col-xs-offset-3 col-sm-offset-3 col-md-offset-3 col-lg-offset-3"
|
||||||
parentId={item.id}
|
parentId={item.id}
|
||||||
|
show={item.show}
|
||||||
numOfEditions={item.num_editions}/>
|
numOfEditions={item.num_editions}/>
|
||||||
</AccordionListItem>
|
</AccordionListItem>
|
||||||
);
|
);
|
||||||
|
@ -24,6 +24,19 @@ class PieceListStore {
|
|||||||
this.bindActions(PieceListActions);
|
this.bindActions(PieceListActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onShowEditionList(pieceId) {
|
||||||
|
this.pieceList
|
||||||
|
.forEach((piece) => {
|
||||||
|
if(piece.id === pieceId) {
|
||||||
|
if(piece.show) {
|
||||||
|
piece.show = false;
|
||||||
|
} else {
|
||||||
|
piece.show = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onUpdatePieceList({ page, pageSize, search, pieceList, orderBy, orderAsc, pieceListCount }) {
|
onUpdatePieceList({ page, pageSize, search, pieceList, orderBy, orderAsc, pieceListCount }) {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.pageSize = pageSize;
|
this.pageSize = pageSize;
|
||||||
|
Loading…
Reference in New Issue
Block a user