diff --git a/js/components/piece_list.js b/js/components/piece_list.js
index b819b4af..522ecebc 100644
--- a/js/components/piece_list.js
+++ b/js/components/piece_list.js
@@ -15,9 +15,16 @@ let PieceList = React.createClass({
},
render() {
+
+ let columnMap = {
+ 'thumbnail': 'Thumbnail',
+ 'artist_name': 'Artist',
+ 'title': 'Title'
+ };
+
return (
-
+
);
}
diff --git a/js/components/table.js b/js/components/table.js
index 08a0433e..b310c65c 100644
--- a/js/components/table.js
+++ b/js/components/table.js
@@ -1,18 +1,32 @@
import React from 'react';
import TableItem from './table_item';
+import TableHeader from './table_header';
let Table = React.createClass({
+ propTypes: {
+ columnMap: React.PropTypes.object.isRequired
+ },
render() {
- return (
-
- {this.props.pieceList.map((piece, i) => {
- return (
-
- );
- })}
-
- );
+
+ if(this.props.itemList && this.props.itemList.length > 0) {
+
+ return (
+
+
+ {this.props.itemList.map((item, i) => {
+ return (
+
+ );
+ })}
+
+ );
+
+ } else {
+ return (
+ Loading
+ );
+ }
}
});
diff --git a/js/components/table_header.js b/js/components/table_header.js
new file mode 100644
index 00000000..9f8d8ea3
--- /dev/null
+++ b/js/components/table_header.js
@@ -0,0 +1,34 @@
+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
+ },
+
+ render() {
+
+ let columnMapValuesList = GeneralUtils.valuesOfObject(this.props.columnMap);
+ let columnClasses = this.calcColumnClasses(this.props.columnMap);
+
+ return (
+
+
+ {columnMapValuesList.map((val, i) => {
+ return (
+
+ {val}
+
+ );
+ })}
+
+
+ );
+
+ }
+});
+
+export default TableHeader;
\ No newline at end of file
diff --git a/js/components/table_item.js b/js/components/table_item.js
index 57bdb602..cfda35f2 100644
--- a/js/components/table_item.js
+++ b/js/components/table_item.js
@@ -1,26 +1,29 @@
import React from 'react';
+import TableColumnMixin from '../mixins/table_column_mixin';
+
let TableItem = React.createClass({
+ mixins: [TableColumnMixin],
+ propTypes: {
+ columnMap: React.PropTypes.object.isRequired,
+ columnContent: React.PropTypes.object.isRequired
+ },
render() {
- let piece = this.props.piece;
- let columnClasses = 'col-xs-3 col-sm-3 col-md-3 col-lg-3';
+ let columnContent = this.props.columnContent;
+ let columnClasses = this.calcColumnClasses(this.props.columnMap);
+ let columnMapKeysList = Object.keys(this.props.columnMap);
return (
-
-
-
-
- {piece.artist_name}
-
-
- {piece.title}
-
-
- {piece.availableActions}
-
+ {columnMapKeysList.map((key, i) => {
+ return (
+
+ {columnContent[key]}
+
+ );
+ })}
);
diff --git a/js/mixins/table_column_mixin.js b/js/mixins/table_column_mixin.js
new file mode 100644
index 00000000..35af442c
--- /dev/null
+++ b/js/mixins/table_column_mixin.js
@@ -0,0 +1,16 @@
+import GeneralUtils from '../utils/general_utils';
+
+let TableColumnMixin = {
+ /**
+ * Generates the bootstrap grid column declarations automatically using
+ * the columnMap.
+ */
+ calcColumnClasses(obj) {
+ let bootstrapClasses = ['col-xs-', 'col-sm-', 'col-md-', 'col-lg-'];
+ let numOfColumns = GeneralUtils.valuesOfObject(obj).length;
+
+ return bootstrapClasses.join( numOfColumns + ' ') + numOfColumns;
+ }
+};
+
+export default TableColumnMixin;
\ No newline at end of file
diff --git a/js/stores/piece_list_store.js b/js/stores/piece_list_store.js
index 5383c922..b3fe0039 100644
--- a/js/stores/piece_list_store.js
+++ b/js/stores/piece_list_store.js
@@ -3,12 +3,12 @@ import PieceListActions from '../actions/piece_list_actions';
class PieceListStore {
constructor() {
- this.pieceList = [];
+ this.itemList = []; // rename this to pieceList after figuring out AltContainer transform
this.bindActions(PieceListActions);
}
- onUpdatePieceList(pieceList) {
- this.pieceList = pieceList;
+ onUpdatePieceList(itemList) {
+ this.itemList = itemList;
}
};
diff --git a/js/utils/general_utils.js b/js/utils/general_utils.js
index bf2e443e..7fdc88ca 100644
--- a/js/utils/general_utils.js
+++ b/js/utils/general_utils.js
@@ -16,6 +16,15 @@ let GeneralUtils = {
});
return obj;
+ },
+
+ /**
+ * Returns the values of an object.
+ */
+ valuesOfObject(obj) {
+ return Object
+ .keys(obj)
+ .map(key => obj[key]);
}
};