Skip to content

Instantly share code, notes, and snippets.

@ChuckJonas
Last active October 11, 2018 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChuckJonas/64018db2f6d8a8cbc0e13364bc0ddd33 to your computer and use it in GitHub Desktop.
Save ChuckJonas/64018db2f6d8a8cbc0e13364bc0ddd33 to your computer and use it in GitHub Desktop.
(function() {
const {$A} = window;
return {
"meta":{
"name":"c$BeerList",
"extends":"markup://aura:component"
},
"controller":{
"locationChange":function(component, event, helper) {
helper.getBeers(component);
},
"pageChange":function(component, event, helper) {
var page = component.get("v.page") || 1;
var direction = event.getParam("direction");
page = direction === "previous" ? (page - 1) : (page + 1);
helper.getBeers(component, page);
},
"alcoholSelectionChange":function(component, event, helper) {
helper.minAlcohol = event.getParam("minAlcohol");
helper.getBeers(component);
}
},
"helper":{
"minAlcohol":0,
"getBeers":function(component, page) {
let foo = {
a: '123',
b: 123
};
let { a, b } = foo;
console.log(a, b);
var searchKey = window.location.hash.substr(1);
page = page || 1;
var action = component.get("c.findAll");
action.setParams({
"searchKey": searchKey,
"minAlcohol": this.minAlcohol,
"pageNumber": page
});
action.setCallback(this, function (a) {
var result = a.getReturnValue();
component.set("v.beers", result.products);
component.set("v.page", result.page);
component.set("v.total", result.total);
component.set("v.pages", Math.ceil(result.total / 12));
});
$A.enqueueAction(action);
}
}
};
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment