diff --git a/js/actions/artwork_list_actions.js b/js/actions/artwork_list_actions.js deleted file mode 100644 index b9618bd4..00000000 --- a/js/actions/artwork_list_actions.js +++ /dev/null @@ -1,22 +0,0 @@ -import alt from '../alt'; -import ArtworkFetcher from '../fetchers/artwork_fetcher'; - -class ArtworkListActions { - constructor() { - this.generateActions( - 'updateArtworkList' - ); - } - - fetchArtworkList() { - ArtworkFetcher.fetch(1, 10) - .then((res) => { - this.actions.updateArtworkList(res.pieces); - }) - .catch((err) => { - console.log(err); - }); - } -}; - -export default alt.createActions(ArtworkListActions); diff --git a/js/actions/piece_list_actions.js b/js/actions/piece_list_actions.js new file mode 100644 index 00000000..51158285 --- /dev/null +++ b/js/actions/piece_list_actions.js @@ -0,0 +1,22 @@ +import alt from '../alt'; +import PieceListFetcher from '../fetchers/piece_list_fetcher'; + +class PieceListActions { + constructor() { + this.generateActions( + 'updatePieceList' + ); + } + + fetchPieceList() { + PieceListFetcher.fetch(1, 10) + .then((res) => { + this.actions.updatePieceList(res.pieces); + }) + .catch((err) => { + console.log(err); + }); + } +}; + +export default alt.createActions(PieceListActions); diff --git a/js/components/artwork.js b/js/components/artwork.js deleted file mode 100644 index 27ab31e2..00000000 --- a/js/components/artwork.js +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react'; - -let Artwork = React.createClass({ - render() { - return ( -

this.props.artwork.title

- ); - } -}); - -export default Artwork; \ No newline at end of file diff --git a/js/components/artwork_list.js b/js/components/artwork_list.js deleted file mode 100644 index 3bde0815..00000000 --- a/js/components/artwork_list.js +++ /dev/null @@ -1,40 +0,0 @@ -import React from 'react'; -import Router from 'react-router'; - -import ArtworkListStore from '../stores/artwork_list_store'; -import ArtworkListActions from '../actions/artwork_list_actions'; - -let Link = Router.Link; - -var ArtworkList = React.createClass({ - getInitialState() { - return ArtworkListStore.getState(); - }, - - componentDidMount() { - ArtworkListStore.listen(this.onChange); - ArtworkListActions.fetchArtworkList(); - }, - - componentWillUnmount() { - ArtworkListStore.unlisten(this.onChange); - }, - - onChange(state) { - this.setState(state); - }, - - render() { - return ( - - ); - } -}); - -export default ArtworkList; diff --git a/js/components/ascribe_app.js b/js/components/ascribe_app.js index 3bd406ff..f5ff7c93 100644 --- a/js/components/ascribe_app.js +++ b/js/components/ascribe_app.js @@ -12,7 +12,7 @@ class AscribeApp extends React.Component {
ascribe
- artworks + pieces
diff --git a/js/components/piece.js b/js/components/piece.js new file mode 100644 index 00000000..80faf6b8 --- /dev/null +++ b/js/components/piece.js @@ -0,0 +1,11 @@ +import React from 'react'; + +let Piece = React.createClass({ + render() { + return ( +

this.props.piece.title

+ ); + } +}); + +export default Piece; \ No newline at end of file diff --git a/js/components/piece_list.js b/js/components/piece_list.js new file mode 100644 index 00000000..516ad62e --- /dev/null +++ b/js/components/piece_list.js @@ -0,0 +1,40 @@ +import React from 'react'; +import Router from 'react-router'; + +import PieceListStore from '../stores/piece_list_store'; +import PieceListActions from '../actions/piece_list_actions'; + +let Link = Router.Link; + +var PieceList = React.createClass({ + getInitialState() { + return PieceListStore.getState(); + }, + + componentDidMount() { + PieceListStore.listen(this.onChange); + PieceListActions.fetchPieceList(); + }, + + componentWillUnmount() { + PieceListStore.unlisten(this.onChange); + }, + + onChange(state) { + this.setState(state); + }, + + render() { + return ( + + ); + } +}); + +export default PieceList; diff --git a/js/fetchers/artwork_fetcher.js b/js/fetchers/piece_list_fetcher.js similarity index 92% rename from js/fetchers/artwork_fetcher.js rename to js/fetchers/piece_list_fetcher.js index 1b06fd83..133070fd 100644 --- a/js/fetchers/artwork_fetcher.js +++ b/js/fetchers/piece_list_fetcher.js @@ -3,7 +3,7 @@ import fetch from 'isomorphic-fetch'; import AppConstants from '../constants/application_constants'; import FetchApiUtils from '../utils/fetch_api_utils'; -var ArtworkListFetcher = { +var PieceListFetcher = { /** * Fetches a list of pieces from the API. * Can be called with all supplied queryparams the API. @@ -27,4 +27,4 @@ var ArtworkListFetcher = { } }; -export default ArtworkListFetcher; \ No newline at end of file +export default PieceListFetcher; \ No newline at end of file diff --git a/js/routes.js b/js/routes.js index a181d2c8..2aa89bc2 100644 --- a/js/routes.js +++ b/js/routes.js @@ -2,15 +2,15 @@ import React from 'react'; import Router from 'react-router'; import AscribeApp from './components/ascribe_app'; -import ArtworkList from './components/artwork_list'; -import Artwork from './components/artwork'; +import PieceList from './components/piece_list'; +import Piece from './components/piece'; var Route = Router.Route; var routes = ( - - + + ); diff --git a/js/stores/artwork_list_store.js b/js/stores/artwork_list_store.js deleted file mode 100644 index ca57d6b1..00000000 --- a/js/stores/artwork_list_store.js +++ /dev/null @@ -1,15 +0,0 @@ -import alt from '../alt'; -import ArtworkListActions from '../actions/artwork_list_actions'; - -class ArtworkListStore { - constructor() { - this.artworkList = []; - this.bindActions(ArtworkListActions); - } - - onUpdateArtworkList(artworkList) { - this.artworkList = artworkList; - } -}; - -export default alt.createStore(ArtworkListStore); diff --git a/js/stores/piece_list_store.js b/js/stores/piece_list_store.js new file mode 100644 index 00000000..5383c922 --- /dev/null +++ b/js/stores/piece_list_store.js @@ -0,0 +1,15 @@ +import alt from '../alt'; +import PieceListActions from '../actions/piece_list_actions'; + +class PieceListStore { + constructor() { + this.pieceList = []; + this.bindActions(PieceListActions); + } + + onUpdatePieceList(pieceList) { + this.pieceList = pieceList; + } +}; + +export default alt.createStore(PieceListStore);