diff --git a/css/main.css b/css/main.css index 30ea36cc..5e19671b 100644 --- a/css/main.css +++ b/css/main.css @@ -51,3 +51,8 @@ display:table-cell; vertical-align: middle; } + +.btn-ascribe, .btn-ascribe:hover, .btn-ascribe:active, .btn-ascribe:focus { + background-color: rgba(2, 182, 163, 0.5); + border-color: rgba(2, 182, 163, 0.5); +} \ No newline at end of file diff --git a/js/actions/edition_list_actions.js b/js/actions/edition_list_actions.js index 35c43764..21c84017 100644 --- a/js/actions/edition_list_actions.js +++ b/js/actions/edition_list_actions.js @@ -9,11 +9,11 @@ class EditionListActions { ); } - fetchList() { + fetchList(pieceId) { EditionListFetcher - .fetch() + .fetch(pieceId) .then((res) => { - this.actions.updateEditionList(res.pieces); + this.actions.updateEditionList(res.editions); }) .catch((err) => { console.log(err); diff --git a/js/components/ascribe_table/table.js b/js/components/ascribe_table/table.js index 71c97658..550cf1a4 100644 --- a/js/components/ascribe_table/table.js +++ b/js/components/ascribe_table/table.js @@ -1,32 +1,39 @@ import React from 'react'; +import ReactAddons from 'react/addons'; import TableHeader from './table_header'; -import TableColumnModel from '../../models/table_column_model'; +import TableColumnContentModel from '../../models/table_column_content_model'; let Table = React.createClass({ propTypes: { - columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnModel)), - changeOrder: React.PropTypes.func.isRequired, - tableItem: React.PropTypes.any.isRequired // Optimally, this should check if tableItem is an instance of React.Component or something like that + columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnContentModel)), + changeOrder: React.PropTypes.func.isRequired + }, + + renderChildren() { + var that = this; + return ReactAddons.Children.map(this.props.children, (child) => { + return that.props.itemList.map((item, i) => { + return ReactAddons.addons.cloneWithProps(child, { + columnList: this.props.columnList, + columnContent: item, + key: i + }); + }); + }); }, render() { - let TableItem = this.props.tableItem; - + if(this.props.itemList && this.props.itemList.length > 0) { return (
Loading
diff --git a/js/components/ascribe_table/table_header.js b/js/components/ascribe_table/table_header.js index 853990bf..564f7725 100644 --- a/js/components/ascribe_table/table_header.js +++ b/js/components/ascribe_table/table_header.js @@ -4,13 +4,13 @@ import TableColumnMixin from '../../mixins/table_column_mixin'; import GeneralUtils from '../../utils/general_utils'; import TableHeaderItem from './table_header_item'; -import TableColumnModel from '../../models/table_column_model'; +import TableColumnContentModel from '../../models/table_column_content_model'; let TableHeader = React.createClass({ mixins: [TableColumnMixin], propTypes: { - columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnModel)), + columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnContentModel)), itemList: React.PropTypes.array.isRequired, changeOrder: React.PropTypes.func.isRequired, orderAsc: React.PropTypes.bool.isRequired, diff --git a/js/components/ascribe_table/table_item.js b/js/components/ascribe_table/table_item.js index 05f9942a..23f91201 100644 --- a/js/components/ascribe_table/table_item.js +++ b/js/components/ascribe_table/table_item.js @@ -1,26 +1,19 @@ import React from 'react'; import TableColumnMixin from '../../mixins/table_column_mixin'; -import TableItemImg from './table_item_img'; -import TableItemText from './table_item_text'; -import TableColumnModel from '../../models/table_column_model'; +import TableColumnContentModel from '../../models/table_column_content_model'; let TableItem = React.createClass({ mixins: [TableColumnMixin], propTypes: { - columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnModel)), - columnContent: React.PropTypes.object.isRequired + columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnContentModel)), + columnContent: React.PropTypes.object }, render() { - - /** - * An element in the Table can have a certain display_type. - * A display_type is just - */ let calcColumnElementContent = () => { return this.props.columnList.map((column, i) => { diff --git a/js/components/ascribe_table/table_item_subtable.js b/js/components/ascribe_table/table_item_subtable.js new file mode 100644 index 00000000..453b0c06 --- /dev/null +++ b/js/components/ascribe_table/table_item_subtable.js @@ -0,0 +1,61 @@ +import React from 'react'; + +import TableColumnContentModel from '../../models/table_column_content_model'; + +// ToDo: Create Table-specific Utils to not lock it to projects utilities +import GeneralUtils from '../../utils/general_utils'; + +import TableItemSubtableButton from './table_item_subtable_button'; + + +let TableItemSubtable = React.createClass({ + propTypes: { + columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnContentModel)), + columnContent: React.PropTypes.object + }, + + calcColumnClasses(list, i) { + let bootstrapClasses = ['col-xs-', 'col-sm-', 'col-md-', 'col-lg-']; + + let listOfRowValues = list.map((column) => column.rowWidth ); + let numOfColumns = GeneralUtils.sumNumList(listOfRowValues); + + if(numOfColumns > 10) { + throw new Error('Bootstrap has only 12 columns to assign. You defined ' + numOfColumns + '. Change this in the columnMap you\'re passing to the table.') + } else { + return bootstrapClasses.join( listOfRowValues[i] + ' ') + listOfRowValues[i]; + } + }, + + render() { + + let calcColumnElementContent = () => { + return this.props.columnList.map((column, i) => { + + let TypeElement = column.displayType; + let columnClass = this.calcColumnClasses(this.props.columnList, i); + + return ( +