-
- )
+ );
}
});
diff --git a/js/components/piece_list.js b/js/components/piece_list.js
index 2b3de95d..504e7909 100644
--- a/js/components/piece_list.js
+++ b/js/components/piece_list.js
@@ -5,9 +5,12 @@ import AltContainer from 'alt/AltContainer';
import PieceListStore from '../stores/piece_list_store';
import PieceListActions from '../actions/piece_list_actions';
-import Table from './table';
-import TableItemImg from './table_item_img';
-import TableItemText from './table_item_text';
+import Table from './ascribe_table/table';
+import TableItemImg from './ascribe_table/table_item_img';
+import TableItemText from './ascribe_table/table_item_text';
+
+import TableColumnModel from '../models/table_column_model';
+
import Pagination from './pagination'
let Link = Router.Link;
@@ -27,32 +30,15 @@ let PieceList = React.createClass({
},
render() {
- // TODO:
- // Specifiy how a TableItemX should look like
- let columnMap = {
- 'thumbnail': {
- 'displayName': '',
- 'displayType': TableItemImg,
- 'rowWidth': 2,
- 'canBeOrdered': false
- },
- 'artist_name': {
- 'displayName': 'Artist',
- 'displayType': TableItemText,
- 'rowWidth': 4,
- 'canBeOrdered': true
- },
- 'title': {
- 'displayName': 'Title',
- 'displayType': TableItemText,
- 'rowWidth': 4,
- 'canBeOrdered': true
- }
- };
+ let columnList = [
+ new TableColumnModel('thumbnail', '', TableItemImg, 2, false),
+ new TableColumnModel('artist_name', 'Artist', TableItemText, 4, true),
+ new TableColumnModel('title', 'Title', TableItemText, 4, true)
+ ];
return (
-
+
);
diff --git a/js/components/table_header.js b/js/components/table_header.js
deleted file mode 100644
index 8754e477..00000000
--- a/js/components/table_header.js
+++ /dev/null
@@ -1,86 +0,0 @@
-import React from 'react';
-
-import TableColumnMixin from '../mixins/table_column_mixin';
-import GeneralUtils from '../utils/general_utils';
-
-
-let TableHeader = React.createClass({
- mixins: [TableColumnMixin],
- propTypes: {
- columnMap: React.PropTypes.object.isRequired,
- itemList: React.PropTypes.array.isRequired,
- fetchList: React.PropTypes.func.isRequired,
- orderAsc: React.PropTypes.bool.isRequired,
- orderBy: React.PropTypes.string.isRequired
- },
-
- sortIndex(i) {
-
- let orderAsc;
-
- if(this.props.orderAsc) {
- orderAsc = false;
- } else {
- orderAsc = true;
- }
-
- this.props.fetchList(1, 10, null, Object.keys(this.props.columnMap)[i], orderAsc);
- },
-
- render() {
-
- let columnMapValuesList = GeneralUtils.valuesOfObject(this.props.columnMap);
-
- let calcHeaderText = (val, i, columnClass) => {
-
- if(columnMapValuesList[i].canBeOrdered && Object.keys(this.props.columnMap)[i] === this.props.orderBy) {
-
- let boundClick = this.sortIndex.bind(this, i);
- let carretDirection = 'glyphicon-triangle-';
-
- if(this.props.orderAsc) {
- carretDirection += 'top';
- } else {
- carretDirection += 'bottom';
- }
-
- return (
-
-
- {val.displayName}
-
-
-
- );
- } else {
- return (
-
-
- {val.displayName}
-
-
- );
- }
- };
-
- return (
-
-
- {columnMapValuesList.map((val, i) => {
-
- let columnClass = this.calcColumnClasses(this.props.columnMap, i);
-
- return (
-
- {calcHeaderText(val, i, columnClass)}
-
- );
- })}
-
-
- );
-
- }
-});
-
-export default TableHeader;
diff --git a/js/components/table_header_item.js b/js/components/table_header_item.js
deleted file mode 100644
index d566975c..00000000
--- a/js/components/table_header_item.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-
-
-let TableHeaderItem = React.createClass({
- mixins: [TableColumnMixin],
- render() {
- return()
- }
-});
diff --git a/js/mixins/table_column_mixin.js b/js/mixins/table_column_mixin.js
index d2bf8977..5904389d 100644
--- a/js/mixins/table_column_mixin.js
+++ b/js/mixins/table_column_mixin.js
@@ -1,16 +1,16 @@
-import GeneralUtils from '../utils/general_utils';
+import React from 'react';
+import GeneralUtils from '../utils/general_utils';
let TableColumnMixin = {
/**
* Generates the bootstrap grid column declarations automatically using
* the columnMap.
*/
- calcColumnClasses(obj, i) {
+ calcColumnClasses(list, i) {
let bootstrapClasses = ['col-xs-', 'col-sm-', 'col-md-', 'col-lg-'];
- let rowData = GeneralUtils.valuesOfObject(obj);
- let listOfRowValues = rowData.map((val) => val.rowWidth );
+ let listOfRowValues = list.map((column) => column.rowWidth );
let numOfColumns = GeneralUtils.sumNumList(listOfRowValues);
if(numOfColumns > 12) {
diff --git a/js/models/table_column_model.js b/js/models/table_column_model.js
new file mode 100644
index 00000000..0a204717
--- /dev/null
+++ b/js/models/table_column_model.js
@@ -0,0 +1,12 @@
+class TableColumnItem {
+ constructor(columnName, displayName, displayType, rowWidth, canBeOrdered) {
+ this.columnName = columnName;
+ this.displayName = displayName;
+ this.displayType = displayType;
+ this.rowWidth = rowWidth;
+ this.canBeOrdered = canBeOrdered;
+ }
+
+}
+
+export default TableColumnItem;
\ No newline at end of file