mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 09:23:13 +01:00
refactor: rename artwork to piece and artworkList to pieceList
This commit is contained in:
parent
47246a9083
commit
9784e09aac
@ -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);
|
22
js/actions/piece_list_actions.js
Normal file
22
js/actions/piece_list_actions.js
Normal 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);
|
@ -1,11 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
let Artwork = React.createClass({
|
||||
render() {
|
||||
return (
|
||||
<p>this.props.artwork.title</p>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
export default Artwork;
|
@ -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;
|
@ -12,7 +12,7 @@ class AscribeApp extends React.Component {
|
||||
<div>
|
||||
<header>ascribe</header>
|
||||
<navigation>
|
||||
<Link to="artworks">artworks</Link>
|
||||
<Link to="pieces">pieces</Link>
|
||||
</navigation>
|
||||
<RouteHandler />
|
||||
</div>
|
||||
|
11
js/components/piece.js
Normal file
11
js/components/piece.js
Normal file
@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
|
||||
let Piece = React.createClass({
|
||||
render() {
|
||||
return (
|
||||
<p>this.props.piece.title</p>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
export default Piece;
|
40
js/components/piece_list.js
Normal file
40
js/components/piece_list.js
Normal 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;
|
@ -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;
|
||||
export default PieceListFetcher;
|
@ -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 = (
|
||||
<Route name="app" path="/" handler={AscribeApp}>
|
||||
<Route name="artworks" handler={ArtworkList} />
|
||||
<Route name="artwork" path="/artworks/:bitcoin_ID_noPrefix" handler={Artwork} />
|
||||
<Route name="pieces" handler={PieceList} />
|
||||
<Route name="piece" path="/artworks/:bitcoin_ID_noPrefix" handler={Piece} />
|
||||
</Route>
|
||||
);
|
||||
|
||||
|
@ -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);
|
15
js/stores/piece_list_store.js
Normal file
15
js/stores/piece_list_store.js
Normal 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);
|
Loading…
Reference in New Issue
Block a user