{ this.state.item.get('name') }
{ this.state.item.get('list_price') } KM
@@ -15,9 +21,14 @@ var SingleItem = React.createClass({
},
getInitialState: function () {
- return { item: this.props.item };
- },
+ return { item: this.props.item };
+ },
+ itemClick: function(e) {
+ if(this.props.itemClick) {
+ this.props.itemClick(this.state.item, e);
+ }
+ }
});
-module.exports = SingleItem;
+module.exports = SingleItem;
diff --git a/front-ui/app/controllers/itemDetailsController.js b/front-ui/app/controllers/itemDetailsController.js
new file mode 100644
index 0000000..b6d4e49
--- /dev/null
+++ b/front-ui/app/controllers/itemDetailsController.js
@@ -0,0 +1,9 @@
+var StartPageSectionsView = require('../views/startPageSectionsView'),
+ StartPageItemsView = require('../views/startPageItemsView');
+
+function ItemDetailsController(id,slug) {
+ alert("clicked on an item" + id + " with a slug " + slug);
+
+}
+
+module.exports = ItemDetailsController;
diff --git a/front-ui/app/models/item.js b/front-ui/app/models/item.js
index 3b14f33..1945a8c 100644
--- a/front-ui/app/models/item.js
+++ b/front-ui/app/models/item.js
@@ -2,7 +2,19 @@ var Backbone = require('backbone');
var Globals = require('../globals');
var Item = Backbone.Model.extend({
- urlRoot : Globals.ApiUrl + '/item'
+ urlRoot : Globals.ApiUrl + '/item',
+
+ getFrontEndUrl : function(withHashPrefix) {
+ var hashPrefix = "";
+ if (withHashPrefix) {
+ hashPrefix = "#!/";
+ }
+ var slug = this.get('name').toLowerCase().replace(/\s+/g,"-");
+ return hashPrefix + "artikal/" + this.get('id') + "/" + slug
+ }
+
+
+
});
module.exports = Item;
diff --git a/front-ui/app/router.js b/front-ui/app/router.js
index a5ab82c..8ad074c 100644
--- a/front-ui/app/router.js
+++ b/front-ui/app/router.js
@@ -1,11 +1,16 @@
var Backbone = require('backbone'),
HomeController = require('./controllers/homeController');
+ ItemDetailsController = require('./controllers/itemDetailsController');
var Router = Backbone.Router.extend({
routes : {
"home" : HomeController,
- "*default": HomeController
+ "artikal/:id/:slug": ItemDetailsController,
+ "*default": HomeController
}
+
});
+//Backbone.history.start();
+
module.exports = Router;
diff --git a/front-ui/app/views/startPageItemsView.js b/front-ui/app/views/startPageItemsView.js
index 43393cd..6377305 100644
--- a/front-ui/app/views/startPageItemsView.js
+++ b/front-ui/app/views/startPageItemsView.js
@@ -2,7 +2,8 @@ var Backbone = require('backbone'),
React = require('react'),
ItemList = require('../components/itemList'),
ItemCollection = require('../models/itemCollection'),
- Item = require('../models/item');
+ Item = require('../models/item'),
+ Router = require('../router');
var StartPageItemsView = Backbone.View.extend({
el: '#content',
@@ -12,7 +13,6 @@ var StartPageItemsView = Backbone.View.extend({
},
render: function() {
this.$el.append(this.template);
-
var items = new ItemCollection();
items.setClassificationType(0);
items.setLimit(30);
@@ -22,13 +22,21 @@ var StartPageItemsView = Backbone.View.extend({
// var resultItems = items.map(function (a) { return a.attributes });
React.render(new ItemList({
- items: items
+ items: items,
+ itemClick: self.itemClick
}),
self.$('.item-list-container').get(0));
}});
return this;
+ },
+ itemClick: function(item) {
+
+ RIBICA.App.router.navigate(item.getFrontEndUrl(), {'trigger': true});
+
+
}
+
});
module.exports = StartPageItemsView;
diff --git a/front-ui/build/index.html b/front-ui/build/index.html
index 40ea6fe..95334d6 100644
--- a/front-ui/build/index.html
+++ b/front-ui/build/index.html
@@ -2,6 +2,7 @@
+