Last active
July 21, 2017 15:58
-
-
Save krivaten/0b5c099e00fdd332a194bee7fae0d9f2 to your computer and use it in GitHub Desktop.
Query Param Visiblity Spike
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'; | |
| // This would live on some non-application route | |
| export default Ember.Controller.extend({ | |
| queryParams: ['inquiryType', 'inquiryId'], | |
| inquiryType: null, | |
| inquiryId: null, | |
| isTransactionInquiry: Ember.computed.equal('inquiryType', 'transaction'), | |
| isAccountInquiry: Ember.computed.equal('inquiryType', 'account'), | |
| actions: { | |
| createInquiry(isTransaction, id) { | |
| this.setProperties({ | |
| inquiryType: isTransaction ? 'transaction' : 'account', | |
| inquiryId: id | |
| }); | |
| }, | |
| resetRoute() { | |
| this.container.lookup('route:application').send('resetQueryParams'); | |
| } | |
| } | |
| }); |
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({ | |
| // This would live on some non-application route | |
| queryParams: { | |
| inquiryType: {}, | |
| inquiryId: {} | |
| }, | |
| actions: { | |
| // This would live on some non-application route | |
| queryParamsDidChange(changed, present) { | |
| if(Ember.isPresent(present.inquiryType) && Ember.isPresent(present.inquiryId)) { | |
| this.send('toggleModal', true); | |
| } else { | |
| this.send('toggleModal', false); | |
| } | |
| }, | |
| // This would get called from the route | |
| toggleModal(visible) { | |
| this.controller.set('showModal', visible); | |
| }, | |
| resetQueryParams() { | |
| this.controller.set('inquiryType', null); | |
| this.controller.set('inquiryId', null); | |
| } | |
| } | |
| }); |
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.10.7", | |
| "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.10.0", | |
| "ember-data": "2.10.0", | |
| "ember-template-compiler": "2.10.0", | |
| "ember-testing": "2.10.0" | |
| }, | |
| "addons": {} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment