From 9a851f6c79e27b080d04659fe49edef63d9e3931 Mon Sep 17 00:00:00 2001 From: acouch Date: Wed, 28 Mar 2018 15:09:33 -0400 Subject: [PATCH 1/7] Issue #99 Updates BaseComponent.js to receive dashboardData and appliedFilters --- dist/react-dashboard.min.js | 8 ++++---- src/components/BaseComponent.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/react-dashboard.min.js b/dist/react-dashboard.min.js index 522e811c..f9c1f13e 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,o.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/react-dash/src/utils/Registry.js"),__REACT_HOT_LOADER__.register(s,"Registry","/home/partisan/workshop/react-dash/src/utils/Registry.js"),__REACT_HOT_LOADER__.register(u,"default","/home/partisan/workshop/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=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 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,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=g;t.default=O;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(b,"CARD_VARS","/home/partisan/workshop/react-dash/src/components/BaseComponent.js"),__REACT_HOT_LOADER__.register(g,"BaseComponent","/home/partisan/workshop/react-dash/src/components/BaseComponent.js"),__REACT_HOT_LOADER__.register(O,"default","/home/partisan/workshop/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","/home/partisan/workshop/react-dash/src/components/BaseFilter.js"),__REACT_HOT_LOADER__.register(_,"default","/home/partisan/workshop/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,l=u;t.default=l,o.default.set("ReactSelect",s.default);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(u,"ReactSelect","/home/partisan/workshop/react-dash/src/components/ReactSelect.js"),__REACT_HOT_LOADER__.register(l,"default","/home/partisan/workshop/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(y.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","/home/partisan/workshop/react-dash/src/components/Dashboard.js"),__REACT_HOT_LOADER__.register(O,"default","/home/partisan/workshop/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","/home/partisan/workshop/react-dash/src/dispatcher/EventDispatcher.js"),__REACT_HOT_LOADER__.register(o,"default","/home/partisan/workshop/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=c[e.field].type||"string";return l[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),l=i(a?"":t.to);return!!(n&&a||""!==s)&&((n||s>=u)&&(a||s<=l))}var s=t.filters||[],u={ +term:n,terms:a,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,o.every)(t,o.identity)})}}]),e}(),s=i;t.default=s;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(i,"MemoryStore","/home/partisan/workshop/react-dash/src/models/MemoryStore.js"),__REACT_HOT_LOADER__.register(s,"default","/home/partisan/workshop/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,c.default.createElement(v.default,s({key:"card_"+this.state.key},this.state.cardVariables),c.default.createElement(h.default,t))}}]),t}(m.default),w=T;t.default=w,p.default.set("Chart",T);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(T,"Chart","/home/partisan/workshop/react-dash/src/components/Chart.js"),__REACT_HOT_LOADER__.register(w,"default","/home/partisan/workshop/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]||{}),c=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(l.Column,s({header:h.default.createElement(l.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(l.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(v.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(l.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: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 k=E;t.default=k,f.default.set("DataTable",E);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(E,"DataTable","/home/partisan/workshop/react-dash/src/components/DataTable.js"),__REACT_HOT_LOADER__.register(k,"default","/home/partisan/workshop/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=c.default.createElement(O.default,s({type:"sparklinePlus",datum:this.state.data,showLastValue:!1,color:["#333333"]},a))}return this.state.showEndNumber&&(n=c.default.createElement("span",{className:"card-goal-end-number"}," ",this.props.divider," ",(0,T.formatNumber)(this.props.endNumber,this.state.numberFormat))),c.default.createElement(m.default,this.state.cardVariables,c.default.createElement(v.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,k.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,T.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,T.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,p.default.set("Goal",R);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(R,"Goal","/home/partisan/workshop/react-dash/src/components/Goal.js"),__REACT_HOT_LOADER__.register(C,"default","/home/partisan/workshop/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,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),v=y;t.default=v,f.default.set("Markup",y);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(y,"Markup","/home/partisan/workshop/react-dash/src/components/Markup.js"),__REACT_HOT_LOADER__.register(v,"default","/home/partisan/workshop/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,c.default.createElement(p.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,p.default.set("Region",_);(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(_,"Region","/home/partisan/workshop/react-dash/src/components/Region.js"),__REACT_HOT_LOADER__.register(m,"default","/home/partisan/workshop/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","/home/partisan/workshop/react-dash/src/datahandlers/NVD3DataHandlers.js"),__REACT_HOT_LOADER__.register(s,"dataHandlers","/home/partisan/workshop/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 l=u;t.default=l;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(s,"libName","/home/partisan/workshop/react-dash/src/datahandlers/common.js"),__REACT_HOT_LOADER__.register(u,"dataHandlers","/home/partisan/workshop/react-dash/src/datahandlers/common.js"),__REACT_HOT_LOADER__.register(l,"default","/home/partisan/workshop/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"===c(e[a]))r?n=e[a]:e[a].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={},a=[];a.push(n[t[0]]),a.push(t[1]),r[t[0]]=a,n=l(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) { - 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); } From 50f7ab90ad6095917d4ba7b65903319f390edce1 Mon Sep 17 00:00:00 2001 From: acouch Date: Mon, 2 Apr 2018 21:24:47 -0400 Subject: [PATCH 2/7] Adds filterHandler to src files --- src/ReactDashboard.js | 2 +- src/components/BaseFilter.js | 7 ++-- src/components/Dashboard.js | 20 ++++++++++- src/components/MultiCheckboxFilter.js | 1 + src/utils/FilterHandler.js | 48 +++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/utils/FilterHandler.js 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/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) }} />