1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 01:25:17 +01:00

refactor: rename artwork to piece and artworkList to pieceList

This commit is contained in:
Tim Daubenschütz 2015-05-19 17:13:09 +02:00
parent 47246a9083
commit 9784e09aac
11 changed files with 95 additions and 95 deletions

View File

@ -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);

View File

@ -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);

View File

@ -1,11 +0,0 @@
import React from 'react';
let Artwork = React.createClass({
render() {
return (
<p>this.props.artwork.title</p>
);
}
});
export default Artwork;

View File

@ -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 (
<ul>
{this.state.artworkList.map((artwork, i) => {
return (
<li key={i}><Link to="artwork" params={{'bitcoin_ID_noPrefix': artwork.bitcoin_ID_noPrefix}}>{artwork.title}</Link></li>
);
})}
</ul>
);
}
});
export default ArtworkList;

View File

@ -12,7 +12,7 @@ class AscribeApp extends React.Component {
<div> <div>
<header>ascribe</header> <header>ascribe</header>
<navigation> <navigation>
<Link to="artworks">artworks</Link> <Link to="pieces">pieces</Link>
</navigation> </navigation>
<RouteHandler /> <RouteHandler />
</div> </div>

11
js/components/piece.js Normal file
View File

@ -0,0 +1,11 @@
import React from 'react';
let Piece = React.createClass({
render() {
return (
<p>this.props.piece.title</p>
);
}
});
export default Piece;

View File

@ -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 (
<ul>
{this.state.pieceList.map((piece, i) => {
return (
<li key={i}><Link to="piece" params={{'bitcoin_ID_noPrefix': piece.bitcoin_ID_noPrefix}}>{piece.title}</Link></li>
);
})}
</ul>
);
}
});
export default PieceList;

View File

@ -3,7 +3,7 @@ import fetch from 'isomorphic-fetch';
import AppConstants from '../constants/application_constants'; import AppConstants from '../constants/application_constants';
import FetchApiUtils from '../utils/fetch_api_utils'; import FetchApiUtils from '../utils/fetch_api_utils';
var ArtworkListFetcher = { var PieceListFetcher = {
/** /**
* Fetches a list of pieces from the API. * Fetches a list of pieces from the API.
* Can be called with all supplied queryparams the API. * Can be called with all supplied queryparams the API.
@ -27,4 +27,4 @@ var ArtworkListFetcher = {
} }
}; };
export default ArtworkListFetcher; export default PieceListFetcher;

View File

@ -2,15 +2,15 @@ import React from 'react';
import Router from 'react-router'; import Router from 'react-router';
import AscribeApp from './components/ascribe_app'; import AscribeApp from './components/ascribe_app';
import ArtworkList from './components/artwork_list'; import PieceList from './components/piece_list';
import Artwork from './components/artwork'; import Piece from './components/piece';
var Route = Router.Route; var Route = Router.Route;
var routes = ( var routes = (
<Route name="app" path="/" handler={AscribeApp}> <Route name="app" path="/" handler={AscribeApp}>
<Route name="artworks" handler={ArtworkList} /> <Route name="pieces" handler={PieceList} />
<Route name="artwork" path="/artworks/:bitcoin_ID_noPrefix" handler={Artwork} /> <Route name="piece" path="/artworks/:bitcoin_ID_noPrefix" handler={Piece} />
</Route> </Route>
); );

View File

@ -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);

View File

@ -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);