Created
February 11, 2017 18:32
-
-
Save tarponjargon/b82c69819c5eb51171c6724960f880fe 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' | |
}); |
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'; | |
// this would not be here, I'd import it to the route and the controller | |
const cfg = { | |
defaultQueryParams: { | |
q: null, | |
paging: '18', | |
search_sort: 'relevance', | |
search_title: null, | |
search_page: null, | |
filter_breadcrumb: [], | |
filter_price: [], | |
filter_size_apparel: [], | |
filter_color: [] | |
} | |
}; | |
export default Ember.Controller.extend({ | |
queryParams: Object.keys(cfg.defaultQueryParams), | |
// the empty array assignments have to be specified directly in the controller properties(?) | |
q: null, | |
paging: '18', | |
search_sort: 'relevance', | |
search_title: null, | |
search_page: null, | |
filter_breadcrumb: [], | |
filter_price: [], | |
filter_size_apparel: [], | |
filter_color: [], | |
//init(){ | |
// this._super(...arguments); | |
// this.setProperties(cfg.defaultQueryParams); | |
//}, | |
actions: { | |
addFilter: function(key, value) { | |
alert(`adding ${key} ${value.toString()}`); | |
console.log(this); | |
this[key].pushObject(value.toString()); | |
}, | |
removeFilter: function(key, value) { | |
this[key].removeObject(value.toString()); | |
console.log(this[key]); | |
}, | |
} | |
}); |
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 function debugFilter([value]) { | |
return Ember.typeOf(value) !== 'function' && typeof value !== 'undefined' && value.length > 0; | |
} | |
export default Ember.Helper.helper(debugFilter); |
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 config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('results'); | |
}); | |
export default Router; |
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'; | |
// this would not be here, I'd import it to the route and the controller | |
const cfg = { | |
defaultQueryParams: { | |
q: null, | |
paging: '18', | |
search_sort: 'relevance', | |
search_title: null, | |
search_page: null, | |
filter_breadcrumb: [], | |
filter_price: [], | |
filter_size_apparel: [], | |
filter_color: [] | |
} | |
}; | |
export default Ember.Route.extend({ | |
queryParams: {}, | |
init() { | |
this._super(...arguments); | |
for (let qp of Object.keys(cfg.defaultQueryParams)) { | |
this.queryParams[qp] = { refreshModel: true }; | |
} | |
}, | |
model(params) { | |
let aggregations = { | |
'aggregations': { | |
'breadcrumb': [ | |
{ | |
'doc_count': 37, | |
'key': 'Home' | |
}, | |
{ | |
'doc_count': 15, | |
'key': 'Home > Kitchen and Bar' | |
}, | |
{ | |
'doc_count': 12, | |
'key': 'Home > Footballz' | |
}, | |
{ | |
'doc_count': 12, | |
'key': 'Home > Garbage Cans' | |
}, | |
{ | |
'doc_count': 16, | |
'key': 'Brand new items' | |
} | |
] | |
} | |
} | |
return aggregations; | |
}, | |
setupController(controller, model) { | |
controller.set('aggregations', model.aggregations); | |
} | |
}); |
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.11.0", | |
"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.2", | |
"ember-data": "2.11.0", | |
"ember-template-compiler": "2.10.2", | |
"ember-testing": "2.10.2" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment