From 47d9d599bf41eae39bd5fa37190919e6878d666e Mon Sep 17 00:00:00 2001 From: Miquel Adell Date: Mon, 5 Feb 2024 15:52:31 +0100 Subject: [PATCH] Release 0.2.2 (#13) Adds compatibility with DHIS2 40 --------- Co-authored-by: xurxodev --- package.json | 2 +- public/240/chart.min.js | 80355 ++++++++++++++++++++++++++++++++ public/240/eventchart.min.js | 30 + public/240/eventreport.min.js | 48516 +++++++++++++++++++ public/240/map.min.js | 3 + public/240/reporttable.min.js | 47848 +++++++++++++++++++ 6 files changed, 176753 insertions(+), 1 deletion(-) create mode 100644 public/240/chart.min.js create mode 100644 public/240/eventchart.min.js create mode 100644 public/240/eventreport.min.js create mode 100644 public/240/map.min.js create mode 100644 public/240/reporttable.min.js diff --git a/package.json b/package.json index 36618ab..8c3d195 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "dashboard-reports", "description": "Dashboard Reports", - "version": "0.2.1", + "version": "0.2.2", "license": "GPL-3.0", "author": "EyeSeeTea team", "homepage": ".", diff --git a/public/240/chart.min.js b/public/240/chart.min.js new file mode 100644 index 0000000..cc988b7 --- /dev/null +++ b/public/240/chart.min.js @@ -0,0 +1,80355 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ((function(modules) { + // Check all modules for deduplicated modules + for(var i in modules) { + if(Object.prototype.hasOwnProperty.call(modules, i)) { + switch(typeof modules[i]) { + case "function": break; + case "object": + // Module can be created from a template + modules[i] = (function(_m) { + var args = _m.slice(1), fn = modules[_m[0]]; + return function (a,b,c) { + fn.apply(this, [a,b,c].concat(args)); + }; + }(modules[i])); + break; + default: + // Module is a copy of another module + modules[i] = modules[modules[i]]; + break; + } + } + } + return modules; +}([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global) {'use strict'; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + __webpack_require__(209); + + var _arrayTo = __webpack_require__(190); + + var _arrayTo2 = _interopRequireDefault(_arrayTo); + + var _isArray = __webpack_require__(11); + + var _isArray2 = _interopRequireDefault(_isArray); + + var _objectApplyIf = __webpack_require__(517); + + var _objectApplyIf2 = _interopRequireDefault(_objectApplyIf); + + var _d2ChartsApi = __webpack_require__(150); + + var _d2Analysis = __webpack_require__(81); + + var _Layout = __webpack_require__(125); + + var _d = __webpack_require__(531); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + // extend + _d2Analysis.api.Layout = _Layout.Layout; + + // references + var refs = { + api: _d2Analysis.api, + init: _d2Analysis.init + }; + + // inits + var inits = [_d2Analysis.init.legendSetsInit, _d2Analysis.init.dimensionsInit]; + + // dimension config + var dimensionConfig = new _d2Analysis.config.DimensionConfig(); + refs.dimensionConfig = dimensionConfig; + + // option config + var optionConfig = new _d2Analysis.config.OptionConfig(); + refs.optionConfig = optionConfig; + + // period config + var periodConfig = new _d2Analysis.config.PeriodConfig(); + refs.periodConfig = periodConfig; + + // chart config + var chartConfig = new _d2Analysis.config.ChartConfig(); + refs.chartConfig = chartConfig; + + // app manager + var appManager = new _d2Analysis.manager.AppManager(refs); + appManager.apiVersion = 31; + refs.appManager = appManager; + + // calendar manager + var calendarManager = new _d2Analysis.manager.CalendarManager(refs); + refs.calendarManager = calendarManager; + + // request manager + var requestManager = new _d2Analysis.manager.RequestManager(refs); + refs.requestManager = requestManager; + + // i18n manager + var i18nManager = new _d2Analysis.manager.I18nManager(refs); + refs.i18nManager = i18nManager; + + // session storage manager + var sessionStorageManager = new _d2Analysis.manager.SessionStorageManager(refs); + refs.sessionStorageManager = sessionStorageManager; + + // dependencies + dimensionConfig.setI18nManager(i18nManager); + dimensionConfig.init(); + optionConfig.setI18nManager(i18nManager); + optionConfig.init(); + periodConfig.setI18nManager(i18nManager); + periodConfig.init(); + + appManager.applyTo((0, _arrayTo2.default)(_d2Analysis.api)); + optionConfig.applyTo((0, _arrayTo2.default)(_d2Analysis.api)); + + // generic period names without year for xAxis labels + function computeGenericPeriodNames(responses) { + var xAxisRes = responses.reduce(function (out, res) { + if (out.metaData) { + if (res.metaData.dimensions.pe.length > out.metaData.dimensions.pe.length) { + out = res; + } + } else { + out = res; + } + + return out; + }, {}); + + var metadata = xAxisRes.metaData; + + return metadata.dimensions.pe.reduce(function (genericPeriodNames, periodId) { + var name = metadata.items[periodId].name; + + // until the day the backend will support this in the API: + // trim off the trailing year in the period name + // english names should all have the year at the end of the string + genericPeriodNames.push(name.replace(/\s+\d{4}$/, '')); + + return genericPeriodNames; + }, []); + } + + // Year over year special handling + function apiFetchAnalyticsForYearOverYear(current, options) { + (0, _d.init)({ baseUrl: appManager.getApiPath() }); + + var d2; + var yearlySeriesLabels = []; + + return (0, _d.getInstance)().then(function (d2Instance) { + d2 = d2Instance; + }).then(function () { + var yearlySeriesReq = new d2.analytics.request().addPeriodDimension(current.yearlySeries).withSkipData(true).withSkipMeta(false).withIncludeMetadataDetails(true); + + if (options.relativePeriodDate) { + yearlySeriesReq = yearlySeriesReq.withRelativePeriodDate(options.relativePeriodDate); + } + + return d2.analytics.aggregate.fetch(yearlySeriesReq); + }).then(function (yearlySeriesRes) { + var requests = []; + + var now = new Date(); + var currentDay = ('' + now.getDate()).padStart(2, 0); + var currentMonth = ('' + (now.getMonth() + 1)).padStart(2, 0); + + yearlySeriesRes.metaData.dimensions['pe'].forEach(function (period) { + yearlySeriesLabels.push(yearlySeriesRes.metaData.items[period].name); + + var startDate = period + '-' + currentMonth + '-' + currentDay; + + var req = new d2.analytics.request().fromModel(current).withParameters(options).withRelativePeriodDate(startDate); + + requests.push(d2.analytics.aggregate.get(req)); + }); + + return Promise.all(requests); + }).then(function (responses) { + return Promise.resolve({ + responses: responses.map(function (res) { + return new d2.analytics.response(res); + }), + yearlySeriesLabels: yearlySeriesLabels + }); + }).catch(function (e) { + return console.log(e); + }); + } + + // plugin + function render(plugin, layout) { + if (!_d2Analysis.util.dom.validateTargetDiv(layout.el)) { + return; + } + + var instanceRefs = _extends({}, refs); + + var uiManager = new _d2Analysis.manager.UiManager(instanceRefs); + instanceRefs.uiManager = uiManager; + uiManager.applyTo((0, _arrayTo2.default)(_d2Analysis.api)); + uiManager.preventMask = true; + + var instanceManager = new _d2Analysis.manager.InstanceManager(instanceRefs); + instanceRefs.instanceManager = instanceManager; + instanceManager.apiResource = 'visualization'; + instanceManager.apiEndpoint = 'visualizations'; + instanceManager.apiModule = 'dhis-web-data-visualizer'; + instanceManager.plugin = true; + instanceManager.dashboard = chartPlugin.dashboard; + instanceManager.applyTo((0, _arrayTo2.default)(_d2Analysis.api)); + + // instance manager + uiManager.setInstanceManager(instanceManager); + + // options passed to createChart + var extraOptions = {}; + + instanceManager.setFn(function (_layout) { + if (!_d2Analysis.util.dom.validateTargetDiv(_layout.el)) { + return; + } + + var fn = function fn(legendSetId) { + var el = _layout.el; + var element = document.getElementById(el); + var response = _layout.getResponse(); + + extraOptions.legendSet = appManager.getLegendSetById(legendSetId); + extraOptions.dashboard = instanceManager.dashboard; + + var _createChart = (0, _d2ChartsApi.createChart)(response, _layout, el, extraOptions), + chart = _createChart.chart; + + // reg + + + uiManager.reg(chart, 'chart'); + + // dashboard item resize + element.setViewportWidth = function (width) { + chart.setSize(width, undefined, { duration: 50 }); + }; + + element.setViewportHeight = function (height) { + chart.setSize(undefined, height, { duration: 50 }); + }; + + element.setViewportSize = function (width, height) { + chart.setSize(width, height, { duration: 50 }); + }; + + // mask + uiManager.unmask(); + }; + + // legend set + if (_layout.doLegendSet()) { + appManager.getLegendSetIdByDxId(_layout.getFirstDxId(), function (legendSetId) { + fn(legendSetId); + }); + } else { + fn(); + } + }); + + if (plugin.loadingIndicator) { + uiManager.renderLoadingIndicator(layout.el); + } + + if (layout.id) { + instanceManager.getById(layout.id, function (_layout) { + _layout = new _d2Analysis.api.Layout(instanceRefs, (0, _objectApplyIf2.default)(layout, _layout)); + + if (!_d2Analysis.util.dom.validateTargetDiv(_layout.el)) { + return; + } + + // special handling for YEAR_OVER_YEAR chart types + if (_layout.type.match(/^YEAR_OVER_YEAR/i)) { + var options = {}; + + if (_layout.aggregationType && _layout.aggregationType !== 'DEFAULT') { + options.aggregationType = _layout.aggregationType; + } + + if (_layout.completedOnly) { + options.completedOnly = _layout.completedOnly; + } + + apiFetchAnalyticsForYearOverYear(_layout, options).then(function (_ref) { + var responses = _ref.responses, + yearlySeriesLabels = _ref.yearlySeriesLabels; + + // set responses in layout object so getReport does not perform analytics requests + _layout.setResponse(responses); + + // extra options to pass to createChart() special for YOY chart types + extraOptions.yearlySeries = yearlySeriesLabels; + extraOptions.xAxisLabels = computeGenericPeriodNames(responses); + + instanceManager.getReport(_layout); + }); + } else { + instanceManager.getReport(_layout); + } + }); + } else { + instanceManager.getReport(new _d2Analysis.api.Layout(instanceRefs, layout), false, false, false, null, { + noError: true, + errorMessage: 'No data to display' + }); + } + } + + global.chartPlugin = new _d2Analysis.util.Plugin({ refs: refs, inits: inits, renderFn: render, type: 'CHART' }); + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + // Utilities + // + 'use strict'; + + + function _class(obj) { return Object.prototype.toString.call(obj); } + + function isString(obj) { return _class(obj) === '[object String]'; } + + var _hasOwnProperty = Object.prototype.hasOwnProperty; + + function has(object, key) { + return _hasOwnProperty.call(object, key); + } + + // Merge objects + // + function assign(obj /*from1, from2, from3, ...*/) { + var sources = Array.prototype.slice.call(arguments, 1); + + sources.forEach(function (source) { + if (!source) { return; } + + if (typeof source !== 'object') { + throw new TypeError(source + 'must be object'); + } + + Object.keys(source).forEach(function (key) { + obj[key] = source[key]; + }); + }); + + return obj; + } + + // Remove element from array and put another array at those position. + // Useful for some operations with tokens + function arrayReplaceAt(src, pos, newElements) { + return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1)); + } + + //////////////////////////////////////////////////////////////////////////////// + + function isValidEntityCode(c) { + /*eslint no-bitwise:0*/ + // broken sequence + if (c >= 0xD800 && c <= 0xDFFF) { return false; } + // never used + if (c >= 0xFDD0 && c <= 0xFDEF) { return false; } + if ((c & 0xFFFF) === 0xFFFF || (c & 0xFFFF) === 0xFFFE) { return false; } + // control codes + if (c >= 0x00 && c <= 0x08) { return false; } + if (c === 0x0B) { return false; } + if (c >= 0x0E && c <= 0x1F) { return false; } + if (c >= 0x7F && c <= 0x9F) { return false; } + // out of range + if (c > 0x10FFFF) { return false; } + return true; + } + + function fromCodePoint(c) { + /*eslint no-bitwise:0*/ + if (c > 0xffff) { + c -= 0x10000; + var surrogate1 = 0xd800 + (c >> 10), + surrogate2 = 0xdc00 + (c & 0x3ff); + + return String.fromCharCode(surrogate1, surrogate2); + } + return String.fromCharCode(c); + } + + + var UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g; + var ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi; + var UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + '|' + ENTITY_RE.source, 'gi'); + + var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i; + + var entities = __webpack_require__(114); + + function replaceEntityPattern(match, name) { + var code = 0; + + if (has(entities, name)) { + return entities[name]; + } + + if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) { + code = name[1].toLowerCase() === 'x' ? + parseInt(name.slice(2), 16) + : + parseInt(name.slice(1), 10); + if (isValidEntityCode(code)) { + return fromCodePoint(code); + } + } + + return match; + } + + /*function replaceEntities(str) { + if (str.indexOf('&') < 0) { return str; } + + return str.replace(ENTITY_RE, replaceEntityPattern); + }*/ + + function unescapeMd(str) { + if (str.indexOf('\\') < 0) { return str; } + return str.replace(UNESCAPE_MD_RE, '$1'); + } + + function unescapeAll(str) { + if (str.indexOf('\\') < 0 && str.indexOf('&') < 0) { return str; } + + return str.replace(UNESCAPE_ALL_RE, function (match, escaped, entity) { + if (escaped) { return escaped; } + return replaceEntityPattern(match, entity); + }); + } + + //////////////////////////////////////////////////////////////////////////////// + + var HTML_ESCAPE_TEST_RE = /[&<>"]/; + var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g; + var HTML_REPLACEMENTS = { + '&': '&', + '<': '<', + '>': '>', + '"': '"' + }; + + function replaceUnsafeChar(ch) { + return HTML_REPLACEMENTS[ch]; + } + + function escapeHtml(str) { + if (HTML_ESCAPE_TEST_RE.test(str)) { + return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar); + } + return str; + } + + //////////////////////////////////////////////////////////////////////////////// + + var REGEXP_ESCAPE_RE = /[.?*+^$[\]\\(){}|-]/g; + + function escapeRE(str) { + return str.replace(REGEXP_ESCAPE_RE, '\\$&'); + } + + //////////////////////////////////////////////////////////////////////////////// + + function isSpace(code) { + switch (code) { + case 0x09: + case 0x20: + return true; + } + return false; + } + + // Zs (unicode class) || [\t\f\v\r\n] + function isWhiteSpace(code) { + if (code >= 0x2000 && code <= 0x200A) { return true; } + switch (code) { + case 0x09: // \t + case 0x0A: // \n + case 0x0B: // \v + case 0x0C: // \f + case 0x0D: // \r + case 0x20: + case 0xA0: + case 0x1680: + case 0x202F: + case 0x205F: + case 0x3000: + return true; + } + return false; + } + + //////////////////////////////////////////////////////////////////////////////// + + /*eslint-disable max-len*/ + var UNICODE_PUNCT_RE = __webpack_require__(59); + + // Currently without astral characters support. + function isPunctChar(ch) { + return UNICODE_PUNCT_RE.test(ch); + } + + + // Markdown ASCII punctuation characters. + // + // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~ + // http://spec.commonmark.org/0.15/#ascii-punctuation-character + // + // Don't confuse with unicode punctuation !!! It lacks some chars in ascii range. + // + function isMdAsciiPunct(ch) { + switch (ch) { + case 0x21/* ! */: + case 0x22/* " */: + case 0x23/* # */: + case 0x24/* $ */: + case 0x25/* % */: + case 0x26/* & */: + case 0x27/* ' */: + case 0x28/* ( */: + case 0x29/* ) */: + case 0x2A/* * */: + case 0x2B/* + */: + case 0x2C/* , */: + case 0x2D/* - */: + case 0x2E/* . */: + case 0x2F/* / */: + case 0x3A/* : */: + case 0x3B/* ; */: + case 0x3C/* < */: + case 0x3D/* = */: + case 0x3E/* > */: + case 0x3F/* ? */: + case 0x40/* @ */: + case 0x5B/* [ */: + case 0x5C/* \ */: + case 0x5D/* ] */: + case 0x5E/* ^ */: + case 0x5F/* _ */: + case 0x60/* ` */: + case 0x7B/* { */: + case 0x7C/* | */: + case 0x7D/* } */: + case 0x7E/* ~ */: + return true; + default: + return false; + } + } + + // Hepler to unify [reference labels]. + // + function normalizeReference(str) { + // use .toUpperCase() instead of .toLowerCase() + // here to avoid a conflict with Object.prototype + // members (most notably, `__proto__`) + return str.trim().replace(/\s+/g, ' ').toUpperCase(); + } + + //////////////////////////////////////////////////////////////////////////////// + + // Re-export libraries commonly used in both markdown-it and its plugins, + // so plugins won't have to depend on them explicitly, which reduces their + // bundled size (e.g. a browser build). + // + exports.lib = {}; + exports.lib.mdurl = __webpack_require__(118); + exports.lib.ucmicro = __webpack_require__(450); + + exports.assign = assign; + exports.isString = isString; + exports.has = has; + exports.unescapeMd = unescapeMd; + exports.unescapeAll = unescapeAll; + exports.isValidEntityCode = isValidEntityCode; + exports.fromCodePoint = fromCodePoint; + // exports.replaceEntities = replaceEntities; + exports.escapeHtml = escapeHtml; + exports.arrayReplaceAt = arrayReplaceAt; + exports.isSpace = isSpace; + exports.isWhiteSpace = isWhiteSpace; + exports.isMdAsciiPunct = isMdAsciiPunct; + exports.isPunctChar = isPunctChar; + exports.escapeRE = escapeRE; + exports.normalizeReference = normalizeReference; + + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + /** + * Check if the value is an Array + * + * @param param Value to be checked + * @returns {boolean} Returns true when the `param` is an Array + * + * @example + * isArray([]); // Returns: true + * isArray({}); // Returns: false + * isArray('Hello'); // Returns: false + */ + exports.default = Array.isArray; + //# sourceMappingURL=isArray.js.map + +/***/ }, +/* 3 */ +[823, 395, 2], +/* 4 */ +[825, 397], +/* 5 */ +/***/ function(module, exports) { + + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = arrayContains; + /** + * Check if an array contains a specified item + * + * @param {Array} array The array to check for the item + * @param {*} item The item to look for in the array + * @returns {boolean} Returns true when the item is found, otherwise false + */ + function arrayContains(array, item) { + return Array.prototype.indexOf.call(array, item) !== -1; + } + //# sourceMappingURL=arrayContains.js.map + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + exports.default = arrayFrom; + + var _isArray = __webpack_require__(2); + + var _isArray2 = _interopRequireDefault(_isArray); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + /** + * Create an array from a value + * + * @param {*} param Value to transform to an array + * @param {boolean} [isNewRef] Should return a new reference than the one from the `param` value + * @returns {Array} The resulting array + * + * @requires isArray + */ + function arrayFrom(param, isNewRef) { + var toArray = function toArray(iterable, start, end) { + if (!iterable || !iterable.length) { + return []; + } + + // FIXME: This will never be called as the if check excludes type string + if (typeof iterable === 'string') { + iterable = iterable.split(''); + } + + if (supportsSliceOnNodeList) { + // FIXME: This does not exist + return slice.call(iterable, start || 0, end || iterable.length); + } + + var array = [], + i; + + // FIXME: start and end are always 0 and iterable.length + start = start || 0; + end = end ? end < 0 ? iterable.length + end : end : iterable.length; + + for (i = start; i < end; i++) { + array.push(iterable[i]); + } + + return array; + }; + + if (param === undefined || param === null) { + return []; + } + + if ((0, _isArray2.default)(param)) { + return isNewRef ? Array.prototype.slice.call(param) : param; + } + + var type = typeof param === 'undefined' ? 'undefined' : _typeof(param); + if (param && param.length !== undefined && type !== 'string' && (type !== 'function' || !param.apply)) { + // TODO: This function call will always fail because of supportsSliceOnNodeList being undefined + return toArray(param); + } + + return [param]; + } + //# sourceMappingURL=arrayFrom.js.map + +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.CHART_TYPE_YEAR_OVER_YEAR_COLUMN = exports.CHART_TYPE_YEAR_OVER_YEAR_LINE = exports.CHART_TYPE_GAUGE = exports.CHART_TYPE_RADAR = exports.CHART_TYPE_PIE = exports.CHART_TYPE_AREA = exports.CHART_TYPE_LINE = exports.CHART_TYPE_STACKED_BAR_LEGACY = exports.CHART_TYPE_STACKED_BAR = exports.CHART_TYPE_BAR = exports.CHART_TYPE_STACKED_COLUMN_LEGACY = exports.CHART_TYPE_STACKED_COLUMN = exports.CHART_TYPE_COLUMN = undefined; + exports.getIsStacked = getIsStacked; + exports.isYearOverYear = isYearOverYear; + exports.isDualAxis = isDualAxis; + + exports.default = function (type) { + switch (type) { + case CHART_TYPE_BAR: + case CHART_TYPE_STACKED_BAR: + case CHART_TYPE_STACKED_BAR_LEGACY: + return { type: 'bar' }; + case CHART_TYPE_LINE: + case CHART_TYPE_YEAR_OVER_YEAR_LINE: + return { type: 'line' }; + case CHART_TYPE_AREA: + return { type: 'area' }; + case CHART_TYPE_PIE: + return { type: 'pie' }; + case CHART_TYPE_RADAR: + return { type: 'line', polar: true }; + case CHART_TYPE_GAUGE: + return { type: 'solidgauge' }; + case CHART_TYPE_COLUMN: + case CHART_TYPE_STACKED_COLUMN: + case CHART_TYPE_STACKED_COLUMN_LEGACY: + case CHART_TYPE_YEAR_OVER_YEAR_COLUMN: + default: + return { type: 'column' }; + } + }; + + var _arrayContains = __webpack_require__(29); + + var _arrayContains2 = _interopRequireDefault(_arrayContains); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + var CHART_TYPE_COLUMN = exports.CHART_TYPE_COLUMN = 'COLUMN'; + var CHART_TYPE_STACKED_COLUMN = exports.CHART_TYPE_STACKED_COLUMN = 'STACKED_COLUMN'; + var CHART_TYPE_STACKED_COLUMN_LEGACY = exports.CHART_TYPE_STACKED_COLUMN_LEGACY = 'STACKEDCOLUMN'; + var CHART_TYPE_BAR = exports.CHART_TYPE_BAR = 'BAR'; + var CHART_TYPE_STACKED_BAR = exports.CHART_TYPE_STACKED_BAR = 'STACKED_BAR'; + var CHART_TYPE_STACKED_BAR_LEGACY = exports.CHART_TYPE_STACKED_BAR_LEGACY = 'STACKEDBAR'; + var CHART_TYPE_LINE = exports.CHART_TYPE_LINE = 'LINE'; + var CHART_TYPE_AREA = exports.CHART_TYPE_AREA = 'AREA'; + var CHART_TYPE_PIE = exports.CHART_TYPE_PIE = 'PIE'; + var CHART_TYPE_RADAR = exports.CHART_TYPE_RADAR = 'RADAR'; + var CHART_TYPE_GAUGE = exports.CHART_TYPE_GAUGE = 'GAUGE'; + var CHART_TYPE_YEAR_OVER_YEAR_LINE = exports.CHART_TYPE_YEAR_OVER_YEAR_LINE = 'YEAR_OVER_YEAR_LINE'; + var CHART_TYPE_YEAR_OVER_YEAR_COLUMN = exports.CHART_TYPE_YEAR_OVER_YEAR_COLUMN = 'YEAR_OVER_YEAR_COLUMN'; + + var stackedTypes = [CHART_TYPE_STACKED_COLUMN, CHART_TYPE_STACKED_COLUMN_LEGACY, CHART_TYPE_STACKED_BAR, CHART_TYPE_STACKED_BAR_LEGACY, CHART_TYPE_AREA]; + + var yearOverYearTypes = [CHART_TYPE_YEAR_OVER_YEAR_LINE, CHART_TYPE_YEAR_OVER_YEAR_COLUMN]; + + var dualAxisTypes = [CHART_TYPE_COLUMN, CHART_TYPE_BAR, CHART_TYPE_LINE]; + + function getIsStacked(type) { + return (0, _arrayContains2.default)(stackedTypes, type); + } + + function isYearOverYear(type) { + return (0, _arrayContains2.default)(yearOverYearTypes, type); + } + + function isDualAxis(type) { + return (0, _arrayContains2.default)(dualAxisTypes, type); + } + //# sourceMappingURL=type.js.map + +/***/ }, +/* 8 */ +[825, 208], +/* 9 */ +[821, 386], +/* 10 */ +[815, 2, 3, 4], +/* 11 */ +2, +/* 12 */ +/***/ function(module, exports) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + exports.checkDefined = checkDefined; + exports.checkType = checkType; + exports.isType = isType; + exports.isString = isString; + exports.isArray = isArray; + exports.isObject = isObject; + exports.isDefined = isDefined; + exports.isInteger = isInteger; + exports.isNumeric = isNumeric; + exports.contains = contains; + exports.isValidUid = isValidUid; + exports.areDefinedAndEqual = areDefinedAndEqual; + exports.checkValidRootJunction = checkValidRootJunction; + /** + * @module lib/check + */ + + /** + * + * @param value + * @param name + * @returns {boolean} + */ + function checkDefined(value, name) { + if (value !== undefined) { + return true; + } + throw new Error([name || 'Value', 'should be provided'].join(' ')); + } + + // TODO: Decide if checkType([], 'object') is a 'false' positive + function checkType(value, type, name) { + checkDefined(value, name); + checkDefined(type, 'Type'); + + if (typeof type === 'function' && value instanceof type || typeof type === 'string' && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === type) { + // eslint-disable-line valid-typeof + return true; + } + throw new Error(['Expected', name || value, 'to have type', type].join(' ')); + } + + // TODO: Log type error? + function isType(value, type) { + function noop() {} + + try { + checkType(value, type); + return true; + } catch (e) { + noop(); + } + + return false; + } + + function isString(value) { + return isType(value, 'string'); + } + + function isArray(value) { + return Array.isArray(value); + } + + function isObject(value) { + return isType(value, Object); + } + + function isDefined(value) { + return value != null; + } + + function isInteger(nVal) { + return typeof nVal === 'number' && isFinite(nVal) && nVal > -9007199254740992 && nVal < 9007199254740992 && Math.floor(nVal) === nVal; + } + + // Polyfill for the isInteger function that will be added in ES6 + // http://wiki.ecmascript.org/doku.php?id=harmony:number.isinteger + /* istanbul ignore if */ + if (!Number.isInteger) { + Number.isInteger = isInteger; + } + + function isNumeric(nVal) { + return typeof nVal === 'number' && isFinite(nVal) && nVal - parseFloat(nVal) + 1 >= 0; + } + + function contains(item, list) { + var listToCheck = isArray(list) && list || []; + + return listToCheck.indexOf(item) >= 0; + } + + var isEmpty = exports.isEmpty = function isEmpty(list) { + return list.length === 0; + }; + + /** + * @deprecated Use isValidUid from the `uid.js` file. + */ + function isValidUid(value) { + return value && value.length === 11; + } + + var hasKeys = exports.hasKeys = function hasKeys(object) { + return object && Object.keys(object).length > 0; + }; + + function areDefinedAndEqual(left, right) { + return isDefined(left) && isDefined(right) && right === left; + } + + var toBe = exports.toBe = function toBe(left, right) { + return left === right; + }; + var toBeAny = exports.toBeAny = function toBeAny(values) { + return function (left) { + return values.some(function (right) { + return toBe(left, right); + }); + }; + }; + var isNullUndefinedOrEmptyString = exports.isNullUndefinedOrEmptyString = toBeAny([undefined, null, '']); + + var isFunction = exports.isFunction = function isFunction(fun) { + return typeof fun === 'function'; + }; + + var hasOwnProperty = exports.hasOwnProperty = function hasOwnProperty(object, propertyName) { + return Object.prototype.hasOwnProperty.call(object, propertyName); + }; + + // The logical mode to use when having multiple filters. + // Default is AND. + // See https://docs.dhis2.org/master/en/developer/html/webapi_metadata_object_filter.html + + var rootJunctions = exports.rootJunctions = ['OR', 'AND']; + var isValidRootJunction = exports.isValidRootJunction = toBeAny(rootJunctions); + function checkValidRootJunction(rootJunction) { + checkType(rootJunction, 'string', 'rootJunction'); + + if (isValidRootJunction(rootJunction)) { + return true; + } + throw new Error('Expected ' + rootJunction + ' to be one of [' + rootJunctions + ']'); + } + //# sourceMappingURL=check.js.map + +/***/ }, +/* 13 */ +[811, 41], +/* 14 */ +[813, 4, 9, 2, 3], +/* 15 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global) {'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** + * @module api + */ + /* global window fetch Headers */ + + + __webpack_require__(510); + + var _check = __webpack_require__(12); + + var _utils = __webpack_require__(23); + + var _System = __webpack_require__(460); + + var _System2 = _interopRequireDefault(_System); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + function getMergeStrategyParam() { + var mergeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'REPLACE'; + + var system = _System2.default.getSystem(); + + if (system.version && Number(system.version.minor) <= 22) { + return 'mergeStrategy=' + mergeType; + } + + return 'mergeMode=' + mergeType; + } + + function getUrl(baseUrl, url) { + // If we are dealing with an absolute url use that instead + if (new RegExp('^(:?https?:)?//').test(url)) { + return url; + } + + var urlParts = []; + + if (baseUrl) { + urlParts.push(baseUrl); + } + urlParts.push(url); + + return urlParts.join('/').replace(new RegExp('(.(?:[^:]))//+', 'g'), '$1/').replace(new RegExp('/$'), ''); + } + + /** + * @description + * Used for interaction with the dhis2 api. + * + * This class is used as the backbone for d2 and handles all the interaction with the server. There is a singleton + * available to be reused across your applications. The singleton can be grabbed from the d2 instance. + * + * ```js + * import { getInstance } from 'd2/lib/d2'; + * + * getInstance() + * .then(d2 => { + * const api = d2.Api.getApi() // Returns the Api singleton. + * + * api.get('resources'); + * }); + * ``` + * + * Uses {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API|Fetch} to do network requests. + * + * @memberof module:api + */ + + var Api = function () { + /** + * @constructor + * + * @param {Fetch} [fetchImpl] The fetch implementation to use. Can be used to pass a different implementation + * similar to the fetch Api. Will default to `window.fetch` in a browser context. + */ + function Api(fetchImpl) { + _classCallCheck(this, Api); + + // Optionally provide fetch to the constructor so it can be mocked during testing + if (typeof fetchImpl === 'function') { + this.fetch = fetchImpl.bind(typeof window !== 'undefined' ? window : global); + } else if (typeof fetch !== 'undefined') { + this.fetch = fetch.bind(typeof window !== 'undefined' ? window : global); + } else { + throw new Error('Failed to initialise D2 Api: No fetch implementation is available'); + } + + this.baseUrl = '/api'; + this.defaultFetchOptions = { + mode: 'cors', // requests to different origins fail + credentials: 'include', // include cookies with same-origin requests + cache: 'default' // See https://fetch.spec.whatwg.org/#concept-request-cache-mode + }; + this.defaultHeaders = { + 'X-Requested-With': 'XMLHttpRequest' + }; + + this.unauthorizedCallback = null; + } + + /** + * Used for setting default headers that should be send with every request. + * + * @example + * const api = Api.getApi(); + * + * api.setDefaultHeaders({ + * 'x-requested-with': 'XMLHttpRequest', // Make sure the Api does not redirect when authorization is expired. + * }); + * + * @param {Object.} headers Default headers that should be set on every request. + */ + + + _createClass(Api, [{ + key: 'setDefaultHeaders', + value: function setDefaultHeaders(headers) { + this.defaultHeaders = headers; + } + + /** + * When any request encounters a 401 - Unauthorized. This callback is called. + * Useful for when you want an session expiration-handler API-wide. + * + * @param {*} cb - Function to call when any request recieves a 401. Called with the response from the server. + */ + + }, { + key: 'setUnauthorizedCallback', + value: function setUnauthorizedCallback(cb) { + if (typeof cb !== 'function') { + throw new Error('Callback must be a function.'); + } + this.unauthorizedCallback = cb; + } + + /** + * Performs a GET request. + * + * @param {string} url The url for the request + * @param {*} data Any data that should be send with the request. For a GET request these are turned into + * query parameters. For POST and PUT requests it becomes the body. + * @param {Object.} options The request options are passed as options to the fetch request. + * These options are passed as the {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters|init} + * parameter to the fetch request. + * + * @returns {Promise.<*>} The response body. + */ + + }, { + key: 'get', + value: function get(url, data, options) { + return this.request('GET', getUrl(this.baseUrl, url), data, options); + } + + /* eslint-disable complexity */ + /** + * Performs a POST request. + * + * @param {string} url The url for the request + * @param {*} data Any data that should be send with the request this becomes the body for the POST request + * @param {Object.} options The request options are passed as options to the fetch request. + * These options are passed as the {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters|init} + * parameter to the fetch request. + * + * @returns {Promise.<*>} The response body. + */ + + }, { + key: 'post', + value: function post(url, data) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + var requestUrl = getUrl(this.baseUrl, url); + var payload = data; + + // Ensure that headers are defined and are treated without case sensitivity + options.headers = new Headers(options.headers || {}); // eslint-disable-line + + if (data !== undefined) { + if (data.constructor.name === 'FormData') { + // Ensure that the browser will set the correct Content-Type header for FormData, including boundary + options.headers.delete('Content-Type'); + payload = data; + } else if (options.headers.has('Content-Type') && options.headers.get('Content-Type').toLocaleLowerCase().startsWith('text/')) { + payload = String(data); + } else { + // Send JSON data by default + options.headers.set('Content-Type', 'application/json'); + payload = JSON.stringify(data); + } + } + + return this.request('POST', requestUrl, payload, options); + } + /** + * Performs a DELETE request. + * + * @param {string} url The url for the request + * @param {Object.} options The request options are passed as options to the fetch request. + * These options are passed as the {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters|init} + * parameter to the fetch request. + * + * @returns {Promise.<*>} The response body. + */ + /* eslint-enable complexity */ + + }, { + key: 'delete', + value: function _delete(url, options) { + return this.request('DELETE', getUrl(this.baseUrl, url), undefined, options); + } + + /** + * Perform a PUT request. + * + * @param {string} url The url for the request + * @param {*} data Any data that should be send with the request. This becomes the body of the PUT request. + * @param {boolean} [useMergeStrategy=false] + * + * @returns {Promise.<*>} The response body. + */ + + }, { + key: 'update', + value: function update(url, data) { + var useMergeStrategy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + + // Since we are currently using PUT to save the full state back, we have to use mergeMode=REPLACE + // to clear out existing values + var urlForUpdate = useMergeStrategy === true ? url + '?' + getMergeStrategyParam() : url; + if (typeof data === 'string') { + return this.request('PUT', getUrl(this.baseUrl, urlForUpdate), String(data), { headers: new Headers({ 'Content-Type': 'text/plain' }) }); + } + + return this.request('PUT', getUrl(this.baseUrl, urlForUpdate), JSON.stringify(data)); + } + + /** + * Perform a PATCH request. + * + * @param {string} url The url for the request + * @param {*} data Any data that should be send with the request. This becomes the body of the PATCH request. + * + * @returns {Promise.<*>} The response body. + */ + + }, { + key: 'patch', + value: function patch(url, data) { + return this.request('PATCH', getUrl(this.baseUrl, url), JSON.stringify(data)); + } + + /** + * General purpose request function for making http requests. + * + * The more specific functions like `delete`, `post` and `get`, utilize this function to make the requests. + * + * @param {string} method The HTTP request method (e.g. POST/GET/PATCH) + * @param {string} url The url for the request + * @param {*} data Any data that should be send with the request. For a GET request these are turned into + * query parameters. For POST and PUT requests it becomes the body. + * @param {Object.} options The request options are passed as options to the fetch request. + * These options are passed as the {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters|init} + * parameter to the fetch request. + * + * @returns {Promise.<*>} The response body. + */ + /* eslint-disable complexity */ + + }, { + key: 'request', + value: function request(method, url, data) { + var _this = this; + + var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; + + (0, _check.checkType)(method, 'string', 'Request type'); + (0, _check.checkType)(url, 'string', 'Url'); + var api = this; + var requestUrl = url; + var query = ''; + + if (requestUrl.indexOf('?') !== -1) { + query = requestUrl.substr(requestUrl.indexOf('?') + 1); + requestUrl = requestUrl.substr(0, requestUrl.indexOf('?')); + } + + // Transfer filter properties from the data object to the query string + if (data && Array.isArray(data.filter)) { + var encodedFilters = data.filter.map(function (filter) { + return filter.split(':').map(encodeURIComponent).join(':'); + }); + + query = '' + (0, _utils.customEncodeURIComponent)(query) + (query.length ? '&' : '') + ('filter=' + encodedFilters.join('&filter=')); + delete data.filter; // eslint-disable-line no-param-reassign + } + + // When using the GET method, transform the data object to query parameters + if (data && method === 'GET') { + Object.keys(data).forEach(function (key) { + query = '' + query + (query.length > 0 ? '&' : '') + (encodeURIComponent(key) + '=' + encodeURIComponent(data[key])); + }); + } + + function getOptions(defaultHeaders, mergeOptions, requestData) { + var resultOptions = Object.assign({}, api.defaultFetchOptions, mergeOptions); + var headers = new Headers(mergeOptions.headers || {}); + + Object.keys(defaultHeaders).filter(function (header) { + return !headers.get(header); + }).forEach(function (header) { + return headers.set(header, defaultHeaders[header]); + }); + + resultOptions.method = method; + + // Only set content type when there is data to send + // GET requests and requests without data do not need a Content-Type header + // 0 and false are valid requestData values and therefore should have a content type + if (resultOptions.method === 'GET' || !requestData && requestData !== 0 && requestData !== false) { + headers.delete('Content-Type'); + } else if (requestData) { + if (data.constructor.name === 'FormData') { + headers.delete('Content-Type'); + } else if (!headers.get('Content-Type')) { + headers.set('Content-Type', 'application/json'); + } + resultOptions.body = requestData; + } + + resultOptions.headers = headers; + return resultOptions; + } + + if (query.length) { + requestUrl = requestUrl + '?' + query; + } + var requestOptions = getOptions(this.defaultHeaders, options, data); + + // If the provided value is valid JSON, return the parsed JSON object. If not, return the raw value as is. + function parseResponseData(value) { + try { + return JSON.parse(value); + } catch (e) { + return value; + } + } + + return new Promise(function (resolve, reject) { + // fetch returns a promise that will resolve with any response received from the server + // It will be rejected ONLY if no response is received from the server, i.e. because there's no internet + _this.fetch(requestUrl, requestOptions).then(function (response) { + // If the request failed, response.ok will be false and response.status will be the status code + if (response.ok) { + response.text().then(function (text) { + return resolve(parseResponseData(text)); + }); + } else { + response.text().then(function (text) { + var parsedResponseData = parseResponseData(text); + if (response.status === 401) { + var request = { + method: method, + url: url, + data: data, + options: options + }; + if (_this.unauthorizedCallback) { + _this.unauthorizedCallback(request, parsedResponseData); + } + } + if (!({"NODE_ENV":'production'}) || ({"NODE_ENV":'production'}).npm_lifecycle_event !== 'test') { + console.warn( // eslint-disable-line + 'API request failed with status ' + response.status + ' ' + response.statusText + '\n', 'Request: ' + requestOptions.method + ' ' + requestUrl); + } + reject(parsedResponseData); + }); + } + }).catch(function (err) { + // It's not usually possible to get much info about the cause of the error programmatically, but + // the user can check the browser console for more info + if (!({"NODE_ENV":'production'}) || ({"NODE_ENV":'production'}).npm_lifecycle_event !== 'test') { + console.error('Server connection error:', err); // eslint-disable-line + } + + reject('Server connection failed for API request: ' + requestOptions.method + ' ' + requestUrl); + }); + }); + } + /* eslint-enable complexity */ + + /** + * Sets the baseUrl that should be used for the api. + * + * When working against the dhis2 demo instance at {@link https://play.dhis2.org/demo} the + * baseUrl would be set as `https://play.dhis2.org/demo/api`. + * + * This method is used when calling the `d2.init` method with the `baseUrl` config property + * to configure the Api singleton. + * + * @param {string} baseUrl The base url to be used for the API. + * + * @returns {this} Itself for chaining purposes + */ + + }, { + key: 'setBaseUrl', + value: function setBaseUrl(baseUrl) { + (0, _check.checkType)(baseUrl, 'string', 'Base url'); + + this.baseUrl = baseUrl; + + return this; + } + }]); + + return Api; + }(); + + /** + * Retrieve the Api singleton or create one. + * + * When called for the first time it creates and Api singleton object. + * Any subsequent calls will return the previously created singleton. + * + * @returns {Api} The Api singleton. + * @memberof module:api~Api + */ + + + function getApi() { + if (getApi.api) { + return getApi.api; + } + return getApi.api = new Api(); + } + + Api.getApi = getApi; + + exports.default = Api; + //# sourceMappingURL=Api.js.map + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }, +/* 16 */, +/* 17 */, +/* 18 */ +/***/ function(module, exports) { + + /* WEBPACK VAR INJECTION */(function(global) {'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + exports.default = isNumeric; + /** + * Check if a value is numeric + * + * @param param Value to be checked + * @returns {boolean} Returns true when the `param` is a numeric value + */ + function isNumeric(param) { + if ((typeof param === 'undefined' ? 'undefined' : _typeof(param)) === 'symbol') { + return false; + } + + return !isNaN(parseFloat(param)) && global.isFinite(param); + } + //# sourceMappingURL=isNumeric.js.map + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }, +/* 19 */ +/***/ function(module, exports) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + var VALUE_CELL = exports.VALUE_CELL = 'value'; + var SUB_TOTAL_CELL = exports.SUB_TOTAL_CELL = 'valueSubtotals'; + var TOTAL_CELL = exports.TOTAL_CELL = 'valueTotal'; + var DIMENSION_CELL = exports.DIMENSION_CELL = 'dimension'; + var DIMENSION_SUB_TOTAL_CELL = exports.DIMENSION_SUB_TOTAL_CELL = 'dimensionSubtotal'; + var DIMENSION_TOTAL_CELL = exports.DIMENSION_TOTAL_CELL = 'dimensionTotal'; + var EMPTY_CELL = exports.EMPTY_CELL = 'empty'; + var LABELED_CELL = exports.LABELED_CELL = 'labeled'; + var PADDING_CELL = exports.PADDING_CELL = 'padding'; + var FILTER_CELL = exports.FILTER_CELL = 'filter'; + + var TOTAL_SORT = exports.TOTAL_SORT = 'total'; + + var COLUMN_AXIS = exports.COLUMN_AXIS = 'column'; + var ROW_AXIS = exports.ROW_AXIS = 'row'; + + var FIXED_STRATEGY = exports.FIXED_STRATEGY = 'fixed'; + var BY_DATA_ITEM_STRATEGY = exports.BY_DATA_ITEM_STRATEGY = 'by_data_item'; + + var FILL_STYLE = exports.FILL_STYLE = 'fill'; + var TEXT_STYLE = exports.TEXT_STYLE = 'text'; + + var NO_BREAK_SPACE = exports.NO_BREAK_SPACE = ' '; + + var BLACK_COLOR = exports.BLACK_COLOR = 'black'; + var WHITE_COLOR = exports.WHITE_COLOR = 'white'; + + var AVERAGE_AGGREGATION_TOTAL = exports.AVERAGE_AGGREGATION_TOTAL = 'AVERAGE'; + var SUM_AGGREGATION_TOTAL = exports.SUM_AGGREGATION_TOTAL = 'SUM'; + var NA_AGGREGATION_TOTAL = exports.NA_AGGREGATION_TOTAL = 'N/A'; + + var DEFAULT_NUMBER_DECIMALS = exports.DEFAULT_NUMBER_DECIMALS = 1; + var SMALL_NUMBER_DECIMALS = exports.SMALL_NUMBER_DECIMALS = 2; + var SKIP_ROUNDING_NUMBER_DECIMALS = exports.SKIP_ROUNDING_NUMBER_DECIMALS = 10; + + var NUMBER_VALUE_TYPE = exports.NUMBER_VALUE_TYPE = 'NUMBER'; + var BOOLEAN_VALUE_TYPE = exports.BOOLEAN_VALUE_TYPE = 'BOOLEAN'; + var DATE_VALUE_TYPE = exports.DATE_VALUE_TYPE = 'DATE'; + var FILE_RESOURCE_VALUE_TYPE = exports.FILE_RESOURCE_VALUE_TYPE = 'FILE_RESOURCE'; + var COORDINATE_VALUE_TYPE = exports.COORDINATE_VALUE_TYPE = 'COORDINATE'; + var TEXT_VALUE_TYPE = exports.TEXT_VALUE_TYPE = 'TEXT'; + + var PIVOT_TABLE_CELLS = exports.PIVOT_TABLE_CELLS = { + VALUE_CELL: VALUE_CELL, + SUB_TOTAL_CELL: SUB_TOTAL_CELL, + TOTAL_CELL: TOTAL_CELL, + DIMENSION_CELL: DIMENSION_CELL, + DIMENSION_SUB_TOTAL_CELL: DIMENSION_SUB_TOTAL_CELL, + DIMENSION_TOTAL_CELL: DIMENSION_TOTAL_CELL, + EMPTY_CELL: EMPTY_CELL, + LABELED_CELL: LABELED_CELL, + PADDING_CELL: PADDING_CELL, + FILTER_CELL: FILTER_CELL + }; + + var PIVOT_TABLE_AXIS = exports.PIVOT_TABLE_AXIS = { + COLUMN_AXIS: COLUMN_AXIS, + ROW_AXIS: ROW_AXIS + }; + + var PIVOT_TABLE_SORT_OPTIONS = exports.PIVOT_TABLE_SORT_OPTIONS = { + TOTAL_SORT: TOTAL_SORT + }; + + var PIVOT_TABLE_LEGEND_SET_OPTIONS = exports.PIVOT_TABLE_LEGEND_SET_OPTIONS = { + FIXED_STRATEGY: FIXED_STRATEGY, + BY_DATA_ITEM_STRATEGY: BY_DATA_ITEM_STRATEGY, + FILL_STYLE: FILL_STYLE, + TEXT_STYLE: TEXT_STYLE + }; + + var PIVOT_TABLE_HTML = exports.PIVOT_TABLE_HTML = { + NO_BREAK_SPACE: NO_BREAK_SPACE + }; + + exports.default = { + VALUE_CELL: VALUE_CELL, + SUB_TOTAL_CELL: SUB_TOTAL_CELL, + TOTAL_CELL: TOTAL_CELL, + DIMENSION_CELL: DIMENSION_CELL, + DIMENSION_SUB_TOTAL_CELL: DIMENSION_SUB_TOTAL_CELL, + DIMENSION_TOTAL_CELL: DIMENSION_TOTAL_CELL, + EMPTY_CELL: EMPTY_CELL, + LABELED_CELL: LABELED_CELL, + PADDING_CELL: PADDING_CELL, + FILTER_CELL: FILTER_CELL, + TOTAL_SORT: TOTAL_SORT, + COLUMN_AXIS: COLUMN_AXIS, + ROW_AXIS: ROW_AXIS, + FIXED_STRATEGY: FIXED_STRATEGY, + BY_DATA_ITEM_STRATEGY: BY_DATA_ITEM_STRATEGY, + FILL_STYLE: FILL_STYLE, + TEXT_STYLE: TEXT_STYLE, + NO_BREAK_SPACE: NO_BREAK_SPACE + }; + //# sourceMappingURL=PivotTableConstants.js.map + +/***/ }, +/* 20 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _lodash = __webpack_require__(393); + + var _lodash2 = _interopRequireDefault(_lodash); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + /** + * Check if the value is a Function + * + * @name isFunction + * @param {*} param Value to be checked + * @returns {boolean} Returns true when the `param` is a Function + */ + exports.default = _lodash2.default; + //# sourceMappingURL=isFunction.js.map + +/***/ }, +/* 21 */ +[823, 206, 11], +/* 22 */ +/***/ function(module, exports) { + + // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 + var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); + if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef + +/***/ }, +/* 23 */ +/***/ function(module, exports) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + exports.throwError = throwError; + exports.curry = curry; + exports.addLockedProperty = addLockedProperty; + exports.copyOwnProperties = copyOwnProperties; + exports.pick = pick; + exports.updateAPIUrlWithBaseUrlVersionNumber = updateAPIUrlWithBaseUrlVersionNumber; + exports.customEncodeURIComponent = customEncodeURIComponent; + exports.identity = identity; + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + /** + * @module lib/utils + */ + + function throwError(message) { + throw new Error(message); + } + + // TODO: Throw an error when `toCurry` is not a function + function curry(toCurry, parameter) { + return function curried() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return toCurry.apply(this, [parameter].concat(args)); + }; + } + + function addLockedProperty(object, name, value) { + var propertyDescriptor = { + enumerable: true, + configurable: false, + writable: false, + value: value + }; + Object.defineProperty(object, name, propertyDescriptor); + } + + function copyOwnProperties(to, from) { + Object.keys(from).filter(function (key) { + return from.hasOwnProperty(key); + }).forEach(function (key) { + to[key] = from[key]; // eslint-disable-line no-param-reassign + }); + + return to; + } + + /** + * Curried get function to pick a property from an object + * Will safely pick a property from an object and guards against the infamous "can not read property of undefined". + * + * @param {String} propertyPath + * @param {Any} defaultValue A default value to be returned when no value was found at the path + * @returns Function + * + * get :: String -> Object -> Any + */ + function pick(propertyPath) { + var propertiesToGet = propertyPath.split('.'); + + return function (item) { + return propertiesToGet.reduce(function (result, property) { + if (result) { + return result[property]; + } + return undefined; + }, item); + }; + } + + var pickOr = exports.pickOr = function pickOr(pathProperty, defaultValue) { + return function (item) { + var pathResult = pick(pathProperty)(item); + + return pathResult !== undefined ? pathResult : defaultValue; + }; + }; + + var Deferred = exports.Deferred = function () { + function Deferred() { + var _this = this; + + _classCallCheck(this, Deferred); + + this.promise = new Promise(function (resolve, reject) { + _this.resolve = resolve; + _this.reject = reject; + }); + } + + _createClass(Deferred, null, [{ + key: 'create', + value: function create() { + return new Deferred(); + } + }]); + + return Deferred; + }(); + + function updateAPIUrlWithBaseUrlVersionNumber(apiUrl, baseUrl) { + if (!baseUrl || !apiUrl) { + return apiUrl; + } + + var apiUrlWithVersionRexExp = /api\/([1-9][0-9])/; + var apiVersionMatch = baseUrl.match(apiUrlWithVersionRexExp); + + var baseUrlHasVersion = apiVersionMatch && apiVersionMatch[1]; + var apiUrlHasVersion = apiUrl && !apiUrlWithVersionRexExp.test(apiUrl); + + if (baseUrlHasVersion && apiUrlHasVersion) { + var version = apiVersionMatch[1]; + + // Inject the current api version number into the endPoint urls + return apiUrl.replace(/api/, 'api/' + version); + } + + return apiUrl; + } + + // Define our very own special list of characters that we don't want to encode in the URI + var whitelistURI = ',&$=/;:'; + var whitelistURICodes = whitelistURI.split('').map(function (c) { + return encodeURIComponent(c); + }); + var whitelistRegExp = new RegExp('(?:' + whitelistURICodes.join('|') + ')', 'g'); + + /** + * Encode all invalid URI characters, except the ones we've decided we don't want to + */ + function customEncodeURIComponent(uri) { + // return uri; + return encodeURIComponent(uri).replace(whitelistRegExp, decodeURIComponent); + } + + function identity(value) { + return value; + } + //# sourceMappingURL=utils.js.map + +/***/ }, +/* 24 */ +/***/ function(module, exports) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + var scrollbarWidth = /\bchrome\b/.test(navigator.userAgent.toLowerCase()) ? 8 : 17; + + exports.default = { + nameCmpWidth: 440 - scrollbarWidth, + buttonCmpWidth: 20, + operatorCmpWidth: 70, + searchCmpWidth: 70, + triggerCmpWidth: 17, + valueCmpWidth: 235, + rangeSetWidth: 135, + namePadding: '3px 3px', + margin: '3px 0 1px', + removeCmpStyle: 'padding: 0; margin-left: 3px', + defaultRangeSetId: 'default' + }; + //# sourceMappingURL=containerConfig.js.map + +/***/ }, +/* 25 */ +/***/ function(module, exports) { + + var core = module.exports = { version: '2.6.9' }; + if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef + + +/***/ }, +/* 26 */ +/***/ function(module, exports) { + + // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 + var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self + // eslint-disable-next-line no-new-func + : Function('return this')(); + if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef + + +/***/ }, +/* 27 */ +/***/ function(module, exports) { + + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = arrayUnique; + /** + * Creates an array of unique values from the array passed. This function does not do a _deep_ compare. + * Objects with the same values will therefore not be filtered. + * + * @param {Array} array The array to create the array of uniques from + * @returns {Array} The array containing the unique values + * + * @throws {TypeError} Is thrown when the argument passed is not an `array` + * + * @example + * const sourceArray = [1, 1, 2, 3, 2, 4, 4, 3]; + * arrayUnique(sourceArray); // returns: [1, 2, 3, 4] + * + * @example + * const A = {name: 'A'}; + * const B = {name: 'B'}; + * arrayUnique([A, A, B, B]); // Returns: [{name: 'A'}, {name: 'B'}] + * + * @example + * const sourceArray = [{name: 'A'}, {name: 'B'}, {name: 'B'}]; + * arrayUnique(sourceArray); // Returns: [{name: 'A'}, {name: 'B'}, {name: 'B'}] + */ + function arrayUnique(array) { + // TODO: Could be written as `return [...(new Set(array))];` + var newArray = []; + var i = 0; + var len = array.length; + var item; + + for (; i < len; i++) { + item = array[i]; + + if (newArray.indexOf(item) === -1) { + newArray.push(item); + } + } + + return newArray; + } + //# sourceMappingURL=arrayUnique.js.map + +/***/ }, +/* 28 */ +[817, 392], +/* 29 */ +5, +/* 30 */ +/***/ function(module, exports) { + + module.exports = function(module) { + if(!module.webpackPolyfill) { + module.deprecate = function() {}; + module.paths = []; + // module.parent = undefined by default + module.children = []; + module.webpackPolyfill = 1; + } + return module; + } + + +/***/ }, +/* 31 */ +/***/ function(module, exports) { + + module.exports = function(it){ + return typeof it === 'object' ? it !== null : typeof it === 'function'; + }; + +/***/ }, +/* 32 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = cleanObject; + + var _isEmpty = __webpack_require__(46); + + var _isEmpty2 = _interopRequireDefault(_isEmpty); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + /** + * Applies properties from "config" if they are undefined in "object. + * + * @param {Object} object The object to be cleaned + * @param {Function} isEmptyFn Optional isEmpty function + * @returns {Object} A new cleaned object + * + * @example + * let object = {id: 1, name: undefined} + * objectClean(object); // returns: {id: 1} + */ + + function cleanObject(object) { + var isEmptyFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _isEmpty2.default; + + return Object.keys(object).reduce(function (acc, key) { + if (!isEmptyFn(object[key])) { + acc[key] = object[key]; + } + return acc; + }, {}); + } + //# sourceMappingURL=objectClean.js.map + +/***/ }, +/* 33 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.DateManager = undefined; + + var _isString = __webpack_require__(4); + + var _isString2 = _interopRequireDefault(_isString); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + var _DateManager; + + exports.DateManager = _DateManager; + exports.DateManager = _DateManager = function DateManager() { + this.klass = _DateManager; + }; + + _DateManager.toDate = function (dateString) { + return (0, _isString2.default)(dateString) ? new Date(dateString) : dateString; + }; + + _DateManager.isValid = function (param) { + param = this.toDate(param); + return Object.prototype.toString.call(param) === '[object Date]' && param.toString() !== 'Invalid Date'; + }; + + _DateManager.getYYYYMMDD = function (param, skipValidation) { + param = this.toDate(param); + + if (!skipValidation && !_DateManager.isValid(param)) { + return null; + } + + var date = new Date(param), + month = '' + (1 + date.getMonth()), + day = '' + date.getDate(); + + month = month.length === 1 ? '0' + month : month; + day = day.length === 1 ? '0' + day : day; + + return date.getFullYear() + '-' + month + '-' + day; + }; + + _DateManager.getTimeDifference = function (date) { + var seconds = Math.floor((new Date() - new Date(date)) / 1000); + + // Dirty hack to avoid having negative time due to difference between client zone and server zone + while (seconds < 0) { + seconds += 3600; + } + var interval = Math.floor(seconds / 31536000); + + if (interval > 1) { + return interval + " years"; + } + interval = Math.floor(seconds / 2592000); + if (interval > 1) { + return interval + " months"; + } + interval = Math.floor(seconds / 86400); + if (interval > 1) { + return interval + " days"; + } + interval = Math.floor(seconds / 3600); + if (interval > 1) { + return interval + " hours"; + } + interval = Math.floor(seconds / 60); + if (interval > 1) { + return interval + " minutes"; + } + return Math.floor(seconds) + " seconds"; + }; + //# sourceMappingURL=DateManager.js.map + +/***/ }, +/* 34 */ +/***/ function(module, exports) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + var textfieldStyle = ['padding-right: 0', 'padding-left: 5px', 'border-color: transparent', 'background: none', 'font-size: 11px', 'line-height: 13px']; + + var textFieldLabelStyle = ['font-size: 11px', 'font-weight: bold', 'color: #111', 'padding-left: 5px', 'padding-top: 4px', 'margin-bottom: 0']; + + var toggleBtnWidth = 22; + var toggleBtnMarginTop = 48; + var toggleBtnMarginRight = 7; + var toggleBtnMarginLeft = 10; + + var windowWidth = 700; + var borderWidth = 14; + var filtersComboBoxWidth = 160; + var windowCmpWidth = windowWidth - borderWidth; + + var createdColWidth = 120; + var lastUpdatedColWidth = 120; + var buttonColWidth = 60; + var paddingColWidth = 8; + + exports.default = { + textfieldStyle: textfieldStyle, + textFieldLabelStyle: textFieldLabelStyle, + toggleBtnWidth: toggleBtnWidth, + toggleBtnMarginTop: toggleBtnMarginTop, + toggleBtnMarginRight: toggleBtnMarginRight, + toggleBtnMarginLeft: toggleBtnMarginLeft, + windowWidth: windowWidth, + borderWidth: borderWidth, + windowCmpWidth: windowCmpWidth, + filtersComboBoxWidth: filtersComboBoxWidth, + createdColWidth: createdColWidth, + lastUpdatedColWidth: lastUpdatedColWidth, + buttonColWidth: buttonColWidth, + paddingColWidth: paddingColWidth + }; + //# sourceMappingURL=FavoriteStyle.js.map + +/***/ }, +/* 35 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.InterpretationWindow = undefined; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + var _SharingWindow = __webpack_require__(36); + + var _MentionToolbar = __webpack_require__(91); + + var _permissions = __webpack_require__(93); + + var _dom = __webpack_require__(37); + + var InterpretationWindow = exports.InterpretationWindow = undefined; + + exports.InterpretationWindow = InterpretationWindow = function InterpretationWindow(c, sharing, interpretation, success, options) { + var _ref = options || {}, + _ref$renderText = _ref.renderText, + renderText = _ref$renderText === undefined ? true : _ref$renderText, + _ref$renderSharing = _ref.renderSharing, + renderSharing = _ref$renderSharing === undefined ? true : _ref$renderSharing; + + var appManager = c.appManager, + uiManager = c.uiManager, + instanceManager = c.instanceManager, + i18n = c.i18nManager.get(), + apiPath = appManager.getApiPath(), + apiResource = instanceManager.apiResource, + apiEndpoint = instanceManager.apiEndpoint; + + var textArea = Ext.create('Ext.form.field.TextArea', { + cls: 'ns-textarea', + height: 130, + width: 407, + fieldStyle: 'padding-left:3px; padding-top:3px', + emptyText: i18n.write_your_interpretation + '...', + enableKeyEvents: true, + value: interpretation ? interpretation.text : undefined, + mentionToolbar: (0, _MentionToolbar.MentionToolbar)(c), + listeners: { + keyup: function keyup(f, e) { + shareButton.xable(); + this.mentionToolbar.displayMentionSuggestion(f, e); + }, + keydown: _dom.onMarkdownEditorKeyDown, + destroy: function destroy(f, e) { + this.mentionToolbar.destroy(); + } + } + }); + + var getSharingWithModel = function getSharingWithModel(sharing) { + return _extends({}, sharing, { + object: _extends({}, sharing.object, { modelName: "interpretation", name: "" }) + }); + }; + + var sharingCmp = renderSharing && sharing ? new _SharingWindow.SharingWindow(c, getSharingWithModel(sharing), true) : null; + + var sharingCt = Ext.create('Ext.container.Container', { + style: 'padding-top:10px; padding-bottom:25px', + items: sharingCmp ? sharingCmp.items : [] + }); + + var method = interpretation ? 'PUT' : 'POST'; + + var interpretationSuccess = function interpretationSuccess(text) { + if (interpretation) { + interpretation.text = text; + } + if (success) { + success(); + } else { + instanceManager.getById(null, function (layout, isFavorite) { + instanceManager.getReport(layout, isFavorite, false, false, function () { + uiManager.unmask(); + }); + }); + } + }; + + var updateSharing = function updateSharing(response, text) { + var interpretationId = interpretation ? interpretation.id : (response.getResponseHeader('location') || '').split('/').pop(), + sharingId = sharing.object.id, + sharingBody = sharingCmp.getBody(); + + Ext.Ajax.request({ + url: encodeURI(apiPath + '/sharing?type=interpretation&id=' + interpretationId), + method: method, + headers: { + 'Content-Type': 'application/json' + }, + params: Ext.encode(sharingBody), + success: function success() { + // Reload favorite to update interpretation sharings in the global object + instanceManager.getById(null, function (layout, isFavorite) { + instanceManager.getReport(layout, isFavorite, false, false, function () { + uiManager.unmask(); + }); + }); + }, + callback: function callback() { + if (text) { + interpretationSuccess(text); + } + } + }); + }; + + var shareButton = Ext.create('Ext.button.Button', { + text: interpretation ? i18n.update : i18n.share, + disabled: !interpretation, + xable: function xable() { + this.setDisabled(!textArea.getValue()); + }, + handler: function handler() { + if (sharingCmp) { + var showSharingError = function showSharingError() { + var errorMessage = i18n.validation_error_interpretation_sharing; + uiManager.alert(errorMessage); + }; + var favorite = instanceManager.getStateFavorite(); + var newSharing = sharingCmp.getBody().object; + + if (!(0, _permissions.validateSharing)("interpretation", favorite, newSharing, showSharingError)) { + return; + } + } + + var text = textArea.getValue(); + var interpretationPath = interpretation ? '/interpretations/' + interpretation.id : '/interpretations/' + apiResource + '/' + instanceManager.getStateFavoriteId(); + + if (renderText) { + Ext.Ajax.request({ + url: encodeURI(apiPath + interpretationPath), + method: method, + params: text, + headers: { 'Content-Type': 'text/html' }, + success: function success(response) { + sharing ? updateSharing(response, text) : interpretationSuccess(text); + textArea.reset(); + window.destroy(); + } + }); + } else if (renderSharing && sharing) { + updateSharing(); + window.destroy(); + } + } + }); + + var window = Ext.create('Ext.window.Window', { + title: renderText ? i18n.write_interpretation : i18n.sharing_settings, + layout: 'fit', + bodyStyle: 'padding:4px; background-color:#fff', + resizable: false, + destroyOnBlur: true, + modal: true, + items: [renderText && textArea, renderSharing && sharingCt].filter(function (item) { + return item; + }), + bbar: { + cls: 'ns-toolbar-bbar', + defaults: { + height: 24 + }, + items: ['->', shareButton] + }, + listeners: { + show: function show(w) { + uiManager.setAnchorPosition(w, 'favoriteButton', { y: 130 }); + + uiManager.enableRightClick(); + + if (!w.hasDestroyOnBlurHandler) { + uiManager.addDestroyOnBlurHandler(w); + } + }, + hide: function hide() { + uiManager.disableRightClick(); + } + } + }); + uiManager.reg(window, 'interpretationWindow'); + + return window; + }; + //# sourceMappingURL=InterpretationWindow.js.map + +/***/ }, +/* 36 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.SharingWindow = undefined; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + var _isArray = __webpack_require__(2); + + var _isArray2 = _interopRequireDefault(_isArray); + + var _permissions = __webpack_require__(93); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + var SharingWindow = exports.SharingWindow = undefined; + + exports.SharingWindow = SharingWindow = function SharingWindow(c, sharing, configOnly) { + var t = this; + + var appManager = c.appManager, + uiManager = c.uiManager, + instanceManager = c.instanceManager, + i18n = c.i18nManager.get(); + + var apiPath = appManager.getApiPath(); + + var SharingAccessRow, getBody, sharingStore, sharingField, sharingButton, userGroupRowContainer, userRowContainer, sharingContainer, externalAccess, publicGroup, items, window; + + var showSharingError = function showSharingError() { + var modelName = sharing.object.modelName; + var errorMessage = modelName === "interpretation" ? i18n.validation_error_interpretation_sharing : i18n.validation_error_object_sharing; + uiManager.alert(errorMessage); + }; + + var favorite = instanceManager.getStateFavorite(); + + var validateAccessField = function validateAccessField(field, oldValue, newValue) { + var modelName = sharing.object.modelName; + return (0, _permissions.validateFieldAccess)(modelName, favorite, showSharingError, field, oldValue, newValue); + }; + + SharingAccessRow = function SharingAccessRow(obj, isPublicAccess, disallowPublicAccess) { + var getData, store, getItems, combo, getAccess, panel; + + getData = function getData() { + var data = [{ id: 'r-------', name: i18n.can_view }, { id: 'rw------', name: i18n.can_edit_and_view }]; + + if (isPublicAccess) { + data.unshift({ id: '--------', name: i18n.none }); + } + + return data; + }; + + store = Ext.create('Ext.data.Store', { + fields: ['id', 'name'], + data: getData() + }); + + getItems = function getItems() { + var items = []; + + combo = Ext.create('Ext.form.field.ComboBox', { + style: 'margin-bottom:2px', + fieldLabel: isPublicAccess ? i18n.public_access : obj.name, + labelStyle: 'color:#333', + cls: 'ns-combo', + width: 380, + labelWidth: 250, + queryMode: 'local', + valueField: 'id', + displayField: 'name', + labelSeparator: null, + editable: false, + disabled: !!disallowPublicAccess, + value: obj.access || 'rw------', + store: store, + listeners: { + select: function select(combo) { + if (isPublicAccess && !validateAccessField("publicAccess", obj.access, combo.getValue())) { + combo.setValue(obj.access); + } + } + } + }); + + items.push(combo); + + if (!isPublicAccess) { + items.push(Ext.create('Ext.container.Container', { + cls: 'ns-grid-row-icon-delete', + style: 'margin-top:2px; margin-left:7px', + bodyStyle: 'border:0 none; background:#fff', + overCls: 'pointer', + width: 16, + height: 16, + listeners: { + render: function render(cmp) { + cmp.getEl().on('click', function (e) { + var currentObject = getBody().object; + var accessToRemove = cmp.up('panel').getAccess(); + var field = cmp.up('#' + userGroupRowContainer.id) ? "userGroupAccesses" : "userAccesses"; + var currentAccesses = currentObject[field] || []; + var newAccesses = currentAccesses.filter(function (access) { + return access.id !== accessToRemove.id; + }); + + if (validateAccessField(field, currentAccesses, newAccesses)) { + cmp.up('panel').destroy(); + + if (window) { + window.doLayout(); + } + } + }); + } + } + })); + } + + return items; + }; + + getAccess = function getAccess() { + return { + id: obj.id, + name: obj.name, + access: combo.getValue() + }; + }; + + panel = Ext.create('Ext.panel.Panel', { + layout: 'column', + bodyStyle: 'border:0 none', + getAccess: getAccess, + items: getItems() + }); + + return panel; + }; + + getBody = function getBody() { + var body = { + object: { + id: sharing.object.id, + name: sharing.object.name, + publicAccess: publicGroup.down('combobox').getValue(), + externalAccess: externalAccess ? externalAccess.getValue() : false + } + }; + + if (userGroupRowContainer.items.items.length > 1) { + body.object.userGroupAccesses = []; + userGroupRowContainer.items.items.forEach(function (item, i) { + if (i > 0) { + body.object.userGroupAccesses.push(item.getAccess()); + } + }); + } + + if (userRowContainer.items.items.length > 1) { + body.object.userAccesses = []; + userRowContainer.items.items.forEach(function (item, i) { + if (i > 0) { + body.object.userAccesses.push(item.getAccess()); + } + }); + } + + return body; + }; + + // Initialize + sharingStore = Ext.create('Ext.data.Store', { + fields: ['id', 'name', 'isGroup'], + proxy: { + type: 'ajax', + url: encodeURI(apiPath + '/sharing/search'), + extraParams: { + pageSize: 50 + }, + startParam: false, + limitParam: false, + reader: { + type: 'json', + getData: function getData(data) { + // manually populate the store with the records from the response + // this is to avoid having to call the endpoint 2 times, one for user groups and one for users + var records = []; + + data.userGroups.forEach(function (_ref) { + var id = _ref.id, + name = _ref.name; + + records.push({ id: id, name: name, isGroup: true }); + }); + + data.users.forEach(function (_ref2) { + var id = _ref2.id, + name = _ref2.name; + + records.push({ id: id, name: name, isGroup: false }); + }); + + return records; + } + } + } + }); + + var comboBoxConfig = { + valueField: 'id', + displayField: 'name', + queryParam: 'key', + queryDelay: 200, + minChars: 1, + hideTrigger: true, + fieldStyle: 'height:26px; padding-left:6px; border-radius:1px; font-size:11px', + style: 'margin-bottom:5px', + width: 380 + }; + + sharingField = Ext.create('Ext.form.field.ComboBox', _extends({}, comboBoxConfig, { + emptyText: i18n.add_users_and_user_groups, + store: sharingStore, + listeners: { + beforeselect: function beforeselect(cb) { + // beforeselect instead of select, fires regardless of currently selected item + sharingButton.enable(); + }, + afterrender: function afterrender(cb) { + cb.inputEl.on('keyup', function (e) { + if (e.getKey() !== e.ENTER) { + sharingButton.disable(); + } + }); + } + } + })); + + var buttonConfig = { + text: '+', + style: 'margin-left:2px; padding-right:4px; padding-left:4px; border-radius:1px', + disabled: true, + height: 26 + }; + + sharingButton = Ext.create('Ext.button.Button', _extends({}, buttonConfig, { + handler: function handler(b) { + var record = sharingStore.getById(sharingField.getValue()); + var currentObject = getBody().object; + + if (record && record.data) { + var newAccess = { + id: record.data.id, + name: record.data.name, + access: 'r-------' + }; + + if (record.data.isGroup) { + var userGroupAccesses = currentObject.userGroupAccesses || []; + if (validateAccessField("userGroupAccesses", userGroupAccesses, userGroupAccesses.concat([newAccess]))) { + userGroupRowContainer.add(SharingAccessRow(newAccess)); + } + } else { + var userAccesses = currentObject.userAccesses || []; + if (validateAccessField("userAccesses", userAccesses, userAccesses.concat([newAccess]))) { + userRowContainer.add(SharingAccessRow(newAccess)); + } + } + } + + sharingField.clearValue(); + b.disable(); + } + })); + + sharingContainer = Ext.create('Ext.container.Container', { + bodyStyle: 'border:0 none' + }); + + var rowContainerConfig = { + hidden: true, + bodyStyle: 'border:0 none', + listeners: { + add: function add(el) { + if (el.items.length > 1) { + // enable the whole container + el.show(); + } + }, + remove: function remove(el) { + if (el.items.length === 1) { + el.hide(); + } + } + } + }; + + userGroupRowContainer = Ext.create('Ext.container.Container', _extends({}, rowContainerConfig, { + items: [{ + html: i18n.groups_access, + bodyStyle: 'border:0 none; font-weight: bold' + }] + })); + + userRowContainer = Ext.create('Ext.container.Container', _extends({}, rowContainerConfig, { + items: [{ + html: i18n.users_access, + bodyStyle: 'border:0 none; font-weight: bold' + }] + })); + + if (sharing.meta.allowExternalAccess) { + externalAccess = sharingContainer.add({ + xtype: 'checkbox', + fieldLabel: i18n.allow_external_access, + labelSeparator: '', + labelWidth: 250, + checked: !!sharing.object.externalAccess + }); + } + + publicGroup = sharingContainer.add(SharingAccessRow({ + id: sharing.object.id, + name: sharing.object.name, + access: sharing.object.publicAccess + }, true, !sharing.meta.allowPublicAccess)); + + if ((0, _isArray2.default)(sharing.object.userGroupAccesses)) { + sharing.object.userGroupAccesses.forEach(function (record) { + userGroupRowContainer.add(SharingAccessRow(record)); + }); + } + + if ((0, _isArray2.default)(sharing.object.userAccesses)) { + sharing.object.userAccesses.forEach(function (record) { + userRowContainer.add(SharingAccessRow(record)); + }); + } + + items = [{ + html: sharing.object.name, + bodyStyle: 'border:0 none; font-weight:bold; color:#333', + style: 'margin-bottom:7px' + }, { + xtype: 'container', + layout: 'column', + bodyStyle: 'border:0 none', + items: [sharingField, sharingButton] + }, { + html: i18n.created_by + ' ' + sharing.object.user.name, + bodyStyle: 'border:0 none; color:#777', + style: 'margin-top:2px;margin-bottom:7px' + }, sharingContainer, userGroupRowContainer, userRowContainer]; + + if (configOnly) { + return { + SharingAccessRow: SharingAccessRow, + getBody: getBody, + sharingStore: sharingStore, + sharingField: sharingField, + sharingButton: sharingButton, + userGroupRowContainer: userGroupRowContainer, + userRowContainer: userRowContainer, + externalAccess: externalAccess, + publicGroup: publicGroup, + items: items + }; + } else { + window = Ext.create('Ext.window.Window', { + title: i18n.sharing_settings, + bodyStyle: 'padding:5px 5px 3px; background-color:#fff', + resizable: false, + modal: true, + destroyOnBlur: true, + items: items, + bbar: ['->', { + text: i18n.save, + handler: function handler() { + if (!(0, _permissions.validateSharing)(sharing.object.modelName, favorite, getBody().object, showSharingError)) return; + + Ext.Ajax.request({ + url: encodeURI(apiPath + '/sharing?type=' + instanceManager.apiResource + '&id=' + sharing.object.id), + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + params: Ext.encode(getBody()), + success: function success() { + instanceManager.getById(null, function (layout, isFavorite) { + instanceManager.getReport(layout, isFavorite, false, false, function () { + uiManager.unmask(); + }); + }); + } + }); + + window.destroy(); + } + }], + listeners: { + show: function show(w) { + var favoriteWindow = uiManager.get('favoriteWindow'); + + if (favoriteWindow && favoriteWindow.rendered) { + + // position + var x = (favoriteWindow.getWidth() - w.getWidth()) / 2 + favoriteWindow.getPosition()[0], + y = w.getPosition()[1] / 3; + + w.setPosition(x, y); + + // blur + favoriteWindow.destroyOnBlur = false; + } else { + uiManager.setAnchorPosition(w, 'favoriteButton'); + } + + if (!w.hasDestroyOnBlurHandler) { + uiManager.addDestroyOnBlurHandler(w); + } + }, + destroy: function destroy() { + var favoriteWindow = uiManager.get('favoriteWindow'); + + if (favoriteWindow) { + favoriteWindow.destroyOnBlur = true; + } + } + } + }); + + return window; + } + }; + //# sourceMappingURL=SharingWindow.js.map + +/***/ }, +/* 37 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.onMarkdownEditorKeyDown = exports.validateTargetDiv = exports.isTargetDiv = undefined; + + var _convertCtrlKey = __webpack_require__(341); + + var _convertCtrlKey2 = _interopRequireDefault(_convertCtrlKey); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + var isTargetDiv = exports.isTargetDiv = function isTargetDiv(elementId) { + return !!document.getElementById(elementId); + }; + + var validateTargetDiv = exports.validateTargetDiv = function validateTargetDiv(elementId, msg) { + if (!isTargetDiv(elementId)) { + if (msg) { + console.log(msg); + } + + return false; + } + + return true; + }; + + var onMarkdownEditorKeyDown = exports.onMarkdownEditorKeyDown = function onMarkdownEditorKeyDown(f, e) { + (0, _convertCtrlKey2.default)(e.browserEvent, function (newValue, newCursorPos) { + var textarea = e.target; + textarea.value = newValue; + textarea.setSelectionRange(newCursorPos, newCursorPos); + }); + }; + //# sourceMappingURL=dom.js.map + +/***/ }, +/* 38 */ +[831, 96], +/* 39 */ +/***/ function(module, exports) { + + module.exports = function (it) { + return typeof it === 'object' ? it !== null : typeof it === 'function'; + }; + + +/***/ }, +/* 40 */ +/***/ function(module, exports) { + + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = arrayPluck; + /** + * + * @param {Array} array + * @param {string|number} propertyName The property of the + * @returns {Array} + * + * @throws {TypeError} When the `propertyName` can not be found on an item in the `array`. This generally happens when a value in the array is `null` or `undefined` + * + * @example + * const values = [{name: 'John'}, {name: 'James'}]; + * arrayPluck(values, 'name') // returns: ['John', 'James'] + * + * @example + * const values = [{name: 'John'}, {}, {name: 'James'}]; + * arrayPluck(values, 'name') // returns: ['John', undefined, 'James'] + * + * @example + * const values = [undefined, {name: 'James'}]; + * arrayPluck(values, 'name') // throws: Cannot read property 'name' of undefined + */ + function arrayPluck(array, propertyName) { + var newArray = []; + var i; + var len; + var item; + + for (i = 0, len = array.length; i < len; i++) { + item = array[i]; + + newArray.push(item[propertyName]); + } + + return newArray; + } + //# sourceMappingURL=arrayPluck.js.map + +/***/ }, +/* 41 */ +[819, 2, 394, 396], +/* 42 */ +/***/ function(module, exports) { + + var core = module.exports = {version: '2.4.0'}; + if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef + +/***/ }, +/* 43 */ +/***/ function(module, exports, __webpack_require__) { + + // Thank's IE8 for his funny defineProperty + module.exports = !__webpack_require__(65)(function(){ + return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; + }); + +/***/ }, +/* 44 */ +/***/ function(module, exports, __webpack_require__) { + + var dP = __webpack_require__(140) + , createDesc = __webpack_require__(141); + module.exports = __webpack_require__(43) ? function(object, key, value){ + return dP.f(object, key, createDesc(1, value)); + } : function(object, key, value){ + object[key] = value; + return object; + }; + +/***/ }, +/* 45 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + exports.default = function (filters, metaData) { + var title = void 0; + + if ((0, _isArray2.default)(filters) && filters.length) { + title = ''; + + var filterItems = void 0, + i = void 0, + l = void 0; + + filters.forEach(function (dimension, index, array) { + filterItems = metaData.dimensions[dimension.dimension]; + + if ((0, _isArray2.default)(filterItems)) { + l = filterItems.length; + var id = void 0; + + for (i = 0; i < l; i++) { + id = filterItems[i]; + + // if the value is present in items take the name to show from there + if (metaData.items[id]) { + title += metaData.items[id].name + (i < l - 1 ? ', ' : ''); + } + // otherwise use the values directly + // this is a temporary fix to avoid app crashing when using filters with data items in EV + else { + title += metaData.items[dimension.dimension].name + ': ' + filterItems.join(', '); + + break; + } + } + + title += index < array.length - 1 ? ' - ' : ''; + } + }); + } + + return title || null; + }; + + var _isArray = __webpack_require__(11); + + var _isArray2 = _interopRequireDefault(_isArray); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + //# sourceMappingURL=getFilterTitle.js.map + +/***/ }, +/* 46 */ +[819, 11, 205, 207], +/* 47 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.assert = exports.defaultProxyGenerator = exports.addMergeValueObject = exports.addMerge = exports.roundAndStrip = exports.roundIf = exports.getPercentageHtml = exports.getRoundedHtmlValue = exports.getNumberOfDecimals = exports.getDefaultNumberDisplayValue = undefined; + + var _numberToFixed = __webpack_require__(387); + + var _numberToFixed2 = _interopRequireDefault(_numberToFixed); + + var _isNumber = __webpack_require__(9); + + var _isNumber2 = _interopRequireDefault(_isNumber); + + var _isNumeric = __webpack_require__(18); + + var _isNumeric2 = _interopRequireDefault(_isNumeric); + + var _PivotTableConstants = __webpack_require__(19); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + var getDefaultNumberDisplayValue = exports.getDefaultNumberDisplayValue = function getDefaultNumberDisplayValue(value, skipRounding) { + return typeof value === null || value === undefined ? '' : skipRounding ? getRoundedHtmlValue(value, _PivotTableConstants.SKIP_ROUNDING_NUMBER_DECIMALS) : getRoundedHtmlValue(value, value < 1 && value > -1 ? _PivotTableConstants.SMALL_NUMBER_DECIMALS : _PivotTableConstants.DEFAULT_NUMBER_DECIMALS); + }; + + /** @description returns the number of decumal of given float + * @param {number} number + * @returns {number} + * @deprecated should switch to use function located in d2-utilizr + */ + var getNumberOfDecimals = exports.getNumberOfDecimals = function getNumberOfDecimals(number) { + var str = new String(number); + return str.indexOf('.') > -1 ? str.length - str.indexOf('.') - 1 : 0; + }; + + /** @description returns the rounded value of the given float. + * @param {number} value + * @param {number} [dec=NUMBER_OF_DECIMALS] + * @returns {number} + */ + var getRoundedHtmlValue = exports.getRoundedHtmlValue = function getRoundedHtmlValue(value) { + var dec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _PivotTableConstants.DEFAULT_NUMBER_DECIMALS; + + return parseFloat(roundAndStrip(value, dec)).toString(); + }; + + /** @description get percentage representation of value. + * @param {number} value + * @param {number} total + * @returns {string} + */ + var getPercentageHtml = exports.getPercentageHtml = function getPercentageHtml(value, total) { + return getRoundedHtmlValue(value / total * 100) + '%'; + }; + + /** @description round number if needed. + * @param {number} number + * @param {number} precision + * @returns {number} + */ + var roundIf = exports.roundIf = function roundIf(number, precision) { + number = parseFloat(number); + precision = parseFloat(precision); + + if ((0, _isNumber2.default)(number) && (0, _isNumber2.default)(precision)) { + var numberOfDecimals = getNumberOfDecimals(number); + return numberOfDecimals > precision ? (0, _numberToFixed2.default)(number, precision) : number; + } + + return number; + }; + + /** @description round number if needed. + * @param {number} number + * @param {number} precision + * @returns {number} + */ + var roundAndStrip = exports.roundAndStrip = function roundAndStrip(number, precision) { + var n = parseFloat(number); + + if (!((0, _isNumeric2.default)(number) && (0, _isNumber2.default)(n))) { + return number; + } + + if (!(0, _isNumeric2.default)(precision)) { + return n; + } + + return n.toFixed(precision); + }; + + var addMerge = exports.addMerge = function addMerge(a, b) { + Object.keys(a).forEach(function (key) { + if (b[key]) { + a[key] += b[key]; + } + }); + }; + + var addMergeValueObject = exports.addMergeValueObject = function addMergeValueObject(a, b) { + Object.keys(a).forEach(function (key) { + if (Boolean(b[key])) { + if (typeof a[key] === 'number') { + a[key] += b[key]; + return; + } else if (key === 'totalAggregationType') { + a[key] = !a[key] ? b[key] : a[key] !== b[key] ? _PivotTableConstants.NA_AGGREGATION_TOTAL : a[key]; + } + } + }); + }; + + var defaultProxyGenerator = exports.defaultProxyGenerator = function defaultProxyGenerator(defaultReturnValue) { + return new Proxy({}, { get: function get(target, name) { + return name in target ? target[name] : defaultReturnValue; + } }); + }; + + var assert = exports.assert = function assert(condition, message) { + if (!condition) { + message = message || "Assertion failed"; + if (typeof Error !== "undefined") { + throw new Error(message); + } + throw message; // Fallback + } + }; + //# sourceMappingURL=PivotTableUtils.js.map + +/***/ }, +/* 48 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + exports.default = function (_ref) { + var layout = _ref.layout, + i18n = _ref.i18n; + + var getValue = function getValue() { + var t = this, + value = (0, _sanitize2.default)(t.rawToValue(t.processRawValue(t.getRawValue()))); + + t.value = value; + + return value; + }; + + var nameTextField = Ext.create('Ext.form.field.Text', { + width: _FavoriteStyle2.default.windowCmpWidth, + height: 45, + style: 'margin-top: 2px; margin-bottom: 0', + fieldStyle: _FavoriteStyle2.default.textfieldStyle.join(';'), + fieldLabel: i18n.name, + labelAlign: 'top', + labelStyle: _FavoriteStyle2.default.textFieldLabelStyle.join(';'), + labelSeparator: '', + emptyText: 'Unnamed', + enableKeyEvents: true, + currentValue: '', + value: layout.name, + getValue: getValue, + setEventChangeHandler: function setEventChangeHandler(handler) { + this.eventChangeHandler = handler; + }, + setEventKeyUpHandler: function setEventKeyUpHandler(handler) { + this.eventKeyUpHandler = handler; + }, + listeners: { + change: function change(cmp, e) { + if (this.eventChangeHandler) { + this.eventChangeHandler(cmp, e); + } + }, + keyup: function keyup(cmp, e) { + if (e.keyCode === 13 && this.eventKeyUpHandler) { + this.eventKeyUpHandler(cmp, e); + } + } + } + }); + + var descriptionTextField = Ext.create('Ext.form.field.TextArea', { + width: _FavoriteStyle2.default.windowCmpWidth, + rows: 3, + style: 'margin-bottom: 0', + fieldStyle: _FavoriteStyle2.default.textfieldStyle.concat(['padding-top: 5px']).join(';'), + fieldLabel: i18n.description, + labelAlign: 'top', + labelStyle: _FavoriteStyle2.default.textFieldLabelStyle.join(';'), + labelSeparator: '', + emptyText: 'No description (optional)', + enableKeyEvents: true, + value: layout.description, + getValue: getValue, + listeners: { + keydown: _dom.onMarkdownEditorKeyDown + } + }); + + var titleTextField = Ext.create('Ext.form.field.Text', { + width: _FavoriteStyle2.default.windowCmpWidth, + height: 45, + style: 'margin-bottom: 0', + fieldStyle: _FavoriteStyle2.default.textfieldStyle.join(';'), + fieldLabel: i18n.title, + labelAlign: 'top', + labelStyle: _FavoriteStyle2.default.textFieldLabelStyle.join(';'), + labelSeparator: '', + emptyText: 'No title (optional)', + enableKeyEvents: true, + currentValue: '', + value: layout.title, + getValue: getValue, + setEventKeyUpHandler: function setEventKeyUpHandler(handler) { + this.eventKeyUpHandler = handler; + }, + listeners: { + keyup: function keyup(cmp, e) { + if (e.keyCode === 13 && this.eventKeyUpHandler) { + this.eventKeyUpHandler(cmp, e); + } + } + } + }); + + return { + nameTextField: nameTextField, + descriptionTextField: descriptionTextField, + titleTextField: titleTextField + }; + }; + + var _sanitize = __webpack_require__(94); + + var _sanitize2 = _interopRequireDefault(_sanitize); + + var _FavoriteStyle = __webpack_require__(34); + + var _FavoriteStyle2 = _interopRequireDefault(_FavoriteStyle); + + var _dom = __webpack_require__(37); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + //# sourceMappingURL=FavoriteTextCmp.js.map + +/***/ }, +/* 49 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.FavoriteWindow = undefined; + + var _RenameWindow = __webpack_require__(50); + + var _SharingWindow = __webpack_require__(36); + + var _GridHeaders = __webpack_require__(89); + + var _FavoriteTextCmp = __webpack_require__(48); + + var _FavoriteTextCmp2 = _interopRequireDefault(_FavoriteTextCmp); + + var _FavoriteStyle = __webpack_require__(34); + + var _FavoriteStyle2 = _interopRequireDefault(_FavoriteStyle); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + var FavoriteWindow = exports.FavoriteWindow = undefined; + + exports.FavoriteWindow = FavoriteWindow = function FavoriteWindow(c, action) { + var appManager = c.appManager, + instanceManager = c.instanceManager, + uiManager = c.uiManager, + i18n = c.i18nManager.get(), + uiConfig = c.uiConfig, + apiPath = appManager.getApiPath(), + apiResource = instanceManager.apiResource, + apiEndpoint = instanceManager.apiEndpoint; + + var getDirection, + getStoreUrl, + favoriteStore, + filtersStore, + getFilterUrlParam, + NameWindow, + nameWindow, + nameTextfield, + createButton, + updateButton, + cancelButton, + textfieldKeyUpHandlers, + showFavoritesLink, + showFavoritesLinkCt, + searchTextfield, + filtersComboBox, + descriptionPanel, + saveButtonHandler, + saveButton, + prevButton, + nextButton, + info, + gridHeaders, + renderers, + windowBbarSeparator, + windowBbar, + grid, + titles, + windowItems, + favoriteWindow, + nameColWidth = _FavoriteStyle2.default.windowCmpWidth - _FavoriteStyle2.default.createdColWidth - _FavoriteStyle2.default.lastUpdatedColWidth - _FavoriteStyle2.default.buttonColWidth - _FavoriteStyle2.default.paddingColWidth - 2, + storeFields = 'id,name,created,lastUpdated,access,title,description,user', + urlFields = 'id,displayName~rename(name),created,lastUpdated,access,title,description,user', + sortField = 'name', + sortDirection = 'asc', + cmpToToggle = [], + layout = instanceManager.getStateCurrent() || {}; + + var _getFavoriteTextCmp = (0, _FavoriteTextCmp2.default)({ layout: layout, i18n: i18n }), + nameTextField = _getFavoriteTextCmp.nameTextField, + descriptionTextField = _getFavoriteTextCmp.descriptionTextField; + + getDirection = function getDirection(keepDir) { + return sortDirection = keepDir ? sortDirection : sortDirection === 'asc' ? 'desc' : 'asc'; + }; + + getStoreUrl = function getStoreUrl(field, keepDir) { + sortField = field || sortField; + + var value = action === 'open' ? searchTextfield.getValue() : null; + + var url = apiPath + '/' + apiEndpoint + '.json?fields=' + urlFields + (value ? '&filter=displayName:ilike:' + value : '') + '&order=' + sortField + ':' + getDirection(keepDir); + + var filterParam = getFilterUrlParam(filtersComboBox.value); + + if (filterParam) { + url += '&filter=' + filterParam; + } + + return url; + }; + + favoriteStore = Ext.create('Ext.data.Store', { + fields: storeFields.split(','), + proxy: { + type: 'ajax', + reader: { + type: 'json', + root: apiEndpoint + }, + startParam: false, + limitParam: false + }, + isLoaded: false, + pageSize: 10, + page: 1, + defaultUrl: apiPath + '/' + apiEndpoint + '.json?fields=' + urlFields + '&order=name:asc', + loadStore: function loadStore(url) { + this.proxy.url = encodeURI(url || this.defaultUrl); + + this.load({ + params: { + pageSize: this.pageSize, + page: this.page + } + }); + }, + loadFn: function loadFn(fn) { + if (this.isLoaded) { + fn.call(); + } else { + this.load(fn); + } + }, + get: function get(field, value) { + var index = this.findExact(field, value); + return index === -1 ? null : this.getAt(index); + }, + listeners: { + load: function load(store, records) { + if (!this.isLoaded) { + this.isLoaded = true; + } + + // pager + var pager = store.proxy.reader.jsonData.pager; + + info.setText('Page ' + pager.page + ' of ' + pager.pageCount); + + prevButton.enable(); + nextButton.enable(); + + if (pager.page === 1) { + prevButton.disable(); + } + + if (pager.page === pager.pageCount) { + nextButton.disable(); + } + } + } + }); + + filtersStore = Ext.create('Ext.data.Store', { + fields: ['id', 'name'], + data: [{ id: 'SHOW_ALL', name: i18n.show_all }, { id: 'CREATED_BY_ME', name: i18n.created_by_me }, { id: 'CREATED_BY_OTHERS', name: i18n.created_by_others }] + }); + + getFilterUrlParam = function getFilterUrlParam(filterId) { + switch (filterId) { + case 'SHOW_ALL': + return null; + case 'CREATED_BY_ME': + return 'user.id:eq:' + appManager.userAccount.id; + case 'CREATED_BY_OTHERS': + return 'user.id:neq:' + appManager.userAccount.id; + default: + return null; + } + }; + + textfieldKeyUpHandlers = { + search: function search(cmp, e) { + var t = cmp, + value = Ext.isString(value) ? value : t.getValue(); + + if (action === 'open' && e.keyCode === 13 && favoriteStore.getRange().length) { + favoriteWindow.destroy(); + instanceManager.getById(favoriteStore.getAt(0).data.id); + } + + if (value !== t.currentValue) { + t.currentValue = value; + + favoriteStore.page = 1; + favoriteStore.loadStore(getStoreUrl(null, true)); + } + } + }; + + showFavoritesLink = Ext.create('Ext.form.Label', { + text: i18n.show_favorites, + style: 'color:#226aba', + nextAction: 'hide', + textMap: { + hide: i18n.hide_favorites, + show: i18n.show_favorites + }, + toggle: function toggle() { + var t = this; + + cmpToToggle.forEach(function (cmp) { + cmp[t.nextAction](); + }); + + this.nextAction = this.nextAction === 'hide' ? 'show' : 'hide'; + + this.setText(this.textMap[this.nextAction]); + }, + listeners: { + render: function render(cmp) { + var t = this, + el = this.getEl(); + + el.setStyle('cursor', 'pointer'); + + el.on('click', function () { + t.toggle(); + }); + } + } + }); + + showFavoritesLinkCt = Ext.create('Ext.container.Container', { + width: _FavoriteStyle2.default.windowCmpWidth, + style: 'text-align:right; padding-right:7px; padding-bottom:4px', + items: showFavoritesLink + }); + + searchTextfield = Ext.create('Ext.form.field.Text', { + width: _FavoriteStyle2.default.windowCmpWidth - _FavoriteStyle2.default.filtersComboBoxWidth, + height: 27, + style: 'margin-bottom: 1px; display: inline-block', + fieldStyle: _FavoriteStyle2.default.textfieldStyle.concat(['color: #333']).join(';'), + emptyText: i18n.search_for_favorites + '..', + enableKeyEvents: true, + currentValue: '', + listeners: { + keyup: { + fn: function fn(cmp, e) { + textfieldKeyUpHandlers['search'](cmp, e); + }, + buffer: 100 + } + } + }); + cmpToToggle.push(searchTextfield); + + filtersComboBox = Ext.create('Ext.form.field.ComboBox', { + width: _FavoriteStyle2.default.filtersComboBoxWidth, + height: 27, + style: 'display: inline-block; top: 7px; right: 5px', + fieldLabel: 'Filter', + labelWidth: 30, + store: filtersStore, + displayField: 'name', + valueField: 'id', + value: 'SHOW_ALL', + editable: false, + listeners: { + select: function select(_ref) { + var value = _ref.value; + + var url = getStoreUrl(null, true, [getFilterUrlParam(value)]), + store = favoriteStore; + + store.page = store.page <= 1 ? 1 : store.page - 1; + store.loadStore(url); + } + } + }); + cmpToToggle.push(filtersComboBox); + + saveButton = Ext.create('Ext.button.Button', { + text: i18n.save, + // DHIS2-1147: avoid server conflict error when name value is not set + disabled: true, + xable: function xable() { + this.setDisabled(!nameTextField.getValue()); + }, + handler: function handler() { + saveButtonHandler(); + } + }); + + saveButtonHandler = function saveButtonHandler() { + var name = nameTextField.getValue(); + + // DHIS2-1147: avoid submitting when no name is available + if (!name) { + return; + } + + var currentLayout = instanceManager.getStateCurrent(), + id = instanceManager.getStateFavoriteId(), + description = descriptionTextField.getValue(); + + var preXhr = function preXhr() { + favoriteWindow.destroy(); + }; + + var fn = function fn(id, success, r) { + currentLayout.id = id || currentLayout.id; + instanceManager.getById(currentLayout.id, function (layout, isFavorite) { + instanceManager.getReport(layout, isFavorite, false, false, function () { + uiManager.unmask(); + }); + }); + }; + + currentLayout.apply({ + id: id, + name: name, + description: description + }, ['id', 'name', 'description']); + + // search for a favorite with the same name + // and ask confirmation for replacing it + var request = new c.api.Request(c, { + baseUrl: apiPath + '/' + apiEndpoint + '.json?fields=id&filter=displayName:eq:' + name, + type: 'ajax', + method: 'GET', + success: function success(obj, _success, r) { + if (obj && obj.pager.total > 0 && obj[apiEndpoint].length) { + uiManager.confirmReplace(i18n.save_favorite, function () { + preXhr(); + currentLayout.clone().put(obj[apiEndpoint][0].id, fn, true, true); + }); + } else { + preXhr(); + currentLayout.clone().post(fn, true, true); + } + } + }); + + request.run(); + }; + + prevButton = Ext.create('Ext.button.Button', { + text: i18n.prev, + handler: function handler() { + var url = getStoreUrl(null, true), + store = favoriteStore; + + store.page = store.page <= 1 ? 1 : store.page - 1; + store.loadStore(url); + } + }); + cmpToToggle.push(prevButton); + + nextButton = Ext.create('Ext.button.Button', { + text: i18n.next, + handler: function handler() { + var url = getStoreUrl(null, true), + store = favoriteStore; + + store.page = store.page + 1; + store.loadStore(url); + } + }); + cmpToToggle.push(nextButton); + + info = Ext.create('Ext.form.Label', { + cls: 'ns-label-info', + width: 300, + height: 22 + }); + cmpToToggle.push(info); + + gridHeaders = (0, _GridHeaders.GridHeaders)({ + width: _FavoriteStyle2.default.windowCmpWidth, + height: 21, + direction: 'asc', + getDirection: function getDirection() {}, + items: [{ + text: i18n.name, + textAlign: 'left', + width: nameColWidth, + height: 20, + handler: function handler() { + var url = getStoreUrl('name'), + store = favoriteStore; + + store.page = 1; + store.loadStore(url); + } + }, { + text: i18n.created, + textAlign: 'left', + width: _FavoriteStyle2.default.createdColWidth, + height: 20, + direction: 'asc', + handler: function handler() { + var url = getStoreUrl('created'), + store = favoriteStore; + + store.page = 1; + store.loadStore(url); + } + }, { + text: i18n.last_updated, + textAlign: 'left', + width: _FavoriteStyle2.default.lastUpdatedColWidth, + height: 20, + direction: 'asc', + handler: function handler() { + var url = getStoreUrl('lastUpdated'), + store = favoriteStore; + + store.page = 1; + store.loadStore(url); + } + }] + }); + cmpToToggle.push(gridHeaders); + + renderers = { + open: function open(value, metaData, record) { + var fn = function fn() { + var element = Ext.get(record.data.id); + + if (element) { + element = element.parent('td'); + element.addClsOnOver('link'); + element.load = function () { + favoriteWindow.destroy(); + instanceManager.getById(record.data.id); + }; + element.handler = function () { + if (instanceManager.isStateUnsaved()) { + uiManager.confirmUnsaved(i18n.open, function () { + element.load(); + }); + } else { + element.load(); + } + }; + element.dom.setAttribute('onclick', 'Ext.get(this).handler();'); + } + }; + + Ext.defer(fn, 100); + + return '
' + value + '
'; + }, + saveas: function saveas(value, metaData, record) { + var fn = function fn() { + var element = Ext.get(record.data.id); + + if (element) { + element = element.parent('td'); + element.handler = function () { + nameTextField.setValue(record.data.name); + descriptionTextField.setValue(record.data.description); + }; + element.dom.setAttribute('onclick', 'Ext.get(this).handler();'); + } + }; + + Ext.defer(fn, 100); + + return '
' + value + '
'; + } + }; + + windowBbarSeparator = Ext.create('Ext.toolbar.Separator', { + height: 20, + style: 'border-color:transparent; border-right-color:#d1d1d1; margin-right:4px' + }); + cmpToToggle.push(windowBbarSeparator); + + windowBbar = function () { + var items = []; + + items.push(info, '->', prevButton, nextButton); + + if (action === 'saveas') { + items.push(' ', windowBbarSeparator, ' ', saveButton); + } + + return items; + }(); + + grid = Ext.create('Ext.grid.Panel', { + cls: 'ns-grid', + scroll: false, + hideHeaders: true, + columns: [{ + dataIndex: 'name', + sortable: true, + width: nameColWidth, + renderer: renderers[action] + }, { + dataIndex: 'created', + sortable: true, + width: _FavoriteStyle2.default.createdColWidth, + renderer: function renderer(value) { + return (value || '').substring(0, 16).split('T').join(', '); + } + }, { + dataIndex: 'lastUpdated', + sortable: true, + width: _FavoriteStyle2.default.lastUpdatedColWidth, + renderer: function renderer(value) { + return (value || '').substring(0, 16).split('T').join(', '); + } + }, { + xtype: 'actioncolumn', + sortable: false, + width: _FavoriteStyle2.default.buttonColWidth, + items: [{ + iconCls: 'ns-grid-row-icon-edit', + getClass: function getClass(value, metaData, record) { + return 'tooltip-favorite-edit' + (!record.data.access.update ? ' disabled' : ''); + }, + handler: function handler(grid, rowIndex, colIndex, col, event) { + var record = this.up('grid').store.getAt(rowIndex), + x = event.target.x - nameColWidth - _FavoriteStyle2.default.lastUpdatedColWidth - _FavoriteStyle2.default.borderWidth + 6, + y = event.target.y - 34, + layoutObj = { + id: record.data.id, + name: record.data.name, + description: record.data.description + }, + listeners = {}, + fn; + + if (record.data.access.update) { + fn = function fn() { + favoriteStore.loadStore(getStoreUrl(null, true)); + }; + + listeners.show = function () { + favoriteWindow.destroyOnBlur = false; + }; + + listeners.destroy = function () { + favoriteWindow.destroyOnBlur = true; + }; + + nameWindow = (0, _RenameWindow.RenameWindow)(c, layoutObj, fn, listeners); + nameWindow.showAt(x, y); + } + } + }, { + iconCls: 'ns-grid-row-icon-sharing', + getClass: function getClass(value, metaData, record) { + return 'tooltip-favorite-sharing' + (!record.data.access.manage ? ' disabled' : ''); + }, + handler: function handler(grid, rowIndex) { + var record = this.up('grid').store.getAt(rowIndex); + + if (record.data.access.manage) { + instanceManager.getSharingById(record.data.id, function (r) { + (0, _SharingWindow.SharingWindow)(c, r).show(); + }); + } + } + }, { + iconCls: 'ns-grid-row-icon-delete', + getClass: function getClass(value, metaData, record) { + return 'tooltip-favorite-delete' + (!record.data.access['delete'] ? ' disabled' : ''); + }, + handler: function handler(grid, rowIndex, colIndex, col, event) { + var record = this.up('grid').store.getAt(rowIndex), + id = record.data.id, + message; + + if (record.data.access['delete']) { + uiManager.confirmDelete(i18n.delete_favorite, function () { + instanceManager.delById(id, function () { + // DHIS2-1475: preserve the filter when reloading the favorite list + favoriteStore.loadStore(getStoreUrl(null, true)); + + if (id === instanceManager.getStateFavoriteId()) { + instanceManager.setState(); + } + }, true, true); + }); + } + } + }] + }, { + sortable: false, + width: _FavoriteStyle2.default.paddingColWidth + }], + store: favoriteStore, + listeners: { + render: function render() { + var size = Math.floor((uiManager.getHeight() - 330) / uiConfig.grid_row_height); + this.store.pageSize = size; + this.store.page = 1; + this.store.loadStore(); + + favoriteStore.on('load', function () { + if (this.isVisible()) { + this.fireEvent('afterrender'); + } + }, this); + }, + afterrender: function afterrender() { + var fn = function fn() { + var editArray = Ext.query('.tooltip-favorite-edit'), + sharingArray = Ext.query('.tooltip-favorite-sharing'), + deleteArray = Ext.query('.tooltip-favorite-delete'), + el; + + for (var i = 0; i < editArray.length; i++) { + var el = editArray[i]; + Ext.create('Ext.tip.ToolTip', { + target: el, + html: i18n.rename, + 'anchor': 'bottom', + anchorOffset: -14, + showDelay: 1000 + }); + } + + for (var i = 0; i < sharingArray.length; i++) { + el = sharingArray[i]; + Ext.create('Ext.tip.ToolTip', { + target: el, + html: i18n.share_with_other_people, + 'anchor': 'bottom', + anchorOffset: -14, + showDelay: 1000 + }); + } + + for (var i = 0; i < deleteArray.length; i++) { + el = deleteArray[i]; + Ext.create('Ext.tip.ToolTip', { + target: el, + html: i18n.delete_, + 'anchor': 'bottom', + anchorOffset: -14, + showDelay: 1000 + }); + } + }; + + Ext.defer(fn, 100); + }, + itemmouseenter: function itemmouseenter(grid, record, item) { + this.currentItem = Ext.get(item); + this.currentItem.removeCls('x-grid-row-over'); + }, + select: function select() { + if (action === 'open') { + this.currentItem.removeCls('x-grid-row-selected'); + } + }, + selectionchange: function selectionchange() { + this.currentItem.removeCls('x-grid-row-focused'); + }, + itemdblclick: function itemdblclick() { + if (action === 'saveas') { + saveButtonHandler(); + } + } + } + }); + cmpToToggle.push(grid); + + titles = { + open: i18n.open_favorite, + saveas: i18n.save_favorite_as + }; + + windowItems = function () { + var items = []; + + if (action === 'saveas') { + items.push(nameTextField, descriptionTextField, showFavoritesLinkCt); + } + + items.push(searchTextfield, filtersComboBox, gridHeaders, grid); + + return items; + }(); + + favoriteWindow = Ext.create('Ext.window.Window', { + title: titles[action], + bodyStyle: 'padding:1px; background-color:#fff', + resizable: false, + modal: true, + width: _FavoriteStyle2.default.windowWidth, + destroyOnBlur: true, + items: windowItems, + bbar: windowBbar, + listeners: { + show: function show(w) { + var favoriteButton = uiManager.get('favoriteButton') || {}; + + if (favoriteButton.rendered) { + uiManager.setAnchorPosition(w, favoriteButton); + + if (!w.hasDestroyOnBlurHandler) { + uiManager.addDestroyOnBlurHandler(w); + } + } + + (action === 'open' ? searchTextfield : nameTextField).focus(false, 500); + + if (action === 'saveas') { + showFavoritesLink.toggle(); + } + }, + destroy: function destroy(w) { + uiManager.unreg('favoriteWindow'); + } + } + }); + + nameTextField.setEventKeyUpHandler(saveButtonHandler); + // DHIS2-1147: enable Save button on name value change + nameTextField.setEventChangeHandler(function () { + saveButton.xable(); + }); + + return favoriteWindow; + }; + //# sourceMappingURL=FavoriteWindow.js.map + +/***/ }, +/* 50 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.RenameWindow = undefined; + + var _isArray = __webpack_require__(2); + + var _isArray2 = _interopRequireDefault(_isArray); + + var _FavoriteTextCmp = __webpack_require__(48); + + var _FavoriteTextCmp2 = _interopRequireDefault(_FavoriteTextCmp); + + var _FavoriteStyle = __webpack_require__(34); + + var _FavoriteStyle2 = _interopRequireDefault(_FavoriteStyle); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + var RenameWindow = exports.RenameWindow = undefined; + + exports.RenameWindow = RenameWindow = function RenameWindow(refs, layout, fn, listeners) { + var t = this, + appManager = refs.appManager, + uiManager = refs.uiManager, + instanceManager = refs.instanceManager, + i18n = refs.i18nManager.get(), + uiConfig = refs.uiConfig, + api = refs.api, + apiPath = appManager.getApiPath(), + apiEndpoint = instanceManager.apiEndpoint; + + listeners = listeners || {}; + + var _getFavoriteTextCmp = (0, _FavoriteTextCmp2.default)({ layout: layout, i18n: i18n }), + nameTextField = _getFavoriteTextCmp.nameTextField, + descriptionTextField = _getFavoriteTextCmp.descriptionTextField; + + var renameButton = Ext.create('Ext.button.Button', { + text: i18n.update, + handler: function handler() { + var name = nameTextField.getValue(), + description = descriptionTextField.getValue(), + patch = function patch() { + var properties = { + name: name, + description: description + }; + + layout.apply(properties); + + layout.patch(properties, function () { + if (fn) { + fn(); + } + instanceManager.getById(null, function (layout, isFavorite) { + instanceManager.getReport(layout, isFavorite, false, false, function () { + uiManager.unmask(); + }); + }); + window.destroy(); + }, true, true); + }; + + if (layout.patch) { + patch(); + } else { + var fields = appManager.getAnalysisFields(), + url = apiPath + '/' + apiEndpoint + '/' + layout.id + '.json?fields=' + fields; + + $.getJSON(encodeURI(url), function (r) { + layout = new api.Layout(refs, r).val(); + patch(); + }); + } + } + }); + + var cancelButton = Ext.create('Ext.button.Button', { + text: i18n.cancel, + handler: function handler() { + window.destroy(); + } + }); + + var window = Ext.create('Ext.window.Window', { + title: id ? 'Rename favorite' : 'Create new favorite', + bodyStyle: 'padding:1px; background:#fff', + resizable: false, + modal: true, + items: [nameTextField, descriptionTextField], + destroyOnBlur: true, + bbar: [cancelButton, '->', renameButton], + listeners: { + show: function show(w) { + var favoriteButton = uiManager.get('favoriteButton') || {}; + + if (favoriteButton.rendered) { + uiManager.setAnchorPosition(w, favoriteButton); + + if (!w.hasDestroyOnBlurHandler) { + uiManager.addDestroyOnBlurHandler(w); + } + } + + nameTextField.focus(false, 500); + + if (listeners.show) { + listeners.show(); + } + }, + destroy: function destroy() { + if (listeners.destroy) { + listeners.destroy(); + } + } + } + }); + + return window; + }; + //# sourceMappingURL=RenameWindow.js.map + +/***/ }, +/* 51 */ +39, +/* 52 */ +[831, 103], +/* 53 */ +[835, 374, 375, 52], +/* 54 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = arrayDifference; + + var _arrayUnique = __webpack_require__(27); + + var _arrayUnique2 = _interopRequireDefault(_arrayUnique); + + var _arrayContains = __webpack_require__(5); + + var _arrayContains2 = _interopRequireDefault(_arrayContains); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + /** + * + * @param {Array} array1 + * @param {Array} array2 + * @param {boolean} biDirectional False returns A-B while true returns A-B concat B-A + * @returns {Array} + * + * @throws {TypeError} When `filter` can not be found on `array`. This generally happens when the array is `null` or `undefined` + * + * @example + * const a = [1, 2]; + * const b = [1, 3]; + * difference(a, b) // returns: [2] + * difference(a, b, true) // returns: [2, 3] + */ + function arrayDifference(array1, array2, biDirectional) { + return (0, _arrayUnique2.default)(array1.filter(function (item) { + return !(0, _arrayContains2.default)(array2, item); + }).concat(biDirectional === true ? array2.filter(function (item) { + return !(0, _arrayContains2.default)(array1, item); + }) : [])); + } + //# sourceMappingURL=arrayDifference.js.map + +/***/ }, +/* 55 */ +/***/ function(module, exports) { + + /* WEBPACK VAR INJECTION */(function(global) {"use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = clone; + // TODO: Throw an error on empty `item` (Unexpected token u) + /** + * Create a clone a value + * + * @param {*} item + * + * @example + * const person1 = {name: 'John'}; + * const person2 = clone(person1); // Returns {name: 'John'} + * // but + * person1 !== person2 // Returns: true + */ + function clone(item) { + return global.JSON.parse(global.JSON.stringify(item)); + } + //# sourceMappingURL=clone.js.map + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }, +/* 56 */ +/***/ function(module, exports) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = uuid; + /** + * Generates a universally unique identifier + * + * @see https://en.wikipedia.org/wiki/Universally_unique_identifier + * + * @returns {string} The uuid + */ + function uuid() { + var s4 = function s4() { + return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); + }; + + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); + } + //# sourceMappingURL=uuid.js.map + +/***/ }, +/* 57 */ +/***/ function(module, exports) { + + /** + * class Ruler + * + * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and + * [[MarkdownIt#inline]] to manage sequences of functions (rules): + * + * - keep rules in defined order + * - assign the name to each rule + * - enable/disable rules + * - add/replace rules + * - allow assign rules to additional named chains (in the same) + * - cacheing lists of active rules + * + * You will not need use this class directly until write plugins. For simple + * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and + * [[MarkdownIt.use]]. + **/ + 'use strict'; + + + /** + * new Ruler() + **/ + function Ruler() { + // List of added rules. Each element is: + // + // { + // name: XXX, + // enabled: Boolean, + // fn: Function(), + // alt: [ name2, name3 ] + // } + // + this.__rules__ = []; + + // Cached rule chains. + // + // First level - chain name, '' for default. + // Second level - diginal anchor for fast filtering by charcodes. + // + this.__cache__ = null; + } + + //////////////////////////////////////////////////////////////////////////////// + // Helper methods, should not be used directly + + + // Find rule index by name + // + Ruler.prototype.__find__ = function (name) { + for (var i = 0; i < this.__rules__.length; i++) { + if (this.__rules__[i].name === name) { + return i; + } + } + return -1; + }; + + + // Build rules lookup cache + // + Ruler.prototype.__compile__ = function () { + var self = this; + var chains = [ '' ]; + + // collect unique names + self.__rules__.forEach(function (rule) { + if (!rule.enabled) { return; } + + rule.alt.forEach(function (altName) { + if (chains.indexOf(altName) < 0) { + chains.push(altName); + } + }); + }); + + self.__cache__ = {}; + + chains.forEach(function (chain) { + self.__cache__[chain] = []; + self.__rules__.forEach(function (rule) { + if (!rule.enabled) { return; } + + if (chain && rule.alt.indexOf(chain) < 0) { return; } + + self.__cache__[chain].push(rule.fn); + }); + }); + }; + + + /** + * Ruler.at(name, fn [, options]) + * - name (String): rule name to replace. + * - fn (Function): new rule function. + * - options (Object): new rule options (not mandatory). + * + * Replace rule by name with new function & options. Throws error if name not + * found. + * + * ##### Options: + * + * - __alt__ - array with names of "alternate" chains. + * + * ##### Example + * + * Replace existing typographer replacement rule with new one: + * + * ```javascript + * var md = require('markdown-it')(); + * + * md.core.ruler.at('replacements', function replace(state) { + * //... + * }); + * ``` + **/ + Ruler.prototype.at = function (name, fn, options) { + var index = this.__find__(name); + var opt = options || {}; + + if (index === -1) { throw new Error('Parser rule not found: ' + name); } + + this.__rules__[index].fn = fn; + this.__rules__[index].alt = opt.alt || []; + this.__cache__ = null; + }; + + + /** + * Ruler.before(beforeName, ruleName, fn [, options]) + * - beforeName (String): new rule will be added before this one. + * - ruleName (String): name of added rule. + * - fn (Function): rule function. + * - options (Object): rule options (not mandatory). + * + * Add new rule to chain before one with given name. See also + * [[Ruler.after]], [[Ruler.push]]. + * + * ##### Options: + * + * - __alt__ - array with names of "alternate" chains. + * + * ##### Example + * + * ```javascript + * var md = require('markdown-it')(); + * + * md.block.ruler.before('paragraph', 'my_rule', function replace(state) { + * //... + * }); + * ``` + **/ + Ruler.prototype.before = function (beforeName, ruleName, fn, options) { + var index = this.__find__(beforeName); + var opt = options || {}; + + if (index === -1) { throw new Error('Parser rule not found: ' + beforeName); } + + this.__rules__.splice(index, 0, { + name: ruleName, + enabled: true, + fn: fn, + alt: opt.alt || [] + }); + + this.__cache__ = null; + }; + + + /** + * Ruler.after(afterName, ruleName, fn [, options]) + * - afterName (String): new rule will be added after this one. + * - ruleName (String): name of added rule. + * - fn (Function): rule function. + * - options (Object): rule options (not mandatory). + * + * Add new rule to chain after one with given name. See also + * [[Ruler.before]], [[Ruler.push]]. + * + * ##### Options: + * + * - __alt__ - array with names of "alternate" chains. + * + * ##### Example + * + * ```javascript + * var md = require('markdown-it')(); + * + * md.inline.ruler.after('text', 'my_rule', function replace(state) { + * //... + * }); + * ``` + **/ + Ruler.prototype.after = function (afterName, ruleName, fn, options) { + var index = this.__find__(afterName); + var opt = options || {}; + + if (index === -1) { throw new Error('Parser rule not found: ' + afterName); } + + this.__rules__.splice(index + 1, 0, { + name: ruleName, + enabled: true, + fn: fn, + alt: opt.alt || [] + }); + + this.__cache__ = null; + }; + + /** + * Ruler.push(ruleName, fn [, options]) + * - ruleName (String): name of added rule. + * - fn (Function): rule function. + * - options (Object): rule options (not mandatory). + * + * Push new rule to the end of chain. See also + * [[Ruler.before]], [[Ruler.after]]. + * + * ##### Options: + * + * - __alt__ - array with names of "alternate" chains. + * + * ##### Example + * + * ```javascript + * var md = require('markdown-it')(); + * + * md.core.ruler.push('my_rule', function replace(state) { + * //... + * }); + * ``` + **/ + Ruler.prototype.push = function (ruleName, fn, options) { + var opt = options || {}; + + this.__rules__.push({ + name: ruleName, + enabled: true, + fn: fn, + alt: opt.alt || [] + }); + + this.__cache__ = null; + }; + + + /** + * Ruler.enable(list [, ignoreInvalid]) -> Array + * - list (String|Array): list of rule names to enable. + * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found. + * + * Enable rules with given names. If any rule name not found - throw Error. + * Errors can be disabled by second param. + * + * Returns list of found rule names (if no exception happened). + * + * See also [[Ruler.disable]], [[Ruler.enableOnly]]. + **/ + Ruler.prototype.enable = function (list, ignoreInvalid) { + if (!Array.isArray(list)) { list = [ list ]; } + + var result = []; + + // Search by name and enable + list.forEach(function (name) { + var idx = this.__find__(name); + + if (idx < 0) { + if (ignoreInvalid) { return; } + throw new Error('Rules manager: invalid rule name ' + name); + } + this.__rules__[idx].enabled = true; + result.push(name); + }, this); + + this.__cache__ = null; + return result; + }; + + + /** + * Ruler.enableOnly(list [, ignoreInvalid]) + * - list (String|Array): list of rule names to enable (whitelist). + * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found. + * + * Enable rules with given names, and disable everything else. If any rule name + * not found - throw Error. Errors can be disabled by second param. + * + * See also [[Ruler.disable]], [[Ruler.enable]]. + **/ + Ruler.prototype.enableOnly = function (list, ignoreInvalid) { + if (!Array.isArray(list)) { list = [ list ]; } + + this.__rules__.forEach(function (rule) { rule.enabled = false; }); + + this.enable(list, ignoreInvalid); + }; + + + /** + * Ruler.disable(list [, ignoreInvalid]) -> Array + * - list (String|Array): list of rule names to disable. + * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found. + * + * Disable rules with given names. If any rule name not found - throw Error. + * Errors can be disabled by second param. + * + * Returns list of found rule names (if no exception happened). + * + * See also [[Ruler.enable]], [[Ruler.enableOnly]]. + **/ + Ruler.prototype.disable = function (list, ignoreInvalid) { + if (!Array.isArray(list)) { list = [ list ]; } + + var result = []; + + // Search by name and disable + list.forEach(function (name) { + var idx = this.__find__(name); + + if (idx < 0) { + if (ignoreInvalid) { return; } + throw new Error('Rules manager: invalid rule name ' + name); + } + this.__rules__[idx].enabled = false; + result.push(name); + }, this); + + this.__cache__ = null; + return result; + }; + + + /** + * Ruler.getRules(chainName) -> Array + * + * Return array of active functions (rules) for given chain name. It analyzes + * rules configuration, compiles caches if not exists and returns result. + * + * Default chain name is `''` (empty string). It can't be skipped. That's + * done intentionally, to keep signature monomorphic for high speed. + **/ + Ruler.prototype.getRules = function (chainName) { + if (this.__cache__ === null) { + this.__compile__(); + } + + // Chain can be empty, if rules disabled. But we still have to return Array. + return this.__cache__[chainName] || []; + }; + + module.exports = Ruler; + + +/***/ }, +/* 58 */ +/***/ function(module, exports) { + + // Token class + + 'use strict'; + + + /** + * class Token + **/ + + /** + * new Token(type, tag, nesting) + * + * Create new token and fill passed properties. + **/ + function Token(type, tag, nesting) { + /** + * Token#type -> String + * + * Type of the token (string, e.g. "paragraph_open") + **/ + this.type = type; + + /** + * Token#tag -> String + * + * html tag name, e.g. "p" + **/ + this.tag = tag; + + /** + * Token#attrs -> Array + * + * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]` + **/ + this.attrs = null; + + /** + * Token#map -> Array + * + * Source map info. Format: `[ line_begin, line_end ]` + **/ + this.map = null; + + /** + * Token#nesting -> Number + * + * Level change (number in {-1, 0, 1} set), where: + * + * - `1` means the tag is opening + * - `0` means the tag is self-closing + * - `-1` means the tag is closing + **/ + this.nesting = nesting; + + /** + * Token#level -> Number + * + * nesting level, the same as `state.level` + **/ + this.level = 0; + + /** + * Token#children -> Array + * + * An array of child nodes (inline and img tokens) + **/ + this.children = null; + + /** + * Token#content -> String + * + * In a case of self-closing tag (code, html, fence, etc.), + * it has contents of this tag. + **/ + this.content = ''; + + /** + * Token#markup -> String + * + * '*' or '_' for emphasis, fence string for fence, etc. + **/ + this.markup = ''; + + /** + * Token#info -> String + * + * fence infostring + **/ + this.info = ''; + + /** + * Token#meta -> Object + * + * A place for plugins to store an arbitrary data + **/ + this.meta = null; + + /** + * Token#block -> Boolean + * + * True for block-level tokens, false for inline tokens. + * Used in renderer to calculate line breaks + **/ + this.block = false; + + /** + * Token#hidden -> Boolean + * + * If it's true, ignore this element when rendering. Used for tight lists + * to hide paragraphs. + **/ + this.hidden = false; + } + + + /** + * Token.attrIndex(name) -> Number + * + * Search attribute index by name. + **/ + Token.prototype.attrIndex = function attrIndex(name) { + var attrs, i, len; + + if (!this.attrs) { return -1; } + + attrs = this.attrs; + + for (i = 0, len = attrs.length; i < len; i++) { + if (attrs[i][0] === name) { return i; } + } + return -1; + }; + + + /** + * Token.attrPush(attrData) + * + * Add `[ name, value ]` attribute to list. Init attrs if necessary + **/ + Token.prototype.attrPush = function attrPush(attrData) { + if (this.attrs) { + this.attrs.push(attrData); + } else { + this.attrs = [ attrData ]; + } + }; + + + /** + * Token.attrSet(name, value) + * + * Set `name` attribute to `value`. Override old value if exists. + **/ + Token.prototype.attrSet = function attrSet(name, value) { + var idx = this.attrIndex(name), + attrData = [ name, value ]; + + if (idx < 0) { + this.attrPush(attrData); + } else { + this.attrs[idx] = attrData; + } + }; + + + /** + * Token.attrGet(name) + * + * Get the value of attribute `name`, or null if it does not exist. + **/ + Token.prototype.attrGet = function attrGet(name) { + var idx = this.attrIndex(name), value = null; + if (idx >= 0) { + value = this.attrs[idx][1]; + } + return value; + }; + + + /** + * Token.attrJoin(name, value) + * + * Join value to existing attribute via space. Or create new attribute if not + * exists. Useful to operate with token classes. + **/ + Token.prototype.attrJoin = function attrJoin(name, value) { + var idx = this.attrIndex(name); + + if (idx < 0) { + this.attrPush([ name, value ]); + } else { + this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value; + } + }; + + + module.exports = Token; + + +/***/ }, +/* 59 */ +/***/ function(module, exports) { + + module.exports=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/ + +/***/ }, +/* 60 */ +/***/ function(module, exports) { + + /* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra + */ + // css base code, injected by the css-loader + module.exports = function() { + var list = []; + + // return the list of modules as css string + list.toString = function toString() { + var result = []; + for(var i = 0; i < this.length; i++) { + var item = this[i]; + if(item[2]) { + result.push("@media " + item[2] + "{" + item[1] + "}"); + } else { + result.push(item[1]); + } + } + return result.join(""); + }; + + // import a list of modules into the list + list.i = function(modules, mediaQuery) { + if(typeof modules === "string") + modules = [[null, modules, ""]]; + var alreadyImportedModules = {}; + for(var i = 0; i < this.length; i++) { + var id = this[i][0]; + if(typeof id === "number") + alreadyImportedModules[id] = true; + } + for(i = 0; i < modules.length; i++) { + var item = modules[i]; + // skip already imported module + // this implementation is not 100% perfect for weird media query combinations + // when a module is imported multiple times with different media queries. + // I hope this will never occur (Hey this way we have smaller bundles) + if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) { + if(mediaQuery && !item[2]) { + item[2] = mediaQuery; + } else if(mediaQuery) { + item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"; + } + list.push(item); + } + } + }; + return list; + }; + + +/***/ }, +/* 61 */ +[821, 77], +/* 62 */ +/***/ function(module, exports, __webpack_require__) { + + /* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra + */ + var stylesInDom = {}, + memoize = function(fn) { + var memo; + return function () { + if (typeof memo === "undefined") memo = fn.apply(this, arguments); + return memo; + }; + }, + isOldIE = memoize(function() { + return /msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase()); + }), + getHeadElement = memoize(function () { + return document.head || document.getElementsByTagName("head")[0]; + }), + singletonElement = null, + singletonCounter = 0, + styleElementsInsertedAtTop = []; + + module.exports = function(list, options) { + if(false) { + if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment"); + } + + options = options || {}; + // Force single-tag solution on IE6-9, which has a hard limit on the # of