added price per unit to item details page

This commit is contained in:
Senad Uka
2015-01-30 07:19:28 +01:00
parent b8caf1a8a7
commit 35cc279527
70 changed files with 12644 additions and 17 deletions

View File

@@ -28,8 +28,11 @@ var ItemWithDetailsPage = React.createClass({
<div className="col-md-7">
<h3> {this.state.item.get('name')} </h3>
<div>
<div className='h4'> {this.state.item.get('list_price')} KM</div>
<div className='h5'>{this.state.item.get('pricePerUnit')}</div>
<div> {this.state.item.get('description')}</div>
</div>

View File

@@ -4,16 +4,8 @@ var Globals = require('../globals');
var Item = Backbone.Model.extend({
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
}
});

View File

@@ -1,9 +1,22 @@
var Backbone = require('backbone');
var Globals = require('../globals');
var Mutators = require('backbone.mutators');
var ItemWithDetails = Backbone.Model.extend({
urlRoot : Globals.ApiUrl + '/item'
urlRoot: Globals.ApiUrl + '/item',
mutators: {
pricePerUnit: function() {
var unitsInPack = this.get('units_in_pack');
if (unitsInPack == undefined || unitsInPack <= 1) return "";
unitsInPack = parseFloat(unitsInPack).toFixed(0);
var price = parseFloat(this.get('list_price')).toFixed(2)
var pricePerUnit = (price / unitsInPack).toFixed(2);
var descriptionSuffix = this.get('unit').description_suffix;
return (+pricePerUnit).toString() + " KM " + descriptionSuffix;
}
}
});
module.exports = ItemWithDetails;
module.exports = ItemWithDetails;

View File

@@ -19,9 +19,9 @@
"grunt-contrib-connect": "~0.9.0",
"grunt-contrib-uglify": "~0.7.0",
"grunt-contrib-watch": "~0.6.1",
"merry-go-round": "^0.1.1",
"reactify": "~0.17.1",
"underscore": "^1.7.0"
"underscore": "^1.7.0",
"Backbone.Mutators": "~0.4.4"
},
"dependencies": {
"react": "~0.12.2",