fixed paging on subcategory browsing page
This commit is contained in:
@@ -24,6 +24,12 @@ var BySubCategoryActions = {
|
|||||||
actionType: BySubCategoryConstants.REMOVE_APPLIED_FILTER,
|
actionType: BySubCategoryConstants.REMOVE_APPLIED_FILTER,
|
||||||
name: name
|
name: name
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
changePage: function(page) {
|
||||||
|
AppDispatcher.handleAction({
|
||||||
|
actionType: BySubCategoryConstants.CHANGE_PAGE,
|
||||||
|
page: page
|
||||||
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ var BySubCategory = React.createClass({
|
|||||||
removeAppliedFilter: function(name) {
|
removeAppliedFilter: function(name) {
|
||||||
BySubCategoryActions.removeAppliedFilter(name);
|
BySubCategoryActions.removeAppliedFilter(name);
|
||||||
},
|
},
|
||||||
|
onChangePage: function(page) {
|
||||||
|
BySubCategoryActions.changePage(page);
|
||||||
|
},
|
||||||
render : function() {
|
render : function() {
|
||||||
|
|
||||||
return (<div>
|
return (<div>
|
||||||
@@ -32,14 +35,17 @@ var BySubCategory = React.createClass({
|
|||||||
</div>
|
</div>
|
||||||
<div classname='col-md-10'>
|
<div classname='col-md-10'>
|
||||||
|
|
||||||
|
<h2>
|
||||||
Podkategorija {this.state.subCategory.get('name')}
|
Podkategorija {this.state.subCategory.get('name')}
|
||||||
|
</h2>
|
||||||
|
|
||||||
Number of items in this subcategory: {this.state.items.length}
|
<div>Number of items in this subcategory: {this.state.items.length}</div>
|
||||||
|
<div>total count : {this.state.items.totalCount}</div>
|
||||||
<div>
|
<div>
|
||||||
<AppliedFiltersList filters={this.appliedSubCategoryFiltersArray()} onRemove={this.removeAppliedFilter} />
|
<AppliedFiltersList filters={this.appliedSubCategoryFiltersArray()} onRemove={this.removeAppliedFilter} />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<ItemList items={this.state.items} paginationEnabled={true} total={this.state.items.totalCount} limit={this.state.pagination.limit} onPageChange={this.changePage} currentOffset={this.state.pagination.offset} />
|
<ItemList items={this.state.items} paginationEnabled={true} total={this.state.items.totalCount} limit={this.state.pagination.limit} onPageChange={this.onChangePage} currentOffset={this.state.pagination.offset} />
|
||||||
</div>
|
</div>
|
||||||
</div>)
|
</div>)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ var ItemList = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<nav>
|
<nav>
|
||||||
<ul className="pagination">
|
<ul className="pagination">
|
||||||
|
|
||||||
{pages}
|
{pages}
|
||||||
</ul>
|
</ul>
|
||||||
</nav>)
|
</nav>)
|
||||||
|
|||||||
@@ -4,5 +4,6 @@ var keyMirror = require('react/lib/keyMirror');
|
|||||||
module.exports = keyMirror({
|
module.exports = keyMirror({
|
||||||
LOAD: null,
|
LOAD: null,
|
||||||
FILTER_CRITERIA_CLICK: null,
|
FILTER_CRITERIA_CLICK: null,
|
||||||
REMOVE_APPLIED_FILTER: null
|
REMOVE_APPLIED_FILTER: null,
|
||||||
|
CHANGE_PAGE: null
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,11 +8,16 @@ var BySubCategoryConstants = require('../constants/bySubCategoryConstants');
|
|||||||
var ItemCollection = require('../models/itemCollection');
|
var ItemCollection = require('../models/itemCollection');
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
|
|
||||||
|
var Globals = require('../globals');
|
||||||
|
|
||||||
var _state = {
|
var _state = {
|
||||||
subCategory : (new SubCategory()),
|
subCategory : (new SubCategory()),
|
||||||
items: (new ItemCollection()),
|
items: (new ItemCollection()),
|
||||||
filter: {},
|
filter: {},
|
||||||
pagination: {}
|
pagination: {
|
||||||
|
offset : 0,
|
||||||
|
limit: Globals.DefaultPageSize
|
||||||
|
}
|
||||||
};
|
};
|
||||||
//var _categoryDetails = new Category();
|
//var _categoryDetails = new Category();
|
||||||
|
|
||||||
@@ -65,7 +70,8 @@ var load = function(subCategoryId, offset, limit, filter) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
_state.filter = filter;
|
_state.filter = filter;
|
||||||
//BySubCategoryStore.emitChange();
|
_state.pagination.limit = limit;
|
||||||
|
_state.pagination.offset = offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
var handleFilterCriteriaClick = function(fc, fcv) {
|
var handleFilterCriteriaClick = function(fc, fcv) {
|
||||||
@@ -83,19 +89,13 @@ var handleRemoveAppliedFilter= function(name) {
|
|||||||
NavigationActions.goToSubCategory(_state.subCategory, 0, _state.pagination.limit, _state.filter);
|
NavigationActions.goToSubCategory(_state.subCategory, 0, _state.pagination.limit, _state.filter);
|
||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
//var loadCategoryDetails = function(categoryId) {
|
|
||||||
//var category = new Category({id : categoryId});
|
|
||||||
//category.fetch({
|
|
||||||
//success: function() {
|
|
||||||
//_categoryDetails = category;
|
|
||||||
//BySubCategoryStore.emitChange();
|
|
||||||
//}
|
|
||||||
//});
|
|
||||||
//};
|
|
||||||
|
|
||||||
//var setHovered = function(id) {
|
var handleChangePage = function(page) {
|
||||||
//sectionState.hoveredSection = id;
|
setTimeout(function() {
|
||||||
//}
|
NavigationActions.goToSubCategory(_state.subCategory, parseInt(page) * _state.pagination.limit, _state.pagination.limit, _state.filter);
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Extend SectionStore with EventEmitter to add eventing capabilities
|
// Extend SectionStore with EventEmitter to add eventing capabilities
|
||||||
@@ -139,6 +139,9 @@ AppDispatcher.register(function(payload) {
|
|||||||
case BySubCategoryConstants.REMOVE_APPLIED_FILTER:
|
case BySubCategoryConstants.REMOVE_APPLIED_FILTER:
|
||||||
handleRemoveAppliedFilter(action.name);
|
handleRemoveAppliedFilter(action.name);
|
||||||
break;
|
break;
|
||||||
|
case BySubCategoryConstants.CHANGE_PAGE:
|
||||||
|
handleChangePage(action.page);
|
||||||
|
break;
|
||||||
|
|
||||||
// Respond to SELECT_ITEM action
|
// Respond to SELECT_ITEM action
|
||||||
//case SectionConstants.LOAD_SECTIONS:
|
//case SectionConstants.LOAD_SECTIONS:
|
||||||
|
|||||||
Reference in New Issue
Block a user