1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 10:25:08 +01:00

Destructure params for fetchPieceList

This commit is contained in:
Brett Sun 2015-12-08 15:09:03 +01:00
parent 349ea8518f
commit 257ff9b5d3
17 changed files with 60 additions and 68 deletions

View File

@ -15,7 +15,7 @@ class PieceListActions {
); );
} }
fetchPieceList(page, pageSize, search, orderBy, orderAsc, filterBy) { fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy}) {
// To prevent flickering on a pagination request, // To prevent flickering on a pagination request,
// we overwrite the piecelist with an empty list before // we overwrite the piecelist with an empty list before
// pieceListCount === -1 defines the loading state // pieceListCount === -1 defines the loading state
@ -34,7 +34,7 @@ class PieceListActions {
// afterwards, we can load the list // afterwards, we can load the list
return Q.Promise((resolve, reject) => { return Q.Promise((resolve, reject) => {
PieceListFetcher PieceListFetcher
.fetch(page, pageSize, search, orderBy, orderAsc, filterBy) .fetch({page, pageSize, search, orderBy, orderAsc, filterBy})
.then((res) => { .then((res) => {
this.actions.updatePieceList({ this.actions.updatePieceList({
page, page,

View File

@ -88,8 +88,9 @@ let AccordionListItemWallet = React.createClass({
}, },
onPollingSuccess(pieceId) { onPollingSuccess(pieceId) {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
EditionListActions.toggleEditionList(pieceId); EditionListActions.toggleEditionList(pieceId);
let notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000); let notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000);

View File

@ -79,8 +79,9 @@ let EditionActionPanel = React.createClass({
}, },
refreshCollection() { refreshCollection() {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
EditionListActions.refreshEditionList({pieceId: this.props.edition.parent}); EditionListActions.refreshEditionList({pieceId: this.props.edition.parent});
}, },

View File

@ -140,15 +140,17 @@ let PieceContainer = React.createClass({
}, },
handleEditionCreationSuccess() { handleEditionCreationSuccess() {
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
PieceActions.updateProperty({key: 'num_editions', value: 0}); PieceActions.updateProperty({key: 'num_editions', value: 0});
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
this.toggleCreateEditionsDialog(); this.toggleCreateEditionsDialog();
}, },
handleDeleteSuccess(response) { handleDeleteSuccess(response) {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
// since we're deleting a piece, we just need to close // since we're deleting a piece, we just need to close
// all editions dialogs and not reload them // all editions dialogs and not reload them
@ -177,6 +179,7 @@ let PieceContainer = React.createClass({
}, },
handlePollingSuccess(pieceId, numEditions) { handlePollingSuccess(pieceId, numEditions) {
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
// we need to refresh the num_editions property of the actual piece we're looking at // we need to refresh the num_editions property of the actual piece we're looking at
PieceActions.updateProperty({ PieceActions.updateProperty({
@ -188,8 +191,7 @@ let PieceContainer = React.createClass({
// btw.: It's not sufficient to just set num_editions to numEditions, since a single accordion // btw.: It's not sufficient to just set num_editions to numEditions, since a single accordion
// list item also uses the firstEdition property which we can only get from the server in that case. // list item also uses the firstEdition property which we can only get from the server in that case.
// Therefore we need to at least refetch the changed piece from the server or on our case simply all // Therefore we need to at least refetch the changed piece from the server or on our case simply all
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
let notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000); let notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);

View File

@ -206,15 +206,15 @@ let PieceList = React.createClass({
}, },
applyOrderBy(orderBy) { applyOrderBy(orderBy) {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, const { filterBy, orderAsc, page, pageSize, search } = this.state;
orderBy, this.state.orderAsc, this.state.filterBy); PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
}, },
loadPieceList({ page, filterBy = this.state.filterBy, search = this.state.search }) { loadPieceList({ page, filterBy = this.state.filterBy, search = this.state.search }) {
const { orderAsc, pageSize } = this.state;
const orderBy = this.state.orderBy || this.props.orderBy; const orderBy = this.state.orderBy || this.props.orderBy;
return PieceListActions.fetchPieceList(page, this.state.pageSize, search, return PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
orderBy, this.state.orderAsc, filterBy);
}, },
fetchSelectedPieceEditionList() { fetchSelectedPieceEditionList() {
@ -240,8 +240,9 @@ let PieceList = React.createClass({
}, },
handleAclSuccess() { handleAclSuccess() {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, const { filterBy, orderBy, orderAsc, page, pageSize, search } = this.state;
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
this.fetchSelectedPieceEditionList() this.fetchSelectedPieceEditionList()
.forEach((pieceId) => { .forEach((pieceId) => {

View File

@ -65,20 +65,15 @@ let RegisterPiece = React.createClass( {
this.setState(state); this.setState(state);
}, },
handleSuccess(response){ handleSuccess(response) {
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
let notification = new GlobalNotificationModel(response.notification, 'success', 10000); let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
// once the user was able to register a piece successfully, we need to make sure to keep // once the user was able to register a piece successfully, we need to make sure to keep
// the piece list up to date // the piece list up to date
PieceListActions.fetchPieceList( PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
this.state.page,
this.state.pageSize,
this.state.searchTerm,
this.state.orderBy,
this.state.orderAsc,
this.state.filterBy
);
this.history.pushState(null, `/pieces/${response.piece.id}`); this.history.pushState(null, `/pieces/${response.piece.id}`);
}, },

View File

@ -58,8 +58,9 @@ let AccordionListItemPrize = React.createClass({
}, },
handleSubmitPrizeSuccess(response) { handleSubmitPrizeSuccess(response) {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
let notification = new GlobalNotificationModel(response.notification, 'success', 10000); let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
@ -138,8 +139,9 @@ let AccordionListItemPrize = React.createClass({
}, },
refreshPieceData() { refreshPieceData() {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
}, },
onSelectChange(){ onSelectChange(){

View File

@ -305,9 +305,10 @@ let PrizePieceRatings = React.createClass({
}, },
refreshPieceData() { refreshPieceData() {
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.props.loadPiece(); this.props.loadPiece();
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
}, },
onSelectChange() { onSelectChange() {

View File

@ -52,8 +52,9 @@ let CylandAccordionListItem = React.createClass({
}, },
handleSubmitSuccess(response) { handleSubmitSuccess(response) {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
let notification = new GlobalNotificationModel(response.notification, 'success', 10000); let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);

View File

@ -74,8 +74,9 @@ let CylandPieceContainer = React.createClass({
}, },
handleDeleteSuccess(response) { handleDeleteSuccess(response) {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
// since we're deleting a piece, we just need to close // since we're deleting a piece, we just need to close
// all editions dialogs and not reload them // all editions dialogs and not reload them

View File

@ -140,14 +140,9 @@ let CylandRegisterPiece = React.createClass({
}, },
refreshPieceList() { refreshPieceList() {
PieceListActions.fetchPieceList( const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.state.page,
this.state.pageSize, PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
this.state.searchTerm,
this.state.orderBy,
this.state.orderAsc,
this.state.filterBy
);
}, },
changeSlide() { changeSlide() {

View File

@ -53,8 +53,9 @@ let IkonotvAccordionListItem = React.createClass({
}, },
handleSubmitSuccess(response) { handleSubmitSuccess(response) {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
let notification = new GlobalNotificationModel(response.notification, 'success', 10000); let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);

View File

@ -83,8 +83,9 @@ let IkonotvPieceContainer = React.createClass({
}, },
handleDeleteSuccess(response) { handleDeleteSuccess(response) {
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
// since we're deleting a piece, we just need to close // since we're deleting a piece, we just need to close
// all editions dialogs and not reload them // all editions dialogs and not reload them

View File

@ -147,14 +147,9 @@ let IkonotvRegisterPiece = React.createClass({
}, },
refreshPieceList() { refreshPieceList() {
PieceListActions.fetchPieceList( const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.state.page,
this.state.pageSize, PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
this.state.searchTerm,
this.state.orderBy,
this.state.orderAsc,
this.state.filterBy
);
}, },
canSubmit() { canSubmit() {

View File

@ -103,14 +103,9 @@ let MarketRegisterPiece = React.createClass({
}, },
refreshPieceList() { refreshPieceList() {
PieceListActions.fetchPieceList( const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
this.state.page,
this.state.pageSize, PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
this.state.searchTerm,
this.state.orderBy,
this.state.orderAsc,
this.state.filterBy
);
}, },
render() { render() {

View File

@ -10,7 +10,7 @@ let 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.
*/ */
fetch(page, pageSize, search, orderBy, orderAsc, filterBy) { fetch({page, pageSize, search, orderBy, orderAsc, filterBy}) {
let ordering = generateOrderingQueryParams(orderBy, orderAsc); let ordering = generateOrderingQueryParams(orderBy, orderAsc);
// filterBy is an object of acl key-value pairs. // filterBy is an object of acl key-value pairs.

View File

@ -31,7 +31,7 @@ class PieceListStore {
this.requestActions = {}; this.requestActions = {};
this.bindActions(PieceListActions); this.bindActions(PieceListActions);
} }
onUpdatePieceList({ page, pageSize, search, pieceList, orderBy, orderAsc, pieceListCount, unfilteredPieceListCount, filterBy }) { onUpdatePieceList({ page, pageSize, search, pieceList, orderBy, orderAsc, pieceListCount, unfilteredPieceListCount, filterBy }) {
this.page = page; this.page = page;
this.pageSize = pageSize; this.pageSize = pageSize;
@ -66,7 +66,7 @@ class PieceListStore {
show: { $set: oldPiece.show } show: { $set: oldPiece.show }
}); });
} }
}); });
this.pieceList = pieceList; this.pieceList = pieceList;