diff --git a/js/actions/pagination_actions.js b/js/actions/pagination_actions.js
new file mode 100644
index 00000000..e58fda17
--- /dev/null
+++ b/js/actions/pagination_actions.js
@@ -0,0 +1,23 @@
+import alt from '../alt';
+import PieceListFetcher from '../fetchers/piece_list_fetcher';
+
+
+class UserActions {
+ constructor() {
+ this.generateActions(
+ 'updateCurrentUser'
+ );
+ }
+
+ fetchCurrentUser() {
+ UserFetcher.fetchOne()
+ .then((res) => {
+ this.actions.updateCurrentUser(res['users'][0]);
+ })
+ .catch((err) => {
+ console.log(err);
+ });
+ }
+};
+
+export default alt.createActions(UserActions);
diff --git a/js/actions/piece_list_actions.js b/js/actions/piece_list_actions.js
index 30ae492c..2ff3b0cf 100644
--- a/js/actions/piece_list_actions.js
+++ b/js/actions/piece_list_actions.js
@@ -15,15 +15,19 @@ class PieceListActions {
.fetch(page, pageSize, search, orderBy, orderAsc)
.then((res) => {
this.actions.updatePieceList({
- 'itemList': res.pieces,
- 'orderBy': orderBy,
- 'orderAsc': orderAsc
+ page,
+ pageSize,
+ search,
+ orderBy,
+ orderAsc,
+ 'itemList': res.pieces
});
})
.catch((err) => {
console.log(err);
});
}
+
};
export default alt.createActions(PieceListActions);
diff --git a/js/app.js b/js/app.js
index 13bad5f5..b757b0ee 100644
--- a/js/app.js
+++ b/js/app.js
@@ -5,11 +5,12 @@ import Router from 'react-router';
import AscribeApp from './components/ascribe_app';
import routes from './routes';
+import alt from './alt';
Router.run(routes, Router.HashLocation, (AscribeApp) => {
- React.render(
- ,
- document.getElementById('main')
- );
+ React.render(
+ ,
+ document.getElementById('main')
+ );
});
diff --git a/js/components/pagination.js b/js/components/pagination.js
new file mode 100644
index 00000000..35a3d726
--- /dev/null
+++ b/js/components/pagination.js
@@ -0,0 +1,43 @@
+import React from 'react';
+import Router from 'react-router';
+
+let Link = Router.Link;
+
+
+let Pagination = React.createClass({
+
+ goToPage(page) {
+ return () => this.props.fetchList(page, this.props.pageSize, this.props.search,
+ this.props.orderBy, this.props.orderAsc);
+ },
+
+ render() {
+ let prev = parseInt(this.props.page, 10) - 1;
+ let next = parseInt(this.props.page, 10) + 1;
+
+ return(
+
+ );
+ }
+});
+
+export default Pagination;
diff --git a/js/components/piece_list.js b/js/components/piece_list.js
index 450dadd3..1a3ce858 100644
--- a/js/components/piece_list.js
+++ b/js/components/piece_list.js
@@ -10,19 +10,23 @@ import TableItemText from './ascribe_table/table_item_text';
import TableColumnModel from '../models/table_column_model';
+import Pagination from './pagination'
+
let PieceList = React.createClass({
+ // FIXME: this might be useless
getInitialState() {
return PieceListStore.getState();
},
componentDidMount() {
- PieceListActions.fetchList(this.state.page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc);
+ let page = this.props.query.page || this.state.page;
+ PieceListActions.fetchList(page, this.state.pageSize, this.state.search,
+ this.state.orderBy, this.state.orderAsc);
},
render() {
-
let columnList = [
new TableColumnModel('thumbnail', '', TableItemImg, 2, false),
new TableColumnModel('artist_name', 'Artist', TableItemText, 4, true),
@@ -32,6 +36,7 @@ let PieceList = React.createClass({
return (
+
);
}
diff --git a/js/routes.js b/js/routes.js
index 4817b069..b9dd01c8 100644
--- a/js/routes.js
+++ b/js/routes.js
@@ -10,7 +10,7 @@ let Route = Router.Route;
let routes = (
-
+
diff --git a/js/stores/piece_list_store.js b/js/stores/piece_list_store.js
index 745a8fc0..44ba7a5a 100644
--- a/js/stores/piece_list_store.js
+++ b/js/stores/piece_list_store.js
@@ -13,7 +13,11 @@ class PieceListStore {
this.bindActions(PieceListActions);
}
- onUpdatePieceList({ itemList, orderBy, orderAsc }) {
+ onUpdatePieceList({ page, pageSize, search, itemList, orderBy, orderAsc }) {
+ console.log('onUpdatePieceList', arguments);
+ this.page = page;
+ this.pageSize = pageSize;
+ this.search = search;
this.orderAsc = orderAsc;
this.orderBy = orderBy;
this.itemList = itemList;
diff --git a/js/utils/general_utils.js b/js/utils/general_utils.js
index 27a40446..fe92611b 100644
--- a/js/utils/general_utils.js
+++ b/js/utils/general_utils.js
@@ -10,7 +10,7 @@ let GeneralUtils = {
.map((key) => {
// By matching null with a double equal, we can match undefined and null
// http://stackoverflow.com/a/15992131
- if(obj[key] == null) {
+ if(obj[key] == null || obj[key] === '') {
delete obj[key];
}
});
@@ -37,4 +37,4 @@ let GeneralUtils = {
}
};
-export default GeneralUtils;
\ No newline at end of file
+export default GeneralUtils;