diff --git a/js/actions/prize_list_actions.js b/js/actions/prize_list_actions.js new file mode 100644 index 00000000..fddf1a04 --- /dev/null +++ b/js/actions/prize_list_actions.js @@ -0,0 +1,34 @@ +'use strict'; + +import alt from '../alt'; +import Q from 'q'; + +import PrizeListFetcher from '../fetchers/prize_list_fetcher'; + +class PrizeListActions { + constructor() { + this.generateActions( + 'updatePrizeList' + ); + } + + fetchPrizeList() { + return Q.Promise((resolve, reject) => { + PrizeListFetcher + .fetch() + .then((res) => { + this.actions.updatePrizeList({ + prizeList: res.prizes, + prizeListCount: res.count + }); + resolve(res); + }) + .catch((err) => { + console.logGlobal(err); + reject(err); + }); + }); + } +} + +export default alt.createActions(PrizeListActions); \ No newline at end of file diff --git a/js/components/ascribe_prizes_dashboard/prizes_dashboard.js b/js/components/ascribe_prizes_dashboard/prizes_dashboard.js new file mode 100644 index 00000000..b4c695f4 --- /dev/null +++ b/js/components/ascribe_prizes_dashboard/prizes_dashboard.js @@ -0,0 +1,82 @@ +'use strict'; + +import React from 'react'; + +import PrizeListActions from '../../actions/prize_list_actions'; +import PrizeListStore from '../../stores/prize_list_store'; + +import Table from '../ascribe_table/table'; +import TableItem from '../ascribe_table/table_item'; +import TableItemText from '../ascribe_table/table_item_text'; + +import { ColumnModel} from '../ascribe_table/models/table_models'; +import { getLangText } from '../../utils/lang_utils'; + +let PrizesDashboard = React.createClass({ + + getInitialState() { + return PrizeListStore.getState(); + }, + + componentDidMount() { + PrizeListStore.listen(this.onChange); + PrizeListActions.fetchPrizeList(); + }, + + componentWillUnmount() { + PrizeListStore.unlisten(this.onChange); + }, + + onChange(state) { + this.setState(state); + }, + + getColumnList() { + return [ + new ColumnModel( + (item) => { + return { + 'content': item.name + }; }, + 'name', + getLangText('Name'), + TableItemText, + 6, + false, + null + ), + new ColumnModel( + (item) => { + return { + 'content': item.domain + }; }, + 'domain', + getLangText('Domain'), + TableItemText, + 1, + false, + null + ) + ]; + }, + + render() { + return ( + + {this.state.prizeList.map((item, i) => { + return ( + + ); + })} +
+ ); + } +}); + +export default PrizesDashboard; \ No newline at end of file diff --git a/js/components/ascribe_table/table_header.js b/js/components/ascribe_table/table_header.js index 8f138fb4..f807627b 100644 --- a/js/components/ascribe_table/table_header.js +++ b/js/components/ascribe_table/table_header.js @@ -2,7 +2,6 @@ import React from 'react'; -import TableColumnMixin from '../../mixins/table_column_mixin'; import TableHeaderItem from './table_header_item'; import { ColumnModel } from './models/table_models'; @@ -17,15 +16,12 @@ let TableHeader = React.createClass({ orderBy: React.PropTypes.string }, - mixins: [TableColumnMixin], - render() { return ( {this.props.columnList.map((column, i) => { - let columnClasses = this.calcColumnClasses(this.props.columnList, i, 12); let columnName = column.columnName; let canBeOrdered = column.canBeOrdered; @@ -33,7 +29,6 @@ let TableHeader = React.createClass({ column.rowWidth ); - let numOfUsedColumns = sumNumList(listOfRowValues); - - if(numOfUsedColumns > numOfColumns) { - throw new Error('This table has only ' + numOfColumns + ' columns to assign. You defined ' + numOfUsedColumns + '. Change this in the columnMap you\'re passing to the table.'); - } else { - return bootstrapClasses.join( listOfRowValues[i] + ' ') + listOfRowValues[i]; - } - } -}; - -export default TableColumnMixin; diff --git a/js/routes.js b/js/routes.js index 90248ef2..f7ea2ea6 100644 --- a/js/routes.js +++ b/js/routes.js @@ -20,6 +20,8 @@ import CoaVerifyContainer from './components/coa_verify_container'; import RegisterPiece from './components/register_piece'; +import PrizesDashboard from './components/ascribe_prizes_dashboard/prizes_dashboard'; + let Route = Router.Route; @@ -35,6 +37,7 @@ const COMMON_ROUTES = ( + ); diff --git a/js/stores/prize_list_store.js b/js/stores/prize_list_store.js new file mode 100644 index 00000000..99ee5d14 --- /dev/null +++ b/js/stores/prize_list_store.js @@ -0,0 +1,20 @@ +'use strict'; + +import alt from '../alt'; + +import PrizeListActions from '../actions/prize_list_actions'; + +class PrizeListStore { + constructor() { + this.prizeList = []; + this.prizeListCount = -1; + this.bindActions(PrizeListActions); + } + + onUpdatePrizeList({ prizeList, prizeListCount }) { + this.prizeList = prizeList; + this.prizeListCount = prizeListCount; + } +} + +export default alt.createStore(PrizeListStore, 'PrizeListStore'); \ No newline at end of file diff --git a/sass/ascribe_table.scss b/sass/ascribe_table.scss index ebb40672..225c27ca 100644 --- a/sass/ascribe_table.scss +++ b/sass/ascribe_table.scss @@ -22,10 +22,11 @@ } .ascribe-table-item-column { - display: table; font-family: 'Source Sans Pro'; font-size: .8em; height:3em; + vertical-align: middle; + display: table-cell; } .ascribe-table-item-column > * { @@ -37,7 +38,8 @@ } .ascribe-table-item-column > span > input { - margin-top:18px; + margin-top:10px; + margin-left:2px; } .ascribe-table-item-selected {