mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 10:25:08 +01:00
Merge branch 'master' of bitbucket.org:ascribe/onion
Conflicts: js/components/piece_list.js
This commit is contained in:
commit
809c89eb97
@ -36,9 +36,9 @@
|
|||||||
background-color: #F5F5F5;
|
background-color: #F5F5F5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ascribe-table-item:hover {
|
/*.ascribe-table-item:hover {
|
||||||
background-color: #EEEEEE;
|
background-color: #EEEEEE;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
.ascribe-table-item-column {
|
.ascribe-table-item-column {
|
||||||
display: table;
|
display: table;
|
||||||
|
@ -13,7 +13,10 @@ class EditionListActions {
|
|||||||
EditionListFetcher
|
EditionListFetcher
|
||||||
.fetch(pieceId)
|
.fetch(pieceId)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.actions.updateEditionList(res.editions);
|
this.actions.updateEditionList({
|
||||||
|
'editionList': res.editions,
|
||||||
|
pieceId
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -14,13 +14,11 @@ let Table = React.createClass({
|
|||||||
|
|
||||||
renderChildren() {
|
renderChildren() {
|
||||||
var that = this;
|
var that = this;
|
||||||
return ReactAddons.Children.map(this.props.children, (child) => {
|
return ReactAddons.Children.map(this.props.children, (child, i) => {
|
||||||
return that.props.itemList.map((item, i) => {
|
return ReactAddons.addons.cloneWithProps(child, {
|
||||||
return ReactAddons.addons.cloneWithProps(child, {
|
columnList: this.props.columnList,
|
||||||
columnList: this.props.columnList,
|
columnContent: this.props.itemList[i],
|
||||||
columnContent: item,
|
key: i
|
||||||
key: i
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -2,9 +2,15 @@ import React from 'react';
|
|||||||
|
|
||||||
import TableColumnContentModel from '../../models/table_column_content_model';
|
import TableColumnContentModel from '../../models/table_column_content_model';
|
||||||
|
|
||||||
|
import EditionListStore from '../../stores/edition_list_store';
|
||||||
|
import EditionListActions from '../../actions/edition_list_actions';
|
||||||
|
|
||||||
// ToDo: Create Table-specific Utils to not lock it to projects utilities
|
// ToDo: Create Table-specific Utils to not lock it to projects utilities
|
||||||
import GeneralUtils from '../../utils/general_utils';
|
import GeneralUtils from '../../utils/general_utils';
|
||||||
|
|
||||||
|
import Table from './table';
|
||||||
|
import TableItem from './table_item';
|
||||||
|
import TableItemText from './table_item_text';
|
||||||
import TableItemSubtableButton from './table_item_subtable_button';
|
import TableItemSubtableButton from './table_item_subtable_button';
|
||||||
|
|
||||||
|
|
||||||
@ -25,12 +31,21 @@ let TableItemSubtable = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.store.listen(this.onChange);
|
EditionListStore.listen(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
loadEditionList() {
|
loadEditionList() {
|
||||||
console.log(this.props);
|
if(this.state.open) {
|
||||||
//this.props.actions.actions.fetchEditionList();
|
this.setState({
|
||||||
|
'open': false
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
EditionListActions.fetchEditionList(this.props.columnContent.id);
|
||||||
|
this.setState({
|
||||||
|
'open': true,
|
||||||
|
'editionList': EditionListStore.getState()
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
calcColumnClasses(list, i) {
|
calcColumnClasses(list, i) {
|
||||||
@ -63,6 +78,34 @@ let TableItemSubtable = React.createClass({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
let renderEditionListTable = () => {
|
||||||
|
|
||||||
|
let columnList = [
|
||||||
|
new TableColumnContentModel('edition_number', 'Edition Number', TableItemText, 2, false),
|
||||||
|
new TableColumnContentModel('user_registered', 'User', TableItemText, 4, true),
|
||||||
|
new TableColumnContentModel('bitcoin_id', 'Bitcoin Address', TableItemText, 4, true)
|
||||||
|
];
|
||||||
|
|
||||||
|
if(this.state.open && this.state.editionList[this.props.columnContent.id] && this.state.editionList[this.props.columnContent.id].length) {
|
||||||
|
return (
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||||
|
<Table itemList={this.state.editionList[this.props.columnContent.id]} columnList={columnList}>
|
||||||
|
{this.state.editionList[this.props.columnContent.id].map((edition, i) => {
|
||||||
|
return (
|
||||||
|
<TableItem
|
||||||
|
key={i}>
|
||||||
|
</TableItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="col-xs-12 col-sm-12 col-md-12 col-lg-12 ascribe-table-item">
|
<div className="col-xs-12 col-sm-12 col-md-12 col-lg-12 ascribe-table-item">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
@ -72,6 +115,7 @@ let TableItemSubtable = React.createClass({
|
|||||||
</TableItemSubtableButton>
|
</TableItemSubtableButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{renderEditionListTable()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,14 @@ import React from 'react';
|
|||||||
let TableItemSubtableButton = React.createClass({
|
let TableItemSubtableButton = React.createClass({
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
content: React.PropTypes.string.isRequired
|
content: React.PropTypes.string.isRequired,
|
||||||
|
onClick: React.PropTypes.func.isRequired
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
<button type="button" className="btn btn-ascribe btn-primary btn-sm">
|
<button type="button" className="btn btn-ascribe btn-primary btn-sm" onClick={this.props.onClick}>
|
||||||
{this.props.content}
|
{this.props.content}
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
|
@ -3,7 +3,10 @@ import React from 'react';
|
|||||||
|
|
||||||
let TableItemText = React.createClass({
|
let TableItemText = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
content: React.PropTypes.string.isRequired
|
content: React.PropTypes.oneOfType([
|
||||||
|
React.PropTypes.string,
|
||||||
|
React.PropTypes.number
|
||||||
|
])
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -4,9 +4,6 @@ import AltContainer from 'alt/AltContainer';
|
|||||||
import PieceListStore from '../stores/piece_list_store';
|
import PieceListStore from '../stores/piece_list_store';
|
||||||
import PieceListActions from '../actions/piece_list_actions';
|
import PieceListActions from '../actions/piece_list_actions';
|
||||||
|
|
||||||
import EditionListStore from '../stores/edition_list_store';
|
|
||||||
import EditionListActions from '../actions/edition_list_actions';
|
|
||||||
|
|
||||||
import Table from './ascribe_table/table';
|
import Table from './ascribe_table/table';
|
||||||
import TableItem from './ascribe_table/table_item';
|
import TableItem from './ascribe_table/table_item';
|
||||||
import TableItemImg from './ascribe_table/table_item_img';
|
import TableItemImg from './ascribe_table/table_item_img';
|
||||||
@ -27,16 +24,16 @@ let PieceList = React.createClass({
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
let page = this.props.query.page || 1;
|
let page = this.props.query.page || 1;
|
||||||
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc);
|
|
||||||
PieceListStore.listen(this.onChange);
|
PieceListStore.listen(this.onChange);
|
||||||
|
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
PieceListStore.unlisten(this.onChange);
|
PieceListStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange() {
|
onChange(state) {
|
||||||
this.setState(this.getInitialState());
|
this.setState(state);
|
||||||
},
|
},
|
||||||
|
|
||||||
paginationGoToPage(page) {
|
paginationGoToPage(page) {
|
||||||
@ -60,29 +57,39 @@ let PieceList = React.createClass({
|
|||||||
let currentPage = parseInt(this.props.query.page, 10) || 1;
|
let currentPage = parseInt(this.props.query.page, 10) || 1;
|
||||||
let totalPages = Math.ceil(this.state.pieceListCount / this.state.pageSize)
|
let totalPages = Math.ceil(this.state.pieceListCount / this.state.pageSize)
|
||||||
|
|
||||||
// Could wrap this altContainer potentially once again.
|
if(this.state.pieceList && this.state.pieceList.length > 0) {
|
||||||
return (
|
return (
|
||||||
<AltContainer
|
<div>
|
||||||
store={PieceListStore}
|
<Table
|
||||||
transform={(props) => {
|
columnList={columnList}
|
||||||
return {
|
changeOrder={this.tableChangeOrder}
|
||||||
'itemList': props.pieceList,
|
itemList={this.state.pieceList}
|
||||||
'itemListCount': props.pieceListCount,
|
itemListCount={this.state.pieceListCount}
|
||||||
'orderBy': props.orderBy,
|
orderBy={this.state.orderBy}
|
||||||
'orderAsc': props.orderAsc,
|
orderAsc={this.state.orderAsc}
|
||||||
'search': props.search,
|
search={this.state.search}
|
||||||
'page': props.page,
|
page={this.state.page}
|
||||||
'pageSize': props.pageSize,
|
pageSize={this.state.pageSize}>
|
||||||
}
|
{this.state.pieceList.map((item, i) => {
|
||||||
}}>
|
return (
|
||||||
<Table columnList={columnList} changeOrder={this.tableChangeOrder}>
|
<TableItemSubtable
|
||||||
<TableItemSubtable store={EditionListStore} actions={EditionListActions}></TableItemSubtable>
|
key={i}>
|
||||||
</Table>
|
</TableItemSubtable>
|
||||||
<Pagination currentPage={currentPage}
|
);
|
||||||
totalPages={totalPages}
|
})}
|
||||||
goToPage={this.paginationGoToPage} />
|
</Table>
|
||||||
</AltContainer>
|
<Pagination currentPage={currentPage}
|
||||||
);
|
totalPages={totalPages}
|
||||||
|
goToPage={this.paginationGoToPage}>
|
||||||
|
</Pagination>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<p>Loading</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3,12 +3,12 @@ import EditionsListActions from '../actions/edition_list_actions';
|
|||||||
|
|
||||||
class EditionListStore {
|
class EditionListStore {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.editionList = [];
|
this.editionList = {};
|
||||||
this.bindActions(EditionsListActions);
|
this.bindActions(EditionsListActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdateEditionList(editionList) {
|
onUpdateEditionList({pieceId, editionList}) {
|
||||||
this.editionList = editionList;
|
this.editionList[pieceId] = editionList;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user