Created
July 9, 2018 22:22
-
-
Save pYr0x/a0b4c56f7bac3cf93ef442ba273a0bc5 to your computer and use it in GitHub Desktop.
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
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