Last active
April 26, 2016 13:10
-
-
Save Mas-Tool/4d5b626aab94def5992825fe48052d47 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains 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', | |
filtersService:Ember.inject.service('filters'), | |
clientState:Ember.computed.alias('filtersService.filters.clientState'), | |
queryStrings:Ember.computed('filtersService.queryStrings',function(){ | |
return JSON.stringify(this.get('filtersService.queryStrings')); | |
}), | |
queryStringsObserver:Ember.observer('filtersService.queryStrings',function(){ | |
console.log(JSON.stringify(this.get('filtersService.queryStrings'))); | |
}), | |
actions:{ | |
checkboxSelectionChanged:function(filter){ | |
filter.set('isSelected',true); | |
} | |
} | |
}); |
This file contains 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.Object.extend({ | |
title:'My Filter', | |
items:[], | |
selectedItems:Ember.computed('items.@each.isSelected',function() { | |
return this.get('items').filterBy('isSelected', true); | |
}), | |
queryString:Ember.computed('items.@each.isSelected',function(){ | |
alert('generating query string'); | |
return this.get('selectedItems').mapBy('name').join(','); | |
}), | |
}); |
This file contains 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'; | |
import FilterModel from '../models/FilterModel'; | |
export default Ember.Service.extend({ | |
init(){ | |
console.log("here"); | |
this.set('filters.clientState',FilterModel.create({ | |
title:'Client State', | |
items:[ | |
Ember.Object.create({name:'All',count:2500,isSelected:true}), | |
Ember.Object.create({name:'Online',count:1000,isSelected:false}), | |
Ember.Object.create({name:'Offline',count:1500,isSelected:false}) | |
] | |
})); | |
}, | |
filters:{ | |
}, | |
queryStrings:Ember.computed('filters.clientState.queryString',function(){ | |
alert('Generating multiple querystrings'); | |
return { | |
clientState:this.get('filters.clientState.queryString') | |
}; | |
}) | |
}); |
This file contains 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.7.2", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.4/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.4/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment