UNPKG

lpio

Version:

The last dashboard app you'll ever need

49 lines (42 loc) 1.5 kB
<link rel="import" href="../../../bower_components/polymer/polymer.html"> <link rel="import" href="../../lp-imports/jquery.html"> <link rel="import" href="../../lp-imports/q.html"> <script> window.ReduxBehaviors = window.ReduxBehaviors || {}; /** * * @polymerBehavior ReduxBehaviors.Dashboard * **/ ReduxBehaviors.DashboardImpl = { created: function(){ this._addReducer(this.dashboardReducer); }, dashboardReducer: function(action){ if(action.key == 'dashboards'){ switch (action.type){ case 'setAll': return this.setAll(action); } } }, setAll: function(action){ if(!action.hasOwnProperty('dashboards') || !_.isArray(action.dashboards)){ console.error("setAll: bad action payload"); return; } var ids = _.map(action.dashboards,function(dash){ return dash._id; }); var byId = {}; action.dashboards.forEach(function(dash){ byId[dash._id] = dash; }); this.mutate('dashboards.ids',ids); this.mutate('dashboards.dashboards',action.dashboards); this.mutate('dashboards.dashboardsById',byId); this.mutate('dashboards.isLoading',false); } }; ReduxBehaviors.Dashboard = [ReduxBehaviors.DashboardImpl]; </script>