groups of articles now shown on ribica.ba/group/1/, background is in cloudinary

This commit is contained in:
Senad Uka
2015-03-23 07:21:53 +01:00
parent 0ff47313df
commit b534d15866
13 changed files with 143 additions and 5 deletions

View File

@@ -9,7 +9,8 @@ var _ = require('underscore');
var _items = new ItemCollection(),
_itemWithDetails = new ItemWithDetails(),
_bestSellingForSection = new ItemCollection(),
_itemsByCategory = new ItemCollection();
_itemsByCategory = new ItemCollection(),
_bestSellingForGroup = new ItemCollection();
var loadItemsForFrontpage = function() {
@@ -93,6 +94,22 @@ var fetchBestSellingItemsForSection = function(sectionId) {
};
var fetchBestSellingItemsForGroup = function(groupId) {
console.log('getting group', groupId);
var items = _bestSellingForGroup;
items.setClassificationType(4);
items.setClassificationId(groupId);
items.setLimit(30);
items.setOffset(0);
items.fetch({
success: function() {
ItemStore.emitChange();
}
});
};
// Extend ItemStore with EventEmitter to add eventing capabilities
var ItemStore = _.extend({}, EventEmitter.prototype, {
@@ -108,6 +125,10 @@ var ItemStore = _.extend({}, EventEmitter.prototype, {
return _itemWithDetails;
},
getItemsForGroup: function () {
return _bestSellingForGroup;
},
// Return All Items
getItems: function() {
@@ -148,6 +169,10 @@ AppDispatcher.register(function(payload) {
fetchBestSellingItemsForSection(action.sectionId);
break;
case ItemConstants.LOAD_BSI_FOR_ITEM_GROUP:
fetchBestSellingItemsForGroup(action.groupId);
break;
case ItemConstants.LOAD_FOR_FRONTPAGE:
loadItemsForFrontpage();
break;

View File

@@ -5,10 +5,24 @@ var NavigationConstants = require('../constants/navigationConstants')
var _ = require('underscore');
var getGroupIdFromUrl = function() {
console.log("yeee" , match);
// ugly but it seems to me that
// router does not want to expose its
// state (for phylosophical reasons)
var url = document.URL;
var itemIdRegex = /grupa\/(\d+)\//g;
var match = itemIdRegex.exec(url);
console.log(match);
return match[1];
};
// Extend ItemStore with EventEmitter to add eventing capabilities
var NavigationStore = _.extend({}, EventEmitter.prototype, {
getGroupIdFromUrl: getGroupIdFromUrl,
// Emit Change event
emitChange: function() {
@@ -29,6 +43,8 @@ var NavigationStore = _.extend({}, EventEmitter.prototype, {
});
// Register callback with AppDispatcher
NavigationStore.dispatchToken = AppDispatcher.register(function(payload) {
var action = payload.action;