@websy/websy-designs 0.0.115 → 0.0.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/helpers/v1/pgHelper.js +73 -10
- package/dist/server/routes/v1/api.js +43 -19
- package/dist/server/utils.js +6 -0
- package/dist/server/websy-designs-server.js +37 -24
- package/dist/websy-designs.debug.js +381 -58
- package/dist/websy-designs.js +447 -104
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
package/dist/websy-designs.js
CHANGED
|
@@ -39,7 +39,9 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
39
39
|
WebsyMap
|
|
40
40
|
WebsyKPI
|
|
41
41
|
WebsyPDFButton
|
|
42
|
+
WebsyTemplate
|
|
42
43
|
APIService
|
|
44
|
+
WebsyUtils
|
|
43
45
|
*/
|
|
44
46
|
var WebsyPopupDialog = /*#__PURE__*/function () {
|
|
45
47
|
function WebsyPopupDialog(elementId, options) {
|
|
@@ -210,8 +212,10 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
210
212
|
_classCallCheck(this, WebsyNavigationMenu);
|
|
211
213
|
|
|
212
214
|
this.options = _extends({}, {
|
|
215
|
+
collapsable: false,
|
|
213
216
|
orientation: 'horizontal',
|
|
214
|
-
parentMap: {}
|
|
217
|
+
parentMap: {},
|
|
218
|
+
childIndentation: 10
|
|
215
219
|
}, options);
|
|
216
220
|
|
|
217
221
|
if (!elementId) {
|
|
@@ -265,8 +269,12 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
265
269
|
if (el) {
|
|
266
270
|
var html = "";
|
|
267
271
|
|
|
272
|
+
if (this.options.collapsable === true) {
|
|
273
|
+
html += "\n <div id='".concat(this.elementId, "_menuIcon' class='websy-menu-icon'>\n <svg viewbox=\"0 0 40 40\" width=\"30\" height=\"40\"> \n <rect x=\"0\" y=\"0\" width=\"30\" height=\"4\" rx=\"2\"></rect>\n <rect x=\"0\" y=\"12\" width=\"30\" height=\"4\" rx=\"2\"></rect>\n <rect x=\"0\" y=\"24\" width=\"30\" height=\"4\" rx=\"2\"></rect>\n </svg>\n </div>\n ");
|
|
274
|
+
}
|
|
275
|
+
|
|
268
276
|
if (this.options.logo) {
|
|
269
|
-
html += "
|
|
277
|
+
html += " \n <div \n class='logo ".concat(this.options.logo.classes && this.options.logo.classes.join(' ') || '', "'\n ").concat(this.options.logo.attributes && this.options.logo.attributes.join(' '), "\n >\n <img src='").concat(this.options.logo.url, "'></img>\n </div>\n <div id='").concat(this.elementId, "_mask' class='websy-menu-mask'></div>\n <div id=\"").concat(this.elementId, "_menuContainer\" class=\"websy-menu-block-container\">\n ");
|
|
270
278
|
}
|
|
271
279
|
|
|
272
280
|
html += this.renderBlock(this.options.items, 'main', 1);
|
|
@@ -295,7 +303,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
295
303
|
|
|
296
304
|
var active = items[i]["default"] === true ? 'active' : '';
|
|
297
305
|
var currentBlock = this.normaliseString(items[i].text);
|
|
298
|
-
html += "\n\t\t\t<li class='websy-".concat(this.options.orientation, "-list-item'>\n\t\t\t\t<div class='websy-menu-header ").concat(items[i].classes && items[i].classes.join(' '), " ").concat(selected, " ").concat(active, "' \n\t\t\t\t\t\t id='").concat(this.elementId, "_").concat(currentBlock, "_label' \n\t\t\t\t\t\t data-id='").concat(currentBlock, "' \n\t\t\t\t\t\t data-popout-id='").concat(level > 1 ? block : currentBlock, "'\n\t\t\t\t\t\t data-text='").concat(items[i].text, "'\n\t\t\t\t\t\t style='padding-left: ").concat(level * this.options.
|
|
306
|
+
html += "\n\t\t\t<li class='websy-".concat(this.options.orientation, "-list-item'>\n\t\t\t\t<div class='websy-menu-header ").concat(items[i].classes && items[i].classes.join(' '), " ").concat(selected, " ").concat(active, "' \n\t\t\t\t\t\t id='").concat(this.elementId, "_").concat(currentBlock, "_label' \n\t\t\t\t\t\t data-id='").concat(currentBlock, "'\n data-menu-id='").concat(this.elementId, "_").concat(currentBlock, "_list'\n\t\t\t\t\t\t data-popout-id='").concat(level > 1 ? block : currentBlock, "'\n\t\t\t\t\t\t data-text='").concat(items[i].text, "'\n\t\t\t\t\t\t style='padding-left: ").concat(level * this.options.childIndentation, "px'\n\t\t\t\t\t\t ").concat(items[i].attributes && items[i].attributes.join(' '), "\n >\n ");
|
|
299
307
|
|
|
300
308
|
if (this.options.orientation === 'horizontal') {
|
|
301
309
|
html += items[i].text;
|
|
@@ -326,6 +334,9 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
326
334
|
html += "</ul>";
|
|
327
335
|
return html;
|
|
328
336
|
}
|
|
337
|
+
}, {
|
|
338
|
+
key: "toggleOpen",
|
|
339
|
+
value: function toggleOpen() {}
|
|
329
340
|
}, {
|
|
330
341
|
key: "toggleMobileMenu",
|
|
331
342
|
value: function toggleMobileMenu(method) {
|
|
@@ -395,6 +406,16 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
395
406
|
}
|
|
396
407
|
|
|
397
408
|
_createClass(WebsyForm, [{
|
|
409
|
+
key: "cancelForm",
|
|
410
|
+
value: function cancelForm() {
|
|
411
|
+
var formEl = document.getElementById("".concat(this.elementId, "Form"));
|
|
412
|
+
formEl.reset();
|
|
413
|
+
|
|
414
|
+
if (this.options.cancelFn) {
|
|
415
|
+
this.options.cancelFn(this.elementId);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}, {
|
|
398
419
|
key: "checkRecaptcha",
|
|
399
420
|
value: function checkRecaptcha() {
|
|
400
421
|
var _this = this;
|
|
@@ -440,8 +461,12 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
440
461
|
}, {
|
|
441
462
|
key: "handleClick",
|
|
442
463
|
value: function handleClick(event) {
|
|
464
|
+
event.preventDefault();
|
|
465
|
+
|
|
443
466
|
if (event.target.classList.contains('submit')) {
|
|
444
467
|
this.submitForm();
|
|
468
|
+
} else if (event.target.classList.contains('cancel')) {
|
|
469
|
+
this.cancelForm();
|
|
445
470
|
}
|
|
446
471
|
}
|
|
447
472
|
}, {
|
|
@@ -492,23 +517,28 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
492
517
|
|
|
493
518
|
if (el) {
|
|
494
519
|
var html = "\n <form id=\"".concat(this.elementId, "Form\">\n ");
|
|
495
|
-
this.options.fields.forEach(function (f) {
|
|
520
|
+
this.options.fields.forEach(function (f, i) {
|
|
496
521
|
if (f.component) {
|
|
497
522
|
componentsToProcess.push(f);
|
|
498
|
-
html += "\n ".concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n
|
|
523
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes, "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <div id='").concat(_this3.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n </div><!--\n ");
|
|
499
524
|
} else if (f.type === 'longtext') {
|
|
500
|
-
html += "\n ".concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n
|
|
525
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes, "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <textarea\n id=\"").concat(_this3.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n name=\"").concat(f.field, "\" \n class=\"websy-input websy-textarea\"\n ></textarea>\n </div><!--\n ");
|
|
501
526
|
} else {
|
|
502
|
-
html += "\n ".concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n
|
|
527
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes, "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <input \n id=\"").concat(_this3.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat(f.type || 'text', "\" \n class=\"websy-input\" \n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.value || '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n </div><!--\n ");
|
|
503
528
|
}
|
|
504
529
|
});
|
|
530
|
+
html += "\n --><button class=\"websy-btn submit ".concat(this.options.submit.classes, "\">").concat(this.options.submit.text || 'Save', "</button>").concat(this.options.cancel ? '<!--' : '', "\n ");
|
|
531
|
+
|
|
532
|
+
if (this.options.cancel) {
|
|
533
|
+
html += "\n --><button class=\"websy-btn cancel ".concat(this.options.cancel.classes, "\">").concat(this.options.cancel.text || 'Cancel', "</button>\n ");
|
|
534
|
+
}
|
|
535
|
+
|
|
505
536
|
html += " \n </form>\n <div id=\"".concat(this.elementId, "_validationFail\" class=\"websy-validation-failure\"></div>\n ");
|
|
506
537
|
|
|
507
538
|
if (this.options.useRecaptcha === true) {
|
|
508
539
|
html += "\n <div id='".concat(this.elementId, "_recaptcha'></div>\n ");
|
|
509
540
|
}
|
|
510
541
|
|
|
511
|
-
html += "\n <button class=\"websy-btn submit ".concat(this.options.submit.classes, "\">").concat(this.options.submit.text || 'Save', "</button>\n ");
|
|
512
542
|
el.innerHTML = html;
|
|
513
543
|
this.processComponents(componentsToProcess, function () {
|
|
514
544
|
if (_this3.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
|
|
@@ -1009,6 +1039,8 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
1009
1039
|
Date.prototype.floor = function () {
|
|
1010
1040
|
return new Date("".concat(this.getMonth() + 1, "/").concat(this.getDate(), "/").concat(this.getFullYear()));
|
|
1011
1041
|
};
|
|
1042
|
+
/* global WebsyUtils */
|
|
1043
|
+
|
|
1012
1044
|
|
|
1013
1045
|
var WebsyDropdown = /*#__PURE__*/function () {
|
|
1014
1046
|
function WebsyDropdown(elementId, options) {
|
|
@@ -1021,8 +1053,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1021
1053
|
style: 'plain',
|
|
1022
1054
|
items: [],
|
|
1023
1055
|
label: '',
|
|
1056
|
+
disabled: false,
|
|
1024
1057
|
minSearchCharacters: 2,
|
|
1025
|
-
showCompleteSelectedList: false
|
|
1058
|
+
showCompleteSelectedList: false,
|
|
1059
|
+
closeAfterSelection: true
|
|
1026
1060
|
};
|
|
1027
1061
|
this.options = _extends({}, DEFAULTS, options);
|
|
1028
1062
|
this.tooltipTimeoutFn = null;
|
|
@@ -1065,6 +1099,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1065
1099
|
var contentEl = document.getElementById("".concat(this.elementId, "_content"));
|
|
1066
1100
|
maskEl.classList.remove('active');
|
|
1067
1101
|
contentEl.classList.remove('active');
|
|
1102
|
+
contentEl.classList.remove('on-top');
|
|
1068
1103
|
var searchEl = document.getElementById("".concat(this.elementId, "_search"));
|
|
1069
1104
|
|
|
1070
1105
|
if (searchEl) {
|
|
@@ -1078,6 +1113,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1078
1113
|
}, {
|
|
1079
1114
|
key: "handleClick",
|
|
1080
1115
|
value: function handleClick(event) {
|
|
1116
|
+
if (this.options.disabled === true) {
|
|
1117
|
+
return;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1081
1120
|
if (event.target.classList.contains('websy-dropdown-header')) {
|
|
1082
1121
|
this.open();
|
|
1083
1122
|
} else if (event.target.classList.contains('websy-dropdown-mask')) {
|
|
@@ -1176,6 +1215,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1176
1215
|
maskEl.classList.add('active');
|
|
1177
1216
|
contentEl.classList.add('active');
|
|
1178
1217
|
|
|
1218
|
+
if (WebsyUtils.getElementPos(contentEl).bottom > window.innerHeight) {
|
|
1219
|
+
contentEl.classList.add('on-top');
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1179
1222
|
if (this.options.disableSearch !== true) {
|
|
1180
1223
|
var searchEl = document.getElementById("".concat(this.elementId, "_search"));
|
|
1181
1224
|
|
|
@@ -1195,10 +1238,13 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1195
1238
|
}
|
|
1196
1239
|
|
|
1197
1240
|
var el = document.getElementById(this.elementId);
|
|
1241
|
+
var headerLabel = this.selectedItems.map(function (s) {
|
|
1242
|
+
return _this7.options.items[s].label || _this7.options.items[s].value;
|
|
1243
|
+
}).join(this.options.multiValueDelimiter);
|
|
1198
1244
|
var headerValue = this.selectedItems.map(function (s) {
|
|
1199
|
-
return _this7.options.items[s].label;
|
|
1245
|
+
return _this7.options.items[s].value || _this7.options.items[s].label;
|
|
1200
1246
|
}).join(this.options.multiValueDelimiter);
|
|
1201
|
-
var html = "\n <div class='websy-dropdown-container ".concat(this.options.disableSearch !== true ? 'with-search' : '', "'>\n <div id='").concat(this.elementId, "_header' class='websy-dropdown-header ").concat(this.selectedItems.length === 1 ? 'one-selected' : '', " ").concat(this.options.allowClear === true ? 'allow-clear' : '', "'>\n <span id='").concat(this.elementId, "_headerLabel' class='websy-dropdown-header-label'>").concat(this.options.label, "</span>\n <span data-info='").concat(
|
|
1247
|
+
var html = "\n <div class='websy-dropdown-container ".concat(this.options.disabled ? 'disabled' : '', " ").concat(this.options.disableSearch !== true ? 'with-search' : '', "'>\n <div id='").concat(this.elementId, "_header' class='websy-dropdown-header ").concat(this.selectedItems.length === 1 ? 'one-selected' : '', " ").concat(this.options.allowClear === true ? 'allow-clear' : '', "'>\n <span id='").concat(this.elementId, "_headerLabel' class='websy-dropdown-header-label'>").concat(this.options.label, "</span>\n <span data-info='").concat(headerLabel, "' class='websy-dropdown-header-value' id='").concat(this.elementId, "_selectedItems'>").concat(headerLabel, "</span>\n <input class='dropdown-input' id='").concat(this.elementId, "_input' name='").concat(this.options.field || this.options.label, "' value='").concat(headerValue, "'>\n <svg class='arrow' xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z\"/></svg>\n ");
|
|
1202
1248
|
|
|
1203
1249
|
if (this.options.allowClear === true) {
|
|
1204
1250
|
html += "\n <svg class='clear' xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 512 512\"><title>ionicons-v5-l</title><line x1=\"368\" y1=\"368\" x2=\"144\" y2=\"144\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"368\" y1=\"144\" x2=\"144\" y2=\"368\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>\n ";
|
|
@@ -1279,19 +1325,26 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1279
1325
|
if (this.selectedItems.length === 1) {
|
|
1280
1326
|
labelEl.innerHTML = item.label;
|
|
1281
1327
|
labelEl.setAttribute('data-info', item.label);
|
|
1282
|
-
inputEl.value = item.
|
|
1328
|
+
inputEl.value = item.value;
|
|
1283
1329
|
} else if (this.selectedItems.length > 1) {
|
|
1284
1330
|
if (this.options.showCompleteSelectedList === true) {
|
|
1331
|
+
var selectedLabels = this.selectedItems.map(function (s) {
|
|
1332
|
+
return _this9.options.items[s].label || _this9.options.items[s].value;
|
|
1333
|
+
}).join(this.options.multiValueDelimiter);
|
|
1285
1334
|
var selectedValues = this.selectedItems.map(function (s) {
|
|
1286
|
-
return _this9.options.items[s].label;
|
|
1335
|
+
return _this9.options.items[s].value || _this9.options.items[s].label;
|
|
1287
1336
|
}).join(this.options.multiValueDelimiter);
|
|
1288
|
-
labelEl.innerHTML =
|
|
1289
|
-
labelEl.setAttribute('data-info',
|
|
1337
|
+
labelEl.innerHTML = selectedLabels;
|
|
1338
|
+
labelEl.setAttribute('data-info', selectedLabels);
|
|
1290
1339
|
inputEl.value = selectedValues;
|
|
1291
1340
|
} else {
|
|
1341
|
+
var _selectedValues = this.selectedItems.map(function (s) {
|
|
1342
|
+
return _this9.options.items[s].value || _this9.options.items[s].label;
|
|
1343
|
+
}).join(this.options.multiValueDelimiter);
|
|
1344
|
+
|
|
1292
1345
|
labelEl.innerHTML = "".concat(this.selectedItems.length, " selected");
|
|
1293
1346
|
labelEl.setAttribute('data-info', '');
|
|
1294
|
-
inputEl.value =
|
|
1347
|
+
inputEl.value = _selectedValues;
|
|
1295
1348
|
}
|
|
1296
1349
|
} else {
|
|
1297
1350
|
labelEl.innerHTML = '';
|
|
@@ -1324,7 +1377,9 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1324
1377
|
this.options.onItemSelected(item, this.selectedItems, this.options.items);
|
|
1325
1378
|
}
|
|
1326
1379
|
|
|
1327
|
-
this.
|
|
1380
|
+
if (this.options.closeAfterSelection === true) {
|
|
1381
|
+
this.close();
|
|
1382
|
+
}
|
|
1328
1383
|
}
|
|
1329
1384
|
}, {
|
|
1330
1385
|
key: "selections",
|
|
@@ -1611,6 +1666,183 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
1611
1666
|
|
|
1612
1667
|
return WebsyResultList;
|
|
1613
1668
|
}();
|
|
1669
|
+
/* global WebsyDesigns */
|
|
1670
|
+
|
|
1671
|
+
|
|
1672
|
+
var WebsyTemplate = /*#__PURE__*/function () {
|
|
1673
|
+
function WebsyTemplate(elementId, options) {
|
|
1674
|
+
var _this14 = this;
|
|
1675
|
+
|
|
1676
|
+
_classCallCheck(this, WebsyTemplate);
|
|
1677
|
+
|
|
1678
|
+
var DEFAULTS = {
|
|
1679
|
+
listeners: {
|
|
1680
|
+
click: {}
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
1684
|
+
this.elementId = elementId;
|
|
1685
|
+
this.templateService = new WebsyDesigns.APIService('');
|
|
1686
|
+
|
|
1687
|
+
if (!elementId) {
|
|
1688
|
+
console.log('No element Id provided for Websy Template');
|
|
1689
|
+
return;
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
var el = document.getElementById(elementId);
|
|
1693
|
+
|
|
1694
|
+
if (el) {
|
|
1695
|
+
el.addEventListener('click', this.handleClick.bind(this));
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
if (_typeof(options.template) === 'object' && options.template.url) {
|
|
1699
|
+
this.templateService.get(options.template.url).then(function (templateString) {
|
|
1700
|
+
_this14.options.template = templateString;
|
|
1701
|
+
|
|
1702
|
+
_this14.render();
|
|
1703
|
+
});
|
|
1704
|
+
} else {
|
|
1705
|
+
this.render();
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
_createClass(WebsyTemplate, [{
|
|
1710
|
+
key: "buildHTML",
|
|
1711
|
+
value: function buildHTML() {
|
|
1712
|
+
var _this15 = this;
|
|
1713
|
+
|
|
1714
|
+
var html = "";
|
|
1715
|
+
|
|
1716
|
+
if (this.options.template) {
|
|
1717
|
+
var template = this.options.template; // find conditional elements
|
|
1718
|
+
|
|
1719
|
+
var ifMatches = _toConsumableArray(template.matchAll(/<\s*if[^>]*>([\s\S]*?)<\s*\/\s*if>/g));
|
|
1720
|
+
|
|
1721
|
+
ifMatches.forEach(function (m) {
|
|
1722
|
+
// get the condition
|
|
1723
|
+
if (m[0] && m.index > -1) {
|
|
1724
|
+
var conditionMatch = m[0].match(/(\scondition=["|']\w.+)["|']/g);
|
|
1725
|
+
|
|
1726
|
+
if (conditionMatch && conditionMatch[0]) {
|
|
1727
|
+
var c = conditionMatch[0].trim().replace('condition=', '');
|
|
1728
|
+
|
|
1729
|
+
if (c.split('')[0] === '"') {
|
|
1730
|
+
c = c.replace(/"/g, '');
|
|
1731
|
+
} else if (c.split('')[0] === '\'') {
|
|
1732
|
+
c = c.replace(/'/g, '');
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
var parts = [];
|
|
1736
|
+
var polarity = true;
|
|
1737
|
+
|
|
1738
|
+
if (c.indexOf('===') !== -1) {
|
|
1739
|
+
parts = c.split('===');
|
|
1740
|
+
} else if (c.indexOf('!==') !== -1) {
|
|
1741
|
+
parts = c.split('!==');
|
|
1742
|
+
polarity = false;
|
|
1743
|
+
} else if (c.indexOf('==') !== -1) {
|
|
1744
|
+
parts = c.split('==');
|
|
1745
|
+
} else if (c.indexOf('!=') !== -1) {
|
|
1746
|
+
parts = c.split('!=');
|
|
1747
|
+
polarity = false;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
var removeAll = true;
|
|
1751
|
+
|
|
1752
|
+
if (parts.length === 2) {
|
|
1753
|
+
if (!isNaN(parts[1])) {
|
|
1754
|
+
parts[1] = +parts[1];
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
if (parts[1] === 'true') {
|
|
1758
|
+
parts[1] = true;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
if (parts[1] === 'false') {
|
|
1762
|
+
parts[1] = false;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
if (typeof parts[1] === 'string') {
|
|
1766
|
+
if (parts[1].indexOf('"') !== -1) {
|
|
1767
|
+
parts[1] = parts[1].replace(/"/g, '');
|
|
1768
|
+
} else if (parts[1].indexOf('\'') !== -1) {
|
|
1769
|
+
parts[1] = parts[1].replace(/'/g, '');
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
if (polarity === true) {
|
|
1774
|
+
if (typeof _this15.options.data[parts[0]] !== 'undefined' && _this15.options.data[parts[0]] === parts[1]) {
|
|
1775
|
+
// remove the <if> tags
|
|
1776
|
+
removeAll = false;
|
|
1777
|
+
} else if (parts[0] === parts[1]) {
|
|
1778
|
+
removeAll = false;
|
|
1779
|
+
}
|
|
1780
|
+
} else if (polarity === false) {
|
|
1781
|
+
if (typeof _this15.options.data[parts[0]] !== 'undefined' && _this15.options.data[parts[0]] !== parts[1]) {
|
|
1782
|
+
// remove the <if> tags
|
|
1783
|
+
removeAll = false;
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
if (removeAll === true) {
|
|
1789
|
+
// remove the whole markup
|
|
1790
|
+
template = template.replace(m[0], '');
|
|
1791
|
+
} else {
|
|
1792
|
+
// remove the <if> tags
|
|
1793
|
+
var newMarkup = m[0];
|
|
1794
|
+
newMarkup = newMarkup.replace('</if>', '').replace(/<\s*if[^>]*>/g, '');
|
|
1795
|
+
template = template.replace(m[0], newMarkup);
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1800
|
+
|
|
1801
|
+
var tagMatches = _toConsumableArray(template.matchAll(/(\sdata-event=["|']\w.+)["|']/g));
|
|
1802
|
+
|
|
1803
|
+
tagMatches.forEach(function (m) {
|
|
1804
|
+
if (m[0] && m.index > -1) {
|
|
1805
|
+
template = template.replace(m[0], "".concat(m[0]));
|
|
1806
|
+
}
|
|
1807
|
+
});
|
|
1808
|
+
|
|
1809
|
+
for (var key in this.options.data) {
|
|
1810
|
+
var rg = new RegExp("{".concat(key, "}"), 'gm');
|
|
1811
|
+
|
|
1812
|
+
if (rg) {
|
|
1813
|
+
template = template.replace(rg, this.options.data[key]);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
html = template;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
return html;
|
|
1821
|
+
}
|
|
1822
|
+
}, {
|
|
1823
|
+
key: "handleClick",
|
|
1824
|
+
value: function handleClick(event) {//
|
|
1825
|
+
}
|
|
1826
|
+
}, {
|
|
1827
|
+
key: "render",
|
|
1828
|
+
value: function render() {
|
|
1829
|
+
this.resize();
|
|
1830
|
+
}
|
|
1831
|
+
}, {
|
|
1832
|
+
key: "resize",
|
|
1833
|
+
value: function resize() {
|
|
1834
|
+
var html = this.buildHTML();
|
|
1835
|
+
var el = document.getElementById(this.elementId);
|
|
1836
|
+
el.innerHTML = html.replace(/\n/g, '');
|
|
1837
|
+
|
|
1838
|
+
if (this.options.readyCallbackFn) {
|
|
1839
|
+
this.options.readyCallbackFn();
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
}]);
|
|
1843
|
+
|
|
1844
|
+
return WebsyTemplate;
|
|
1845
|
+
}();
|
|
1614
1846
|
|
|
1615
1847
|
var WebsyPubSub = /*#__PURE__*/function () {
|
|
1616
1848
|
function WebsyPubSub(elementId, options) {
|
|
@@ -2254,7 +2486,7 @@ var APIService = /*#__PURE__*/function () {
|
|
|
2254
2486
|
query.push("id:".concat(id));
|
|
2255
2487
|
}
|
|
2256
2488
|
|
|
2257
|
-
return "".concat(this.baseUrl, "/").concat(entity).concat(query.length > 0 ? "?where=".concat(query.join(';')) : '');
|
|
2489
|
+
return "".concat(this.baseUrl, "/").concat(entity).concat(query.length > 0 ? "".concat(entity.indexOf('?') === -1 ? '?' : '&', "where=").concat(query.join(';')) : '');
|
|
2258
2490
|
}
|
|
2259
2491
|
}, {
|
|
2260
2492
|
key: "delete",
|
|
@@ -2425,58 +2657,58 @@ var WebsyPDFButton = /*#__PURE__*/function () {
|
|
|
2425
2657
|
_createClass(WebsyPDFButton, [{
|
|
2426
2658
|
key: "handleClick",
|
|
2427
2659
|
value: function handleClick(event) {
|
|
2428
|
-
var
|
|
2660
|
+
var _this16 = this;
|
|
2429
2661
|
|
|
2430
2662
|
if (event.target.classList.contains('websy-pdf-button')) {
|
|
2431
2663
|
this.loader.show();
|
|
2432
2664
|
setTimeout(function () {
|
|
2433
|
-
if (
|
|
2434
|
-
var el = document.getElementById(
|
|
2665
|
+
if (_this16.options.targetId) {
|
|
2666
|
+
var el = document.getElementById(_this16.options.targetId);
|
|
2435
2667
|
|
|
2436
2668
|
if (el) {
|
|
2437
2669
|
var pdfData = {
|
|
2438
2670
|
options: {}
|
|
2439
2671
|
};
|
|
2440
2672
|
|
|
2441
|
-
if (
|
|
2442
|
-
pdfData.options = _extends({},
|
|
2673
|
+
if (_this16.options.pdfOptions) {
|
|
2674
|
+
pdfData.options = _extends({}, _this16.options.pdfOptions);
|
|
2443
2675
|
}
|
|
2444
2676
|
|
|
2445
|
-
if (
|
|
2446
|
-
if (
|
|
2447
|
-
var headerEl = document.getElementById(
|
|
2677
|
+
if (_this16.options.header) {
|
|
2678
|
+
if (_this16.options.header.elementId) {
|
|
2679
|
+
var headerEl = document.getElementById(_this16.options.header.elementId);
|
|
2448
2680
|
|
|
2449
2681
|
if (headerEl) {
|
|
2450
2682
|
pdfData.header = headerEl.outerHTML;
|
|
2451
2683
|
|
|
2452
|
-
if (
|
|
2453
|
-
pdfData.options.headerCSS =
|
|
2684
|
+
if (_this16.options.header.css) {
|
|
2685
|
+
pdfData.options.headerCSS = _this16.options.header.css;
|
|
2454
2686
|
}
|
|
2455
2687
|
}
|
|
2456
|
-
} else if (
|
|
2457
|
-
pdfData.header =
|
|
2688
|
+
} else if (_this16.options.header.html) {
|
|
2689
|
+
pdfData.header = _this16.options.header.html;
|
|
2458
2690
|
|
|
2459
|
-
if (
|
|
2460
|
-
pdfData.options.headerCSS =
|
|
2691
|
+
if (_this16.options.header.css) {
|
|
2692
|
+
pdfData.options.headerCSS = _this16.options.header.css;
|
|
2461
2693
|
}
|
|
2462
2694
|
} else {
|
|
2463
|
-
pdfData.header =
|
|
2695
|
+
pdfData.header = _this16.options.header;
|
|
2464
2696
|
}
|
|
2465
2697
|
}
|
|
2466
2698
|
|
|
2467
|
-
if (
|
|
2468
|
-
if (
|
|
2469
|
-
var footerEl = document.getElementById(
|
|
2699
|
+
if (_this16.options.footer) {
|
|
2700
|
+
if (_this16.options.footer.elementId) {
|
|
2701
|
+
var footerEl = document.getElementById(_this16.options.footer.elementId);
|
|
2470
2702
|
|
|
2471
2703
|
if (footerEl) {
|
|
2472
2704
|
pdfData.footer = footerEl.outerHTML;
|
|
2473
2705
|
|
|
2474
|
-
if (
|
|
2475
|
-
pdfData.options.footerCSS =
|
|
2706
|
+
if (_this16.options.footer.css) {
|
|
2707
|
+
pdfData.options.footerCSS = _this16.options.footer.css;
|
|
2476
2708
|
}
|
|
2477
2709
|
}
|
|
2478
2710
|
} else {
|
|
2479
|
-
pdfData.footer =
|
|
2711
|
+
pdfData.footer = _this16.options.footer;
|
|
2480
2712
|
}
|
|
2481
2713
|
}
|
|
2482
2714
|
|
|
@@ -2485,17 +2717,17 @@ var WebsyPDFButton = /*#__PURE__*/function () {
|
|
|
2485
2717
|
// document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
|
|
2486
2718
|
// document.getElementById(`${this.elementId}_form`).submit()
|
|
2487
2719
|
|
|
2488
|
-
|
|
2720
|
+
_this16.service.add('', pdfData, {
|
|
2489
2721
|
responseType: 'blob'
|
|
2490
2722
|
}).then(function (response) {
|
|
2491
|
-
|
|
2723
|
+
_this16.loader.hide();
|
|
2492
2724
|
|
|
2493
2725
|
var blob = new Blob([response], {
|
|
2494
2726
|
type: 'application/pdf'
|
|
2495
2727
|
});
|
|
2496
2728
|
|
|
2497
|
-
|
|
2498
|
-
message: "\n <div class='text-center websy-pdf-download'>\n <div>Your file is ready to download</div>\n <a href='".concat(URL.createObjectURL(blob), "' target='_blank'>\n <button class='websy-btn download-pdf'>").concat(
|
|
2729
|
+
_this16.popup.show({
|
|
2730
|
+
message: "\n <div class='text-center websy-pdf-download'>\n <div>Your file is ready to download</div>\n <a href='".concat(URL.createObjectURL(blob), "' target='_blank'>\n <button class='websy-btn download-pdf'>").concat(_this16.options.buttonText, "</button>\n </a>\n </div>\n "),
|
|
2499
2731
|
mask: true
|
|
2500
2732
|
});
|
|
2501
2733
|
}, function (err) {
|
|
@@ -2552,20 +2784,20 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
2552
2784
|
_createClass(WebsyTable, [{
|
|
2553
2785
|
key: "appendRows",
|
|
2554
2786
|
value: function appendRows(data) {
|
|
2555
|
-
var
|
|
2787
|
+
var _this17 = this;
|
|
2556
2788
|
|
|
2557
2789
|
var bodyHTML = '';
|
|
2558
2790
|
|
|
2559
2791
|
if (data) {
|
|
2560
2792
|
bodyHTML += data.map(function (r, rowIndex) {
|
|
2561
2793
|
return '<tr>' + r.map(function (c, i) {
|
|
2562
|
-
if (
|
|
2563
|
-
if (
|
|
2564
|
-
return "\n <td data-row-index='".concat(
|
|
2565
|
-
} else if (
|
|
2566
|
-
return "\n <td data-view='".concat(c.value, "' data-row-index='").concat(
|
|
2794
|
+
if (_this17.options.columns[i].show !== false) {
|
|
2795
|
+
if (_this17.options.columns[i].showAsLink === true && c.value.trim() !== '') {
|
|
2796
|
+
return "\n <td data-row-index='".concat(_this17.rowCount + rowIndex, "' data-col-index='").concat(i, "' class='").concat(_this17.options.columns[i].classes || '', "' ").concat(_this17.options.columns[i].width ? 'style="width: ' + _this17.options.columns[i].width + '"' : '', "><a href='").concat(c.value, "' target='").concat(_this17.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(_this17.options.columns[i].linkText || c.value, "</a></td>\n ");
|
|
2797
|
+
} else if (_this17.options.columns[i].showAsNavigatorLink === true && c.value.trim() !== '') {
|
|
2798
|
+
return "\n <td data-view='".concat(c.value, "' data-row-index='").concat(_this17.rowCount + rowIndex, "' data-col-index='").concat(i, "' class='trigger-item ").concat(_this17.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this17.options.columns[i].classes || '', "' ").concat(_this17.options.columns[i].width ? 'style="width: ' + _this17.options.columns[i].width + '"' : '', ">").concat(_this17.options.columns[i].linkText || c.value, "</td>\n ");
|
|
2567
2799
|
} else {
|
|
2568
|
-
return "\n <td data-info='".concat(c.value, "' data-row-index='").concat(
|
|
2800
|
+
return "\n <td data-info='".concat(c.value, "' data-row-index='").concat(_this17.rowCount + rowIndex, "' data-col-index='").concat(i, "' class='").concat(_this17.options.columns[i].classes || '', "' ").concat(_this17.options.columns[i].width ? 'style="width: ' + (_this17.options.columns[i].width || 'auto') + '"' : '', ">").concat(c.value, "</td>\n ");
|
|
2569
2801
|
}
|
|
2570
2802
|
}
|
|
2571
2803
|
}).join('') + '</tr>';
|
|
@@ -2704,7 +2936,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
2704
2936
|
}, {
|
|
2705
2937
|
key: "render",
|
|
2706
2938
|
value: function render(data) {
|
|
2707
|
-
var
|
|
2939
|
+
var _this18 = this;
|
|
2708
2940
|
|
|
2709
2941
|
if (!this.options.columns) {
|
|
2710
2942
|
return;
|
|
@@ -2727,7 +2959,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
2727
2959
|
|
|
2728
2960
|
var headHTML = '<tr>' + this.options.columns.map(function (c, i) {
|
|
2729
2961
|
if (c.show !== false) {
|
|
2730
|
-
return "\n <th ".concat(c.width ? 'style="width: ' + (c.width || 'auto') + ';"' : '', ">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-index=\"").concat(i, "\" \n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n <!--").concat(c.searchable === true ?
|
|
2962
|
+
return "\n <th ".concat(c.width ? 'style="width: ' + (c.width || 'auto') + ';"' : '', ">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-index=\"").concat(i, "\" \n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n <!--").concat(c.searchable === true ? _this18.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
|
|
2731
2963
|
}
|
|
2732
2964
|
}).join('') + '</tr>';
|
|
2733
2965
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
@@ -2862,11 +3094,11 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
2862
3094
|
}, {
|
|
2863
3095
|
key: "handleEventMouseMove",
|
|
2864
3096
|
value: function handleEventMouseMove(event, d) {
|
|
2865
|
-
var
|
|
3097
|
+
var _this19 = this;
|
|
2866
3098
|
|
|
2867
3099
|
// console.log('mouse move', event, d, d3.pointer(event))
|
|
2868
3100
|
var bisectDate = d3.bisector(function (d) {
|
|
2869
|
-
return
|
|
3101
|
+
return _this19.parseX(d.x.value);
|
|
2870
3102
|
}).left;
|
|
2871
3103
|
|
|
2872
3104
|
if (this.options.showTrackingLine === true && d3.pointer(event)) {
|
|
@@ -2885,18 +3117,18 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
2885
3117
|
var pointB = s.data[index];
|
|
2886
3118
|
|
|
2887
3119
|
if (pointA) {
|
|
2888
|
-
xPoint =
|
|
3120
|
+
xPoint = _this19.bottomAxis(_this19.parseX(pointA.x.value));
|
|
2889
3121
|
tooltipTitle = pointA.x.value;
|
|
2890
3122
|
|
|
2891
3123
|
if (typeof pointA.x.value.getTime !== 'undefined') {
|
|
2892
|
-
tooltipTitle = d3.timeFormat(
|
|
3124
|
+
tooltipTitle = d3.timeFormat(_this19.options.dateFormat)(pointA.x.value);
|
|
2893
3125
|
}
|
|
2894
3126
|
}
|
|
2895
3127
|
|
|
2896
3128
|
if (pointA && pointB) {
|
|
2897
|
-
var d0 =
|
|
3129
|
+
var d0 = _this19.bottomAxis(_this19.parseX(pointA.x.value));
|
|
2898
3130
|
|
|
2899
|
-
var d1 =
|
|
3131
|
+
var d1 = _this19.bottomAxis(_this19.parseX(pointB.x.value));
|
|
2900
3132
|
|
|
2901
3133
|
var mid = Math.abs(d0 - d1) / 2;
|
|
2902
3134
|
|
|
@@ -2905,7 +3137,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
2905
3137
|
tooltipTitle = pointB.x.value;
|
|
2906
3138
|
|
|
2907
3139
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
2908
|
-
tooltipTitle = d3.timeFormat(
|
|
3140
|
+
tooltipTitle = d3.timeFormat(_this19.options.dateFormat)(pointB.x.value);
|
|
2909
3141
|
}
|
|
2910
3142
|
|
|
2911
3143
|
tooltipData.push(pointB.y);
|
|
@@ -2956,6 +3188,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
2956
3188
|
this.areaLayer = this.svg.append('g');
|
|
2957
3189
|
this.lineLayer = this.svg.append('g');
|
|
2958
3190
|
this.barLayer = this.svg.append('g');
|
|
3191
|
+
this.labelLayer = this.svg.append('g');
|
|
2959
3192
|
this.symbolLayer = this.svg.append('g');
|
|
2960
3193
|
this.trackingLineLayer = this.svg.append('g');
|
|
2961
3194
|
this.trackingLineLayer.append('line').attr('class', 'tracking-line');
|
|
@@ -2967,7 +3200,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
2967
3200
|
}, {
|
|
2968
3201
|
key: "render",
|
|
2969
3202
|
value: function render(options) {
|
|
2970
|
-
var
|
|
3203
|
+
var _this20 = this;
|
|
2971
3204
|
|
|
2972
3205
|
/* global d3 options */
|
|
2973
3206
|
if (typeof options !== 'undefined') {
|
|
@@ -3150,6 +3383,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3150
3383
|
this.areaLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3151
3384
|
this.lineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3152
3385
|
this.barLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3386
|
+
this.labelLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3153
3387
|
this.symbolLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3154
3388
|
this.trackingLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3155
3389
|
this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
@@ -3200,7 +3434,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3200
3434
|
|
|
3201
3435
|
if (this.options.data.bottom.formatter) {
|
|
3202
3436
|
bAxisFunc.tickFormat(function (d) {
|
|
3203
|
-
return
|
|
3437
|
+
return _this20.options.data.bottom.formatter(d);
|
|
3204
3438
|
});
|
|
3205
3439
|
}
|
|
3206
3440
|
|
|
@@ -3226,8 +3460,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3226
3460
|
|
|
3227
3461
|
if (this.options.margin.axisLeft > 0) {
|
|
3228
3462
|
this.leftAxisLayer.call(d3.axisLeft(this.leftAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
3229
|
-
if (
|
|
3230
|
-
d =
|
|
3463
|
+
if (_this20.options.data.left.formatter) {
|
|
3464
|
+
d = _this20.options.data.left.formatter(d);
|
|
3231
3465
|
}
|
|
3232
3466
|
|
|
3233
3467
|
return d;
|
|
@@ -3262,8 +3496,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3262
3496
|
|
|
3263
3497
|
if (this.options.margin.axisRight > 0) {
|
|
3264
3498
|
this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
3265
|
-
if (
|
|
3266
|
-
d =
|
|
3499
|
+
if (_this20.options.data.right.formatter) {
|
|
3500
|
+
d = _this20.options.data.right.formatter(d);
|
|
3267
3501
|
}
|
|
3268
3502
|
|
|
3269
3503
|
return d;
|
|
@@ -3289,14 +3523,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3289
3523
|
|
|
3290
3524
|
this.options.data.series.forEach(function (series, index) {
|
|
3291
3525
|
if (!series.key) {
|
|
3292
|
-
series.key =
|
|
3526
|
+
series.key = _this20.createIdentity();
|
|
3293
3527
|
}
|
|
3294
3528
|
|
|
3295
3529
|
if (!series.color) {
|
|
3296
|
-
series.color =
|
|
3530
|
+
series.color = _this20.options.colors[index % _this20.options.colors.length];
|
|
3297
3531
|
}
|
|
3298
3532
|
|
|
3299
|
-
|
|
3533
|
+
_this20["render".concat(series.type || 'bar')](series, index);
|
|
3534
|
+
|
|
3535
|
+
_this20.renderLabels(series, index);
|
|
3300
3536
|
});
|
|
3301
3537
|
}
|
|
3302
3538
|
}
|
|
@@ -3304,17 +3540,17 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3304
3540
|
}, {
|
|
3305
3541
|
key: "renderarea",
|
|
3306
3542
|
value: function renderarea(series, index) {
|
|
3307
|
-
var
|
|
3543
|
+
var _this21 = this;
|
|
3308
3544
|
|
|
3309
3545
|
/* global d3 series index */
|
|
3310
3546
|
var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
|
|
3311
3547
|
return d3.area().x(function (d) {
|
|
3312
|
-
return
|
|
3548
|
+
return _this21[xAxis](_this21.parseX(d.x.value));
|
|
3313
3549
|
}).y0(function (d) {
|
|
3314
|
-
return
|
|
3550
|
+
return _this21[yAxis](0);
|
|
3315
3551
|
}).y1(function (d) {
|
|
3316
|
-
return
|
|
3317
|
-
}).curve(d3[curveStyle ||
|
|
3552
|
+
return _this21[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
3553
|
+
}).curve(d3[curveStyle || _this21.options.curveStyle]);
|
|
3318
3554
|
};
|
|
3319
3555
|
|
|
3320
3556
|
var xAxis = 'bottomAxis';
|
|
@@ -3400,18 +3636,72 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3400
3636
|
return "bar bar_".concat(series.key);
|
|
3401
3637
|
});
|
|
3402
3638
|
}
|
|
3639
|
+
}, {
|
|
3640
|
+
key: "renderLabels",
|
|
3641
|
+
value: function renderLabels(series, index) {
|
|
3642
|
+
/* global series index d3 */
|
|
3643
|
+
var xAxis = 'bottomAxis';
|
|
3644
|
+
var yAxis = 'leftAxis';
|
|
3645
|
+
var that = this;
|
|
3646
|
+
|
|
3647
|
+
if (this.options.orientation === 'horizontal') {
|
|
3648
|
+
xAxis = 'leftAxis';
|
|
3649
|
+
yAxis = 'bottomAxis';
|
|
3650
|
+
}
|
|
3651
|
+
|
|
3652
|
+
if (this.options.showLabels) {
|
|
3653
|
+
// need to add logic to handle positioning options
|
|
3654
|
+
// e.g. Inside, Outide, Auto (this will also affect the available plot space)
|
|
3655
|
+
// We currently only support 'Auto'
|
|
3656
|
+
var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
|
|
3657
|
+
labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
3658
|
+
labels.attr('x', getLabelX.bind(this)).attr('y', getLabelY.bind(this)).attr('class', ".label_".concat(series.key)).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
|
|
3659
|
+
return d.y.label || d.y.value;
|
|
3660
|
+
});
|
|
3661
|
+
labels.enter().append('text').attr('class', ".label_".concat(series.key)).attr('x', getLabelX.bind(this)).attr('y', getLabelY.bind(this)).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
|
|
3662
|
+
return d.y.label || d.y.value;
|
|
3663
|
+
}).each(function (d, i) {
|
|
3664
|
+
if (that.options.orientation === 'horizontal') {
|
|
3665
|
+
if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
3666
|
+
this.setAttribute('text-anchor', 'end');
|
|
3667
|
+
this.setAttribute('x', +this.getAttribute('x') - 8);
|
|
3668
|
+
}
|
|
3669
|
+
} else {
|
|
3670
|
+
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|
|
3671
|
+
this.setAttribute('y', +this.getAttribute('y') + 8);
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
});
|
|
3675
|
+
}
|
|
3676
|
+
|
|
3677
|
+
function getLabelX(d) {
|
|
3678
|
+
if (this.options.orientation === 'horizontal') {
|
|
3679
|
+
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4;
|
|
3680
|
+
} else {
|
|
3681
|
+
return this[xAxis](this.parseX(d.x.value)) + this[xAxis].bandwidth() / 2;
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
|
|
3685
|
+
function getLabelY(d) {
|
|
3686
|
+
if (this.options.orientation === 'horizontal') {
|
|
3687
|
+
return this[xAxis](this.parseX(d.x.value)) + this[xAxis].bandwidth() / 2;
|
|
3688
|
+
} else {
|
|
3689
|
+
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - 4;
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
}
|
|
3403
3693
|
}, {
|
|
3404
3694
|
key: "renderline",
|
|
3405
3695
|
value: function renderline(series, index) {
|
|
3406
|
-
var
|
|
3696
|
+
var _this22 = this;
|
|
3407
3697
|
|
|
3408
3698
|
/* global series index d3 */
|
|
3409
3699
|
var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
|
|
3410
3700
|
return d3.line().x(function (d) {
|
|
3411
|
-
return
|
|
3701
|
+
return _this22[xAxis](_this22.parseX(d.x.value));
|
|
3412
3702
|
}).y(function (d) {
|
|
3413
|
-
return
|
|
3414
|
-
}).curve(d3[curveStyle ||
|
|
3703
|
+
return _this22[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
3704
|
+
}).curve(d3[curveStyle || _this22.options.curveStyle]);
|
|
3415
3705
|
};
|
|
3416
3706
|
|
|
3417
3707
|
var xAxis = 'bottomAxis';
|
|
@@ -3449,14 +3739,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3449
3739
|
}, {
|
|
3450
3740
|
key: "rendersymbol",
|
|
3451
3741
|
value: function rendersymbol(series, index) {
|
|
3452
|
-
var
|
|
3742
|
+
var _this23 = this;
|
|
3453
3743
|
|
|
3454
3744
|
/* global d3 series index series.key */
|
|
3455
3745
|
var drawSymbol = function drawSymbol(size) {
|
|
3456
3746
|
return d3.symbol() // .type(d => {
|
|
3457
3747
|
// return d3.symbols[0]
|
|
3458
3748
|
// })
|
|
3459
|
-
.size(size ||
|
|
3749
|
+
.size(size || _this23.options.symbolSize);
|
|
3460
3750
|
};
|
|
3461
3751
|
|
|
3462
3752
|
var xAxis = 'bottomAxis';
|
|
@@ -3474,7 +3764,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3474
3764
|
symbols.attr('d', function (d) {
|
|
3475
3765
|
return drawSymbol(d.y.size || series.symbolSize)(d);
|
|
3476
3766
|
}).transition(this.transition).attr('fill', 'white').attr('stroke', series.color).attr('transform', function (d) {
|
|
3477
|
-
return "translate(".concat(
|
|
3767
|
+
return "translate(".concat(_this23[xAxis](_this23.parseX(d.x.value)), ", ").concat(_this23[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
3478
3768
|
}); // Enter
|
|
3479
3769
|
|
|
3480
3770
|
symbols.enter().append('path').attr('d', function (d) {
|
|
@@ -3483,7 +3773,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3483
3773
|
.attr('fill', 'white').attr('stroke', series.color).attr('class', function (d) {
|
|
3484
3774
|
return "symbol symbol_".concat(series.key);
|
|
3485
3775
|
}).attr('transform', function (d) {
|
|
3486
|
-
return "translate(".concat(
|
|
3776
|
+
return "translate(".concat(_this23[xAxis](_this23.parseX(d.x.value)), ", ").concat(_this23[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
3487
3777
|
});
|
|
3488
3778
|
}
|
|
3489
3779
|
}, {
|
|
@@ -3496,9 +3786,11 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3496
3786
|
this.width = el.clientWidth;
|
|
3497
3787
|
this.height = el.clientHeight;
|
|
3498
3788
|
this.svg.attr('width', this.width).attr('height', this.height); // Define the plot height
|
|
3789
|
+
// this.plotWidth = this.width - this.options.margin.left - this.options.margin.right - this.options.margin.axisLeft - this.options.margin.axisRight
|
|
3790
|
+
// this.plotHeight = this.height - this.options.margin.top - this.options.margin.bottom - this.options.margin.axisBottom
|
|
3499
3791
|
|
|
3500
3792
|
this.plotWidth = this.width - this.options.margin.left - this.options.margin.right - this.options.margin.axisLeft - this.options.margin.axisRight;
|
|
3501
|
-
this.plotHeight = this.height - this.options.margin.top - this.options.margin.bottom - this.options.margin.axisBottom; // establish the space needed for the various axes
|
|
3793
|
+
this.plotHeight = this.height - this.options.margin.top - this.options.margin.bottom - this.options.margin.axisBottom - this.options.margin.axisTop; // establish the space needed for the various axes
|
|
3502
3794
|
|
|
3503
3795
|
this.longestRight = 5;
|
|
3504
3796
|
this.longestBottom = 5;
|
|
@@ -3531,17 +3823,42 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3531
3823
|
this.options.margin.axisBottom = 0;
|
|
3532
3824
|
}
|
|
3533
3825
|
} // Translate the layers
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
this.bottomAxisLayer
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3826
|
+
// this.leftAxisLayer
|
|
3827
|
+
// .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
|
|
3828
|
+
// this.rightAxisLayer
|
|
3829
|
+
// .attr('transform', `translate(${this.options.margin.left + this.plotWidth + this.options.margin.axisLeft}, ${this.options.margin.top})`)
|
|
3830
|
+
// this.bottomAxisLayer
|
|
3831
|
+
// .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.plotHeight})`)
|
|
3832
|
+
// this.plotArea
|
|
3833
|
+
// .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
|
|
3834
|
+
// this.areaLayer
|
|
3835
|
+
// .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
|
|
3836
|
+
// this.lineLayer
|
|
3837
|
+
// .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
|
|
3838
|
+
// this.barLayer
|
|
3839
|
+
// .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
|
|
3840
|
+
// this.labelLayer
|
|
3841
|
+
// .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
|
|
3842
|
+
// this.symbolLayer
|
|
3843
|
+
// .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
|
|
3844
|
+
// this.trackingLineLayer
|
|
3845
|
+
// .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
|
|
3846
|
+
|
|
3847
|
+
|
|
3848
|
+
this.leftAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3849
|
+
this.rightAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.plotWidth + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3850
|
+
this.bottomAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop + this.plotHeight, ")"));
|
|
3851
|
+
this.leftAxisLabel.attr('transform', "translate(".concat(this.options.margin.left, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3852
|
+
this.rightAxisLabel.attr('transform', "translate(".concat(this.options.margin.left + this.plotWidth + this.options.margin.axisLeft + this.options.margin.axisRight, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3853
|
+
this.bottomAxisLabel.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop + this.plotHeight, ")"));
|
|
3854
|
+
this.plotArea.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3855
|
+
this.areaLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3856
|
+
this.lineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3857
|
+
this.barLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3858
|
+
this.labelLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3859
|
+
this.symbolLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3860
|
+
this.trackingLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3861
|
+
this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
3545
3862
|
}
|
|
3546
3863
|
}
|
|
3547
3864
|
}, {
|
|
@@ -3689,7 +4006,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
3689
4006
|
}, {
|
|
3690
4007
|
key: "render",
|
|
3691
4008
|
value: function render() {
|
|
3692
|
-
var
|
|
4009
|
+
var _this24 = this;
|
|
3693
4010
|
|
|
3694
4011
|
var el = document.getElementById("".concat(this.options.elementId, "_map"));
|
|
3695
4012
|
var t = L.tileLayer(this.options.tileUrl, {
|
|
@@ -3756,30 +4073,30 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
3756
4073
|
if (r.Latitude.qNum !== 0 && r.Longitude.qNum !== 0) {
|
|
3757
4074
|
var markerOptions = {};
|
|
3758
4075
|
|
|
3759
|
-
if (
|
|
4076
|
+
if (_this24.options.simpleMarker === true) {
|
|
3760
4077
|
markerOptions.icon = L.divIcon({
|
|
3761
4078
|
className: 'simple-marker'
|
|
3762
4079
|
});
|
|
3763
4080
|
}
|
|
3764
4081
|
|
|
3765
|
-
if (
|
|
4082
|
+
if (_this24.options.markerUrl) {
|
|
3766
4083
|
markerOptions.icon = L.icon({
|
|
3767
|
-
iconUrl:
|
|
4084
|
+
iconUrl: _this24.options.markerUrl
|
|
3768
4085
|
});
|
|
3769
4086
|
}
|
|
3770
4087
|
|
|
3771
4088
|
markerOptions.data = r;
|
|
3772
4089
|
var m = L.marker([r.Latitude.qText, r.Longitude.qText], markerOptions);
|
|
3773
|
-
m.on('click',
|
|
4090
|
+
m.on('click', _this24.handleMapClick.bind(_this24));
|
|
3774
4091
|
|
|
3775
|
-
if (
|
|
3776
|
-
m.addTo(
|
|
4092
|
+
if (_this24.options.useClustering === false) {
|
|
4093
|
+
m.addTo(_this24.map);
|
|
3777
4094
|
}
|
|
3778
4095
|
|
|
3779
|
-
|
|
4096
|
+
_this24.markers.push(m);
|
|
3780
4097
|
|
|
3781
|
-
if (
|
|
3782
|
-
|
|
4098
|
+
if (_this24.options.useClustering === true) {
|
|
4099
|
+
_this24.cluster.addLayer(m);
|
|
3783
4100
|
}
|
|
3784
4101
|
}
|
|
3785
4102
|
});
|
|
@@ -3864,6 +4181,30 @@ var WebsyChartTooltip = /*#__PURE__*/function () {
|
|
|
3864
4181
|
return WebsyChartTooltip;
|
|
3865
4182
|
}();
|
|
3866
4183
|
|
|
4184
|
+
var WebsyUtils = {
|
|
4185
|
+
createIdentity: function createIdentity() {
|
|
4186
|
+
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 6;
|
|
4187
|
+
var text = '';
|
|
4188
|
+
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
4189
|
+
|
|
4190
|
+
for (var i = 0; i < size; i++) {
|
|
4191
|
+
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
4192
|
+
}
|
|
4193
|
+
|
|
4194
|
+
return text;
|
|
4195
|
+
},
|
|
4196
|
+
getElementPos: function getElementPos(el) {
|
|
4197
|
+
var rect = el.getBoundingClientRect();
|
|
4198
|
+
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
4199
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
4200
|
+
return {
|
|
4201
|
+
top: rect.top + scrollTop,
|
|
4202
|
+
left: rect.left + scrollLeft,
|
|
4203
|
+
bottom: rect.top + scrollTop + el.clientHeight,
|
|
4204
|
+
right: rect.left + scrollLeft + el.clientWidth
|
|
4205
|
+
};
|
|
4206
|
+
}
|
|
4207
|
+
};
|
|
3867
4208
|
var WebsyDesigns = {
|
|
3868
4209
|
WebsyPopupDialog: WebsyPopupDialog,
|
|
3869
4210
|
WebsyLoadingDialog: WebsyLoadingDialog,
|
|
@@ -3872,6 +4213,7 @@ var WebsyDesigns = {
|
|
|
3872
4213
|
WebsyDatePicker: WebsyDatePicker,
|
|
3873
4214
|
WebsyDropdown: WebsyDropdown,
|
|
3874
4215
|
WebsyResultList: WebsyResultList,
|
|
4216
|
+
WebsyTemplate: WebsyTemplate,
|
|
3875
4217
|
WebsyPubSub: WebsyPubSub,
|
|
3876
4218
|
WebsyRouter: WebsyRouter,
|
|
3877
4219
|
WebsyTable: WebsyTable,
|
|
@@ -3881,7 +4223,8 @@ var WebsyDesigns = {
|
|
|
3881
4223
|
WebsyKPI: WebsyKPI,
|
|
3882
4224
|
WebsyPDFButton: WebsyPDFButton,
|
|
3883
4225
|
PDFButton: WebsyPDFButton,
|
|
3884
|
-
APIService: APIService
|
|
4226
|
+
APIService: APIService,
|
|
4227
|
+
WebsyUtils: WebsyUtils
|
|
3885
4228
|
};
|
|
3886
4229
|
var GlobalPubSub = new WebsyPubSub('empty', {});
|
|
3887
4230
|
|