lpio
Version:
The last dashboard app you'll ever need
45 lines (41 loc) • 1.36 kB
HTML
<link rel="import" href="../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../lp-imports/jquery.html">
<link rel="import" href="../../lp-imports/underscore.html">
<script>
window.ReduxBehaviors = window.ReduxBehaviors || {};
/**
*
* @polymerBehavior ReduxBehaviors.App
*
**/
ReduxBehaviors.AppImpl = {
created: function(){
this._addReducer(this.appReducer);
},
appReducer: function(action){
if(action.key == 'app'){
switch (action.type){
case 'setCurrentDashboard':
return this.setCurrentDashboard(action);
case 'setOnline':
return this.setOnline(action);
}
}
},
setOnline: function(action){
if(action.value){
this.mutate('app.online',true);
} else {
this.mutate('app.online',false);
}
},
setCurrentDashboard: function(action){
if(!action.hasOwnProperty('id')){
console.error("setCurrentDashboard: id is required");
return;
}
this.mutate('app.currentDashboard',action.id);
}
};
ReduxBehaviors.App = [ReduxBehaviors.AppImpl];
</script>