Skip to content

Instantly share code, notes, and snippets.

@pYr0x
Created July 9, 2018 22:22
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 pYr0x/a0b4c56f7bac3cf93ef442ba273a0bc5 to your computer and use it in GitHub Desktop.
Save pYr0x/a0b4c56f7bac3cf93ef442ba273a0bc5 to your computer and use it in GitHub Desktop.
export const ViewModel = DefineMap.extend({
filter: {
Type: Filter
},
charts: {
Default: DefineList
},
dashboardPromise: {
get: function () {
return canAjax({
url: loader.serviceBaseURL+"/api/dashboard/logistics",
type: "GET"
}).then((response) => {
const charts = new DefineList();
for(const chart of response){
let chartComponent;
const chartVM = Object.assign({
filter: value.from(this, "filter") //this.filter // this is 2-way-bound... error with value.from(this, "filter");
}, chart);
switch (chart.chart) {
case "signal":
chartComponent = new SignalChart({viewModel: chartVM});
break;
case "bar":
chartComponent = new BarChart({viewModel: chartVM});
break;
case "pie":
chartComponent = new PieChart({viewModel: chartVM});
break;
}
charts.push(chartComponent);
}
this.charts.update(charts);
});
}
}
});
export default Component.extend({
tag: "x-dashboard-logistics",
ViewModel,
view
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment