'use strict'; import React from 'react'; import PieceListStore from '../stores/piece_list_store'; import PieceListActions from '../actions/piece_list_actions'; import AccordionList from './ascribe_accordion_list/accordion_list'; import AccordionListItem from './ascribe_accordion_list/accordion_list_item'; import AccordionListItemTableEditions from './ascribe_accordion_list/accordion_list_item_table_editions'; import Pagination from './ascribe_pagination/pagination'; import PieceListBulkModal from './ascribe_piece_list_bulk_modal/piece_list_bulk_modal'; import PieceListToolbar from './ascribe_piece_list_toolbar/piece_list_toolbar'; let PieceList = React.createClass({ propTypes: { query: React.PropTypes.object }, getInitialState() { return PieceListStore.getState(); }, componentDidMount() { let page = this.props.query.page || 1; PieceListStore.listen(this.onChange); PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc); }, componentWillUnmount() { PieceListStore.unlisten(this.onChange); }, onChange(state) { this.setState(state); }, paginationGoToPage(page) { return () => PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc); }, accordionChangeOrder(orderBy, orderAsc) { PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, orderBy, orderAsc); }, render() { let currentPage = parseInt(this.props.query.page, 10) || 1; let totalPages = Math.ceil(this.state.pieceListCount / this.state.pageSize); return (