Forked from alexmiddeleer/controllers.application.js
Last active
July 18, 2018 17:08
-
-
Save bsylvain/b136f90c0f9469404f52fa3f7cfb0281 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
totalCosts:Ember.computed('pricing', | |
function(){ | |
var costs = {}; | |
costs["price"]=this.get('pricing').get('buy_price'); | |
costs["subscription"]=this.get('pricing').buy_subscription; | |
costs["perRoom"]=this.get('pricing').buy_per_room; | |
return costs; | |
}), | |
margins:Ember.computed('totalCosts', function(){ | |
var totals={}; | |
// totals['costs']=this.get('totalCosts'); | |
// margin={}; | |
// seller={}; | |
// for(var index in totals["costs"]){ | |
// margin[index]=pricing.get(index)-totals['costs'][index] | |
// seller[index]=pricing.get(index+'_reseller')*margin[index]/100 | |
// } | |
// totals['margin']=margin; | |
// totals['seller']=seller; | |
return totals; | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
totalCosts:Ember.computed('', | |
function(){ | |
var costs = {}; | |
costs["price"]=this.get('model').get('price'); | |
return costs; | |
//return JSON.stringify(costs); | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
export default DS.Model.extend({ | |
currency:DS.attr('string'), | |
buy_price_cents:DS.attr('number'), | |
price_cents:DS.attr('number'), | |
buy_price:Ember.computed('buy_price_cents',{ | |
get(key){return (this.get('buy_price_cents')/100)}, | |
set(key,value){this.set('buy_price_cents', (value*100));return value} | |
}), | |
price:Ember.computed('price_cents',{ | |
get(key){return (this.get('price_cents')/100)}, | |
set(key,value){this.set('price_cents', (value*100));return value} | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model(){ | |
return this.get('store').createRecord('pricing',{buy_price_cents: 20.0,price_cents: 20.0}); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "2.14.1", | |
"ember-template-compiler": "2.14.1", | |
"ember-testing": "2.14.1" | |
}, | |
"addons": { | |
"ember-data": "2.14.10" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment