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:
parent
349ea8518f
commit
257ff9b5d3
@ -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,
|
||||
// we overwrite the piecelist with an empty list before
|
||||
// pieceListCount === -1 defines the loading state
|
||||
@ -34,7 +34,7 @@ class PieceListActions {
|
||||
// afterwards, we can load the list
|
||||
return Q.Promise((resolve, reject) => {
|
||||
PieceListFetcher
|
||||
.fetch(page, pageSize, search, orderBy, orderAsc, filterBy)
|
||||
.fetch({page, pageSize, search, orderBy, orderAsc, filterBy})
|
||||
.then((res) => {
|
||||
this.actions.updatePieceList({
|
||||
page,
|
||||
|
@ -88,8 +88,9 @@ let AccordionListItemWallet = React.createClass({
|
||||
},
|
||||
|
||||
onPollingSuccess(pieceId) {
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
EditionListActions.toggleEditionList(pieceId);
|
||||
|
||||
let notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000);
|
||||
|
@ -79,8 +79,9 @@ let EditionActionPanel = React.createClass({
|
||||
},
|
||||
|
||||
refreshCollection() {
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
EditionListActions.refreshEditionList({pieceId: this.props.edition.parent});
|
||||
},
|
||||
|
||||
|
@ -140,15 +140,17 @@ let PieceContainer = React.createClass({
|
||||
},
|
||||
|
||||
handleEditionCreationSuccess() {
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceActions.updateProperty({key: 'num_editions', value: 0});
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
this.toggleCreateEditionsDialog();
|
||||
},
|
||||
|
||||
handleDeleteSuccess(response) {
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
|
||||
// since we're deleting a piece, we just need to close
|
||||
// all editions dialogs and not reload them
|
||||
@ -177,6 +179,7 @@ let PieceContainer = React.createClass({
|
||||
},
|
||||
|
||||
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
|
||||
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
|
||||
// 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
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
|
||||
let notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
|
@ -206,15 +206,15 @@ let PieceList = React.createClass({
|
||||
},
|
||||
|
||||
applyOrderBy(orderBy) {
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
const { filterBy, orderAsc, page, pageSize, search } = this.state;
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
},
|
||||
|
||||
loadPieceList({ page, filterBy = this.state.filterBy, search = this.state.search }) {
|
||||
const { orderAsc, pageSize } = this.state;
|
||||
const orderBy = this.state.orderBy || this.props.orderBy;
|
||||
|
||||
return PieceListActions.fetchPieceList(page, this.state.pageSize, search,
|
||||
orderBy, this.state.orderAsc, filterBy);
|
||||
return PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
},
|
||||
|
||||
fetchSelectedPieceEditionList() {
|
||||
@ -240,8 +240,9 @@ let PieceList = React.createClass({
|
||||
},
|
||||
|
||||
handleAclSuccess() {
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
const { filterBy, orderBy, orderAsc, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
|
||||
this.fetchSelectedPieceEditionList()
|
||||
.forEach((pieceId) => {
|
||||
|
@ -66,19 +66,14 @@ let RegisterPiece = React.createClass( {
|
||||
},
|
||||
|
||||
handleSuccess(response) {
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
|
||||
// once the user was able to register a piece successfully, we need to make sure to keep
|
||||
// the piece list up to date
|
||||
PieceListActions.fetchPieceList(
|
||||
this.state.page,
|
||||
this.state.pageSize,
|
||||
this.state.searchTerm,
|
||||
this.state.orderBy,
|
||||
this.state.orderAsc,
|
||||
this.state.filterBy
|
||||
);
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
|
||||
this.history.pushState(null, `/pieces/${response.piece.id}`);
|
||||
},
|
||||
|
@ -58,8 +58,9 @@ let AccordionListItemPrize = React.createClass({
|
||||
},
|
||||
|
||||
handleSubmitPrizeSuccess(response) {
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
|
||||
let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
@ -138,8 +139,9 @@ let AccordionListItemPrize = React.createClass({
|
||||
},
|
||||
|
||||
refreshPieceData() {
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
},
|
||||
|
||||
onSelectChange(){
|
||||
|
@ -305,9 +305,10 @@ let PrizePieceRatings = React.createClass({
|
||||
},
|
||||
|
||||
refreshPieceData() {
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
this.props.loadPiece();
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
},
|
||||
|
||||
onSelectChange() {
|
||||
|
@ -52,8 +52,9 @@ let CylandAccordionListItem = React.createClass({
|
||||
},
|
||||
|
||||
handleSubmitSuccess(response) {
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
|
||||
let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
|
@ -74,8 +74,9 @@ let CylandPieceContainer = React.createClass({
|
||||
},
|
||||
|
||||
handleDeleteSuccess(response) {
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
|
||||
// since we're deleting a piece, we just need to close
|
||||
// all editions dialogs and not reload them
|
||||
|
@ -140,14 +140,9 @@ let CylandRegisterPiece = React.createClass({
|
||||
},
|
||||
|
||||
refreshPieceList() {
|
||||
PieceListActions.fetchPieceList(
|
||||
this.state.page,
|
||||
this.state.pageSize,
|
||||
this.state.searchTerm,
|
||||
this.state.orderBy,
|
||||
this.state.orderAsc,
|
||||
this.state.filterBy
|
||||
);
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
},
|
||||
|
||||
changeSlide() {
|
||||
|
@ -53,8 +53,9 @@ let IkonotvAccordionListItem = React.createClass({
|
||||
},
|
||||
|
||||
handleSubmitSuccess(response) {
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
|
||||
let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
|
@ -83,8 +83,9 @@ let IkonotvPieceContainer = React.createClass({
|
||||
},
|
||||
|
||||
handleDeleteSuccess(response) {
|
||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
|
||||
// since we're deleting a piece, we just need to close
|
||||
// all editions dialogs and not reload them
|
||||
|
@ -147,14 +147,9 @@ let IkonotvRegisterPiece = React.createClass({
|
||||
},
|
||||
|
||||
refreshPieceList() {
|
||||
PieceListActions.fetchPieceList(
|
||||
this.state.page,
|
||||
this.state.pageSize,
|
||||
this.state.searchTerm,
|
||||
this.state.orderBy,
|
||||
this.state.orderAsc,
|
||||
this.state.filterBy
|
||||
);
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
},
|
||||
|
||||
canSubmit() {
|
||||
|
@ -103,14 +103,9 @@ let MarketRegisterPiece = React.createClass({
|
||||
},
|
||||
|
||||
refreshPieceList() {
|
||||
PieceListActions.fetchPieceList(
|
||||
this.state.page,
|
||||
this.state.pageSize,
|
||||
this.state.searchTerm,
|
||||
this.state.orderBy,
|
||||
this.state.orderAsc,
|
||||
this.state.filterBy
|
||||
);
|
||||
const { filterBy, orderAsc, orderBy, page, pageSize, search } = this.state;
|
||||
|
||||
PieceListActions.fetchPieceList({page, pageSize, search, orderBy, orderAsc, filterBy});
|
||||
},
|
||||
|
||||
render() {
|
||||
|
@ -10,7 +10,7 @@ let PieceListFetcher = {
|
||||
* Fetches a list of pieces from 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);
|
||||
|
||||
// filterBy is an object of acl key-value pairs.
|
||||
|
Loading…
Reference in New Issue
Block a user