Created
          June 3, 2017 03:50 
        
      - 
      
- 
        Save TheHomeRepo/a4b81eddd6e1c9880cde210f9c81e92c 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({ | |
| choice: null, | |
| sortAscending: true, | |
| sortProperties: ['id'], | |
| sortedItems: Ember.computed.sort('visits', 'sortProperties'), | |
| // Ember.computed.sort('visits', | |
| // function(itemA, itemB) { | |
| // let searchTerm = this.get('query'); | |
| // if (itemA < itemB) { | |
| // return 1; | |
| // } else if (itemA > itemB) { | |
| // return -1; | |
| // } | |
| // return 0; | |
| // }).property('searchTerm'), | |
| setDefaultChoice: function() { | |
| this.set('choice', this.get('visits').get('firstObject').visitId); | |
| //this.set('choice', this.get('sortedItems').get('firstObject').visitId); | |
| }.on('init'), | |
| actions: { | |
| selectVisit: function(itemIndex, visitId) { | |
| this.set('choice', visitId); | |
| this.set('selectedMenuIndex', itemIndex); | |
| this.set('model.visitId', visitId); | |
| }, | |
| sortBy: function(sortProperty) { | |
| if(sortProperty == this.get('sortProperties')[0]) { | |
| this.toggleProperty('sortAscending'); | |
| }else { | |
| this.set('sortAscending', true); | |
| } | |
| this.set('sortProperties', [sortProperty]); | |
| } | |
| } | |
| }); | 
  
    
      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' | |
| }); | 
  
    
      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({ | |
| visits: [{ | |
| date: "01/01/2016", | |
| location: "Denver" | |
| }, { | |
| date: "03/12/2016", | |
| location: "New York" | |
| }, { | |
| date: "06/04/2016", | |
| location: "St. Louis" | |
| }, { | |
| date: "01/21/2017", | |
| location: "San Francisco" | |
| }] | |
| }); | 
  
    
      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