Forked from feanor07/components.to-display-computed.js
Last active
March 22, 2017 08:46
-
-
Save ykaragol/fe52aa1a251c19e879250d79280c0d66 to your computer and use it in GitHub Desktop.
patlama#2
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'; | |
const {computed} = Ember; | |
let Errors = Ember.Object.extend({ | |
/* | |
errorsX: computed.alias('component.errors.x'), | |
errorsY: computed.alias('component.errors.y'), | |
errorsZ: computed.alias('component.errors.external'), | |
*/ | |
errorsXBinding: 'component.errors.x', | |
errorsYBinding: 'component.errors.y', | |
errorsZBinding: 'component.errors.z' | |
}); | |
export default Ember.Component.extend({ | |
init() { | |
this._super(...arguments); | |
this.set('errorBag', Errors.create({component:this})); | |
}, | |
errors:Ember.computed('item.x','item.y', 'externalField', function(){ | |
return Ember.merge({'x': this.get('item.x'), 'y': this.get('item.y')}, | |
this.get('externalField')); | |
}), | |
actions: { | |
onupdateX(value) { | |
this.get('item').set('x', value); | |
}, | |
onupdateY(value) { | |
this.get('item').set('y', value); | |
}, | |
onexternalupdate(value) { | |
this.set('externalField', 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.Component.extend({ | |
errors:Ember.computed('item.z', function(){ | |
let z = {'z': this.get('item.z')}; | |
this.get('onexternalupdate')(z); | |
return z; | |
}), | |
actions: { | |
onupdateZ(value) { | |
this.get('item').set('z', 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.Controller.extend({ | |
item: Ember.Object.create({}) | |
}); |
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.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment