diff --git a/dist/react-dashboard.min.css b/dist/react-dashboard.min.css index 40315445..c9143c57 100644 --- a/dist/react-dashboard.min.css +++ b/dist/react-dashboard.min.css @@ -1 +1 @@ -@import url(https://fonts.googleapis.com/css?family=Open+Sans);body{font-family:Open Sans,sans-serif}h1{font-size:1.75em;border-bottom:1px solid #eee;margin-bottom:10px;border:none;font-size:36px;margin:25px 0}h1,h2{padding:0;color:#000}h2{border-bottom:1px solid #eee}h2,h3{font-size:1.75em;margin-bottom:10px}h3{padding:0;color:#000;border-bottom:1px solid #eee;border:none;font-size:1.15em}body{background:#fff}.glyphicon{top:3px}a{color:#0a77bd}a:focus,a:hover{color:#002245}.loader{position:relative;min-height:30px}.sp{width:32px;height:32px;position:absolute;left:50%;margin-left:-16px;z-index:2}.sp.sp-slices{border-radius:50%;border-top:16px solid rgba(0,0,0,.75);border-left:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.25);border-right:16px solid rgba(0,0,0,.25);-webkit-animation:spSlices 1s infinite linear;animation:spSlices 1s infinite linear}@-webkit-keyframes spSlices{0%{border-top:16px solid rgba(0,0,0,.75);border-right:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.25);border-left:16px solid rgba(0,0,0,.25)}25%{border-top:16px solid rgba(0,0,0,.25);border-right:16px solid rgba(0,0,0,.75);border-bottom:16px solid rgba(0,0,0,.25);border-left:16px solid rgba(0,0,0,.25)}50%{border-top:16px solid rgba(0,0,0,.25);border-right:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.75);border-left:16px solid rgba(0,0,0,.25)}75%{border-top:16px solid rgba(0,0,0,.25);border-right:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.25);border-left:16px solid rgba(0,0,0,.75)}to{border-top:16px solid rgba(0,0,0,.75);border-right:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.25);border-left:16px solid rgba(0,0,0,.25)}}@keyframes spSlices{0%{border-top:16px solid rgba(0,0,0,.75);border-right:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.25);border-left:16px solid rgba(0,0,0,.25)}25%{border-top:16px solid rgba(0,0,0,.25);border-right:16px solid rgba(0,0,0,.75);border-bottom:16px solid rgba(0,0,0,.25);border-left:16px solid rgba(0,0,0,.25)}50%{border-top:16px solid rgba(0,0,0,.25);border-right:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.75);border-left:16px solid rgba(0,0,0,.25)}75%{border-top:16px solid rgba(0,0,0,.25);border-right:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.25);border-left:16px solid rgba(0,0,0,.75)}to{border-top:16px solid rgba(0,0,0,.75);border-right:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.25);border-left:16px solid rgba(0,0,0,.25)}}.card-header{font-size:1.75em;padding:0;color:#000;border-bottom:1px solid #eee;margin-bottom:10px}.card-header .glyphicon{margin-right:12px}.card-header .fa{padding-right:10px}.card-card{margin:20px 0}.card-card .card-content{padding-bottom:10px;padding-top:5px}.Select-control,.Select-menu-outer{border-radius:0}.public_fixedDataTable_header,.public_fixedDataTable_header .public_fixedDataTableCell_main{background-color:#eee;background-image:none}.fixedDataTableLayout_hasBottomBorder{border:none}.legend{width:auto;min-width:120px}.legend-container div{text-align:left!important}.hoverinfo{position:fixed;width:100px;min-height:50px;background-color:#fff;box-shadow:1px 1px 3px grey;padding:10px}.pagination>.active>a,.pagination>.active>a:focus,.pagination>.active>a:hover,.pagination>.active>span,.pagination>.active>span:focus,.pagination>.active>span:hover{background-color:#0a77bd;border-color:#0a77bd}.pagination>li>a,.pagination>li>span{color:#0a77bd}.pagination>li>a:focus,.pagination>li>a:hover,.pagination>li>span:focus,.pagination>li>span:hover{color:#002245}.goal{color:#333;background:#9f3e69;padding-bottom:17px;padding-top:17px;margin:20px 0}@media (max-width:991px){.goal{text-align:center}}.card-goal-icon{text-align:center;background:rgba(0,0,0,.1);border-radius:50%;height:70px;width:70px;margin:0 auto}.card-goal-icon span{height:70px;width:70px;line-height:2em;font-size:2em}.card-goal-icon .glyphicon:before{position:absolute;left:20px;height:30px;width:30px;top:18px;line-height:30px}@media (max-width:767px){.card-goal-icon{margin:0 auto}}.card-goal-progress{font-size:2.4em;font-weight:700;text-align:center}@media (max-width:991px){.card-goal-progress{text-align:center}}.card-goal-status{font-size:1.2em;font-weight:700;text-transform:uppercase}.card-goal-end-date{font-size:.9em}.card-goal-caption{display:table-cell;font-weight:700;height:70px;vertical-align:middle}@media (max-width:991px){.card-goal-caption{display:block;margin:1em 0;text-align:center;height:auto}}.card-goal-end-number{font-size:.7em;color:#999}.metric{background:#9f3e69;color:#fff;padding-bottom:17px;padding-top:17px;margin:20px 0;overflow:auto}.card-metric-icon{position:relative;text-align:center;background:rgba(0,0,0,.3);border-radius:50%;height:70px;width:70px;margin-left:10px}@media (max-width:767px){.card-metric-icon{margin:0 auto}}.card-metric-icon[class$=-icon] .glyphicon{position:absolute;height:70px;width:70px;line-height:2em;font-size:30px;text-align:center;top:0;left:0}.card-metric-icon[class$=-icon] .glyphicon:before{position:absolute;left:20px;height:30px;width:30px;top:20px;line-height:30px}.card-metric-number{font-size:2.5em;font-weight:700}@media (max-width:767px){.card-metric-number{text-align:center}}.card-metric-caption{text-transform:uppercase;opacity:.7}@media (max-width:767px){.card-metric-caption{text-align:center}}.metric-without-icon .card-metric-number{margin:auto;text-align:center}#main-wrapper .card-header{padding:10px 0}#main-wrapper .card-header .glyphicon{top:4px}#main-wrapper .card-goal-metric,#main-wrapper .card-metric-number{font-weight:600;line-height:1.25em}#main-wrapper .card-goal-end-number{line-height:1em;margin:-.3em;padding-left:5px}.react-dash-checkbox input[type=checkbox]{-ms-transform:scale(2);-moz-transform:scale(2);-webkit-transform:scale(2);-o-transform:scale(2);padding:10px;margin-right:1em}.react-dash-checkbox li{font-size:2.5em;list-style:none;float:left;margin-right:2em}.react-dash-checkbox li label{font-weight:300}.highlight-col{float:left}.highlight-label{font-weight:600;margin-right:1em}.highlight-cols-2{width:50%} \ No newline at end of file +@import url(https://fonts.googleapis.com/css?family=Open+Sans);body{font-family:Open Sans,sans-serif}h1{font-size:1.75em;border-bottom:1px solid #eee;margin-bottom:10px;border:none;font-size:36px;margin:25px 0}h1,h2{padding:0;color:#000}h2{border-bottom:1px solid #eee}h2,h3{font-size:1.75em;margin-bottom:10px}h3{padding:0;color:#000;border-bottom:1px solid #eee;border:none;font-size:1.15em}body{background:#fff}.glyphicon{top:3px}a{color:#0a77bd}a:focus,a:hover{color:#002245}.loader{position:relative;min-height:30px}.sp{width:32px;height:32px;position:absolute;left:50%;margin-left:-16px;z-index:2}.sp.sp-slices{border-radius:50%;border-top:16px solid rgba(0,0,0,.75);border-left:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.25);border-right:16px solid rgba(0,0,0,.25);animation:spSlices 1s infinite linear}@keyframes spSlices{0%{border-top:16px solid rgba(0,0,0,.75);border-right:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.25);border-left:16px solid rgba(0,0,0,.25)}25%{border-top:16px solid rgba(0,0,0,.25);border-right:16px solid rgba(0,0,0,.75);border-bottom:16px solid rgba(0,0,0,.25);border-left:16px solid rgba(0,0,0,.25)}50%{border-top:16px solid rgba(0,0,0,.25);border-right:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.75);border-left:16px solid rgba(0,0,0,.25)}75%{border-top:16px solid rgba(0,0,0,.25);border-right:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.25);border-left:16px solid rgba(0,0,0,.75)}to{border-top:16px solid rgba(0,0,0,.75);border-right:16px solid rgba(0,0,0,.25);border-bottom:16px solid rgba(0,0,0,.25);border-left:16px solid rgba(0,0,0,.25)}}.card-header{font-size:1.75em;padding:0;color:#000;border-bottom:1px solid #eee;margin-bottom:10px}.card-header .glyphicon{margin-right:12px}.card-header .fa{padding-right:10px}.card-card{margin:20px 0}.card-card .card-content{padding-bottom:10px;padding-top:5px}.Select-control,.Select-menu-outer{border-radius:0}.public_fixedDataTable_header,.public_fixedDataTable_header .public_fixedDataTableCell_main{background-color:#eee;background-image:none}.fixedDataTableLayout_hasBottomBorder{border:none}.legend{width:auto;min-width:120px}.legend-container div{text-align:left!important}.hoverinfo{position:fixed;width:100px;min-height:50px;background-color:#fff;box-shadow:1px 1px 3px grey;padding:10px}.pagination>.active>a,.pagination>.active>a:focus,.pagination>.active>a:hover,.pagination>.active>span,.pagination>.active>span:focus,.pagination>.active>span:hover{background-color:#0a77bd;border-color:#0a77bd}.pagination>li>a,.pagination>li>span{color:#0a77bd}.pagination>li>a:focus,.pagination>li>a:hover,.pagination>li>span:focus,.pagination>li>span:hover{color:#002245}.goal{color:#333;background:#9f3e69;padding-bottom:17px;padding-top:17px;margin:20px 0}@media (max-width:991px){.goal{text-align:center}}.card-goal-icon{text-align:center;background:rgba(0,0,0,.1);border-radius:50%;height:70px;width:70px;margin:0 auto}.card-goal-icon span{height:70px;width:70px;line-height:2em;font-size:2em}.card-goal-icon .glyphicon:before{position:absolute;left:20px;height:30px;width:30px;top:18px;line-height:30px}@media (max-width:767px){.card-goal-icon{margin:0 auto}}.card-goal-progress{font-size:2.4em;font-weight:700;text-align:center}@media (max-width:991px){.card-goal-progress{text-align:center}}.card-goal-status{font-size:1.2em;font-weight:700;text-transform:uppercase}.card-goal-end-date{font-size:.9em}.card-goal-caption{display:table-cell;font-weight:700;height:70px;vertical-align:middle}@media (max-width:991px){.card-goal-caption{display:block;margin:1em 0;text-align:center;height:auto}}.card-goal-end-number{font-size:.7em;color:#999}.metric{background:#9f3e69;color:#fff;padding-bottom:17px;padding-top:17px;margin:20px 0;overflow:auto}.card-metric-icon{position:relative;text-align:center;background:rgba(0,0,0,.3);border-radius:50%;height:70px;width:70px;margin-left:10px}@media (max-width:767px){.card-metric-icon{margin:0 auto}}.card-metric-icon[class$=-icon] .glyphicon{position:absolute;height:70px;width:70px;line-height:2em;font-size:30px;text-align:center;top:0;left:0}.card-metric-icon[class$=-icon] .glyphicon:before{position:absolute;left:20px;height:30px;width:30px;top:20px;line-height:30px}.card-metric-number{font-size:2.5em;font-weight:700}@media (max-width:767px){.card-metric-number{text-align:center}}.card-metric-caption{text-transform:uppercase;opacity:.7}@media (max-width:767px){.card-metric-caption{text-align:center}}.metric-without-icon .card-metric-number{margin:auto;text-align:center}#main-wrapper .card-header{padding:10px 0}#main-wrapper .card-header .glyphicon{top:4px}#main-wrapper .card-goal-metric,#main-wrapper .card-metric-number{font-weight:600;line-height:1.25em}#main-wrapper .card-goal-end-number{line-height:1em;margin:-.3em;padding-left:5px}.react-dash-checkbox input[type=checkbox]{-ms-transform:scale(2);-moz-transform:scale(2);-webkit-transform:scale(2);-o-transform:scale(2);padding:10px;margin-right:1em}.react-dash-checkbox li{font-size:2.5em;list-style:none;float:left;margin-right:2em}.react-dash-checkbox li label{font-weight:300}.highlight-col{float:left}.highlight-label{font-weight:600;margin-right:1em}.highlight-cols-2{width:50%} \ No newline at end of file diff --git a/dist/react-dashboard.min.js b/dist/react-dashboard.min.js index 522e811c..8e62ada6 100644 --- a/dist/react-dashboard.min.js +++ b/dist/react-dashboard.min.js @@ -1,4 +1,4 @@ -!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("lodash"),require("d3"),require("react-router"),require("classnames"),require("react-nvd3"),require("csv-es6-data-backend"),require("dkan-es6-data-backend"),require("fixed-data-table-2"),require("flux"),require("react-dom"),require("react-responsive-accordion"),require("react-select"),require("topojson"));else if("function"==typeof define&&define.amd)define(["react","lodash","d3","react-router","classnames","react-nvd3","csv-es6-data-backend","dkan-es6-data-backend","fixed-data-table-2","flux","react-dom","react-responsive-accordion","react-select","topojson"],t);else{var r="object"==typeof exports?t(require("react"),require("lodash"),require("d3"),require("react-router"),require("classnames"),require("react-nvd3"),require("csv-es6-data-backend"),require("dkan-es6-data-backend"),require("fixed-data-table-2"),require("flux"),require("react-dom"),require("react-responsive-accordion"),require("react-select"),require("topojson")):t(e.react,e.lodash,e.d3,e["react-router"],e.classnames,e["react-nvd3"],e["csv-es6-data-backend"],e["dkan-es6-data-backend"],e["fixed-data-table-2"],e.flux,e["react-dom"],e["react-responsive-accordion"],e["react-select"],e.topojson);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,function(e,t,r,n,a,o,i,s,u,c,l,f,p,d){return function(e){function t(n){if(r[n])return r[n].exports;var a=r[n]={exports:{},id:n,loaded:!1};return e[n].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var r={};return t.m=e,t.c=r,t.p="/static/",t(0)}([function(e,t,r){e.exports=r(8)},function(e,t){e.exports=require("react")},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r=0?t:(0,o.get)(e.root,t)}}]),e}(),u=s;t.default=u;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(i,"reactEls","/Users/civicactions/workspace/dkan-sites/react-dash/src/utils/Registry.js"),__REACT_HOT_LOADER__.register(s,"Registry","/Users/civicactions/workspace/dkan-sites/react-dash/src/utils/Registry.js"),__REACT_HOT_LOADER__.register(u,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/utils/Registry.js"))})()},function(e,t){e.exports=require("lodash")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t0){var t=y.default.handle(this.props.stateHandlers,this.props.data,this.state.dashboardData);e=s(e,t)}return e}},{key:"getCardVariables",value:function(){var e=this,t={};return b.forEach(function(r){t[r]=e.state[r]||e.props[r]}),t}},{key:"addResizeListener",value:function(){var e=this;this._resizeHandler=function(t){var r=(0,l.findDOMNode)(e).getBoundingClientRect().width;e.setState({componentWidth:r}),e.onResize(t)},window.addEventListener("resize",this._resizeHandler)}},{key:"onResize",value:function(){}},{key:"onAction",value:function(){}}]),t}(c.Component),O=g;t.default=O;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(b,"CARD_VARS","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/BaseComponent.js"),__REACT_HOT_LOADER__.register(g,"BaseComponent","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/BaseComponent.js"),__REACT_HOT_LOADER__.register(O,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/BaseComponent.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:5,t="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",n=0;n=0)&&e.replace("fid","")}Object.defineProperty(t,"__esModule",{value:!0});var f=Object.assign||function(e){for(var t=1;t=0&&(e=!0)}),e}},{key:"getData",value:function(){var e=this.props.data;return e}},{key:"getOptions",value:function(e){var t=this.getData();return this.props.options?this.props.options:t&&t[0]?this.props.data[0]:[]}}]),t}(d.default)),_=h;t.default=_,f.default.set("BaseFilter",h);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(h,"BaseFilter","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/BaseFilter.js"),__REACT_HOT_LOADER__.register(_,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/BaseFilter.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=r(2),o=n(a),i=r(55),s=n(i),u=s.default,c=u;t.default=c,o.default.set("ReactSelect",s.default);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(u,"ReactSelect","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/ReactSelect.js"),__REACT_HOT_LOADER__.register(c,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/ReactSelect.js"))})()},function(e,t){e.exports=require("react-router")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:[],r=e,n=this.state.appliedFilters||{},a=d.DataHandler.handle.call(this,r,t,this.state.data,{e:"foo"},n);return a}},{key:"getUrlFilters",value:function(){var e=this,t=this.props.location.query,r={};return Object.keys(t).forEach(function(n){var a={};a.field=n,a.value=t[n].split(","),a.vals=a.value.map(function(e){return isNaN(e)||parseInt(e),e}),r=e.getUpdatedAppliedFilters(a,r)}),r}},{key:"getDashboardData",value:function(){console.log("Warning. getDashboardData should be defined in your application which extends this dashboard component. getDashboardData should return an object with dataKeys. See @@LINK")}},{key:"getChildData",value:function(e){var t=[];return e.dataHandlers?t=this._applyDataHandlers(e.dataHandlers,e.data):e.data&&e.data.length>0&&(t=e.data),t}},{key:"getFilters",value:function(e,t){return Object.keys(t).map(function(r){var n=t[r];if(n&&n.willFilter&&n.willFilter.length>0){var a=n.willFilter.indexOf(e);if(a>=0)return t[r]}})}},{key:"getFilterByField",value:function(e){var t=void 0;return this.props.regions.forEach(function(r){return r.children?r.children.forEach(function(r){r.field===e&&(t=r)}):void(r.elements&&Object.keys(r.elements).forEach(function(n){r.elements[n].forEach(function(r){r.field===e&&(t=r)})}))}),t}},{key:"onAction",value:function(e){switch(e.actionType){case"AUTOCOMPLETE_CHANGE":var t=s({},this.state.appliedFilters),r=this.getUpdatedAppliedFilters(e,t),n=(0,_.appliedFiltersToQueryString)(r),a=this.props.basePath||"";this.props.doFilterRouting!==!1&&p.browserHistory.push(a+"?"+n),this.setState({appliedFilters:r,isFetching:!0}),this.getDashboardData(r);break;case"MULTICHECKBOX_CHANGE":break;default:console.warn("Actions should define an actionType. See docs @@LINK")}}},{key:"getUpdatedAppliedFilters",value:function(e,t){var r=e.field,n=this.getFilterByField(r),a=s(e,n);return(0,h.isArray)(a.value)&&a.value.length>0?(a.vals=a.value.map(function(e){return isNaN(e)?isNaN(e.value)?e.value:parseInt(e.value):parseInt(e)}),t[r]=a):a.value&&a.value.value?(isNaN(a.value.value)||(a.value.value=parseInt(a.value.value)),a.value=[a.value],t[r]=a):a.value&&"string"==typeof a.value||"number"==typeof a.value?(a.value=[a.value],t[r]=a):delete t[r],t}},{key:"updateProps",value:function(e){var t=f.default.isValidElement(e)?e.props:e,r=[];return this.props.doFilterRouting&&(r=(0,h.pick)(this.props,["history","location","params","route","routeParams","routes"])),t.data=this.getChildData(e)||[],t.globalData=s({},this.state.data||{}),t.appliedFilters=s({},this.state.appliedFilters||{}),t.vars=s({},this.props.vars||{}),t.routeParams=r,t}},{key:"getRegion",value:function(e){var t=this;return f.default.createElement("div",{key:e.id,id:e.id,className:e.className},e.children.map(function(e,r){var n=t.updateProps(e);e.isFetching=t.state.isFetching;var a=f.default.isValidElement(e)?e:f.default.createElement(d.Registry.get(e.type),n);return a}))}},{key:"getAccordionRegion",value:function(e){var t=this;return f.default.createElement("div",{id:e.id,className:e.className,key:e.id},f.default.createElement(v.default,{key:e.id,closeable:!0},e.children.map(function(e,r){var n=t.updateProps(e),a=f.default.isValidElement(e)?e:f.default.createElement(d.Registry.get(e.type),n);return f.default.createElement("div",{"data-trigger":e.dataTrigger,key:"wrap_"+r},a)})))}},{key:"getRegions",value:function(){var e=this,t=void 0;return t=this.props.regions?this.props.regions.map(function(t,r){if(t.multi){var n=e.getChildData(t);t.key=r,t.children=t.elements[n]}return t.accordion?e.getAccordionRegion(t):e.getRegion(t)}):this.props.children}},{key:"render",value:function(){var e=void 0,t=["container-fluid"],r=(0,b.default)(this.props.dashWrapperClass,t);return this.props.title&&(e=f.default.createElement("h1",{className:"dashboard-title"}," + ",this.props.title," + ")),f.default.createElement("div",{className:r,key:"dashboard-container"},f.default.createElement("link",{rel:"stylesheet",type:"text/css",href:this.props.faPath}),e,this.getRegions())}}]),t}(d.BaseComponent),O=g;t.default=O;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(g,"Dashboard","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/Dashboard.js"),__REACT_HOT_LOADER__.register(O,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/Dashboard.js"))})()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(52),a=new n.Dispatcher,o=a;t.default=o;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(a,"EventDispatcher","/Users/civicactions/workspace/dkan-sites/react-dash/src/dispatcher/EventDispatcher.js"),__REACT_HOT_LOADER__.register(o,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/dispatcher/EventDispatcher.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(r,n){var a=t.size||e.records.length,o=t.from||0,i=e.records;i=e._applyFilters(i,t),i=e._applyFreeTextQuery(i,t);var s={total:i.length,hits:i.slice(o,o+a)};r(s)})}},{key:"_applyFreeTextQuery",value:function(e,t){var r=this;if(t.q){var n=t.q.split(" "),a=n.map(function(e){return new RegExp(e.toLowerCase())});e=e.filter(function(e){var t=!0;return a.forEach(function(n){var a=!1;r.fields.forEach(function(t){var r=e[t.id];r=null!==r&&void 0!==r?r.toString():"",a=a||n.test(r.toLowerCase())}),t=t&&a}),t})}return e}},{key:"_applyFilters", -value:function(e,t){function r(e){var t=l[e.field].type||"string";return c[t]}function n(e,t){var n=r(t),a=n(e[t.field]),o=n(t.term);return a===o}function a(e,t){var n=r(t),a=n(e[t.field]),o=n(t.terms).split(",");return o.indexOf(a)>=0}function i(e,t){var n=(0,o.isUndefined)(t.from)||null===t.from||""===t.from,a=(0,o.isUndefined)(t.to)||null===t.to||""===t.to,i=r(t),s=i(e[t.field]),u=i(n?"":t.from),c=i(a?"":t.to);return!!(n&&a||""!==s)&&((n||s>=u)&&(a||s<=c))}var s=t.filters||[],u={term:n,terms:a,range:i},c={integer:function(e){return parseFloat(e,10)},float:function(e){return parseFloat(e,10)},number:function(e){return parseFloat(e,10)},string:function(e){return e.toString()},date:function(e){return Date.parse(e)},datetime:function(e){return new Date(e).valueOf()}},l=this.fields.reduce(function(e,t){return e[t.id]=t,e},{});return e.filter(function(e){var t=s.map(function(t){return u[t.type](e,t)});return(0,o.every)(t,o.identity)})}}]),e}(),s=i;t.default=s;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(i,"MemoryStore","/Users/civicactions/workspace/dkan-sites/react-dash/src/models/MemoryStore.js"),__REACT_HOT_LOADER__.register(s,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/models/MemoryStore.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]&&arguments[1];return"string"==typeof e?(0,k.format)(e):(0,E.isFunction)(e)?e:void 0}},{key:"getFormattedSettings",value:function(){var e=this,t=s({},this.props.settings);if(t.color&&!Array.isArray(t.color)){var r=void 0;r=this.props.data.length&&this.props.data[0].values?(0,E.map)((0,E.flatten)((0,E.map)(this.props.data,"values")),t.x):(0,E.uniq)((0,E.map)(this.props.data,t.x)),t.color=(0,E.values)((0,E.pick)(t.color,r))}return Object.keys(t).forEach(function(r){t[r].tickFormat&&(t[r].tickFormat=e.getFormatter(t[r].tickFormat))}),t}},{key:"render",value:function(){var e=s({},this.props),t=s({datum:this.props.data,key:this.state.key},this.getFormattedSettings());return e.header=this.state.header||e.header,e.footer=this.state.footer||e.footer,l.default.createElement(m.default,s({key:"card_"+this.state.key},this.state.cardVariables),l.default.createElement(h.default,t))}}]),t}(y.default),w=T;t.default=w,p.default.set("Chart",T);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(T,"Chart","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/Chart.js"),__REACT_HOT_LOADER__.register(w,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/Chart.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;rn?(i=Math.max(n-a,1),s=r+o>n?n:r+o):(i=r-o,s=r+o),(0,O.range)(i,s+1)}},{key:"getPageNumbers",value:function(e,t,r){var n=this;if(this.getTotalPages()&&!(this.getTotalPages()<2))return this.getPages(e,t,r).map(function(e){return h.default.createElement("li",{className:e==n.state.currentPage?"active":"",key:"page-"+e},h.default.createElement("a",{onClick:(0,O.partialRight)(n._onPageChange,e).bind(n),href:"#"},e))})}},{key:"getLastPage",value:function(e,t){var r=getTotalPages(e,t);return r[r.length-1]}},{key:"getTotalPages",value:function(e,t){return Math.ceil(t/e)}},{key:"onResize",value:function(){var e=this.table,t=e.offsetWidth,r=e.offsetHeight;this.setState({gridWidth:t,gridHeight:r})}},{key:"_onPageChange",value:function(e,t,r,n){e.preventDefault();var a=this.state.rowsPerPage,o=s({},this.state.queryObj,{size:a,from:n*a-a});this.query(o),this.setState({currentPage:n,queryObj:o})}},{key:"_onFilterChange",value:function(e){var t=this.state.rowsPerPage,r=s({},this.state.queryObj,{size:t,from:this.state.currentPage*t-t,q:e.target.value});this.query(r),this.setState({currentPage:1})}},{key:"_onRowsPerPageChange",value:function(e){var t=s({},this.state.queryObj);t.size=Number(e.target.value),t.from=0,this.query(t),this.setState({rowsPerPage:Number(e.target.value),currentPage:1})}},{key:"render",value:function(){var e=this,t=this.state,r=t.gridWidth,n=(t.gridHeight,this.props.data[0]||[]),a=(0,p.getProp)("settings.table",this.props),o=(0,p.getProp)("settings.columns",this.props),i=(0,p.getProp)("settings.rows",this.props),u=Object.keys(n[0]||{}),l=this.getTotalPages(this.state.rowsPerPage,this.state.total),f=u.map(function(t,r){var a=(0,p.getProp)("columns."+t,e.props.overrides);return h.default.createElement(c.Column,s({header:h.default.createElement(c.Cell,null,t),key:t+r,columnKey:t,flexGrow:1,cell:function(r){var o=(0,p.getProp)("rows."+r.rowIndex,e.props.overrides),u=(0,p.getProp)("cells."+t+"_"+r.rowIndex,e.props.overrides);return h.default.createElement(c.Cell,s({},r,a,i,o,u),n[r.rowIndex][r.columnKey])}},o,a))}),d="",_="";return this.props.hideFilterHeader||(d=h.default.createElement("div",{className:"col-md-10"},h.default.createElement("div",{className:"form-group"},h.default.createElement("input",{onChange:this._onFilterChange.bind(this),placeholder:"Filter",className:"form-control"})))),this.props.hideControls||(_=h.default.createElement("div",{className:"col-md-2"},h.default.createElement("div",{onChange:this._onRowsPerPageChange.bind(this),className:"form-group"},h.default.createElement("select",{className:"form-control"},h.default.createElement("option",{value:"10"},"10"),h.default.createElement("option",{value:"25"},"25"),h.default.createElement("option",{value:"50"},"50"),h.default.createElement("option",{value:"100"},"100"),h.default.createElement("option",{value:"500"},"500"))))),h.default.createElement(m.default,s({key:"card_"+this.state.key},this.state.cardVariables),h.default.createElement("div",{ref:function(t){return e.table=t},className:"table-wrapper"},h.default.createElement("div",{className:"row"},d,_),h.default.createElement(g.default,{isFetching:this.props.isFetching||!n.length},h.default.createElement("div",{className:"table-container"},h.default.createElement(c.Table,s({rowsCount:n.length},a,{width:r,rowHeightGetter:this.rowHeightGetter}),f)),h.default.createElement("nav",null,h.default.createElement("ul",{className:"pagination"},h.default.createElement("li",{className:1===this.state.currentPage?"hide":""},h.default.createElement("a",{onClick:(0,O.partialRight)(this._onPageChange,1).bind(this),href:"#","aria-label":"Previous"},h.default.createElement("span",{"aria-hidden":"true"},"«"))),h.default.createElement("li",{className:1===this.state.currentPage?"hide":""},h.default.createElement("a",{onClick:(0,O.partialRight)(this._onPageChange,this.state.currentPage-1).bind(this),href:"#","aria-label":"Previous"},h.default.createElement("span",{"aria-hidden":"true"},"«"))),this.getPageNumbers(this.state.rowsPerPage,this.state.total,this.state.currentPage),h.default.createElement("li",{className:l&&this.state.currentPage!==l?"":"hide"},h.default.createElement("a",{onClick:(0,O.partialRight)(this._onPageChange,this.state.currentPage+1).bind(this),href:"#","aria-label":"Next"},h.default.createElement("span",{"aria-hidden":"true"},"»"))),h.default.createElement("li",{className:l&&this.state.currentPage!==l?"":"hide"},h.default.createElement("a",{onClick:(0,O.partialRight)(this._onPageChange,l).bind(this),href:"#","aria-label":"Next"},h.default.createElement("span",{"aria-hidden":"true"},"»"))))))))}}]),t}(y.default);E.defaultProps={rowsPerPage:10,queryObj:{size:10,from:0}};var k=E;t.default=k,f.default.set("DataTable",E);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(E,"DataTable","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/DataTable.js"),__REACT_HOT_LOADER__.register(k,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/DataTable.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=function(){function e(e,t){for(var r=0;re.from&&n<=e.to})}},{key:"trackStatus",value:function(){var e=Date.parse(this.props.startDate),t=Date.parse(this.props.endDate),r=Number(this.props.startNumber),n=Number(this.props.endNumber),a=this.getTracker(e,t,r,n),o=a(Date.now()),i=o-this.getMetric(this.state.data),s={increase:i<=0,decrease:i>=0,maintain_above:i<=0,maintain_below:i>=0,maintain:!0,mesure:!0};return this.getTolerance(i,s[this.props.action])}},{key:"getTracker",value:function(e,t,r,n){return function(a){var o=(n-r)/(t-e),i=o*(a-e);return i}}},{key:"formatActionName",value:function(e){return(0,b.capitalize)(this.props.action.replace("_"," "))}},{key:"getCaption",value:function(){var e={action:this.formatActionName(this.props.action),caption:this.props.caption,startNumber:(0,T.formatNumber)(this.props.startNumber,this.state.numberFormat),endNumber:(0,T.formatNumber)(this.props.endNumber,this.state.numberFormat),startDate:(0,T.formatDate)(new Date(this.props.startDate),this.state.dateFormat),endDate:(0,T.formatDate)(new Date(this.props.endDate),this.state.dateFormat)},t=(0,b.template)(this.props.captionTemplates[this.props.action]);return t(e)}},{key:"render",value:function(){var e=s({},(0,b.head)(this.trackStatus())),t={background:this.props.background},r=void 0,n=void 0;if(t=s({},t,this.props.style),this.props.spline){var a=s({},this.props.spline);r=l.default.createElement(O.default,s({type:"sparklinePlus",datum:this.state.data,showLastValue:!1,color:["#333333"]},a))}return this.state.showEndNumber&&(n=l.default.createElement("span",{className:"card-goal-end-number"}," ",this.props.divider," ",(0,T.formatNumber)(this.props.endNumber,this.state.numberFormat))),l.default.createElement(y.default,this.state.cardVariables,l.default.createElement(m.default,{isFetching:this.props.isFetching},l.default.createElement("div",{className:"goal",style:t},l.default.createElement("div",{className:"row"},l.default.createElement("div",{className:"col-md-4"},l.default.createElement("div",{className:"card-goal-icon"},l.default.createElement("span",{className:(0,k.default)("glyphicon",this.props.icon)}))),l.default.createElement("div",{className:"col-md-8"},l.default.createElement("div",{className:"card-goal-caption"},this.getCaption()))),l.default.createElement("div",{className:"row"},l.default.createElement("div",{className:"col-md-4"},l.default.createElement("div",{className:"card-goal-progress"},l.default.createElement("span",{className:"card-goal-metric"},(0,T.formatNumber)(this.getMetric(this.state.data),this.state.numberFormat)),n)),l.default.createElement("div",{className:"col-md-8"},l.default.createElement("div",{className:"card-goal-status"},l.default.createElement("a",{style:{color:e.color},href:this.props.link},e.label)),l.default.createElement("div",{className:"card-goal-end-date"},(0,T.formatDate)(new Date(this.props.endDate),this.state.dateFormat)))),l.default.createElement("div",{className:"row"},l.default.createElement("div",{className:"col-md-12"},l.default.createElement("div",{className:"spline"},r))))))}}]),t}(h.default);R.defaultProps={captionTemplates:{increase:"${action} ${caption} ${endNumber} by ${endDate}",decrease:"${action} ${caption} ${endNumber} by ${endDate}",maintain:"${action} at ${endNumber} ${caption} by ${endDate}",maintain_above:"${action} ${endNumber} ${caption} by ${endDate}",maintain_below:"${action} ${endNumber} ${caption} by ${endDate}",mesure:"${caption}"},divider:" / ",style:{color:"black",background:"white"}};var C=R;t.default=C,p.default.set("Goal",R);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(R,"Goal","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/Goal.js"),__REACT_HOT_LOADER__.register(C,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/Goal.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r0?this.props.data[0]:this.props.data&&!(0,y.isArray)(this.props.data)?this.props.data:this.props.content?this.props.content:""}},{key:"render",value:function(){return c.default.createElement(_.default,this.state.cardVariables,c.default.createElement("div",{dangerouslySetInnerHTML:{__html:this.getContent()}}))}}]),t}(d.default),m=v;t.default=m,f.default.set("Markup",v);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(v,"Markup","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/Markup.js"),__REACT_HOT_LOADER__.register(m,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/Markup.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:[];return d.DataHandler.handle.call(this,e,r,this.props.globalData,{},t)}},{key:"getChildren",value:function(){var e=this,t=void 0;return this.props.children&&(t=this.props.children.map(function(t,r){var n=s(t,{globalData:e.props.globalData,appliedFilters:e.props.appliedFilters});return t.dataHandlers?n.data=e._applyDataHandlers(t.dataHandlers,t.appliedFilters,t.data):t.data&&t.data.length>0&&(n.data=t.data),n.key=r,l.default.createElement(p.default.get(t.type),n)})),t}},{key:"render",value:function(){var e=this.getChildren();return l.default.createElement("div",{className:this.props.className},e)}}]),t}(c.Component)),y=_;t.default=y,p.default.set("Region",_);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(_,"Region","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/Region.js"),__REACT_HOT_LOADER__.register(y,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/components/Region.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t0?i[0]:[]}};o.default.setLib("NVD3",s);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(i,"LibName","/Users/civicactions/workspace/dkan-sites/react-dash/src/datahandlers/NVD3DataHandlers.js"),__REACT_HOT_LOADER__.register(s,"dataHandlers","/Users/civicactions/workspace/dkan-sites/react-dash/src/datahandlers/NVD3DataHandlers.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=r(10),o=n(a),i=r(7),s="common",u={fieldsToXYSeries:function(e,t,r,n,a,o){var i=o||e;if(!i.length)return[];Array.isArray(i[1])||(i=[i]);var s=i.map(function(e){var t=r.xField||"x";r.field;return e.map(function(e){return{y:e[r.field],x:e[t]}})});return s},fieldToD3Format:function(e,t,r,n,a,o){var s=o||e||[],u=(0,i.format)(r.format);return s.map(function(e){return e.map(function(e){return e[r.field]=u(e[r.field]),e})}),s},filterDashboardDataByParamEquals:function(e,t,r,n,a,o){var i=t,s=i.filter(function(e){return e[r.field]===r.value});return[s]},parseDateField:function(e,t,r,n,a,o){var i=o||e;return i.map(function(e){return e[r.field]=Date.parse(e[r.field]),e})},getEventReturn:function(e,t,r,n,a,o){return n?n.value:e},getXYByQueryData:function(e,t,r,n,a,o){if(t&&t[r.dataKey]&&t[r.dataKey][r.queryKey]){var i=t[r.dataKey][r.queryKey].result.records,s=i.map(function(e){var t={};return t[r.xField]=e[r.xField],t[r.yField]=e[r.yField],t});return[s]}return[]},getXYByQueryDataWhere:function(e,t,r,n,a,o){if(t&&t[r.dataKey]&&t[r.dataKey][r.queryKey]){var i=t[r.dataKey][r.queryKey].result.records,s=i.filter(function(e){var t=r.whereFieldValueIn.indexOf(e[r.whereField])>=0;return t}),u=s.map(function(e){var t={};return t[r.xField]=e[r.xField],t[r.yField]=e[r.yField],t});return[u]}return[]},getXYByQueryDataWhereFieldsIn:function(e,t,r,n,a,o){if(t&&t[r.dataKey]&&t[r.dataKey][r.queryKey]){var i=t[r.dataKey][r.queryKey].result.records,s=i.filter(function(e){var t=void 0;return r.whereField.forEach(function(n){t=r.whereFieldValueIn.indexOf(e[n])>=0}),t}),u=s.map(function(e){var t={};return t[r.xField]=e[r.xField],t[r.yField]=e[r.yField],t});return[u]}return[]},getPercentileSeries:function(e,t,r,n,a,o){},groupByRange:function(e,t,r,n,a,o){var i=o||e,s=[];return i.forEach(function(e){var t=[],n=function(n){var a=r.ranges[n][0],o=r.ranges[n][1],i=a+" - "+o,s=0,u={};e.forEach(function(e){e[r.xField]>=a&&e[r.xField]<=o&&(s+=parseInt(e[r.yField]))}),u[r.xField]=i,u[r.yField]=s,t.push(u)};for(var a in r.ranges)n(a);s.push(t)}),s},seriesFromRanges:function(e,t,r,n,a,o){var i=o||e;if(i.length>0){var s=i[0].map(function(e,t){var n={},a=[],o={};return n.key=e[r.xField],n.color=r.colors[t],o.label=r.xLabel,o.value=e[r.yField],a.push(o),n.values=a,n});return s}return i},rekeySeries:function(e,t,r,n,a,o){var i=o||e;if(i.length>0){var s=i[0].map(function(e){var t={};return Object.keys(e).forEach(function(n,a){t[r.newKeys[a]]=e[n]}),t});return[s]}return[]},parseInts:function(e,t,r,n,a,o){var i=o||e;return i.forEach(function(e){e.forEach(function(e){r.fields.forEach(function(t){e[t]=parseInt(e[t])})})}),i},toPieChartSeries:function(e,t,r,n,a,o){var i=o||e;return i.length>0?i[0]:[]},changeFieldNames:function(e,t,r,n,a,o){var i=o||e,s=[];return i.forEach(function(e){var t=void 0;t=e.map(function(e){return e[r.xField]=r.fields[e[r.xField]],e}),s.push(t)}),s},whitelistValues:function(e,t,r,n,a,o){var i=o||e,s=void 0;return i.length>0?s=i.map(function(e){return e.filter(function(e){if(r.whiteList.indexOf(e[r.field])>=0)return!0})}):i},inspect:function(e,t,r,n,a,o){var i=o||e;return console.log("INSPECT>>",this,i,arguments),i}};o.default.setLib("common",u);var c=u;t.default=c;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(s,"libName","/Users/civicactions/workspace/dkan-sites/react-dash/src/datahandlers/common.js"),__REACT_HOT_LOADER__.register(u,"dataHandlers","/Users/civicactions/workspace/dkan-sites/react-dash/src/datahandlers/common.js"),__REACT_HOT_LOADER__.register(c,"default","/Users/civicactions/workspace/dkan-sites/react-dash/src/datahandlers/common.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=r(44);Object.defineProperty(t,"NVD3DataHandlers",{enumerable:!0,get:function(){return n(a).default}});var o=r(45);Object.defineProperty(t,"common",{enumerable:!0,get:function(){return n(o).default}});(function(){"undefined"==typeof __REACT_HOT_LOADER__})()},function(e,t,r){"use strict";function n(e){var t=[];for(var r in e)t.push(r+"="+e[r]);return"?"+t.join("&")}function a(e){return!!(e.indexOf&&e.indexOf("fid")>=0)&&e.replace("fid","")}function o(e){return JSON.parse('{"'+decodeURI(e).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}')}function i(e,t,r){var n={};if(Object.keys(e).forEach(function(a){if(a===t)if("object"===l(e[a]))r?n=e[a]:e[a].forEach(function(e){var t=e.split("__");if(n[t[0]]&&"object"===l(n[t[0]]))n[t[0]].push(t[1]);else if(n[t[0]]&&"string"==typeof n[t[0]]){var r={},a=[];a.push(n[t[0]]),a.push(t[1]),r[t[0]]=a,n=c(n,r)}else n[t[0]]=t[1]});else if(e[a].indexOf("__")<0)console.log("gop",e[a],n),n[a]=e[a];else{var o=e[a].split("__");n[o[0]]=o[1]}}),!(0,f.isEmpty)(n))return n}function s(e){var t,r,n,a,o,i;if(r=[],o=/%20/g,n=function(e,t){t="function"==typeof t?t():null==t?"":t,r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)},e instanceof Array)for(a in e)n(a,e[a]);else for(t in e)u(t,e[t],n);return i=r.join("&").replace(o,"+")}function u(e,t,r){var n,a,o,i;if(i=/\[\]$/,t instanceof Array)for(a=0,o=t.length;a=0?t:(0,a.get)(e.root,t)}}]),e}(),u=s;t.default=u;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(i,"reactEls","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/utils/Registry.js"),__REACT_HOT_LOADER__.register(s,"Registry","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/utils/Registry.js"),__REACT_HOT_LOADER__.register(u,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/utils/Registry.js"))})()},function(e,t){e.exports=require("lodash")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t0){var t=m.default.handle(this.props.stateHandlers,this.props.data,this.props.globalData,this.props.appliedFilters);e=s(e,t)}return e}},{key:"getCardVariables",value:function(){var e=this,t={};return g.forEach(function(r){t[r]=e.state[r]||e.props[r]}),t}},{key:"addResizeListener",value:function(){var e=this;this._resizeHandler=function(t){var r=(0,c.findDOMNode)(e).getBoundingClientRect().width;e.setState({componentWidth:r}),e.onResize(t)},window.addEventListener("resize",this._resizeHandler)}},{key:"onResize",value:function(){}},{key:"onAction",value:function(){}}]),t}(l.Component),O=v;t.default=O;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(g,"CARD_VARS","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/BaseComponent.js"),__REACT_HOT_LOADER__.register(v,"BaseComponent","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/BaseComponent.js"),__REACT_HOT_LOADER__.register(O,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/BaseComponent.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:5,t="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",n=0;n=0)&&e.replace("fid","")}Object.defineProperty(t,"__esModule",{value:!0});var p=Object.assign||function(e){for(var t=1;t=0&&(e=!0)}),e}},{key:"getData",value:function(){var e=this.props.data;return e}},{key:"getOptions",value:function(e){var t=this.getData();return this.props.options?this.props.options:t&&t[0]?this.props.data[0]:[]}}]),t}(d.default)),_=h;t.default=_,p.default.set("BaseFilter",h);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(h,"BaseFilter","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/BaseFilter.js"),__REACT_HOT_LOADER__.register(_,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/BaseFilter.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),a=n(o),i=r(56),s=n(i),u=s.default,l=u;t.default=l,a.default.set("ReactSelect",s.default);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(u,"ReactSelect","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/ReactSelect.js"),__REACT_HOT_LOADER__.register(l,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/ReactSelect.js"))})()},function(e,t){e.exports=require("react-router")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:[],r=e,n=this.state.appliedFilters||{},o=d.DataHandler.handle.call(this,r,t,this.state.data,{e:"foo"},n);return o}},{key:"getUrlFilters",value:function(){var e=this,t=this.props.location.query,r={};return Object.keys(t).forEach(function(n){var o={};o.field=n,o.value=t[n].split(","),o.vals=o.value.map(function(e){return isNaN(e)||parseInt(e),e}),r=e.getUpdatedAppliedFilters(o,r)}),r}},{key:"getDashboardData",value:function(){console.log("Warning. getDashboardData should be defined in your application which extends this dashboard component. getDashboardData should return an object with dataKeys. See @@LINK")}},{key:"getChildData",value:function(e){var t=[];return e.dataHandlers?t=this._applyDataHandlers(e.dataHandlers,e.data):e.data&&e.data.length>0&&(t=e.data),t}},{key:"getFilters",value:function(e,t){return Object.keys(t).map(function(r){var n=t[r];if(n&&n.willFilter&&n.willFilter.length>0){var o=n.willFilter.indexOf(e);if(o>=0)return t[r]}})}},{key:"getFilterByField",value:function(e){var t=void 0;return this.props.regions.forEach(function(r){return r.children?r.children.forEach(function(r){r.field===e&&(t=r)}):void(r.elements&&Object.keys(r.elements).forEach(function(n){r.elements[n].forEach(function(r){r.field===e&&(t=r)})}))}),t}},{key:"executeFilterHandlers",value:function(e){return e.filterHandlers&&e.filterHandlers.length>0?(O.default.handle(e.filterHandlers,e,this.state),e):e}},{key:"onAction",value:function(e){var t=this.executeFilterHandlers(e);switch(t.actionType){case"AUTOCOMPLETE_CHANGE":var r=s({},this.state.appliedFilters),n=this.getUpdatedAppliedFilters(t,r),o=(0,_.appliedFiltersToQueryString)(n),a=this.props.basePath||"";this.props.doFilterRouting!==!1&&f.browserHistory.push(a+"?"+o),this.setState({appliedFilters:n,isFetching:!0}),this.getDashboardData(n);break;case"MULTICHECKBOX_CHANGE":break;default:console.warn("Actions should define an actionType. See docs @@LINK")}}},{key:"getUpdatedAppliedFilters",value:function(e,t){var r=e.field,n=this.getFilterByField(r),o=s(e,n);return(0,h.isArray)(o.value)&&o.value.length>0?(o.vals=o.value.map(function(e){return isNaN(e)?isNaN(e.value)?e.value:parseInt(e.value):parseInt(e)}),t[r]=o):o.value&&o.value.value?(isNaN(o.value.value)||(o.value.value=parseInt(o.value.value)),o.value=[o.value],t[r]=o):o.value&&"string"==typeof o.value||"number"==typeof o.value?(o.value=[o.value],t[r]=o):delete t[r],t}},{key:"updateProps",value:function(e){var t=p.default.isValidElement(e)?e.props:e,r=[];return this.props.doFilterRouting&&(r=(0,h.pick)(this.props,["history","location","params","route","routeParams","routes"])),t.data=this.getChildData(e)||[],t.globalData=s({},this.state.data||{}),t.appliedFilters=s({},this.state.appliedFilters||{}),t.vars=s({},this.props.vars||{}),t.routeParams=r,t}},{key:"getRegion",value:function(e){var t=this;return p.default.createElement("div",{key:e.id,id:e.id,className:e.className},e.children.map(function(e,r){var n=t.updateProps(e);e.isFetching=t.state.isFetching;var o=p.default.isValidElement(e)?e:p.default.createElement(d.Registry.get(e.type),n);return o}))}},{key:"getAccordionRegion",value:function(e){var t=this;return p.default.createElement("div",{id:e.id,className:e.className,key:e.id},p.default.createElement(b.default,{key:e.id,closeable:!0},e.children.map(function(e,r){var n=t.updateProps(e),o=p.default.isValidElement(e)?e:p.default.createElement(d.Registry.get(e.type),n);return p.default.createElement("div",{"data-trigger":e.dataTrigger,key:"wrap_"+r},o)})))}},{key:"getRegions",value:function(){var e=this,t=void 0;return t=this.props.regions?this.props.regions.map(function(t,r){if(t.multi){var n=e.getChildData(t);t.key=r,t.children=t.elements[n]}return t.accordion?e.getAccordionRegion(t):e.getRegion(t)}):this.props.children}},{key:"render",value:function(){var e=void 0,t=["container-fluid"],r=(0,g.default)(this.props.dashWrapperClass,t);return this.props.title&&(e=p.default.createElement("h1",{className:"dashboard-title"}," + ",this.props.title," + ")),p.default.createElement("div",{className:r,key:"dashboard-container"},p.default.createElement("link",{rel:"stylesheet",type:"text/css",href:this.props.faPath}),e,this.getRegions())}}]),t}(d.BaseComponent),w=E;t.default=w;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(E,"Dashboard","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/Dashboard.js"),__REACT_HOT_LOADER__.register(w,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/Dashboard.js"))})()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(53),o=new n.Dispatcher,a=o;t.default=a;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(o,"EventDispatcher","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/dispatcher/EventDispatcher.js"),__REACT_HOT_LOADER__.register(a,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/dispatcher/EventDispatcher.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(r,n){var o=t.size||e.records.length,a=t.from||0,i=e.records;i=e._applyFilters(i,t),i=e._applyFreeTextQuery(i,t);var s={total:i.length,hits:i.slice(a,a+o)};r(s)})}},{key:"_applyFreeTextQuery",value:function(e,t){var r=this;if(t.q){var n=t.q.split(" "),o=n.map(function(e){return new RegExp(e.toLowerCase())});e=e.filter(function(e){var t=!0;return o.forEach(function(n){var o=!1;r.fields.forEach(function(t){var r=e[t.id];r=null!==r&&void 0!==r?r.toString():"",o=o||n.test(r.toLowerCase())}),t=t&&o}),t})}return e}},{key:"_applyFilters",value:function(e,t){function r(e){var t=c[e.field].type||"string";return l[t]}function n(e,t){var n=r(t),o=n(e[t.field]),a=n(t.term);return o===a}function o(e,t){var n=r(t),o=n(e[t.field]),a=n(t.terms).split(",");return a.indexOf(o)>=0}function i(e,t){var n=(0,a.isUndefined)(t.from)||null===t.from||""===t.from,o=(0,a.isUndefined)(t.to)||null===t.to||""===t.to,i=r(t),s=i(e[t.field]),u=i(n?"":t.from),l=i(o?"":t.to);return!!(n&&o||""!==s)&&((n||s>=u)&&(o||s<=l))}var s=t.filters||[],u={term:n,terms:o,range:i},l={integer:function(e){return parseFloat(e,10)},float:function(e){return parseFloat(e,10)},number:function(e){return parseFloat(e,10)},string:function(e){return e.toString()},date:function(e){return Date.parse(e)},datetime:function(e){return new Date(e).valueOf()}},c=this.fields.reduce(function(e,t){return e[t.id]=t,e},{});return e.filter(function(e){var t=s.map(function(t){return u[t.type](e,t)});return(0,a.every)(t,a.identity)})}}]),e}(),s=i;t.default=s;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(i,"MemoryStore","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/models/MemoryStore.js"),__REACT_HOT_LOADER__.register(s,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/models/MemoryStore.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]&&arguments[1];return"string"==typeof e?(0,w.format)(e):(0,E.isFunction)(e)?e:void 0}},{key:"getFormattedSettings",value:function(){var e=this,t=s({},this.props.settings);if(t.color&&!Array.isArray(t.color)){var r=void 0;r=this.props.data.length&&this.props.data[0].values?(0,E.map)((0,E.flatten)((0,E.map)(this.props.data,"values")),t.x):(0,E.uniq)((0,E.map)(this.props.data,t.x)),t.color=(0,E.values)((0,E.pick)(t.color,r))}return Object.keys(t).forEach(function(r){t[r].tickFormat&&(t[r].tickFormat=e.getFormatter(t[r].tickFormat))}),t}},{key:"render",value:function(){var e=s({},this.props),t=s({datum:this.props.data,key:this.state.key},this.getFormattedSettings());return e.header=this.state.header||e.header,e.footer=this.state.footer||e.footer,c.default.createElement(y.default,s({key:"card_"+this.state.key},this.state.cardVariables),c.default.createElement(h.default,t))}}]),t}(m.default),T=k;t.default=T,f.default.set("Chart",k);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(k,"Chart","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/Chart.js"),__REACT_HOT_LOADER__.register(T,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/Chart.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;rn?(i=Math.max(n-o,1),s=r+a>n?n:r+a):(i=r-a,s=r+a),(0,O.range)(i,s+1)}},{key:"getPageNumbers",value:function(e,t,r){var n=this;if(this.getTotalPages()&&!(this.getTotalPages()<2))return this.getPages(e,t,r).map(function(e){return h.default.createElement("li",{className:e==n.state.currentPage?"active":"",key:"page-"+e},h.default.createElement("a",{onClick:(0,O.partialRight)(n._onPageChange,e).bind(n),href:"#"},e))})}},{key:"getLastPage",value:function(e,t){var r=getTotalPages(e,t);return r[r.length-1]}},{key:"getTotalPages",value:function(e,t){return Math.ceil(t/e)}},{key:"onResize",value:function(){var e=this.table,t=e.offsetWidth,r=e.offsetHeight;this.setState({gridWidth:t,gridHeight:r})}},{key:"_onPageChange",value:function(e,t,r,n){e.preventDefault();var o=this.state.rowsPerPage,a=s({},this.state.queryObj,{size:o,from:n*o-o});this.query(a),this.setState({currentPage:n,queryObj:a})}},{key:"_onFilterChange",value:function(e){var t=this.state.rowsPerPage,r=s({},this.state.queryObj,{size:t,from:this.state.currentPage*t-t,q:e.target.value});this.query(r),this.setState({currentPage:1})}},{key:"_onRowsPerPageChange",value:function(e){var t=s({},this.state.queryObj);t.size=Number(e.target.value),t.from=0,this.query(t),this.setState({rowsPerPage:Number(e.target.value),currentPage:1})}},{key:"render",value:function(){var e=this,t=this.state,r=t.gridWidth,n=(t.gridHeight,this.props.data[0]||[]),o=(0,f.getProp)("settings.table",this.props),a=(0,f.getProp)("settings.columns",this.props),i=(0,f.getProp)("settings.rows",this.props),u=Object.keys(n[0]||{}),c=this.getTotalPages(this.state.rowsPerPage,this.state.total),p=u.map(function(t,r){var o=(0,f.getProp)("columns."+t,e.props.overrides);return h.default.createElement(l.Column,s({header:h.default.createElement(l.Cell,null,t),key:t+r,columnKey:t,flexGrow:1,cell:function(r){var a=(0,f.getProp)("rows."+r.rowIndex,e.props.overrides),u=(0,f.getProp)("cells."+t+"_"+r.rowIndex,e.props.overrides);return h.default.createElement(l.Cell,s({},r,o,i,a,u),n[r.rowIndex][r.columnKey])}},a,o))}),d="",_="";return this.props.hideFilterHeader||(d=h.default.createElement("div",{className:"col-md-10"},h.default.createElement("div",{className:"form-group"},h.default.createElement("input",{onChange:this._onFilterChange.bind(this),placeholder:"Filter",className:"form-control"})))),this.props.hideControls||(_=h.default.createElement("div",{className:"col-md-2"},h.default.createElement("div",{onChange:this._onRowsPerPageChange.bind(this),className:"form-group"},h.default.createElement("select",{className:"form-control"},h.default.createElement("option",{value:"10"},"10"),h.default.createElement("option",{value:"25"},"25"),h.default.createElement("option",{value:"50"},"50"),h.default.createElement("option",{value:"100"},"100"),h.default.createElement("option",{value:"500"},"500"))))),h.default.createElement(y.default,s({key:"card_"+this.state.key},this.state.cardVariables),h.default.createElement("div",{ref:function(t){return e.table=t},className:"table-wrapper"},h.default.createElement("div",{className:"row"},d,_),h.default.createElement(v.default,{isFetching:this.props.isFetching||!n.length},h.default.createElement("div",{className:"table-container"},h.default.createElement(l.Table,s({rowsCount:n.length},o,{width:r,rowHeightGetter:this.rowHeightGetter}),p)),h.default.createElement("nav",null,h.default.createElement("ul",{className:"pagination"},h.default.createElement("li",{className:1===this.state.currentPage?"hide":""},h.default.createElement("a",{onClick:(0,O.partialRight)(this._onPageChange,1).bind(this),href:"#","aria-label":"Previous"},h.default.createElement("span",{"aria-hidden":"true"},"«"))),h.default.createElement("li",{className:1===this.state.currentPage?"hide":""},h.default.createElement("a",{onClick:(0,O.partialRight)(this._onPageChange,this.state.currentPage-1).bind(this),href:"#","aria-label":"Previous"},h.default.createElement("span",{"aria-hidden":"true"},"«"))),this.getPageNumbers(this.state.rowsPerPage,this.state.total,this.state.currentPage),h.default.createElement("li",{className:c&&this.state.currentPage!==c?"":"hide"},h.default.createElement("a",{onClick:(0,O.partialRight)(this._onPageChange,this.state.currentPage+1).bind(this),href:"#","aria-label":"Next"},h.default.createElement("span",{"aria-hidden":"true"},"»"))),h.default.createElement("li",{className:c&&this.state.currentPage!==c?"":"hide"},h.default.createElement("a",{onClick:(0,O.partialRight)(this._onPageChange,c).bind(this),href:"#","aria-label":"Next"},h.default.createElement("span",{"aria-hidden":"true"},"»"))))))))}}]),t}(m.default);E.defaultProps={rowsPerPage:10,queryObj:{size:10,from:0}};var w=E;t.default=w,p.default.set("DataTable",E);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(E,"DataTable","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/DataTable.js"),__REACT_HOT_LOADER__.register(w,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/DataTable.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=function(){function e(e,t){for(var r=0;re.from&&n<=e.to})}},{key:"trackStatus",value:function(){var e=Date.parse(this.props.startDate),t=Date.parse(this.props.endDate),r=Number(this.props.startNumber),n=Number(this.props.endNumber),o=this.getTracker(e,t,r,n),a=o(Date.now()),i=a-this.getMetric(this.state.data),s={increase:i<=0,decrease:i>=0,maintain_above:i<=0,maintain_below:i>=0,maintain:!0,mesure:!0};return this.getTolerance(i,s[this.props.action])}},{key:"getTracker",value:function(e,t,r,n){return function(o){var a=(n-r)/(t-e),i=a*(o-e);return i}}},{key:"formatActionName",value:function(e){return(0,g.capitalize)(this.props.action.replace("_"," "))}},{key:"getCaption",value:function(){var e={action:this.formatActionName(this.props.action),caption:this.props.caption,startNumber:(0,k.formatNumber)(this.props.startNumber,this.state.numberFormat),endNumber:(0,k.formatNumber)(this.props.endNumber,this.state.numberFormat),startDate:(0,k.formatDate)(new Date(this.props.startDate),this.state.dateFormat),endDate:(0,k.formatDate)(new Date(this.props.endDate),this.state.dateFormat)},t=(0,g.template)(this.props.captionTemplates[this.props.action]);return t(e)}},{key:"render",value:function(){var e=s({},(0,g.head)(this.trackStatus())),t={background:this.props.background},r=void 0,n=void 0;if(t=s({},t,this.props.style),this.props.spline){var o=s({},this.props.spline);r=c.default.createElement(O.default,s({type:"sparklinePlus",datum:this.state.data,showLastValue:!1,color:["#333333"]},o))}return this.state.showEndNumber&&(n=c.default.createElement("span",{className:"card-goal-end-number"}," ",this.props.divider," ",(0,k.formatNumber)(this.props.endNumber,this.state.numberFormat))),c.default.createElement(m.default,this.state.cardVariables,c.default.createElement(y.default,{isFetching:this.props.isFetching},c.default.createElement("div",{className:"goal",style:t},c.default.createElement("div",{className:"row"},c.default.createElement("div",{className:"col-md-4"},c.default.createElement("div",{className:"card-goal-icon"},c.default.createElement("span",{className:(0,w.default)("glyphicon",this.props.icon)}))),c.default.createElement("div",{className:"col-md-8"},c.default.createElement("div",{className:"card-goal-caption"},this.getCaption()))),c.default.createElement("div",{className:"row"},c.default.createElement("div",{className:"col-md-4"},c.default.createElement("div",{className:"card-goal-progress"},c.default.createElement("span",{className:"card-goal-metric"},(0,k.formatNumber)(this.getMetric(this.state.data),this.state.numberFormat)),n)),c.default.createElement("div",{className:"col-md-8"},c.default.createElement("div",{className:"card-goal-status"},c.default.createElement("a",{style:{color:e.color},href:this.props.link},e.label)),c.default.createElement("div",{className:"card-goal-end-date"},(0,k.formatDate)(new Date(this.props.endDate),this.state.dateFormat)))),c.default.createElement("div",{className:"row"},c.default.createElement("div",{className:"col-md-12"},c.default.createElement("div",{className:"spline"},r))))))}}]),t}(h.default);R.defaultProps={captionTemplates:{increase:"${action} ${caption} ${endNumber} by ${endDate}",decrease:"${action} ${caption} ${endNumber} by ${endDate}",maintain:"${action} at ${endNumber} ${caption} by ${endDate}",maintain_above:"${action} ${endNumber} ${caption} by ${endDate}",maintain_below:"${action} ${endNumber} ${caption} by ${endDate}",mesure:"${caption}"},divider:" / ",style:{color:"black",background:"white"}};var C=R;t.default=C,f.default.set("Goal",R);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(R,"Goal","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/Goal.js"),__REACT_HOT_LOADER__.register(C,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/Goal.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r0?this.props.data[0]:this.props.data&&!(0,m.isArray)(this.props.data)?this.props.data:this.props.content?this.props.content:""}},{key:"render",value:function(){return l.default.createElement(_.default,this.state.cardVariables,l.default.createElement("div",{dangerouslySetInnerHTML:{__html:this.getContent()}}))}}]),t}(d.default),y=b;t.default=y,p.default.set("Markup",b);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(b,"Markup","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/Markup.js"),__REACT_HOT_LOADER__.register(y,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/Markup.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:[];return d.DataHandler.handle.call(this,e,r,this.props.globalData,{},t)}},{key:"getChildren",value:function(){var e=this,t=void 0;return this.props.children&&(t=this.props.children.map(function(t,r){var n=s(t,{globalData:e.props.globalData,appliedFilters:e.props.appliedFilters});return t.dataHandlers?n.data=e._applyDataHandlers(t.dataHandlers,t.appliedFilters,t.data):t.data&&t.data.length>0&&(n.data=t.data),n.key=r,c.default.createElement(f.default.get(t.type),n)})),t}},{key:"render",value:function(){var e=this.getChildren();return c.default.createElement("div",{className:this.props.className},e)}}]),t}(l.Component)),m=_;t.default=m,f.default.set("Region",_);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(_,"Region","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/Region.js"),__REACT_HOT_LOADER__.register(m,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/components/Region.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t0?i[0]:[]}};a.default.setLib("NVD3",s);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(i,"LibName","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/datahandlers/NVD3DataHandlers.js"),__REACT_HOT_LOADER__.register(s,"dataHandlers","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/datahandlers/NVD3DataHandlers.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(10),a=n(o),i=r(7),s="common",u={fieldsToXYSeries:function(e,t,r,n,o,a){var i=a||e;if(!i.length)return[];Array.isArray(i[1])||(i=[i]);var s=i.map(function(e){var t=r.xField||"x";r.field;return e.map(function(e){return{y:e[r.field],x:e[t]}})});return s},fieldToD3Format:function(e,t,r,n,o,a){var s=a||e||[],u=(0,i.format)(r.format);return s.map(function(e){return e.map(function(e){return e[r.field]=u(e[r.field]),e})}),s},filterDashboardDataByParamEquals:function(e,t,r,n,o,a){var i=t,s=i.filter(function(e){return e[r.field]===r.value});return[s]},parseDateField:function(e,t,r,n,o,a){var i=a||e;return i.map(function(e){return e[r.field]=Date.parse(e[r.field]),e})},getEventReturn:function(e,t,r,n,o,a){return n?n.value:e},getXYByQueryData:function(e,t,r,n,o,a){if(t&&t[r.dataKey]&&t[r.dataKey][r.queryKey]){var i=t[r.dataKey][r.queryKey].result.records,s=i.map(function(e){var t={};return t[r.xField]=e[r.xField],t[r.yField]=e[r.yField],t});return[s]}return[]},getXYByQueryDataWhere:function(e,t,r,n,o,a){if(t&&t[r.dataKey]&&t[r.dataKey][r.queryKey]){var i=t[r.dataKey][r.queryKey].result.records,s=i.filter(function(e){var t=r.whereFieldValueIn.indexOf(e[r.whereField])>=0;return t}),u=s.map(function(e){var t={};return t[r.xField]=e[r.xField],t[r.yField]=e[r.yField],t});return[u]}return[]},getXYByQueryDataWhereFieldsIn:function(e,t,r,n,o,a){if(t&&t[r.dataKey]&&t[r.dataKey][r.queryKey]){var i=t[r.dataKey][r.queryKey].result.records,s=i.filter(function(e){var t=void 0;return r.whereField.forEach(function(n){t=r.whereFieldValueIn.indexOf(e[n])>=0}),t}),u=s.map(function(e){var t={};return t[r.xField]=e[r.xField],t[r.yField]=e[r.yField],t});return[u]}return[]},getPercentileSeries:function(e,t,r,n,o,a){},groupByRange:function(e,t,r,n,o,a){var i=a||e,s=[];return i.forEach(function(e){var t=[],n=function(n){var o=r.ranges[n][0],a=r.ranges[n][1],i=o+" - "+a,s=0,u={};e.forEach(function(e){e[r.xField]>=o&&e[r.xField]<=a&&(s+=parseInt(e[r.yField]))}),u[r.xField]=i,u[r.yField]=s,t.push(u)};for(var o in r.ranges)n(o);s.push(t)}),s},seriesFromRanges:function(e,t,r,n,o,a){var i=a||e;if(i.length>0){var s=i[0].map(function(e,t){var n={},o=[],a={};return n.key=e[r.xField],n.color=r.colors[t],a.label=r.xLabel,a.value=e[r.yField],o.push(a),n.values=o,n});return s}return i},rekeySeries:function(e,t,r,n,o,a){var i=a||e;if(i.length>0){var s=i[0].map(function(e){var t={};return Object.keys(e).forEach(function(n,o){t[r.newKeys[o]]=e[n]}),t});return[s]}return[]},parseInts:function(e,t,r,n,o,a){var i=a||e;return i.forEach(function(e){e.forEach(function(e){r.fields.forEach(function(t){e[t]=parseInt(e[t])})})}),i},toPieChartSeries:function(e,t,r,n,o,a){var i=a||e;return i.length>0?i[0]:[]},changeFieldNames:function(e,t,r,n,o,a){var i=a||e,s=[];return i.forEach(function(e){var t=void 0;t=e.map(function(e){return e[r.xField]=r.fields[e[r.xField]],e}),s.push(t)}),s},whitelistValues:function(e,t,r,n,o,a){var i=a||e,s=void 0;return i.length>0?s=i.map(function(e){return e.filter(function(e){if(r.whiteList.indexOf(e[r.field])>=0)return!0})}):i},inspect:function(e,t,r,n,o,a){var i=a||e;return console.log("INSPECT>>",this,i,arguments),i}};a.default.setLib("common",u);var l=u;t.default=l;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(s,"libName","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/datahandlers/common.js"),__REACT_HOT_LOADER__.register(u,"dataHandlers","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/datahandlers/common.js"),__REACT_HOT_LOADER__.register(l,"default","/home/partisan/workshop/ca/ga_gbpw/docroot/sites/all/modules/contrib/rd/src/datahandlers/common.js"))})()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(45);Object.defineProperty(t,"NVD3DataHandlers",{enumerable:!0,get:function(){return n(o).default}});var a=r(46);Object.defineProperty(t,"common",{enumerable:!0,get:function(){return n(a).default}});(function(){"undefined"==typeof __REACT_HOT_LOADER__})()},function(e,t,r){"use strict";function n(e){var t=[];for(var r in e)t.push(r+"="+e[r]);return"?"+t.join("&")}function o(e){return!!(e.indexOf&&e.indexOf("fid")>=0)&&e.replace("fid","")}function a(e){return JSON.parse('{"'+decodeURI(e).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}')}function i(e,t,r){var n={};if(Object.keys(e).forEach(function(o){if(o===t)if("object"===c(e[o]))r?n=e[o]:e[o].forEach(function(e){var t=e.split("__");if(n[t[0]]&&"object"===c(n[t[0]]))n[t[0]].push(t[1]);else if(n[t[0]]&&"string"==typeof n[t[0]]){var r={},o=[];o.push(n[t[0]]),o.push(t[1]),r[t[0]]=o,n=l(n,r)}else n[t[0]]=t[1]});else if(e[o].indexOf("__")<0)console.log("gop",e[o],n),n[o]=e[o];else{var a=e[o].split("__");n[a[0]]=a[1]}}),!(0,p.isEmpty)(n))return n}function s(e){var t,r,n,o,a,i;if(r=[],a=/%20/g,n=function(e,t){t="function"==typeof t?t():null==t?"":t,r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)},e instanceof Array)for(o in e)n(o,e[o]);else for(t in e)u(t,e[t],n);return i=r.join("&").replace(a,"+")}function u(e,t,r){var n,o,a,i;if(i=/\[\]$/,t instanceof Array)for(o=0,a=t.length;o { + // Get current values. + const vals = filter.vals; + // Do logic to get different values; + const newVals = functionThatGetsNewVals(vals); + return newVals; +} +``` + +## datahandler arguments + +### componentData +Data set on the component as this.state.data - this could come from a fetch call, be passed as props, or through some novel method on a custom component. + +### dashboardData +Also referred to as globalData - this is the data available to the entire dashboard + +### handler +The handler as deffined in settings.js. Any properties set on the handler are available as `handler.foo`, etc + +### filter +The filter to which values are being updated. + +### state +Current app state. + +### payload +The update event that comes from a filter component. diff --git a/docs/development/data/index.rst b/docs/development/data/index.rst index 69470332..9c780ce4 100644 --- a/docs/development/data/index.rst +++ b/docs/development/data/index.rst @@ -6,4 +6,5 @@ Data Handling overview datahandlers statehandlers + filterhandlers backends diff --git a/docs/development/data/statehandlers.md b/docs/development/data/statehandlers.md index aadf0834..f3f47fbd 100644 --- a/docs/development/data/statehandlers.md +++ b/docs/development/data/statehandlers.md @@ -8,17 +8,19 @@ Consider the following stateHandler configuration for a chart component: ```eval_rst .. literalinclude:: ../../../examples/settings.js - :start-after: start stateHandler example - :end-before: end stateHandler example + :language: javascript + :emphasize-lines: 216-221 :dedent: 4 + :lines: 205-230 ``` The *stateHandler* should return a literal value, which will be applied the state using the handlers *attribute* property. When looking up props, the component checks the state first, and if that prop is set on the state, will use that instead, allowing the state to override props on a case-by-case basis, using *stateHandler.attribute* ```eval_rst .. literalinclude:: ../../../examples/customStateHandlers.js - :start-after: start stateHandler example - :end-before: end stateHandler example + :language: javascript + :dedent: 2 + :lines: 17-23 ``` ## Attributes diff --git a/docs/development/intro.md b/docs/development/intro.md index 252e444d..a5471a81 100644 --- a/docs/development/intro.md +++ b/docs/development/intro.md @@ -8,6 +8,8 @@ You can define a dashboard using familiar JSX syntax. Following is a complete ex ```eval_rst .. literalinclude:: ../../examples/jsx_static_example/app.js + :language: javascript + :lines: 10- ``` ## Javascript Settings object @@ -17,6 +19,7 @@ In many cases it is useful to define dashboard configuration in JSON - allowing ```eval_rst .. literalinclude:: ../../examples/js_static_example/app.js + :language: javascript ``` ## Complete Dashboard Application @@ -27,10 +30,10 @@ The app at `/examples/app.js` runs an example of a more robust application with ## Boilerplate project The boilerplate module includes the above application in a complete development environment suitable for doing dashbaord development. -`git clone https://github.com/NuCivic/react-dash-boilerplate.git` -`cd react-dash-boilerplate` -`npm install` -`npm run init` -`npm run start` + git clone https://github.com/NuCivic/react-dash-boilerplate.git + cd react-dash-boilerplate + npm install + npm run init + npm run start This will spin up the example application, and you can use it as a starting point for developing your own app. diff --git a/docs/development/settings.js.md b/docs/development/settings.js.md index ffa41e0e..f6e99444 100644 --- a/docs/development/settings.js.md +++ b/docs/development/settings.js.md @@ -5,6 +5,7 @@ A simple example: ```eval_rst .. literalinclude:: ../../examples/js_static_example/settings.js + :language: javascript ``` ## Regions diff --git a/examples/settings.js b/examples/settings.js index 812d8415..8a5b8e8e 100644 --- a/examples/settings.js +++ b/examples/settings.js @@ -189,15 +189,15 @@ export var settings = { legend: { classesCount: 5, pallete: - [ - "#e6ffff", - "#00ffff", - "#00cccc", - "#00b3b3", - "#009999", - "#008080", - "#004d4d" - ] + [ + "#e6ffff", + "#00ffff", + "#00cccc", + "#00b3b3", + "#009999", + "#008080", + "#004d4d" + ] }, }, ] @@ -256,15 +256,15 @@ export var settings = { let climateVars = { - PCP: 'Precipitation Index', - TAVG: 'Temperature Index', - TMIN: 'Minimum Temperature Index', - TMAX: 'Maximum Temperature Index', - PDSI: 'Palmer Drought Severity Index', - PHDI: 'Palmer Hydrological Drought Index', - ZNDX: 'Palmer Z-Index', - PMDI: 'Modified Palmer Drought Severity Index', - CDD: 'Cooling Degree Days', - HDD: 'Heating Degree Days', - SPnn: 'Standard Precipitation Index' - }; + PCP: 'Precipitation Index', + TAVG: 'Temperature Index', + TMIN: 'Minimum Temperature Index', + TMAX: 'Maximum Temperature Index', + PDSI: 'Palmer Drought Severity Index', + PHDI: 'Palmer Hydrological Drought Index', + ZNDX: 'Palmer Z-Index', + PMDI: 'Modified Palmer Drought Severity Index', + CDD: 'Cooling Degree Days', + HDD: 'Heating Degree Days', + SPnn: 'Standard Precipitation Index' + }; diff --git a/src/ReactDashboard.js b/src/ReactDashboard.js index 85258085..cec455f9 100644 --- a/src/ReactDashboard.js +++ b/src/ReactDashboard.js @@ -25,6 +25,7 @@ export {default as Region} from './components/Region'; export {default as Registry } from './utils/Registry'; export {default as DataHandler } from './utils/DataHandler'; export {default as StateHandler } from './utils/StateHandler'; +export {default as FilterHandler } from './utils/FilterHandler'; export * from './utils/utils'; // MODELS @@ -37,4 +38,3 @@ export {default as DashboardConstants} from './constants/DashboardConstants'; // DATAHANDLERS export {default as DataHandlers} from './datahandlers/index'; - diff --git a/src/components/BaseComponent.js b/src/components/BaseComponent.js index 0af87532..e4d0196b 100644 --- a/src/components/BaseComponent.js +++ b/src/components/BaseComponent.js @@ -76,7 +76,7 @@ export default class BaseComponent extends Component { let newState = {}; if (this.props.stateHandlers && this.props.stateHandlers.length > 0) { - let handledState = StateHandler.handle(this.props.stateHandlers, this.props.data, this.state.dashboardData); + let handledState = StateHandler.handle(this.props.stateHandlers, this.props.data, this.props.globalData, this.props.appliedFilters); newState = Object.assign(newState, handledState); } diff --git a/src/components/BaseFilter.js b/src/components/BaseFilter.js index 60b1aac2..c563c942 100644 --- a/src/components/BaseFilter.js +++ b/src/components/BaseFilter.js @@ -40,7 +40,6 @@ export default class BaseFilter extends BaseComponent { onChange(e) { this.onFilter(e); - let filter = Object.assign({}, this.props); filter.value = e; @@ -51,13 +50,13 @@ export default class BaseFilter extends BaseComponent { } // Check if the filter is disabled - // Filters can be disabled via props, or if a specified filter is present - // in applied filters + // Filters can be disabled via props, state, or if a specified filter is + // present in applied filters isDisabled() { let disabled = false; let appliedFilters = (this.props.appliedFilters) ? Object.keys(this.props.appliedFilters) : []; - if (this.props.disabled) disabled = true; + if (this.props.disabled || this.state.disabled) disabled = true; if (this.props.disabledBy) { this.props.disabledBy.forEach(field => { diff --git a/src/components/Dashboard.js b/src/components/Dashboard.js index cf9d45a0..97b31bf0 100644 --- a/src/components/Dashboard.js +++ b/src/components/Dashboard.js @@ -5,6 +5,7 @@ import { isArray, isEqual, pick} from 'lodash'; import { appliedFiltersToQueryString, makeKey } from '../utils/utils'; import Accordion from 'react-responsive-accordion'; import classNames from 'classnames/bind'; +import FilterHandler from '../utils/FilterHandler'; export default class Dashboard extends BaseComponent { @@ -130,12 +131,29 @@ export default class Dashboard extends BaseComponent { return filter; } + /** + * If filterHandlers are defined on the component call them and return the result + * + * @returns {obj} object with updated payload + */ + executeFilterHandlers(payload) { + + if (payload.filterHandlers && payload.filterHandlers.length > 0) { + FilterHandler.handle(payload.filterHandlers, payload, this.state); + return payload; + } + return payload; + } + + /** * Handle actions here. * Update appliedFilters on state triggers re-render * App parses appliedFilters and updates dash accordingly **/ - onAction(payload) { + onAction(_payload) { + + const payload = this.executeFilterHandlers(_payload); switch(payload.actionType) { case 'AUTOCOMPLETE_CHANGE': let appliedFilters = Object.assign({}, this.state.appliedFilters); diff --git a/src/components/MultiCheckboxFilter.js b/src/components/MultiCheckboxFilter.js index dd55668c..364fa0ef 100644 --- a/src/components/MultiCheckboxFilter.js +++ b/src/components/MultiCheckboxFilter.js @@ -48,6 +48,7 @@ export default class MultiCheckboxFilter extends BaseFilter { value={el.value} id={idx + this.state.key} checked={el.checked} + disabled={this.isDisabled()} onChange={() => { this.checkboxClick(el) }} />