@websy/websy-designs 1.2.32 → 1.2.33
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/websy-designs-es6.debug.js +880 -19
- package/dist/websy-designs-es6.js +1187 -200
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +880 -20
- package/dist/websy-designs.js +1180 -192
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -1238,12 +1238,326 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
1238
1238
|
Date.prototype.floor = function () {
|
|
1239
1239
|
return new Date("".concat(this.getMonth() + 1, "/").concat(this.getDate(), "/").concat(this.getFullYear()));
|
|
1240
1240
|
};
|
|
1241
|
+
/* global WebsyDesigns GlobalPubSub */
|
|
1242
|
+
|
|
1243
|
+
|
|
1244
|
+
var WebsyDragDrop = /*#__PURE__*/function () {
|
|
1245
|
+
function WebsyDragDrop(elementId, options) {
|
|
1246
|
+
_classCallCheck(this, WebsyDragDrop);
|
|
1247
|
+
|
|
1248
|
+
var DEFAULTS = {
|
|
1249
|
+
items: [],
|
|
1250
|
+
orientation: 'horizontal',
|
|
1251
|
+
dropPlaceholder: 'Drop item here'
|
|
1252
|
+
};
|
|
1253
|
+
this.busy = false;
|
|
1254
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
1255
|
+
this.elementId = elementId;
|
|
1256
|
+
|
|
1257
|
+
if (!elementId) {
|
|
1258
|
+
console.log('No element Id provided for Websy DragDrop');
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
var el = document.getElementById(elementId);
|
|
1263
|
+
|
|
1264
|
+
if (el) {
|
|
1265
|
+
el.innerHTML = "\n <div id='".concat(this.elementId, "_container' class='websy-drag-drop-container ").concat(this.options.orientation, "'>\n <div>\n </div>\n ");
|
|
1266
|
+
el.addEventListener('click', this.handleClick.bind(this));
|
|
1267
|
+
el.addEventListener('dragstart', this.handleDragStart.bind(this));
|
|
1268
|
+
el.addEventListener('dragover', this.handleDragOver.bind(this));
|
|
1269
|
+
el.addEventListener('dragleave', this.handleDragLeave.bind(this));
|
|
1270
|
+
el.addEventListener('drop', this.handleDrop.bind(this));
|
|
1271
|
+
window.addEventListener('dragend', this.handleDragEnd.bind(this));
|
|
1272
|
+
} else {
|
|
1273
|
+
console.error("No element found with ID ".concat(this.elementId));
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
GlobalPubSub.subscribe(this.elementId, 'requestForDDItem', this.handleRequestForItem.bind(this));
|
|
1277
|
+
console.log('constructor dd');
|
|
1278
|
+
console.trace();
|
|
1279
|
+
GlobalPubSub.subscribe(this.elementId, 'add', this.addItem.bind(this));
|
|
1280
|
+
this.render();
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
_createClass(WebsyDragDrop, [{
|
|
1284
|
+
key: "addItem",
|
|
1285
|
+
value: function addItem(data) {
|
|
1286
|
+
if (data.target === this.elementId && this.busy === false) {
|
|
1287
|
+
this.busy = true;
|
|
1288
|
+
console.log('adding item to dd'); // check that an item with the same id doesn't already exist
|
|
1289
|
+
|
|
1290
|
+
var index = this.getItemIndex(data.item.id);
|
|
1291
|
+
|
|
1292
|
+
if (index === -1) {
|
|
1293
|
+
this.options.items.splice(data.index, 0, data.item);
|
|
1294
|
+
var startEl = document.getElementById("".concat(this.elementId, "start_item"));
|
|
1295
|
+
|
|
1296
|
+
if (startEl) {
|
|
1297
|
+
if (this.options.items.length === 0) {
|
|
1298
|
+
startEl.classList.add('empty');
|
|
1299
|
+
} else {
|
|
1300
|
+
startEl.classList.remove('empty');
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
if (this.options.onItemAdded) {
|
|
1305
|
+
this.options.onItemAdded();
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
this.busy = false;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
}, {
|
|
1313
|
+
key: "createItemHtml",
|
|
1314
|
+
value: function createItemHtml(elementId, index, item) {
|
|
1315
|
+
if (!item.id) {
|
|
1316
|
+
item.id = WebsyDesigns.Utils.createIdentity();
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
var html = "\n <div id='".concat(item.id, "_item' class='websy-dragdrop-item' draggable='true' data-id='").concat(item.id, "'> \n <div id='").concat(item.id, "_itemInner' class='websy-dragdrop-item-inner' data-id='").concat(item.id, "'>\n ");
|
|
1320
|
+
|
|
1321
|
+
if (item.component) {
|
|
1322
|
+
html += "<div id='".concat(item.id, "_component'></div>");
|
|
1323
|
+
} else {
|
|
1324
|
+
html += "".concat(item.html || item.label || '');
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
html += "\n </div>\n <div id='".concat(item.id, "_dropZone' class='websy-drop-zone droppable' data-index='").concat(item.id, "' data-side='right' data-id='").concat(item.id, "' data-placeholder='").concat(this.options.dropPlaceholder, "'></div> \n </div>\n ");
|
|
1328
|
+
return html;
|
|
1329
|
+
}
|
|
1330
|
+
}, {
|
|
1331
|
+
key: "getItemIndex",
|
|
1332
|
+
value: function getItemIndex(id) {
|
|
1333
|
+
for (var i = 0; i < this.options.items.length; i++) {
|
|
1334
|
+
if (this.options.items[i].id === id) {
|
|
1335
|
+
return i;
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
return -1;
|
|
1340
|
+
}
|
|
1341
|
+
}, {
|
|
1342
|
+
key: "handleClick",
|
|
1343
|
+
value: function handleClick(event) {}
|
|
1344
|
+
}, {
|
|
1345
|
+
key: "handleDragStart",
|
|
1346
|
+
value: function handleDragStart(event) {
|
|
1347
|
+
this.draggedId = event.target.getAttribute('data-id');
|
|
1348
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
1349
|
+
event.dataTransfer.setData('application/wd-item', JSON.stringify({
|
|
1350
|
+
el: event.target.id,
|
|
1351
|
+
id: this.elementId,
|
|
1352
|
+
itemId: this.draggedId
|
|
1353
|
+
}));
|
|
1354
|
+
console.log('drag start', event);
|
|
1355
|
+
event.target.style.opacity = 0.5;
|
|
1356
|
+
this.dragging = true;
|
|
1357
|
+
}
|
|
1358
|
+
}, {
|
|
1359
|
+
key: "handleDragOver",
|
|
1360
|
+
value: function handleDragOver(event) {
|
|
1361
|
+
console.log('drag over', event.target.classList);
|
|
1362
|
+
|
|
1363
|
+
if (event.preventDefault) {
|
|
1364
|
+
event.preventDefault();
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
if (!event.target.classList.contains('droppable')) {
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
event.target.classList.add('drag-over');
|
|
1372
|
+
}
|
|
1373
|
+
}, {
|
|
1374
|
+
key: "handleDragLeave",
|
|
1375
|
+
value: function handleDragLeave(event) {
|
|
1376
|
+
console.log('drag leave', event.target.classList);
|
|
1377
|
+
|
|
1378
|
+
if (!event.target.classList.contains('droppable')) {
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
event.target.classList.remove('drag-over'); // let side = event.target.getAttribute('data-side')
|
|
1383
|
+
// let id = event.target.getAttribute('data-id')
|
|
1384
|
+
// let droppedItem = this.options.items[id]
|
|
1385
|
+
// this.removeExpandedDrop(side, id, droppedItem)
|
|
1386
|
+
}
|
|
1387
|
+
}, {
|
|
1388
|
+
key: "handleDrop",
|
|
1389
|
+
value: function handleDrop(event) {
|
|
1390
|
+
console.log('drag drop');
|
|
1391
|
+
console.log(event.dataTransfer.getData('application/wd-item'));
|
|
1392
|
+
var data = JSON.parse(event.dataTransfer.getData('application/wd-item'));
|
|
1393
|
+
|
|
1394
|
+
if (event.preventDefault) {
|
|
1395
|
+
event.preventDefault();
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
if (!event.target.classList.contains('droppable')) {
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
var side = event.target.getAttribute('data-side');
|
|
1403
|
+
var id = event.target.getAttribute('data-id');
|
|
1404
|
+
var index = this.getItemIndex(id);
|
|
1405
|
+
var draggedIndex = this.getItemIndex(data.id);
|
|
1406
|
+
var droppedItem = this.options.items[index];
|
|
1407
|
+
|
|
1408
|
+
if (side === 'right') {
|
|
1409
|
+
index += 1;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
if (draggedIndex === -1) {
|
|
1413
|
+
console.log('requestForDDItem');
|
|
1414
|
+
GlobalPubSub.publish(data.id, 'requestForDDItem', {
|
|
1415
|
+
group: this.options.group,
|
|
1416
|
+
source: data.id,
|
|
1417
|
+
target: this.elementId,
|
|
1418
|
+
index: index,
|
|
1419
|
+
id: data.itemId
|
|
1420
|
+
});
|
|
1421
|
+
} else if (index > draggedIndex) {
|
|
1422
|
+
// insert and then remove
|
|
1423
|
+
this.options.items.splice(index, 0, droppedItem);
|
|
1424
|
+
this.options.items.splice(draggedIndex, 1);
|
|
1425
|
+
|
|
1426
|
+
if (this.options.onOrderUpdated) {
|
|
1427
|
+
this.options.onOrderUpdated();
|
|
1428
|
+
}
|
|
1429
|
+
} else {
|
|
1430
|
+
// remove and then insert
|
|
1431
|
+
this.options.items.splice(draggedIndex, 1);
|
|
1432
|
+
this.options.items.splice(index, 0, droppedItem);
|
|
1433
|
+
|
|
1434
|
+
if (this.options.onOrderUpdated) {
|
|
1435
|
+
this.options.onOrderUpdated();
|
|
1436
|
+
}
|
|
1437
|
+
} // this.removeExpandedDrop(side, id, droppedItem)
|
|
1438
|
+
// const draggedEl = document.getElementById(`${this.elementId}_${this.draggedId}_item`)
|
|
1439
|
+
|
|
1440
|
+
|
|
1441
|
+
var draggedEl = document.getElementById(data.el);
|
|
1442
|
+
var droppedEl = document.getElementById("".concat(id, "_item"));
|
|
1443
|
+
|
|
1444
|
+
if (draggedEl) {
|
|
1445
|
+
droppedEl.insertAdjacentElement('afterend', draggedEl);
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
var dragOverEl = droppedEl.querySelector('.drag-over');
|
|
1449
|
+
|
|
1450
|
+
if (dragOverEl) {
|
|
1451
|
+
dragOverEl.classList.remove('drag-over');
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}, {
|
|
1455
|
+
key: "handleDragEnd",
|
|
1456
|
+
value: function handleDragEnd(event) {
|
|
1457
|
+
console.log('drag end');
|
|
1458
|
+
event.target.style.opacity = 1;
|
|
1459
|
+
this.draggedId = null;
|
|
1460
|
+
this.dragging = false;
|
|
1461
|
+
var startEl = document.getElementById("".concat(this.elementId, "start_item"));
|
|
1462
|
+
|
|
1463
|
+
if (startEl) {
|
|
1464
|
+
if (this.options.items.length === 0) {
|
|
1465
|
+
startEl.classList.add('empty');
|
|
1466
|
+
} else {
|
|
1467
|
+
startEl.classList.remove('empty');
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
}, {
|
|
1472
|
+
key: "handleRequestForItem",
|
|
1473
|
+
value: function handleRequestForItem(data) {
|
|
1474
|
+
if (data.group === this.options.group) {
|
|
1475
|
+
var index = this.getItemIndex(data.id);
|
|
1476
|
+
|
|
1477
|
+
if (index !== -1) {
|
|
1478
|
+
var itemToAdd = this.options.items.splice(index, 1);
|
|
1479
|
+
GlobalPubSub.publish(data.target, 'add', {
|
|
1480
|
+
target: data.target,
|
|
1481
|
+
index: data.index,
|
|
1482
|
+
item: itemToAdd[0]
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
}, {
|
|
1488
|
+
key: "measureItems",
|
|
1489
|
+
value: function measureItems() {
|
|
1490
|
+
var el = document.getElementById("".concat(this.elementId, "_container"));
|
|
1491
|
+
this.options.items.forEach(function (d) {});
|
|
1492
|
+
} // removeExpandedDrop (side, id, droppedItem) {
|
|
1493
|
+
// let dropEl
|
|
1494
|
+
// const dropImageEl = document.getElementById(`${id}_itemInner`)
|
|
1495
|
+
// // const placeholderEl = document.getElementById(`${this.elementId}_${id}_dropZonePlaceholder`)
|
|
1496
|
+
// if (side === 'left') {
|
|
1497
|
+
// dropEl = document.getElementById(`${this.elementId}_${id}_dropZoneLeft`)
|
|
1498
|
+
// dropImageEl.style.left = `0px`
|
|
1499
|
+
// }
|
|
1500
|
+
// else if (side === 'right') {
|
|
1501
|
+
// dropEl = document.getElementById(`${this.elementId}_${id}_dropZoneRight`)
|
|
1502
|
+
// }
|
|
1503
|
+
// else {
|
|
1504
|
+
// dropEl = document.getElementById(`${this.elementId}_${id}_dropZoneEnd`)
|
|
1505
|
+
// }
|
|
1506
|
+
// if (dropEl) {
|
|
1507
|
+
// const dropElSize = dropEl.getBoundingClientRect()
|
|
1508
|
+
// dropEl.style.width = `${(dropElSize.width / 2)}px`
|
|
1509
|
+
// dropEl.style.marginLeft = null
|
|
1510
|
+
// dropEl.style.border = null
|
|
1511
|
+
// }
|
|
1512
|
+
// if (placeholderEl) {
|
|
1513
|
+
// placeholderEl.classList.remove('active')
|
|
1514
|
+
// placeholderEl.style.left = null
|
|
1515
|
+
// placeholderEl.style.right = null
|
|
1516
|
+
// placeholderEl.style.width = null
|
|
1517
|
+
// placeholderEl.style.height = null
|
|
1518
|
+
// }
|
|
1519
|
+
// }
|
|
1520
|
+
|
|
1521
|
+
}, {
|
|
1522
|
+
key: "removeItem",
|
|
1523
|
+
value: function removeItem(id) {}
|
|
1524
|
+
}, {
|
|
1525
|
+
key: "render",
|
|
1526
|
+
value: function render() {
|
|
1527
|
+
var _this8 = this;
|
|
1528
|
+
|
|
1529
|
+
var el = document.getElementById("".concat(this.elementId, "_container"));
|
|
1530
|
+
|
|
1531
|
+
if (el) {
|
|
1532
|
+
this.measureItems();
|
|
1533
|
+
var html = "\n <div id='".concat(this.elementId, "start_item' class='websy-dragdrop-item ").concat(this.options.items.length === 0 ? 'empty' : '', "' data-id='").concat(this.elementId, "start'>\n <div id='").concat(this.elementId, "start_dropZone' class='websy-drop-zone droppable' data-index='start' data-side='start' data-id='").concat(this.elementId, "start' data-placeholder='").concat(this.options.dropPlaceholder, "'></div>\n </div>\n ");
|
|
1534
|
+
html += this.options.items.map(function (d, i) {
|
|
1535
|
+
return _this8.createItemHtml(_this8.elementId, i, d);
|
|
1536
|
+
}).join('');
|
|
1537
|
+
el.innerHTML = html;
|
|
1538
|
+
this.options.items.forEach(function (item, i) {
|
|
1539
|
+
if (item.component) {
|
|
1540
|
+
if (item.isQlikPlugin && WebsyDesigns.QlikPlugin[item.component]) {
|
|
1541
|
+
item.instance = new WebsyDesigns.QlikPlugin[item.component]("".concat(item.id, "_component"), item.options);
|
|
1542
|
+
} else if (WebsyDesigns[item.component]) {
|
|
1543
|
+
item.instance = new WebsyDesigns[item.component]("".concat(item.id, "_component"), item.options);
|
|
1544
|
+
} else {
|
|
1545
|
+
console.error("Component ".concat(item.component, " not found."));
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
}]);
|
|
1552
|
+
|
|
1553
|
+
return WebsyDragDrop;
|
|
1554
|
+
}();
|
|
1241
1555
|
/* global WebsyUtils */
|
|
1242
1556
|
|
|
1243
1557
|
|
|
1244
1558
|
var WebsyDropdown = /*#__PURE__*/function () {
|
|
1245
1559
|
function WebsyDropdown(elementId, options) {
|
|
1246
|
-
var
|
|
1560
|
+
var _this9 = this;
|
|
1247
1561
|
|
|
1248
1562
|
_classCallCheck(this, WebsyDropdown);
|
|
1249
1563
|
|
|
@@ -1291,10 +1605,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1291
1605
|
el.addEventListener('mouseout', this.handleMouseOut.bind(this));
|
|
1292
1606
|
el.addEventListener('mousemove', this.handleMouseMove.bind(this));
|
|
1293
1607
|
var headerLabel = this.selectedItems.map(function (s) {
|
|
1294
|
-
return
|
|
1608
|
+
return _this9.options.items[s].label || _this9.options.items[s].value;
|
|
1295
1609
|
}).join(this.options.multiValueDelimiter);
|
|
1296
1610
|
var headerValue = this.selectedItems.map(function (s) {
|
|
1297
|
-
return
|
|
1611
|
+
return _this9.options.items[s].value || _this9.options.items[s].label;
|
|
1298
1612
|
}).join(this.options.multiValueDelimiter);
|
|
1299
1613
|
var html = "\n <div id='".concat(this.elementId, "_container' class='websy-dropdown-container ").concat(this.options.disabled ? 'disabled' : '', " ").concat(this.options.disableSearch !== true ? 'with-search' : '', " ").concat(this.options.style, " ").concat(this.options.customActions.length > 0 ? 'with-actions' : '', "'>\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 ").concat(this.options.searchIcon, "\n <span>\n <span class='websy-dropdown-header-value' data-info='").concat(headerLabel, "' id='").concat(this.elementId, "_selectedItems'>").concat(headerLabel, "</span> \n <span class='websy-dropdown-header-label' id='").concat(this.elementId, "_headerLabel'>").concat(this.options.label, "</span>\n </span>\n <input class='dropdown-input' id='").concat(this.elementId, "_input' name='").concat(this.options.field || this.options.label, "' value='").concat(headerValue, "'>\n ").concat(this.options.arrowIcon, "\n ");
|
|
1300
1614
|
|
|
@@ -1577,10 +1891,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1577
1891
|
}, {
|
|
1578
1892
|
key: "renderItems",
|
|
1579
1893
|
value: function renderItems() {
|
|
1580
|
-
var
|
|
1894
|
+
var _this10 = this;
|
|
1581
1895
|
|
|
1582
1896
|
var html = this.options.items.map(function (r, i) {
|
|
1583
|
-
return "\n <li data-index='".concat(r.index, "' class='websy-dropdown-item ").concat((r.classes || []).join(' '), " ").concat(
|
|
1897
|
+
return "\n <li data-index='".concat(r.index, "' class='websy-dropdown-item ").concat((r.classes || []).join(' '), " ").concat(_this10.selectedItems.indexOf(r.index) !== -1 ? 'active' : '', "'>").concat(r.label, "</li>\n ");
|
|
1584
1898
|
}).join('');
|
|
1585
1899
|
var el = document.getElementById("".concat(this.elementId, "_items"));
|
|
1586
1900
|
|
|
@@ -1599,7 +1913,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1599
1913
|
}, {
|
|
1600
1914
|
key: "updateHeader",
|
|
1601
1915
|
value: function updateHeader(item) {
|
|
1602
|
-
var
|
|
1916
|
+
var _this11 = this;
|
|
1603
1917
|
|
|
1604
1918
|
var el = document.getElementById(this.elementId);
|
|
1605
1919
|
var headerEl = document.getElementById("".concat(this.elementId, "_header"));
|
|
@@ -1646,17 +1960,17 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1646
1960
|
} else if (this.selectedItems.length > 1) {
|
|
1647
1961
|
if (this.options.showCompleteSelectedList === true) {
|
|
1648
1962
|
var selectedLabels = this.selectedItems.map(function (s) {
|
|
1649
|
-
return
|
|
1963
|
+
return _this11.options.items[s].label || _this11.options.items[s].value;
|
|
1650
1964
|
}).join(this.options.multiValueDelimiter);
|
|
1651
1965
|
var selectedValues = this.selectedItems.map(function (s) {
|
|
1652
|
-
return
|
|
1966
|
+
return _this11.options.items[s].value || _this11.options.items[s].label;
|
|
1653
1967
|
}).join(this.options.multiValueDelimiter);
|
|
1654
1968
|
labelEl.innerHTML = selectedLabels;
|
|
1655
1969
|
labelEl.setAttribute('data-info', selectedLabels);
|
|
1656
1970
|
inputEl.value = selectedValues;
|
|
1657
1971
|
} else {
|
|
1658
1972
|
var _selectedValues = this.selectedItems.map(function (s) {
|
|
1659
|
-
return
|
|
1973
|
+
return _this11.options.items[s].value || _this11.options.items[s].label;
|
|
1660
1974
|
}).join(this.options.multiValueDelimiter);
|
|
1661
1975
|
|
|
1662
1976
|
labelEl.innerHTML = "".concat(this.selectedItems.length, " selected");
|
|
@@ -1685,13 +1999,14 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1685
1999
|
this.selectedItems.push(index);
|
|
1686
2000
|
}
|
|
1687
2001
|
}
|
|
1688
|
-
}
|
|
2002
|
+
} // const item = this.options.items[index]
|
|
2003
|
+
|
|
1689
2004
|
|
|
1690
|
-
var item = this.options.items[index];
|
|
2005
|
+
var item = this._originalData[index] || this.options.items[index];
|
|
1691
2006
|
this.updateHeader(item);
|
|
1692
2007
|
|
|
1693
2008
|
if (item && this.options.onItemSelected) {
|
|
1694
|
-
this.options.onItemSelected(item, this.selectedItems, this.options.items, this.options);
|
|
2009
|
+
this.options.onItemSelected(item, this.selectedItems, this._originalData || this.options.items, this.options);
|
|
1695
2010
|
}
|
|
1696
2011
|
|
|
1697
2012
|
if (this.options.closeAfterSelection === true) {
|
|
@@ -1713,6 +2028,12 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1713
2028
|
|
|
1714
2029
|
return d;
|
|
1715
2030
|
});
|
|
2031
|
+
var headerEl = document.getElementById("".concat(this.elementId, "_header"));
|
|
2032
|
+
|
|
2033
|
+
if (headerEl) {
|
|
2034
|
+
headerEl.classList["".concat(this.options.allowClear === true ? 'add' : 'remove')]('allow-clear');
|
|
2035
|
+
}
|
|
2036
|
+
|
|
1716
2037
|
var el = document.getElementById("".concat(this.elementId, "_items"));
|
|
1717
2038
|
|
|
1718
2039
|
if (el.childElementCount === 0) {
|
|
@@ -1793,16 +2114,16 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1793
2114
|
}, {
|
|
1794
2115
|
key: "checkRecaptcha",
|
|
1795
2116
|
value: function checkRecaptcha() {
|
|
1796
|
-
var
|
|
2117
|
+
var _this12 = this;
|
|
1797
2118
|
|
|
1798
2119
|
return new Promise(function (resolve, reject) {
|
|
1799
|
-
if (
|
|
2120
|
+
if (_this12.options.useRecaptcha === true) {
|
|
1800
2121
|
// if (this.recaptchaValue) {
|
|
1801
2122
|
grecaptcha.ready(function () {
|
|
1802
2123
|
grecaptcha.execute(ENVIRONMENT.RECAPTCHA_KEY, {
|
|
1803
2124
|
action: 'submit'
|
|
1804
2125
|
}).then(function (token) {
|
|
1805
|
-
|
|
2126
|
+
_this12.apiService.add('google/checkrecaptcha', {
|
|
1806
2127
|
grecaptcharesponse: token
|
|
1807
2128
|
}).then(function (response) {
|
|
1808
2129
|
if (response.success && response.success === true) {
|
|
@@ -1865,14 +2186,14 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1865
2186
|
}, {
|
|
1866
2187
|
key: "processComponents",
|
|
1867
2188
|
value: function processComponents(components, callbackFn) {
|
|
1868
|
-
var
|
|
2189
|
+
var _this13 = this;
|
|
1869
2190
|
|
|
1870
2191
|
if (components.length === 0) {
|
|
1871
2192
|
callbackFn();
|
|
1872
2193
|
} else {
|
|
1873
2194
|
components.forEach(function (c) {
|
|
1874
2195
|
if (typeof WebsyDesigns[c.component] !== 'undefined') {
|
|
1875
|
-
c.instance = new WebsyDesigns[c.component]("".concat(
|
|
2196
|
+
c.instance = new WebsyDesigns[c.component]("".concat(_this13.elementId, "_input_").concat(c.field, "_component"), c.options);
|
|
1876
2197
|
} else {// some user feedback here
|
|
1877
2198
|
}
|
|
1878
2199
|
});
|
|
@@ -1893,7 +2214,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1893
2214
|
}, {
|
|
1894
2215
|
key: "render",
|
|
1895
2216
|
value: function render(update, data) {
|
|
1896
|
-
var
|
|
2217
|
+
var _this14 = this;
|
|
1897
2218
|
|
|
1898
2219
|
var el = document.getElementById(this.elementId);
|
|
1899
2220
|
var componentsToProcess = [];
|
|
@@ -1903,11 +2224,11 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1903
2224
|
this.options.fields.forEach(function (f, i) {
|
|
1904
2225
|
if (f.component) {
|
|
1905
2226
|
componentsToProcess.push(f);
|
|
1906
|
-
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(
|
|
2227
|
+
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(_this14.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n </div><!--\n ");
|
|
1907
2228
|
} else if (f.type === 'longtext') {
|
|
1908
|
-
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(
|
|
2229
|
+
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(_this14.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n name=\"").concat(f.field, "\" \n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea\"\n ></textarea>\n </div><!--\n ");
|
|
1909
2230
|
} else {
|
|
1910
|
-
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(
|
|
2231
|
+
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(_this14.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat(f.type || 'text', "\" \n class=\"websy-input\" \n ").concat((f.attributes || []).join(' '), "\n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.value || '', "\"\n valueAsDate=\"").concat(f.type === 'date' ? f.value : '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n </div><!--\n ");
|
|
1911
2232
|
}
|
|
1912
2233
|
});
|
|
1913
2234
|
html += "\n --><button class=\"websy-btn submit ".concat(this.options.submit.classes || '', "\">").concat(this.options.submit.text || 'Save', "</button>").concat(this.options.cancel ? '<!--' : '', "\n ");
|
|
@@ -1924,7 +2245,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1924
2245
|
|
|
1925
2246
|
el.innerHTML = html;
|
|
1926
2247
|
this.processComponents(componentsToProcess, function () {
|
|
1927
|
-
if (
|
|
2248
|
+
if (_this14.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {// this.recaptchaReady()
|
|
1928
2249
|
}
|
|
1929
2250
|
});
|
|
1930
2251
|
}
|
|
@@ -1932,7 +2253,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1932
2253
|
}, {
|
|
1933
2254
|
key: "submitForm",
|
|
1934
2255
|
value: function submitForm() {
|
|
1935
|
-
var
|
|
2256
|
+
var _this15 = this;
|
|
1936
2257
|
|
|
1937
2258
|
var formEl = document.getElementById("".concat(this.elementId, "Form"));
|
|
1938
2259
|
|
|
@@ -1946,32 +2267,32 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1946
2267
|
data[key] = value;
|
|
1947
2268
|
});
|
|
1948
2269
|
|
|
1949
|
-
if (
|
|
1950
|
-
var
|
|
2270
|
+
if (_this15.options.url) {
|
|
2271
|
+
var _this15$apiService;
|
|
1951
2272
|
|
|
1952
|
-
var params = [
|
|
2273
|
+
var params = [_this15.options.url];
|
|
1953
2274
|
|
|
1954
|
-
if (
|
|
1955
|
-
params.push(
|
|
2275
|
+
if (_this15.options.mode === 'update') {
|
|
2276
|
+
params.push(_this15.options.id);
|
|
1956
2277
|
}
|
|
1957
2278
|
|
|
1958
2279
|
params.push(data);
|
|
1959
2280
|
|
|
1960
|
-
(
|
|
1961
|
-
if (
|
|
2281
|
+
(_this15$apiService = _this15.apiService)[_this15.options.mode].apply(_this15$apiService, params).then(function (result) {
|
|
2282
|
+
if (_this15.options.clearAfterSave === true) {
|
|
1962
2283
|
// this.render()
|
|
1963
2284
|
formEl.reset();
|
|
1964
2285
|
}
|
|
1965
2286
|
|
|
1966
|
-
|
|
2287
|
+
_this15.options.onSuccess.call(_this15, result);
|
|
1967
2288
|
}, function (err) {
|
|
1968
2289
|
console.log('Error submitting form data:', err);
|
|
1969
2290
|
|
|
1970
|
-
|
|
2291
|
+
_this15.options.onError.call(_this15, err);
|
|
1971
2292
|
});
|
|
1972
|
-
} else if (
|
|
1973
|
-
|
|
1974
|
-
if (
|
|
2293
|
+
} else if (_this15.options.submitFn) {
|
|
2294
|
+
_this15.options.submitFn(data, function () {
|
|
2295
|
+
if (_this15.options.clearAfterSave === true) {
|
|
1975
2296
|
// this.render()
|
|
1976
2297
|
formEl.reset();
|
|
1977
2298
|
}
|
|
@@ -1991,17 +2312,17 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1991
2312
|
}, {
|
|
1992
2313
|
key: "data",
|
|
1993
2314
|
set: function set(d) {
|
|
1994
|
-
var
|
|
2315
|
+
var _this16 = this;
|
|
1995
2316
|
|
|
1996
2317
|
if (!this.options.fields) {
|
|
1997
2318
|
this.options.fields = [];
|
|
1998
2319
|
}
|
|
1999
2320
|
|
|
2000
2321
|
var _loop = function _loop(key) {
|
|
2001
|
-
|
|
2322
|
+
_this16.options.fields.forEach(function (f) {
|
|
2002
2323
|
if (f.field === key) {
|
|
2003
2324
|
f.value = d[key];
|
|
2004
|
-
var el = document.getElementById("".concat(
|
|
2325
|
+
var el = document.getElementById("".concat(_this16.elementId, "_input_").concat(f.field));
|
|
2005
2326
|
el.value = f.value;
|
|
2006
2327
|
}
|
|
2007
2328
|
});
|
|
@@ -2313,7 +2634,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
2313
2634
|
|
|
2314
2635
|
var Pager = /*#__PURE__*/function () {
|
|
2315
2636
|
function Pager(elementId, options) {
|
|
2316
|
-
var
|
|
2637
|
+
var _this17 = this;
|
|
2317
2638
|
|
|
2318
2639
|
_classCallCheck(this, Pager);
|
|
2319
2640
|
|
|
@@ -2366,8 +2687,8 @@ var Pager = /*#__PURE__*/function () {
|
|
|
2366
2687
|
allowClear: false,
|
|
2367
2688
|
disableSearch: true,
|
|
2368
2689
|
onItemSelected: function onItemSelected(selectedItem) {
|
|
2369
|
-
if (
|
|
2370
|
-
|
|
2690
|
+
if (_this17.options.onChangePageSize) {
|
|
2691
|
+
_this17.options.onChangePageSize(selectedItem.value);
|
|
2371
2692
|
}
|
|
2372
2693
|
}
|
|
2373
2694
|
});
|
|
@@ -2391,13 +2712,13 @@ var Pager = /*#__PURE__*/function () {
|
|
|
2391
2712
|
}, {
|
|
2392
2713
|
key: "render",
|
|
2393
2714
|
value: function render() {
|
|
2394
|
-
var
|
|
2715
|
+
var _this18 = this;
|
|
2395
2716
|
|
|
2396
2717
|
var el = document.getElementById("".concat(this.elementId, "_pageList"));
|
|
2397
2718
|
|
|
2398
2719
|
if (el) {
|
|
2399
2720
|
var pages = this.options.pages.map(function (item, index) {
|
|
2400
|
-
return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(
|
|
2721
|
+
return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(_this18.options.activePage === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
2401
2722
|
});
|
|
2402
2723
|
var startIndex = 0;
|
|
2403
2724
|
|
|
@@ -2465,58 +2786,58 @@ var WebsyPDFButton = /*#__PURE__*/function () {
|
|
|
2465
2786
|
_createClass(WebsyPDFButton, [{
|
|
2466
2787
|
key: "handleClick",
|
|
2467
2788
|
value: function handleClick(event) {
|
|
2468
|
-
var
|
|
2789
|
+
var _this19 = this;
|
|
2469
2790
|
|
|
2470
2791
|
if (event.target.classList.contains('websy-pdf-button')) {
|
|
2471
2792
|
this.loader.show();
|
|
2472
2793
|
setTimeout(function () {
|
|
2473
|
-
if (
|
|
2474
|
-
var el = document.getElementById(
|
|
2794
|
+
if (_this19.options.targetId) {
|
|
2795
|
+
var el = document.getElementById(_this19.options.targetId);
|
|
2475
2796
|
|
|
2476
2797
|
if (el) {
|
|
2477
2798
|
var pdfData = {
|
|
2478
2799
|
options: {}
|
|
2479
2800
|
};
|
|
2480
2801
|
|
|
2481
|
-
if (
|
|
2482
|
-
pdfData.options = _extends({},
|
|
2802
|
+
if (_this19.options.pdfOptions) {
|
|
2803
|
+
pdfData.options = _extends({}, _this19.options.pdfOptions);
|
|
2483
2804
|
}
|
|
2484
2805
|
|
|
2485
|
-
if (
|
|
2486
|
-
if (
|
|
2487
|
-
var headerEl = document.getElementById(
|
|
2806
|
+
if (_this19.options.header) {
|
|
2807
|
+
if (_this19.options.header.elementId) {
|
|
2808
|
+
var headerEl = document.getElementById(_this19.options.header.elementId);
|
|
2488
2809
|
|
|
2489
2810
|
if (headerEl) {
|
|
2490
2811
|
pdfData.header = headerEl.outerHTML;
|
|
2491
2812
|
|
|
2492
|
-
if (
|
|
2493
|
-
pdfData.options.headerCSS =
|
|
2813
|
+
if (_this19.options.header.css) {
|
|
2814
|
+
pdfData.options.headerCSS = _this19.options.header.css;
|
|
2494
2815
|
}
|
|
2495
2816
|
}
|
|
2496
|
-
} else if (
|
|
2497
|
-
pdfData.header =
|
|
2817
|
+
} else if (_this19.options.header.html) {
|
|
2818
|
+
pdfData.header = _this19.options.header.html;
|
|
2498
2819
|
|
|
2499
|
-
if (
|
|
2500
|
-
pdfData.options.headerCSS =
|
|
2820
|
+
if (_this19.options.header.css) {
|
|
2821
|
+
pdfData.options.headerCSS = _this19.options.header.css;
|
|
2501
2822
|
}
|
|
2502
2823
|
} else {
|
|
2503
|
-
pdfData.header =
|
|
2824
|
+
pdfData.header = _this19.options.header;
|
|
2504
2825
|
}
|
|
2505
2826
|
}
|
|
2506
2827
|
|
|
2507
|
-
if (
|
|
2508
|
-
if (
|
|
2509
|
-
var footerEl = document.getElementById(
|
|
2828
|
+
if (_this19.options.footer) {
|
|
2829
|
+
if (_this19.options.footer.elementId) {
|
|
2830
|
+
var footerEl = document.getElementById(_this19.options.footer.elementId);
|
|
2510
2831
|
|
|
2511
2832
|
if (footerEl) {
|
|
2512
2833
|
pdfData.footer = footerEl.outerHTML;
|
|
2513
2834
|
|
|
2514
|
-
if (
|
|
2515
|
-
pdfData.options.footerCSS =
|
|
2835
|
+
if (_this19.options.footer.css) {
|
|
2836
|
+
pdfData.options.footerCSS = _this19.options.footer.css;
|
|
2516
2837
|
}
|
|
2517
2838
|
}
|
|
2518
2839
|
} else {
|
|
2519
|
-
pdfData.footer =
|
|
2840
|
+
pdfData.footer = _this19.options.footer;
|
|
2520
2841
|
}
|
|
2521
2842
|
}
|
|
2522
2843
|
|
|
@@ -2525,31 +2846,31 @@ var WebsyPDFButton = /*#__PURE__*/function () {
|
|
|
2525
2846
|
// document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
|
|
2526
2847
|
// document.getElementById(`${this.elementId}_form`).submit()
|
|
2527
2848
|
|
|
2528
|
-
|
|
2849
|
+
_this19.service.add('', pdfData, {
|
|
2529
2850
|
responseType: 'blob'
|
|
2530
2851
|
}).then(function (response) {
|
|
2531
|
-
|
|
2852
|
+
_this19.loader.hide();
|
|
2532
2853
|
|
|
2533
2854
|
var blob = new Blob([response], {
|
|
2534
2855
|
type: 'application/pdf'
|
|
2535
2856
|
});
|
|
2536
2857
|
var msg = "\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 ");
|
|
2537
2858
|
|
|
2538
|
-
if (
|
|
2859
|
+
if (_this19.options.directDownload === true) {
|
|
2539
2860
|
var fileName;
|
|
2540
2861
|
|
|
2541
|
-
if (typeof
|
|
2542
|
-
fileName =
|
|
2862
|
+
if (typeof _this19.options.fileName === 'function') {
|
|
2863
|
+
fileName = _this19.options.fileName() || 'Export';
|
|
2543
2864
|
} else {
|
|
2544
|
-
fileName =
|
|
2865
|
+
fileName = _this19.options.fileName || 'Export';
|
|
2545
2866
|
}
|
|
2546
2867
|
|
|
2547
2868
|
msg += "download='".concat(fileName, ".pdf'");
|
|
2548
2869
|
}
|
|
2549
2870
|
|
|
2550
|
-
msg += "\n >\n <button class='websy-btn download-pdf'>".concat(
|
|
2871
|
+
msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this19.options.buttonText, "</button>\n </a>\n </div>\n ");
|
|
2551
2872
|
|
|
2552
|
-
|
|
2873
|
+
_this19.popup.show({
|
|
2553
2874
|
message: msg,
|
|
2554
2875
|
mask: true
|
|
2555
2876
|
});
|
|
@@ -2711,21 +3032,37 @@ var WebsyPubSub = /*#__PURE__*/function () {
|
|
|
2711
3032
|
|
|
2712
3033
|
_createClass(WebsyPubSub, [{
|
|
2713
3034
|
key: "publish",
|
|
2714
|
-
value: function publish(method, data) {
|
|
2715
|
-
if (
|
|
2716
|
-
this.subscriptions[method]
|
|
2717
|
-
|
|
2718
|
-
}
|
|
3035
|
+
value: function publish(id, method, data) {
|
|
3036
|
+
if (arguments.length === 3) {
|
|
3037
|
+
if (this.subscriptions[id] && this.subscriptions[id][method]) {
|
|
3038
|
+
this.subscriptions[id][method](data);
|
|
3039
|
+
}
|
|
3040
|
+
} else {
|
|
3041
|
+
if (this.subscriptions[method]) {
|
|
3042
|
+
this.subscriptions[method].forEach(function (fn) {
|
|
3043
|
+
fn(data);
|
|
3044
|
+
});
|
|
3045
|
+
}
|
|
2719
3046
|
}
|
|
2720
3047
|
}
|
|
2721
3048
|
}, {
|
|
2722
3049
|
key: "subscribe",
|
|
2723
|
-
value: function subscribe(method, fn) {
|
|
2724
|
-
if (
|
|
2725
|
-
this.subscriptions[
|
|
2726
|
-
|
|
3050
|
+
value: function subscribe(id, method, fn) {
|
|
3051
|
+
if (arguments.length === 3) {
|
|
3052
|
+
if (!this.subscriptions[id]) {
|
|
3053
|
+
this.subscriptions[id] = {};
|
|
3054
|
+
}
|
|
2727
3055
|
|
|
2728
|
-
|
|
3056
|
+
if (!this.subscriptions[id][method]) {
|
|
3057
|
+
this.subscriptions[id][method] = fn;
|
|
3058
|
+
}
|
|
3059
|
+
} else {
|
|
3060
|
+
if (!this.subscriptions[method]) {
|
|
3061
|
+
this.subscriptions[method] = [];
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
this.subscriptions[method].push(fn);
|
|
3065
|
+
}
|
|
2729
3066
|
}
|
|
2730
3067
|
}]);
|
|
2731
3068
|
|
|
@@ -2734,7 +3071,7 @@ var WebsyPubSub = /*#__PURE__*/function () {
|
|
|
2734
3071
|
|
|
2735
3072
|
var ResponsiveText = /*#__PURE__*/function () {
|
|
2736
3073
|
function ResponsiveText(elementId, options) {
|
|
2737
|
-
var
|
|
3074
|
+
var _this20 = this;
|
|
2738
3075
|
|
|
2739
3076
|
_classCallCheck(this, ResponsiveText);
|
|
2740
3077
|
|
|
@@ -2747,7 +3084,7 @@ var ResponsiveText = /*#__PURE__*/function () {
|
|
|
2747
3084
|
this.elementId = elementId;
|
|
2748
3085
|
this.canvas = document.createElement('canvas');
|
|
2749
3086
|
window.addEventListener('resize', function () {
|
|
2750
|
-
return
|
|
3087
|
+
return _this20.render();
|
|
2751
3088
|
});
|
|
2752
3089
|
var el = document.getElementById(this.elementId);
|
|
2753
3090
|
|
|
@@ -2966,7 +3303,7 @@ var ResponsiveText = /*#__PURE__*/function () {
|
|
|
2966
3303
|
|
|
2967
3304
|
var WebsyResultList = /*#__PURE__*/function () {
|
|
2968
3305
|
function WebsyResultList(elementId, options) {
|
|
2969
|
-
var
|
|
3306
|
+
var _this21 = this;
|
|
2970
3307
|
|
|
2971
3308
|
_classCallCheck(this, WebsyResultList);
|
|
2972
3309
|
|
|
@@ -2994,9 +3331,9 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
2994
3331
|
|
|
2995
3332
|
if (_typeof(options.template) === 'object' && options.template.url) {
|
|
2996
3333
|
this.templateService.get(options.template.url).then(function (templateString) {
|
|
2997
|
-
|
|
3334
|
+
_this21.options.template = templateString;
|
|
2998
3335
|
|
|
2999
|
-
|
|
3336
|
+
_this21.render();
|
|
3000
3337
|
});
|
|
3001
3338
|
} else {
|
|
3002
3339
|
this.render();
|
|
@@ -3015,7 +3352,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3015
3352
|
}, {
|
|
3016
3353
|
key: "buildHTML",
|
|
3017
3354
|
value: function buildHTML(d) {
|
|
3018
|
-
var
|
|
3355
|
+
var _this22 = this;
|
|
3019
3356
|
|
|
3020
3357
|
var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
3021
3358
|
var html = "";
|
|
@@ -3023,7 +3360,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3023
3360
|
if (this.options.template) {
|
|
3024
3361
|
if (d.length > 0) {
|
|
3025
3362
|
d.forEach(function (row, ix) {
|
|
3026
|
-
var template = "".concat(ix > 0 ? '-->' : '').concat(
|
|
3363
|
+
var template = "".concat(ix > 0 ? '-->' : '').concat(_this22.options.template).concat(ix < d.length - 1 ? '<!--' : ''); // find conditional elements
|
|
3027
3364
|
|
|
3028
3365
|
var ifMatches = _toConsumableArray(template.matchAll(/<\s*if[^>]*>([\s\S]*?)<\s*\/\s*if>/g));
|
|
3029
3366
|
|
|
@@ -3143,7 +3480,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3143
3480
|
}, {
|
|
3144
3481
|
key: "handleClick",
|
|
3145
3482
|
value: function handleClick(event) {
|
|
3146
|
-
var
|
|
3483
|
+
var _this23 = this;
|
|
3147
3484
|
|
|
3148
3485
|
if (event.target.classList.contains('clickable')) {
|
|
3149
3486
|
var l = event.target.getAttribute('data-event');
|
|
@@ -3161,8 +3498,8 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3161
3498
|
l = l[0];
|
|
3162
3499
|
params = params.map(function (p) {
|
|
3163
3500
|
if (typeof p !== 'string' && typeof p !== 'number') {
|
|
3164
|
-
if (
|
|
3165
|
-
p =
|
|
3501
|
+
if (_this23.rows[+id]) {
|
|
3502
|
+
p = _this23.rows[+id][p];
|
|
3166
3503
|
}
|
|
3167
3504
|
} else if (typeof p === 'string') {
|
|
3168
3505
|
p = p.replace(/"/g, '').replace(/'/g, '');
|
|
@@ -3184,13 +3521,13 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3184
3521
|
}, {
|
|
3185
3522
|
key: "render",
|
|
3186
3523
|
value: function render() {
|
|
3187
|
-
var
|
|
3524
|
+
var _this24 = this;
|
|
3188
3525
|
|
|
3189
3526
|
if (this.options.entity) {
|
|
3190
3527
|
this.apiService.get(this.options.entity).then(function (results) {
|
|
3191
|
-
|
|
3528
|
+
_this24.rows = results.rows;
|
|
3192
3529
|
|
|
3193
|
-
|
|
3530
|
+
_this24.resize();
|
|
3194
3531
|
});
|
|
3195
3532
|
} else {
|
|
3196
3533
|
this.resize();
|
|
@@ -3269,14 +3606,14 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
3269
3606
|
_createClass(WebsyRouter, [{
|
|
3270
3607
|
key: "addGroup",
|
|
3271
3608
|
value: function addGroup(group) {
|
|
3272
|
-
var
|
|
3609
|
+
var _this25 = this;
|
|
3273
3610
|
|
|
3274
3611
|
if (!this.groups[group]) {
|
|
3275
3612
|
var els = document.querySelectorAll(".websy-view[data-group=\"".concat(group, "\"]"));
|
|
3276
3613
|
|
|
3277
3614
|
if (els) {
|
|
3278
3615
|
this.getClosestParent(els[0], function (parent) {
|
|
3279
|
-
|
|
3616
|
+
_this25.groups[group] = {
|
|
3280
3617
|
activeView: '',
|
|
3281
3618
|
views: [],
|
|
3282
3619
|
parent: parent.getAttribute('data-view')
|
|
@@ -3601,12 +3938,12 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
3601
3938
|
}, {
|
|
3602
3939
|
key: "showComponents",
|
|
3603
3940
|
value: function showComponents(view) {
|
|
3604
|
-
var
|
|
3941
|
+
var _this26 = this;
|
|
3605
3942
|
|
|
3606
3943
|
if (this.options.views && this.options.views[view] && this.options.views[view].components) {
|
|
3607
3944
|
this.options.views[view].components.forEach(function (c) {
|
|
3608
3945
|
if (typeof c.instance === 'undefined') {
|
|
3609
|
-
|
|
3946
|
+
_this26.prepComponent(c.elementId, c.options);
|
|
3610
3947
|
|
|
3611
3948
|
c.instance = new c.Component(c.elementId, c.options);
|
|
3612
3949
|
} else if (c.instance.render) {
|
|
@@ -3975,7 +4312,7 @@ var Switch = /*#__PURE__*/function () {
|
|
|
3975
4312
|
|
|
3976
4313
|
var WebsyTemplate = /*#__PURE__*/function () {
|
|
3977
4314
|
function WebsyTemplate(elementId, options) {
|
|
3978
|
-
var
|
|
4315
|
+
var _this27 = this;
|
|
3979
4316
|
|
|
3980
4317
|
_classCallCheck(this, WebsyTemplate);
|
|
3981
4318
|
|
|
@@ -4001,9 +4338,9 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
4001
4338
|
|
|
4002
4339
|
if (_typeof(options.template) === 'object' && options.template.url) {
|
|
4003
4340
|
this.templateService.get(options.template.url).then(function (templateString) {
|
|
4004
|
-
|
|
4341
|
+
_this27.options.template = templateString;
|
|
4005
4342
|
|
|
4006
|
-
|
|
4343
|
+
_this27.render();
|
|
4007
4344
|
});
|
|
4008
4345
|
} else {
|
|
4009
4346
|
this.render();
|
|
@@ -4013,7 +4350,7 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
4013
4350
|
_createClass(WebsyTemplate, [{
|
|
4014
4351
|
key: "buildHTML",
|
|
4015
4352
|
value: function buildHTML() {
|
|
4016
|
-
var
|
|
4353
|
+
var _this28 = this;
|
|
4017
4354
|
|
|
4018
4355
|
var html = "";
|
|
4019
4356
|
|
|
@@ -4075,14 +4412,14 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
4075
4412
|
}
|
|
4076
4413
|
|
|
4077
4414
|
if (polarity === true) {
|
|
4078
|
-
if (typeof
|
|
4415
|
+
if (typeof _this28.options.data[parts[0]] !== 'undefined' && _this28.options.data[parts[0]] === parts[1]) {
|
|
4079
4416
|
// remove the <if> tags
|
|
4080
4417
|
removeAll = false;
|
|
4081
4418
|
} else if (parts[0] === parts[1]) {
|
|
4082
4419
|
removeAll = false;
|
|
4083
4420
|
}
|
|
4084
4421
|
} else if (polarity === false) {
|
|
4085
|
-
if (typeof
|
|
4422
|
+
if (typeof _this28.options.data[parts[0]] !== 'undefined' && _this28.options.data[parts[0]] !== parts[1]) {
|
|
4086
4423
|
// remove the <if> tags
|
|
4087
4424
|
removeAll = false;
|
|
4088
4425
|
}
|
|
@@ -4369,7 +4706,7 @@ var WebsyUtils = {
|
|
|
4369
4706
|
|
|
4370
4707
|
var WebsyTable = /*#__PURE__*/function () {
|
|
4371
4708
|
function WebsyTable(elementId, options) {
|
|
4372
|
-
var
|
|
4709
|
+
var _this29 = this;
|
|
4373
4710
|
|
|
4374
4711
|
_classCallCheck(this, WebsyTable);
|
|
4375
4712
|
|
|
@@ -4407,8 +4744,8 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4407
4744
|
allowClear: false,
|
|
4408
4745
|
disableSearch: true,
|
|
4409
4746
|
onItemSelected: function onItemSelected(selectedItem) {
|
|
4410
|
-
if (
|
|
4411
|
-
|
|
4747
|
+
if (_this29.options.onChangePageSize) {
|
|
4748
|
+
_this29.options.onChangePageSize(selectedItem.value);
|
|
4412
4749
|
}
|
|
4413
4750
|
}
|
|
4414
4751
|
});
|
|
@@ -4429,7 +4766,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4429
4766
|
_createClass(WebsyTable, [{
|
|
4430
4767
|
key: "appendRows",
|
|
4431
4768
|
value: function appendRows(data) {
|
|
4432
|
-
var
|
|
4769
|
+
var _this30 = this;
|
|
4433
4770
|
|
|
4434
4771
|
this.hideError();
|
|
4435
4772
|
var bodyHTML = '';
|
|
@@ -4437,15 +4774,15 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4437
4774
|
if (data) {
|
|
4438
4775
|
bodyHTML += data.map(function (r, rowIndex) {
|
|
4439
4776
|
return '<tr>' + r.map(function (c, i) {
|
|
4440
|
-
if (
|
|
4777
|
+
if (_this30.options.columns[i].show !== false) {
|
|
4441
4778
|
var style = '';
|
|
4442
4779
|
|
|
4443
4780
|
if (c.style) {
|
|
4444
4781
|
style += c.style;
|
|
4445
4782
|
}
|
|
4446
4783
|
|
|
4447
|
-
if (
|
|
4448
|
-
style += "width: ".concat(
|
|
4784
|
+
if (_this30.options.columns[i].width) {
|
|
4785
|
+
style += "width: ".concat(_this30.options.columns[i].width, "; ");
|
|
4449
4786
|
}
|
|
4450
4787
|
|
|
4451
4788
|
if (c.backgroundColor) {
|
|
@@ -4460,18 +4797,18 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4460
4797
|
style += "color: ".concat(c.color, "; ");
|
|
4461
4798
|
}
|
|
4462
4799
|
|
|
4463
|
-
if (
|
|
4464
|
-
return "\n <td \n data-row-index='".concat(
|
|
4465
|
-
} else if ((
|
|
4466
|
-
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(
|
|
4800
|
+
if (_this30.options.columns[i].showAsLink === true && c.value.trim() !== '') {
|
|
4801
|
+
return "\n <td \n data-row-index='".concat(_this30.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this30.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this30.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this30.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
|
|
4802
|
+
} else if ((_this30.options.columns[i].showAsNavigatorLink === true || _this30.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
|
|
4803
|
+
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this30.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this30.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this30.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this30.options.columns[i].linkText || c.value, "</td>\n ");
|
|
4467
4804
|
} else {
|
|
4468
4805
|
var info = c.value;
|
|
4469
4806
|
|
|
4470
|
-
if (
|
|
4807
|
+
if (_this30.options.columns[i].showAsImage === true) {
|
|
4471
4808
|
c.value = "\n <img src='".concat(c.value, "'>\n ");
|
|
4472
4809
|
}
|
|
4473
4810
|
|
|
4474
|
-
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(
|
|
4811
|
+
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this30.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this30.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.value, "</td>\n ");
|
|
4475
4812
|
}
|
|
4476
4813
|
}
|
|
4477
4814
|
}).join('') + '</tr>';
|
|
@@ -4643,7 +4980,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4643
4980
|
}, {
|
|
4644
4981
|
key: "render",
|
|
4645
4982
|
value: function render(data) {
|
|
4646
|
-
var
|
|
4983
|
+
var _this31 = this;
|
|
4647
4984
|
|
|
4648
4985
|
if (!this.options.columns) {
|
|
4649
4986
|
return;
|
|
@@ -4668,7 +5005,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4668
5005
|
|
|
4669
5006
|
var headHTML = '<tr>' + this.options.columns.map(function (c, i) {
|
|
4670
5007
|
if (c.show !== false) {
|
|
4671
|
-
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 ?
|
|
5008
|
+
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 ? _this31.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
|
|
4672
5009
|
}
|
|
4673
5010
|
}).join('') + '</tr>';
|
|
4674
5011
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
@@ -4687,7 +5024,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4687
5024
|
|
|
4688
5025
|
if (pagingEl) {
|
|
4689
5026
|
var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
|
|
4690
|
-
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(
|
|
5027
|
+
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this31.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
4691
5028
|
});
|
|
4692
5029
|
var startIndex = 0;
|
|
4693
5030
|
|
|
@@ -4755,7 +5092,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4755
5092
|
|
|
4756
5093
|
var WebsyTable2 = /*#__PURE__*/function () {
|
|
4757
5094
|
function WebsyTable2(elementId, options) {
|
|
4758
|
-
var
|
|
5095
|
+
var _this32 = this;
|
|
4759
5096
|
|
|
4760
5097
|
_classCallCheck(this, WebsyTable2);
|
|
4761
5098
|
|
|
@@ -4796,8 +5133,8 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
4796
5133
|
allowClear: false,
|
|
4797
5134
|
disableSearch: true,
|
|
4798
5135
|
onItemSelected: function onItemSelected(selectedItem) {
|
|
4799
|
-
if (
|
|
4800
|
-
|
|
5136
|
+
if (_this32.options.onChangePageSize) {
|
|
5137
|
+
_this32.options.onChangePageSize(selectedItem.value);
|
|
4801
5138
|
}
|
|
4802
5139
|
}
|
|
4803
5140
|
});
|
|
@@ -4821,7 +5158,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
4821
5158
|
_createClass(WebsyTable2, [{
|
|
4822
5159
|
key: "appendRows",
|
|
4823
5160
|
value: function appendRows(data) {
|
|
4824
|
-
var
|
|
5161
|
+
var _this33 = this;
|
|
4825
5162
|
|
|
4826
5163
|
this.hideError();
|
|
4827
5164
|
var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
|
|
@@ -4830,15 +5167,15 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
4830
5167
|
if (data) {
|
|
4831
5168
|
bodyHTML += data.map(function (r, rowIndex) {
|
|
4832
5169
|
return '<tr>' + r.map(function (c, i) {
|
|
4833
|
-
if (
|
|
4834
|
-
var style = "height: ".concat(
|
|
5170
|
+
if (_this33.options.columns[i].show !== false) {
|
|
5171
|
+
var style = "height: ".concat(_this33.options.cellSize, "px; line-height: ").concat(_this33.options.cellSize, "px;");
|
|
4835
5172
|
|
|
4836
5173
|
if (c.style) {
|
|
4837
5174
|
style += c.style;
|
|
4838
5175
|
}
|
|
4839
5176
|
|
|
4840
|
-
if (
|
|
4841
|
-
style += "width: ".concat(
|
|
5177
|
+
if (_this33.options.columns[i].width) {
|
|
5178
|
+
style += "width: ".concat(_this33.options.columns[i].width, "; ");
|
|
4842
5179
|
}
|
|
4843
5180
|
|
|
4844
5181
|
if (c.backgroundColor) {
|
|
@@ -4853,18 +5190,18 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
4853
5190
|
style += "color: ".concat(c.color, "; ");
|
|
4854
5191
|
}
|
|
4855
5192
|
|
|
4856
|
-
if (
|
|
4857
|
-
return "\n <td \n data-row-index='".concat(
|
|
4858
|
-
} else if ((
|
|
4859
|
-
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(
|
|
5193
|
+
if (_this33.options.columns[i].showAsLink === true && c.value.trim() !== '') {
|
|
5194
|
+
return "\n <td \n data-row-index='".concat(_this33.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this33.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this33.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this33.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
|
|
5195
|
+
} else if ((_this33.options.columns[i].showAsNavigatorLink === true || _this33.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
|
|
5196
|
+
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this33.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this33.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this33.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this33.options.columns[i].linkText || c.value, "</td>\n ");
|
|
4860
5197
|
} else {
|
|
4861
5198
|
var info = c.value;
|
|
4862
5199
|
|
|
4863
|
-
if (
|
|
5200
|
+
if (_this33.options.columns[i].showAsImage === true) {
|
|
4864
5201
|
c.value = "\n <img src='".concat(c.value, "'>\n ");
|
|
4865
5202
|
}
|
|
4866
5203
|
|
|
4867
|
-
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(
|
|
5204
|
+
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this33.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this33.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.value, "</td>\n ");
|
|
4868
5205
|
}
|
|
4869
5206
|
}
|
|
4870
5207
|
}).join('') + '</tr>';
|
|
@@ -5077,7 +5414,11 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5077
5414
|
}, {
|
|
5078
5415
|
key: "hideLoading",
|
|
5079
5416
|
value: function hideLoading() {
|
|
5080
|
-
this.
|
|
5417
|
+
if (this.options.onLoading) {
|
|
5418
|
+
this.options.onLoading(false);
|
|
5419
|
+
} else {
|
|
5420
|
+
this.loadingDialog.hide();
|
|
5421
|
+
}
|
|
5081
5422
|
}
|
|
5082
5423
|
}, {
|
|
5083
5424
|
key: "internalSort",
|
|
@@ -5123,7 +5464,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5123
5464
|
}, {
|
|
5124
5465
|
key: "render",
|
|
5125
5466
|
value: function render(data) {
|
|
5126
|
-
var
|
|
5467
|
+
var _this34 = this;
|
|
5127
5468
|
|
|
5128
5469
|
if (!this.options.columns) {
|
|
5129
5470
|
return;
|
|
@@ -5159,7 +5500,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5159
5500
|
style += "width: ".concat(c.width || 'auto', "; ");
|
|
5160
5501
|
}
|
|
5161
5502
|
|
|
5162
|
-
return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-sort-index=\"").concat(c.sortIndex || i, "\"\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 ?
|
|
5503
|
+
return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-sort-index=\"").concat(c.sortIndex || i, "\"\n data-index=\"").concat(i, "\"\n data-sort=\"").concat(c.sort, "\"\n style=\"").concat(c.style || '', "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n ").concat(c.searchable === true ? _this34.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
|
|
5163
5504
|
}
|
|
5164
5505
|
}).join('') + '</tr>';
|
|
5165
5506
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
@@ -5170,7 +5511,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5170
5511
|
var dropdownHTML = "";
|
|
5171
5512
|
this.options.columns.forEach(function (c, i) {
|
|
5172
5513
|
if (c.searchable && c.searchField) {
|
|
5173
|
-
dropdownHTML += "\n <div id=\"".concat(
|
|
5514
|
+
dropdownHTML += "\n <div id=\"".concat(_this34.elementId, "_columnSearch_").concat(i, "\" class=\"websy-modal-dropdown\"></div>\n ");
|
|
5174
5515
|
}
|
|
5175
5516
|
});
|
|
5176
5517
|
dropdownEl.innerHTML = dropdownHTML;
|
|
@@ -5192,7 +5533,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5192
5533
|
|
|
5193
5534
|
if (pagingEl) {
|
|
5194
5535
|
var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
|
|
5195
|
-
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(
|
|
5536
|
+
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this34.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
5196
5537
|
});
|
|
5197
5538
|
var startIndex = 0;
|
|
5198
5539
|
|
|
@@ -5274,12 +5615,16 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5274
5615
|
}, {
|
|
5275
5616
|
key: "showLoading",
|
|
5276
5617
|
value: function showLoading(options) {
|
|
5277
|
-
this.
|
|
5618
|
+
if (this.options.onLoading) {
|
|
5619
|
+
this.options.onLoading(true);
|
|
5620
|
+
} else {
|
|
5621
|
+
this.loadingDialog.show(options);
|
|
5622
|
+
}
|
|
5278
5623
|
}
|
|
5279
5624
|
}, {
|
|
5280
5625
|
key: "getColumnParameters",
|
|
5281
5626
|
value: function getColumnParameters(values) {
|
|
5282
|
-
var
|
|
5627
|
+
var _this35 = this;
|
|
5283
5628
|
|
|
5284
5629
|
var tableEl = document.getElementById("".concat(this.elementId, "_table"));
|
|
5285
5630
|
tableEl.style.tableLayout = 'auto';
|
|
@@ -5287,10 +5632,10 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5287
5632
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
5288
5633
|
var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
|
|
5289
5634
|
headEl.innerHTML = '<tr style="visibility: hidden;">' + values.map(function (c, i) {
|
|
5290
|
-
return "\n <th>\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField\" \n >\n ".concat(c.value || 'nbsp;', "\n </div>\n </div> \n ").concat(c.searchable === true ?
|
|
5635
|
+
return "\n <th>\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField\" \n >\n ".concat(c.value || 'nbsp;', "\n </div>\n </div> \n ").concat(c.searchable === true ? _this35.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
|
|
5291
5636
|
}).join('') + '</tr>';
|
|
5292
5637
|
bodyEl.innerHTML = '<tr style="visibility: hidden;">' + values.map(function (c) {
|
|
5293
|
-
return "\n <td \n style='height: ".concat(
|
|
5638
|
+
return "\n <td \n style='height: ".concat(_this35.options.cellSize, "px; line-height: ").concat(_this35.options.cellSize, "px; padding: 10px 5px;'\n >").concat(c.value || ' ', "</td>\n ");
|
|
5294
5639
|
}).join('') + '</tr>'; // get height of the first data cell
|
|
5295
5640
|
|
|
5296
5641
|
var cells = bodyEl.querySelectorAll("tr:first-of-type td");
|
|
@@ -5335,12 +5680,639 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5335
5680
|
|
|
5336
5681
|
return WebsyTable2;
|
|
5337
5682
|
}();
|
|
5683
|
+
/* global WebsyDesigns */
|
|
5684
|
+
|
|
5685
|
+
|
|
5686
|
+
var WebsyTable3 = /*#__PURE__*/function () {
|
|
5687
|
+
function WebsyTable3(elementId, options) {
|
|
5688
|
+
_classCallCheck(this, WebsyTable3);
|
|
5689
|
+
|
|
5690
|
+
this.elementId = elementId;
|
|
5691
|
+
var DEFAULTS = {
|
|
5692
|
+
virtualScroll: false,
|
|
5693
|
+
showTotalsAbove: true,
|
|
5694
|
+
minHandleSize: 20,
|
|
5695
|
+
maxColWidth: '50%',
|
|
5696
|
+
allowPivoting: false
|
|
5697
|
+
};
|
|
5698
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
5699
|
+
this.sizes = {};
|
|
5700
|
+
this.scrollDragging = false;
|
|
5701
|
+
this.cellDragging = false;
|
|
5702
|
+
this.vScrollRequired = false;
|
|
5703
|
+
this.hScrollRequired = false;
|
|
5704
|
+
this.pinnedColumns = 0;
|
|
5705
|
+
this.startRow = 0;
|
|
5706
|
+
this.endRow = 0;
|
|
5707
|
+
this.startCol = 0;
|
|
5708
|
+
this.endCol = 0;
|
|
5709
|
+
this.mouseYStart = 0;
|
|
5710
|
+
this.mouseYStart = 0;
|
|
5711
|
+
|
|
5712
|
+
if (!elementId) {
|
|
5713
|
+
console.log('No element Id provided for Websy Table');
|
|
5714
|
+
return;
|
|
5715
|
+
}
|
|
5716
|
+
|
|
5717
|
+
var el = document.getElementById(this.elementId);
|
|
5718
|
+
|
|
5719
|
+
if (el) {
|
|
5720
|
+
var html = "\n <div id='".concat(this.elementId, "_tableContainer' class='websy-vis-table-3 ").concat(this.options.paging === 'pages' ? 'with-paging' : '', " ").concat(this.options.virtualScroll === true ? 'with-virtual-scroll' : '', "'>\n <!--<div class=\"download-button\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M16 11h5l-9 10-9-10h5v-11h8v11zm1 11h-10v2h10v-2z\"/></svg>\n </div>-->\n <div id=\"").concat(this.elementId, "_tableInner\" class=\"websy-table-inner-container\">\n <table id=\"").concat(this.elementId, "_tableHeader\" class=\"websy-table-header\"></table>\n <table id=\"").concat(this.elementId, "_tableBody\" class=\"websy-table-body\"></table>\n <table id=\"").concat(this.elementId, "_tableFooter\" class=\"websy-table-footer\"></table>\n <div id=\"").concat(this.elementId, "_vScrollContainer\" class=\"websy-v-scroll-container\">\n <div id=\"").concat(this.elementId, "_vScrollHandle\" class=\"websy-scroll-handle websy-scroll-handle-y\"></div>\n </div>\n <div id=\"").concat(this.elementId, "_hScrollContainer\" class=\"websy-h-scroll-container\">\n <div id=\"").concat(this.elementId, "_hScrollHandle\" class=\"websy-scroll-handle websy-scroll-handle-x\"></div>\n </div>\n </div> \n <div id=\"").concat(this.elementId, "_errorContainer\" class='websy-vis-error-container'>\n <div>\n <div id=\"").concat(this.elementId, "_errorTitle\"></div>\n <div id=\"").concat(this.elementId, "_errorMessage\"></div>\n </div> \n </div>\n <div id=\"").concat(this.elementId, "_dropdownContainer\"></div>\n <div id=\"").concat(this.elementId, "_loadingContainer\"></div>\n </div>\n ");
|
|
5721
|
+
|
|
5722
|
+
if (this.options.paging === 'pages') {
|
|
5723
|
+
html += "\n <div class=\"websy-table-paging-container\">\n Show <div id=\"".concat(this.elementId, "_pageSizeSelector\" class=\"websy-vis-page-selector\"></div> rows\n <ul id=\"").concat(this.elementId, "_pageList\" class=\"websy-vis-page-list\"></ul>\n </div>\n ");
|
|
5724
|
+
}
|
|
5725
|
+
|
|
5726
|
+
el.innerHTML = html;
|
|
5727
|
+
el.addEventListener('click', this.handleClick.bind(this));
|
|
5728
|
+
el.addEventListener('mousedown', this.handleMouseDown.bind(this));
|
|
5729
|
+
window.addEventListener('mousemove', this.handleMouseMove.bind(this));
|
|
5730
|
+
window.addEventListener('mouseup', this.handleMouseUp.bind(this));
|
|
5731
|
+
var scrollEl = document.getElementById("".concat(this.elementId, "_tableBody"));
|
|
5732
|
+
|
|
5733
|
+
if (scrollEl) {
|
|
5734
|
+
scrollEl.addEventListener('wheel', this.handleScrollWheel.bind(this));
|
|
5735
|
+
}
|
|
5736
|
+
|
|
5737
|
+
this.loadingDialog = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loadingContainer"));
|
|
5738
|
+
this.render(this.options.data);
|
|
5739
|
+
} else {
|
|
5740
|
+
console.error("No element found with ID ".concat(this.elementId));
|
|
5741
|
+
}
|
|
5742
|
+
}
|
|
5743
|
+
|
|
5744
|
+
_createClass(WebsyTable3, [{
|
|
5745
|
+
key: "appendRows",
|
|
5746
|
+
value: function appendRows(data) {
|
|
5747
|
+
this.hideError();
|
|
5748
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody"));
|
|
5749
|
+
|
|
5750
|
+
if (bodyEl) {
|
|
5751
|
+
if (this.options.virtualScroll === true) {
|
|
5752
|
+
bodyEl.innerHTML = this.buildBodyHtml(data, true);
|
|
5753
|
+
} else {
|
|
5754
|
+
bodyEl.innerHTML += this.buildBodyHtml(data, true);
|
|
5755
|
+
}
|
|
5756
|
+
} // this.data = this.data.concat(data)
|
|
5757
|
+
// this.rowCount = this.data.length
|
|
5758
|
+
|
|
5759
|
+
}
|
|
5760
|
+
}, {
|
|
5761
|
+
key: "buildBodyHtml",
|
|
5762
|
+
value: function buildBodyHtml() {
|
|
5763
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
5764
|
+
var useWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
5765
|
+
|
|
5766
|
+
if (data.length === 0) {
|
|
5767
|
+
return '';
|
|
5768
|
+
}
|
|
5769
|
+
|
|
5770
|
+
var bodyHtml = "";
|
|
5771
|
+
var sizingColumns = this.options.columns[this.options.columns.length - 1];
|
|
5772
|
+
|
|
5773
|
+
if (useWidths === true) {
|
|
5774
|
+
bodyHtml += '<colgroup>';
|
|
5775
|
+
bodyHtml += sizingColumns.map(function (c) {
|
|
5776
|
+
return "\n <col\n style='width: ".concat(c.width || c.actualWidth, "px!important'\n ></col>\n ");
|
|
5777
|
+
}).join('');
|
|
5778
|
+
bodyHtml += '</colgroup>';
|
|
5779
|
+
}
|
|
5780
|
+
|
|
5781
|
+
data.forEach(function (row) {
|
|
5782
|
+
bodyHtml += "<tr class=\"websy-table-row\">";
|
|
5783
|
+
row.forEach(function (cell, cellIndex) {
|
|
5784
|
+
bodyHtml += "<td \n class='websy-table-cell'\n style='".concat(cell.style, "'\n data-info='").concat(cell.value, "'\n colspan='").concat(cell.colspan || 1, "'\n rowspan='").concat(cell.rowspan || 1, "'\n "); // if (useWidths === true) {
|
|
5785
|
+
// bodyHtml += `
|
|
5786
|
+
// style='width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important'
|
|
5787
|
+
// width='${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}'
|
|
5788
|
+
// `
|
|
5789
|
+
// }
|
|
5790
|
+
|
|
5791
|
+
bodyHtml += "\n >\n ".concat(cell.value, "\n </td>");
|
|
5792
|
+
});
|
|
5793
|
+
bodyHtml += "</tr>";
|
|
5794
|
+
}); // bodyHtml += `</div>`
|
|
5795
|
+
|
|
5796
|
+
return bodyHtml;
|
|
5797
|
+
}
|
|
5798
|
+
}, {
|
|
5799
|
+
key: "buildHeaderHtml",
|
|
5800
|
+
value: function buildHeaderHtml() {
|
|
5801
|
+
var _this36 = this;
|
|
5802
|
+
|
|
5803
|
+
var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
5804
|
+
var headerHtml = '';
|
|
5805
|
+
var sizingColumns = this.options.columns[this.options.columns.length - 1];
|
|
5806
|
+
|
|
5807
|
+
if (useWidths === true) {
|
|
5808
|
+
headerHtml += '<colgroup>';
|
|
5809
|
+
headerHtml += sizingColumns.map(function (c) {
|
|
5810
|
+
return "\n <col\n style='width: ".concat(c.width || c.actualWidth, "px!important'\n ></col>\n ");
|
|
5811
|
+
}).join('');
|
|
5812
|
+
headerHtml += '</colgroup>';
|
|
5813
|
+
}
|
|
5814
|
+
|
|
5815
|
+
this.options.columns.forEach(function (row, rowIndex) {
|
|
5816
|
+
if (useWidths === false && rowIndex !== _this36.options.columns.length - 1) {
|
|
5817
|
+
// if we're calculating the size we only want to render the last row of column headers
|
|
5818
|
+
return;
|
|
5819
|
+
}
|
|
5820
|
+
|
|
5821
|
+
headerHtml += "<tr class=\"websy-table-row websy-table-header-row\">";
|
|
5822
|
+
row.forEach(function (col) {
|
|
5823
|
+
headerHtml += "<td \n class='websy-table-cell' \n style='".concat(col.style, "' \n colspan='").concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n "); // if (useWidths === true && rowIndex === this.options.columns.length - 1) {
|
|
5824
|
+
// headerHtml += `
|
|
5825
|
+
// style='width: ${col.width || col.actualWidth}px'
|
|
5826
|
+
// width='${col.width || col.actualWidth}'
|
|
5827
|
+
// `
|
|
5828
|
+
// }
|
|
5829
|
+
|
|
5830
|
+
headerHtml += " \n >\n ".concat(col.name, "\n </td>");
|
|
5831
|
+
});
|
|
5832
|
+
headerHtml += "</tr>";
|
|
5833
|
+
});
|
|
5834
|
+
return headerHtml;
|
|
5835
|
+
}
|
|
5836
|
+
}, {
|
|
5837
|
+
key: "buildTotalHtml",
|
|
5838
|
+
value: function buildTotalHtml() {
|
|
5839
|
+
var _this37 = this;
|
|
5840
|
+
|
|
5841
|
+
var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
5842
|
+
|
|
5843
|
+
if (!this.options.totals) {
|
|
5844
|
+
return '';
|
|
5845
|
+
}
|
|
5846
|
+
|
|
5847
|
+
var totalHtml = "<tr class=\"websy-table-row websy-table-total-row\">";
|
|
5848
|
+
this.options.totals.forEach(function (col, colIndex) {
|
|
5849
|
+
totalHtml += "<td \n class='websy-table-cell'\n colspan='".concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n ");
|
|
5850
|
+
|
|
5851
|
+
if (useWidths === true) {
|
|
5852
|
+
totalHtml += "\n style='width: ".concat(_this37.options.columns[_this37.options.columns.length - 1][colIndex].width || _this37.options.columns[_this37.options.columns.length - 1][colIndex].actualWidth, "px'\n width='").concat(col.width || col.actualWidth, "'\n ");
|
|
5853
|
+
}
|
|
5854
|
+
|
|
5855
|
+
totalHtml += " \n >\n ".concat(col.value, "\n </td>");
|
|
5856
|
+
});
|
|
5857
|
+
totalHtml += "</tr>";
|
|
5858
|
+
return totalHtml;
|
|
5859
|
+
}
|
|
5860
|
+
}, {
|
|
5861
|
+
key: "calculateSizes",
|
|
5862
|
+
value: function calculateSizes() {
|
|
5863
|
+
var _this38 = this;
|
|
5864
|
+
|
|
5865
|
+
var sample = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
5866
|
+
var totalRowCount = arguments.length > 1 ? arguments[1] : undefined;
|
|
5867
|
+
var totalColumnCount = arguments.length > 2 ? arguments[2] : undefined;
|
|
5868
|
+
var pinnedColumns = arguments.length > 3 ? arguments[3] : undefined;
|
|
5869
|
+
this.totalRowCount = totalRowCount; // probably need some error handling here if no value is passed in
|
|
5870
|
+
|
|
5871
|
+
this.totalColumnCount = totalColumnCount; // probably need some error handling here if no value is passed in
|
|
5872
|
+
|
|
5873
|
+
this.pinnedColumns = pinnedColumns; // probably need some error handling here if no value is passed in
|
|
5874
|
+
|
|
5875
|
+
var outerEl = document.getElementById(this.elementId);
|
|
5876
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
5877
|
+
var headEl = document.getElementById("".concat(this.elementId, "_tableHeader"));
|
|
5878
|
+
headEl.style.width = 'auto';
|
|
5879
|
+
headEl.innerHTML = this.buildHeaderHtml();
|
|
5880
|
+
this.sizes.outer = outerEl.getBoundingClientRect();
|
|
5881
|
+
this.sizes.table = tableEl.getBoundingClientRect();
|
|
5882
|
+
this.sizes.header = headEl.getBoundingClientRect();
|
|
5883
|
+
var maxWidth;
|
|
5884
|
+
|
|
5885
|
+
if (typeof this.options.maxColWidth === 'number') {
|
|
5886
|
+
maxWidth = this.options.maxColWidth;
|
|
5887
|
+
} else if (this.options.maxColWidth.indexOf('%') !== -1) {
|
|
5888
|
+
maxWidth = this.sizes.outer.width * (+this.options.maxColWidth.replace('%', '') / 100);
|
|
5889
|
+
} else if (this.options.maxColWidth.indexOf('px') !== -1) {
|
|
5890
|
+
maxWidth = +this.options.maxColWidth.replace('px', '');
|
|
5891
|
+
}
|
|
5892
|
+
|
|
5893
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody"));
|
|
5894
|
+
bodyEl.style.width = 'auto';
|
|
5895
|
+
bodyEl.innerHTML = this.buildBodyHtml([sample]);
|
|
5896
|
+
var footerEl = document.getElementById("".concat(this.elementId, "_tableFooter"));
|
|
5897
|
+
footerEl.innerHTML = this.buildTotalHtml();
|
|
5898
|
+
this.sizes.total = footerEl.getBoundingClientRect();
|
|
5899
|
+
var rows = Array.from(tableEl.querySelectorAll('.websy-table-row'));
|
|
5900
|
+
var totalWidth = 0;
|
|
5901
|
+
this.sizes.scrollableWidth = this.sizes.outer.width;
|
|
5902
|
+
rows.forEach(function (row, rowIndex) {
|
|
5903
|
+
Array.from(row.children).forEach(function (col, colIndex) {
|
|
5904
|
+
var colSize = col.getBoundingClientRect();
|
|
5905
|
+
_this38.sizes.cellHeight = colSize.height;
|
|
5906
|
+
|
|
5907
|
+
if (_this38.options.columns[_this38.options.columns.length - 1][colIndex]) {
|
|
5908
|
+
if (!_this38.options.columns[_this38.options.columns.length - 1][colIndex].actualWidth) {
|
|
5909
|
+
_this38.options.columns[_this38.options.columns.length - 1][colIndex].actualWidth = 0;
|
|
5910
|
+
}
|
|
5911
|
+
|
|
5912
|
+
_this38.options.columns[_this38.options.columns.length - 1][colIndex].actualWidth = Math.min(Math.max(_this38.options.columns[_this38.options.columns.length - 1][colIndex].actualWidth, colSize.width), maxWidth);
|
|
5913
|
+
_this38.options.columns[_this38.options.columns.length - 1][colIndex].cellHeight = colSize.height;
|
|
5914
|
+
}
|
|
5915
|
+
});
|
|
5916
|
+
});
|
|
5917
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
|
|
5918
|
+
if (colIndex < _this38.pinnedColumns) {
|
|
5919
|
+
_this38.sizes.scrollableWidth -= col.actualWidth;
|
|
5920
|
+
}
|
|
5921
|
+
});
|
|
5922
|
+
this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce(function (a, b) {
|
|
5923
|
+
return a + (b.width || b.actualWidth);
|
|
5924
|
+
}, 0);
|
|
5925
|
+
var outerSize = outerEl.getBoundingClientRect();
|
|
5926
|
+
|
|
5927
|
+
if (this.sizes.totalWidth < outerSize.width) {
|
|
5928
|
+
this.sizes.totalWidth = 0;
|
|
5929
|
+
var equalWidth = outerSize.width / this.options.columns[this.options.columns.length - 1].length;
|
|
5930
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (c, i) {
|
|
5931
|
+
if (!c.width) {
|
|
5932
|
+
if (c.actualWidth < equalWidth) {
|
|
5933
|
+
// adjust the width
|
|
5934
|
+
c.actualWidth = equalWidth;
|
|
5935
|
+
}
|
|
5936
|
+
}
|
|
5937
|
+
|
|
5938
|
+
_this38.sizes.totalWidth += c.width || c.actualWidth;
|
|
5939
|
+
equalWidth = (outerSize.width - _this38.sizes.totalWidth) / (_this38.options.columns[_this38.options.columns.length - 1].length - (i + 1));
|
|
5940
|
+
});
|
|
5941
|
+
} // take the height of the last cell as the official height for data cells
|
|
5942
|
+
// this.sizes.dataCellHeight = this.options.columns[this.options.columns.length - 1].cellHeight
|
|
5943
|
+
|
|
5944
|
+
|
|
5945
|
+
headEl.innerHTML = '';
|
|
5946
|
+
bodyEl.innerHTML = '';
|
|
5947
|
+
footerEl.innerHTML = '';
|
|
5948
|
+
headEl.style.width = 'initial';
|
|
5949
|
+
bodyEl.style.width = 'initial';
|
|
5950
|
+
this.sizes.bodyHeight = this.sizes.table.height - (this.sizes.header.height + this.sizes.total.height);
|
|
5951
|
+
this.sizes.rowsToRender = Math.ceil(this.sizes.bodyHeight / this.sizes.cellHeight);
|
|
5952
|
+
this.sizes.rowsToRenderPrecise = this.sizes.bodyHeight / this.sizes.cellHeight;
|
|
5953
|
+
this.startRow = 0;
|
|
5954
|
+
this.endRow = this.sizes.rowsToRender;
|
|
5955
|
+
this.startCol = 0;
|
|
5956
|
+
this.endCol = this.options.columns[this.options.columns.length - 1].length;
|
|
5957
|
+
|
|
5958
|
+
if (this.sizes.rowsToRender < this.totalRowCount) {
|
|
5959
|
+
this.vScrollRequired = true;
|
|
5960
|
+
}
|
|
5961
|
+
|
|
5962
|
+
if (this.sizes.totalWidth > this.sizes.outer.width) {
|
|
5963
|
+
this.hScrollRequired = true;
|
|
5964
|
+
}
|
|
5965
|
+
|
|
5966
|
+
this.options.allColumns = this.options.columns.map(function (c) {
|
|
5967
|
+
return c;
|
|
5968
|
+
});
|
|
5969
|
+
console.log('sizes', this.sizes);
|
|
5970
|
+
return this.sizes;
|
|
5971
|
+
}
|
|
5972
|
+
}, {
|
|
5973
|
+
key: "createSample",
|
|
5974
|
+
value: function createSample(data) {
|
|
5975
|
+
var output = [];
|
|
5976
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
|
|
5977
|
+
if (col.maxLength) {
|
|
5978
|
+
output.push({
|
|
5979
|
+
value: new Array(col.maxLength).fill('W').join('')
|
|
5980
|
+
});
|
|
5981
|
+
} else if (data) {
|
|
5982
|
+
var longest = '';
|
|
5983
|
+
|
|
5984
|
+
for (var i = 0; i < Math.min(data.length, 1000); i++) {
|
|
5985
|
+
if (longest.length < data[i][colIndex].value.length) {
|
|
5986
|
+
longest = data[i][colIndex].value;
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5989
|
+
|
|
5990
|
+
output.push({
|
|
5991
|
+
value: longest
|
|
5992
|
+
});
|
|
5993
|
+
} else {
|
|
5994
|
+
output.push({
|
|
5995
|
+
value: ''
|
|
5996
|
+
});
|
|
5997
|
+
}
|
|
5998
|
+
});
|
|
5999
|
+
return output;
|
|
6000
|
+
}
|
|
6001
|
+
}, {
|
|
6002
|
+
key: "handleClick",
|
|
6003
|
+
value: function handleClick(event) {}
|
|
6004
|
+
}, {
|
|
6005
|
+
key: "handleMouseDown",
|
|
6006
|
+
value: function handleMouseDown(event) {
|
|
6007
|
+
if (event.target.classList.contains('websy-scroll-handle-y')) {
|
|
6008
|
+
// set up the scroll start values
|
|
6009
|
+
this.scrollDragging = true;
|
|
6010
|
+
this.scrollDirection = 'y';
|
|
6011
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
6012
|
+
this.handleYStart = scrollHandleEl.offsetTop;
|
|
6013
|
+
this.mouseYStart = event.pageY;
|
|
6014
|
+
console.log('mouse down', this.handleYStart, this.mouseYStart);
|
|
6015
|
+
console.log(scrollHandleEl.offsetTop);
|
|
6016
|
+
} else if (event.target.classList.contains('websy-scroll-handle-x')) {
|
|
6017
|
+
this.scrollDragging = true;
|
|
6018
|
+
this.scrollDirection = 'x';
|
|
6019
|
+
|
|
6020
|
+
var _scrollHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
6021
|
+
|
|
6022
|
+
this.handleXStart = _scrollHandleEl.offsetLeft;
|
|
6023
|
+
this.mouseXStart = event.pageX;
|
|
6024
|
+
}
|
|
6025
|
+
}
|
|
6026
|
+
}, {
|
|
6027
|
+
key: "handleMouseMove",
|
|
6028
|
+
value: function handleMouseMove(event) {
|
|
6029
|
+
// event.preventDefault()
|
|
6030
|
+
if (this.scrollDragging === true) {
|
|
6031
|
+
if (this.scrollDirection === 'y') {
|
|
6032
|
+
var diff = event.pageY - this.mouseYStart;
|
|
6033
|
+
this.scrollY(diff);
|
|
6034
|
+
} else if (this.scrollDirection === 'x') {
|
|
6035
|
+
var _diff = event.pageX - this.mouseXStart;
|
|
6036
|
+
|
|
6037
|
+
this.scrollX(_diff);
|
|
6038
|
+
}
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
}, {
|
|
6042
|
+
key: "handleMouseUp",
|
|
6043
|
+
value: function handleMouseUp(event) {
|
|
6044
|
+
this.scrollDragging = false;
|
|
6045
|
+
this.cellDragging = false;
|
|
6046
|
+
this.handleYStart = null;
|
|
6047
|
+
this.mouseYStart = null;
|
|
6048
|
+
this.handleXStart = null;
|
|
6049
|
+
this.mouseXStart = null;
|
|
6050
|
+
}
|
|
6051
|
+
}, {
|
|
6052
|
+
key: "handleScrollWheel",
|
|
6053
|
+
value: function handleScrollWheel(event) {
|
|
6054
|
+
event.preventDefault();
|
|
6055
|
+
console.log('scrollwheel', event);
|
|
6056
|
+
|
|
6057
|
+
if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
|
|
6058
|
+
this.scrollX(Math.max(-5, Math.min(5, event.deltaX)));
|
|
6059
|
+
} else {
|
|
6060
|
+
this.scrollY(Math.max(-5, Math.min(5, event.deltaY)));
|
|
6061
|
+
}
|
|
6062
|
+
}
|
|
6063
|
+
}, {
|
|
6064
|
+
key: "hideError",
|
|
6065
|
+
value: function hideError() {
|
|
6066
|
+
var el = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
6067
|
+
|
|
6068
|
+
if (el) {
|
|
6069
|
+
el.classList.remove('has-error');
|
|
6070
|
+
}
|
|
6071
|
+
|
|
6072
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_tableInner"));
|
|
6073
|
+
tableEl.classList.remove('hidden');
|
|
6074
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
6075
|
+
|
|
6076
|
+
if (containerEl) {
|
|
6077
|
+
containerEl.classList.remove('active');
|
|
6078
|
+
}
|
|
6079
|
+
}
|
|
6080
|
+
}, {
|
|
6081
|
+
key: "hideLoading",
|
|
6082
|
+
value: function hideLoading() {
|
|
6083
|
+
this.loadingDialog.hide();
|
|
6084
|
+
}
|
|
6085
|
+
}, {
|
|
6086
|
+
key: "render",
|
|
6087
|
+
value: function render(data) {
|
|
6088
|
+
var calcSizes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
6089
|
+
|
|
6090
|
+
if (!this.options.columns) {
|
|
6091
|
+
console.log("No columns provided for table with ID ".concat(this.elementId));
|
|
6092
|
+
return;
|
|
6093
|
+
}
|
|
6094
|
+
|
|
6095
|
+
if (this.options.columns.length === 0) {
|
|
6096
|
+
console.log("No columns provided for table with ID ".concat(this.elementId));
|
|
6097
|
+
return;
|
|
6098
|
+
} // this.data = []
|
|
6099
|
+
// Adjust the sizing of the header/body/footer
|
|
6100
|
+
|
|
6101
|
+
|
|
6102
|
+
if (calcSizes === true) {
|
|
6103
|
+
var sample = this.createSample(data);
|
|
6104
|
+
this.calculateSizes(sample, data.length, (data[0] || []).length, 0);
|
|
6105
|
+
}
|
|
6106
|
+
|
|
6107
|
+
console.log(this.options.columns);
|
|
6108
|
+
var tableInnerEl = document.getElementById("".concat(this.elementId, "_tableInner"));
|
|
6109
|
+
|
|
6110
|
+
if (tableInnerEl) {
|
|
6111
|
+
tableInnerEl.style.width = "".concat(this.sizes.totalWidth, "px");
|
|
6112
|
+
}
|
|
6113
|
+
|
|
6114
|
+
this.renderColumnHeaders();
|
|
6115
|
+
this.renderTotals();
|
|
6116
|
+
|
|
6117
|
+
if (data) {
|
|
6118
|
+
this.appendRows(data);
|
|
6119
|
+
}
|
|
6120
|
+
|
|
6121
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody")); // bodyEl.innerHTML = this.buildBodyHtml(data, true)
|
|
6122
|
+
|
|
6123
|
+
bodyEl.style.height = "calc(100% - ".concat(this.sizes.header.height, "px - ").concat(this.sizes.total.height, "px)");
|
|
6124
|
+
|
|
6125
|
+
if (this.options.virtualScroll === true) {
|
|
6126
|
+
// set the scroll element positions
|
|
6127
|
+
if (this.vScrollRequired === true) {
|
|
6128
|
+
var vScrollEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
|
|
6129
|
+
var vHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
6130
|
+
vScrollEl.style.top = "".concat(this.sizes.header.height + this.sizes.total.height, "px");
|
|
6131
|
+
vScrollEl.style.height = "".concat(this.sizes.bodyHeight, "px");
|
|
6132
|
+
vHandleEl.style.height = Math.max(this.options.minHandleSize, this.sizes.bodyHeight * (this.sizes.rowsToRenderPrecise / this.totalRowCount)) + 'px';
|
|
6133
|
+
}
|
|
6134
|
+
|
|
6135
|
+
if (this.hScrollRequired === true) {
|
|
6136
|
+
var hScrollEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
|
|
6137
|
+
var hHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
6138
|
+
hScrollEl.style.left = "".concat(this.sizes.table.width - this.sizes.scrollableWidth, "px");
|
|
6139
|
+
hScrollEl.style.width = "".concat(this.sizes.scrollableWidth - 20, "px");
|
|
6140
|
+
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalWidth)) + 'px';
|
|
6141
|
+
}
|
|
6142
|
+
}
|
|
6143
|
+
}
|
|
6144
|
+
}, {
|
|
6145
|
+
key: "renderColumnHeaders",
|
|
6146
|
+
value: function renderColumnHeaders() {
|
|
6147
|
+
var headEl = document.getElementById("".concat(this.elementId, "_tableHeader"));
|
|
6148
|
+
|
|
6149
|
+
if (headEl) {
|
|
6150
|
+
headEl.innerHTML = this.buildHeaderHtml(true);
|
|
6151
|
+
}
|
|
6152
|
+
}
|
|
6153
|
+
}, {
|
|
6154
|
+
key: "renderTotals",
|
|
6155
|
+
value: function renderTotals() {
|
|
6156
|
+
var headEl = document.getElementById("".concat(this.elementId, "_tableHeader"));
|
|
6157
|
+
var totalHtml = this.buildTotalHtml(true);
|
|
6158
|
+
|
|
6159
|
+
if (this.options.showTotalsAbove === true) {
|
|
6160
|
+
headEl.innerHTML += totalHtml;
|
|
6161
|
+
} else {
|
|
6162
|
+
var footerEl = document.getElementById("".concat(this.elementId, "_tableFooter"));
|
|
6163
|
+
|
|
6164
|
+
if (footerEl) {
|
|
6165
|
+
footerEl.innerHTML = totalHtml;
|
|
6166
|
+
}
|
|
6167
|
+
}
|
|
6168
|
+
}
|
|
6169
|
+
}, {
|
|
6170
|
+
key: "resize",
|
|
6171
|
+
value: function resize() {}
|
|
6172
|
+
}, {
|
|
6173
|
+
key: "showError",
|
|
6174
|
+
value: function showError(options) {
|
|
6175
|
+
var el = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
6176
|
+
|
|
6177
|
+
if (el) {
|
|
6178
|
+
el.classList.add('has-error');
|
|
6179
|
+
}
|
|
6180
|
+
|
|
6181
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_tableInner"));
|
|
6182
|
+
tableEl.classList.add('hidden');
|
|
6183
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
6184
|
+
|
|
6185
|
+
if (containerEl) {
|
|
6186
|
+
containerEl.classList.add('active');
|
|
6187
|
+
}
|
|
6188
|
+
|
|
6189
|
+
if (options.title) {
|
|
6190
|
+
var titleEl = document.getElementById("".concat(this.elementId, "_errorTitle"));
|
|
6191
|
+
|
|
6192
|
+
if (titleEl) {
|
|
6193
|
+
titleEl.innerHTML = options.title;
|
|
6194
|
+
}
|
|
6195
|
+
}
|
|
6196
|
+
|
|
6197
|
+
if (options.message) {
|
|
6198
|
+
var messageEl = document.getElementById("".concat(this.elementId, "_errorMessage"));
|
|
6199
|
+
|
|
6200
|
+
if (messageEl) {
|
|
6201
|
+
messageEl.innerHTML = options.message;
|
|
6202
|
+
}
|
|
6203
|
+
}
|
|
6204
|
+
}
|
|
6205
|
+
}, {
|
|
6206
|
+
key: "scrollX",
|
|
6207
|
+
value: function scrollX(diff) {
|
|
6208
|
+
var scrollContainerEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
|
|
6209
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
6210
|
+
var handlePos;
|
|
6211
|
+
|
|
6212
|
+
if (typeof this.handleXStart !== 'undefined' && this.handleXStart !== null) {
|
|
6213
|
+
handlePos = this.handleXStart + diff;
|
|
6214
|
+
} else {
|
|
6215
|
+
handlePos = scrollHandleEl.offsetLeft + diff;
|
|
6216
|
+
}
|
|
6217
|
+
|
|
6218
|
+
var scrollableSpace = scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width;
|
|
6219
|
+
console.log('dragging x', diff, scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width);
|
|
6220
|
+
scrollHandleEl.style.left = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px';
|
|
6221
|
+
|
|
6222
|
+
if (this.options.onScroll) {
|
|
6223
|
+
var actualLeft = (this.sizes.totalWidth - this.sizes.scrollableWidth) * (Math.min(scrollableSpace, Math.max(0, handlePos)) / scrollableSpace);
|
|
6224
|
+
var cumulativeWidth = 0;
|
|
6225
|
+
this.startCol = 0;
|
|
6226
|
+
this.endCol = 0;
|
|
6227
|
+
|
|
6228
|
+
for (var i = 0; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
6229
|
+
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth;
|
|
6230
|
+
console.log(actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth);
|
|
6231
|
+
|
|
6232
|
+
if (actualLeft < cumulativeWidth) {
|
|
6233
|
+
this.startCol = i;
|
|
6234
|
+
break;
|
|
6235
|
+
}
|
|
6236
|
+
}
|
|
6237
|
+
|
|
6238
|
+
cumulativeWidth = 0;
|
|
6239
|
+
|
|
6240
|
+
for (var _i10 = this.startCol; _i10 < this.options.allColumns[this.options.allColumns.length - 1].length; _i10++) {
|
|
6241
|
+
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][_i10].actualWidth;
|
|
6242
|
+
|
|
6243
|
+
if (cumulativeWidth < this.sizes.scrollableWidth) {
|
|
6244
|
+
this.endCol = _i10;
|
|
6245
|
+
}
|
|
6246
|
+
}
|
|
6247
|
+
|
|
6248
|
+
if (this.endCol < this.options.allColumns[this.options.allColumns.length - 1].length - 1) {
|
|
6249
|
+
this.endCol += 1;
|
|
6250
|
+
}
|
|
6251
|
+
|
|
6252
|
+
if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.totalWidth) {
|
|
6253
|
+
this.startCol += 1;
|
|
6254
|
+
}
|
|
6255
|
+
|
|
6256
|
+
this.endCol = Math.max(this.startCol, this.endCol);
|
|
6257
|
+
this.options.onScroll('y', this.startRow, this.endRow, this.startCol, this.endCol);
|
|
6258
|
+
}
|
|
6259
|
+
}
|
|
6260
|
+
}, {
|
|
6261
|
+
key: "scrollY",
|
|
6262
|
+
value: function scrollY(diff) {
|
|
6263
|
+
var scrollContainerEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
|
|
6264
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
6265
|
+
var handlePos;
|
|
6266
|
+
|
|
6267
|
+
if (typeof this.handleYStart !== 'undefined' && this.handleYStart !== null) {
|
|
6268
|
+
handlePos = this.handleYStart + diff;
|
|
6269
|
+
} else {
|
|
6270
|
+
console.log('appending not resetting');
|
|
6271
|
+
handlePos = scrollHandleEl.offsetTop + diff;
|
|
6272
|
+
}
|
|
6273
|
+
|
|
6274
|
+
var scrollableSpace = scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height;
|
|
6275
|
+
console.log('dragging y', diff, scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height);
|
|
6276
|
+
scrollHandleEl.style.top = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px';
|
|
6277
|
+
|
|
6278
|
+
if (this.options.onScroll) {
|
|
6279
|
+
this.startRow = Math.min(this.totalRowCount - this.sizes.rowsToRender, Math.max(0, Math.round((this.totalRowCount - this.sizes.rowsToRender) * (handlePos / scrollableSpace))));
|
|
6280
|
+
this.endRow = this.startRow + this.sizes.rowsToRender;
|
|
6281
|
+
|
|
6282
|
+
if (this.endRow === this.totalRowCount) {
|
|
6283
|
+
this.startRow += 1;
|
|
6284
|
+
}
|
|
6285
|
+
|
|
6286
|
+
this.options.onScroll('y', this.startRow, this.endRow, this.startCol, this.endCol);
|
|
6287
|
+
}
|
|
6288
|
+
}
|
|
6289
|
+
}, {
|
|
6290
|
+
key: "showLoading",
|
|
6291
|
+
value: function showLoading(options) {
|
|
6292
|
+
this.loadingDialog.show(options);
|
|
6293
|
+
}
|
|
6294
|
+
}, {
|
|
6295
|
+
key: "columns",
|
|
6296
|
+
set: function set(columns) {
|
|
6297
|
+
this.options.columns = columns;
|
|
6298
|
+
this.renderColumnHeaders();
|
|
6299
|
+
}
|
|
6300
|
+
}, {
|
|
6301
|
+
key: "totals",
|
|
6302
|
+
set: function set(totals) {
|
|
6303
|
+
this.options.totals = totals;
|
|
6304
|
+
this.renderTotals();
|
|
6305
|
+
}
|
|
6306
|
+
}]);
|
|
6307
|
+
|
|
6308
|
+
return WebsyTable3;
|
|
6309
|
+
}();
|
|
5338
6310
|
/* global d3 include WebsyDesigns */
|
|
5339
6311
|
|
|
5340
6312
|
|
|
5341
6313
|
var WebsyChart = /*#__PURE__*/function () {
|
|
5342
6314
|
function WebsyChart(elementId, options) {
|
|
5343
|
-
var
|
|
6315
|
+
var _this39 = this;
|
|
5344
6316
|
|
|
5345
6317
|
_classCallCheck(this, WebsyChart);
|
|
5346
6318
|
|
|
@@ -5389,22 +6361,22 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5389
6361
|
this.invertOverride = function (input, input2) {
|
|
5390
6362
|
var xAxis = 'bottomAxis';
|
|
5391
6363
|
|
|
5392
|
-
if (
|
|
6364
|
+
if (_this39.options.orientation === 'horizontal') {
|
|
5393
6365
|
xAxis = 'leftAxis';
|
|
5394
6366
|
}
|
|
5395
6367
|
|
|
5396
|
-
var width =
|
|
6368
|
+
var width = _this39[xAxis].step();
|
|
5397
6369
|
|
|
5398
6370
|
var output;
|
|
5399
6371
|
|
|
5400
|
-
var domain = _toConsumableArray(
|
|
6372
|
+
var domain = _toConsumableArray(_this39[xAxis].domain());
|
|
5401
6373
|
|
|
5402
|
-
if (
|
|
6374
|
+
if (_this39.options.orientation === 'horizontal') {
|
|
5403
6375
|
domain = domain.reverse();
|
|
5404
6376
|
}
|
|
5405
6377
|
|
|
5406
6378
|
for (var j = 0; j < domain.length; j++) {
|
|
5407
|
-
var breakA =
|
|
6379
|
+
var breakA = _this39[xAxis](domain[j]) - width / 2;
|
|
5408
6380
|
var breakB = breakA + width;
|
|
5409
6381
|
|
|
5410
6382
|
if (input > breakA && input <= breakB) {
|
|
@@ -5504,10 +6476,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5504
6476
|
}, {
|
|
5505
6477
|
key: "handleEventMouseMove",
|
|
5506
6478
|
value: function handleEventMouseMove(event, d) {
|
|
5507
|
-
var
|
|
6479
|
+
var _this40 = this;
|
|
5508
6480
|
|
|
5509
6481
|
var bisectDate = d3.bisector(function (d) {
|
|
5510
|
-
return
|
|
6482
|
+
return _this40.parseX(d.x.value);
|
|
5511
6483
|
}).left;
|
|
5512
6484
|
|
|
5513
6485
|
if (this.options.showTrackingLine === true && d3.pointer(event)) {
|
|
@@ -5546,8 +6518,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5546
6518
|
}
|
|
5547
6519
|
|
|
5548
6520
|
this.options.data.series.forEach(function (s) {
|
|
5549
|
-
if (
|
|
5550
|
-
xPoint =
|
|
6521
|
+
if (_this40.options.data[xData].scale !== 'Time') {
|
|
6522
|
+
xPoint = _this40[xAxis](_this40.parseX(xLabel));
|
|
5551
6523
|
s.data.forEach(function (d) {
|
|
5552
6524
|
if (d.x.value === xLabel) {
|
|
5553
6525
|
if (!tooltipTitle) {
|
|
@@ -5566,13 +6538,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5566
6538
|
var pointA = s.data[index - 1];
|
|
5567
6539
|
var pointB = s.data[index];
|
|
5568
6540
|
|
|
5569
|
-
if (
|
|
6541
|
+
if (_this40.options.orientation === 'horizontal') {
|
|
5570
6542
|
pointA = _toConsumableArray(s.data).reverse()[index - 1];
|
|
5571
6543
|
pointB = _toConsumableArray(s.data).reverse()[index];
|
|
5572
6544
|
}
|
|
5573
6545
|
|
|
5574
6546
|
if (pointA && !pointB) {
|
|
5575
|
-
xPoint =
|
|
6547
|
+
xPoint = _this40[xAxis](_this40.parseX(pointA.x.value));
|
|
5576
6548
|
tooltipTitle = pointA.x.value;
|
|
5577
6549
|
|
|
5578
6550
|
if (!pointA.y.color) {
|
|
@@ -5582,12 +6554,12 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5582
6554
|
tooltipData.push(pointA.y);
|
|
5583
6555
|
|
|
5584
6556
|
if (typeof pointA.x.value.getTime !== 'undefined') {
|
|
5585
|
-
tooltipTitle = d3.timeFormat(
|
|
6557
|
+
tooltipTitle = d3.timeFormat(_this40.options.dateFormat || _this40.options.calculatedTimeFormatPattern)(pointA.x.value);
|
|
5586
6558
|
}
|
|
5587
6559
|
}
|
|
5588
6560
|
|
|
5589
6561
|
if (pointB && !pointA) {
|
|
5590
|
-
xPoint =
|
|
6562
|
+
xPoint = _this40[xAxis](_this40.parseX(pointB.x.value));
|
|
5591
6563
|
tooltipTitle = pointB.x.value;
|
|
5592
6564
|
|
|
5593
6565
|
if (!pointB.y.color) {
|
|
@@ -5597,14 +6569,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5597
6569
|
tooltipData.push(pointB.y);
|
|
5598
6570
|
|
|
5599
6571
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
5600
|
-
tooltipTitle = d3.timeFormat(
|
|
6572
|
+
tooltipTitle = d3.timeFormat(_this40.options.dateFormat || _this40.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
5601
6573
|
}
|
|
5602
6574
|
}
|
|
5603
6575
|
|
|
5604
6576
|
if (pointA && pointB) {
|
|
5605
|
-
var d0 =
|
|
6577
|
+
var d0 = _this40[xAxis](_this40.parseX(pointA.x.value));
|
|
5606
6578
|
|
|
5607
|
-
var d1 =
|
|
6579
|
+
var d1 = _this40[xAxis](_this40.parseX(pointB.x.value));
|
|
5608
6580
|
|
|
5609
6581
|
var mid = Math.abs(d0 - d1) / 2;
|
|
5610
6582
|
|
|
@@ -5613,7 +6585,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5613
6585
|
tooltipTitle = pointB.x.value;
|
|
5614
6586
|
|
|
5615
6587
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
5616
|
-
tooltipTitle = d3.timeFormat(
|
|
6588
|
+
tooltipTitle = d3.timeFormat(_this40.options.dateFormat || _this40.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
5617
6589
|
}
|
|
5618
6590
|
|
|
5619
6591
|
if (!pointB.y.color) {
|
|
@@ -5626,7 +6598,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5626
6598
|
tooltipTitle = pointA.x.value;
|
|
5627
6599
|
|
|
5628
6600
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
5629
|
-
tooltipTitle = d3.timeFormat(
|
|
6601
|
+
tooltipTitle = d3.timeFormat(_this40.options.dateFormat || _this40.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
5630
6602
|
}
|
|
5631
6603
|
|
|
5632
6604
|
if (!pointA.y.color) {
|
|
@@ -5731,7 +6703,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5731
6703
|
}, {
|
|
5732
6704
|
key: "render",
|
|
5733
6705
|
value: function render(options) {
|
|
5734
|
-
var
|
|
6706
|
+
var _this41 = this;
|
|
5735
6707
|
|
|
5736
6708
|
/* global d3 options WebsyUtils */
|
|
5737
6709
|
if (typeof options !== 'undefined') {
|
|
@@ -5800,7 +6772,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5800
6772
|
var legendData = this.options.data.series.map(function (s, i) {
|
|
5801
6773
|
return {
|
|
5802
6774
|
value: s.label || s.key,
|
|
5803
|
-
color: s.color ||
|
|
6775
|
+
color: s.color || _this41.options.colors[i % _this41.options.colors.length]
|
|
5804
6776
|
};
|
|
5805
6777
|
});
|
|
5806
6778
|
|
|
@@ -6052,7 +7024,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6052
7024
|
|
|
6053
7025
|
if (this.options.data.bottom.formatter) {
|
|
6054
7026
|
bAxisFunc.tickFormat(function (d) {
|
|
6055
|
-
return
|
|
7027
|
+
return _this41.options.data.bottom.formatter(d);
|
|
6056
7028
|
});
|
|
6057
7029
|
}
|
|
6058
7030
|
|
|
@@ -6078,8 +7050,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6078
7050
|
|
|
6079
7051
|
if (this.options.margin.axisLeft > 0) {
|
|
6080
7052
|
this.leftAxisLayer.call(d3.axisLeft(this.leftAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
6081
|
-
if (
|
|
6082
|
-
d =
|
|
7053
|
+
if (_this41.options.data.left.formatter) {
|
|
7054
|
+
d = _this41.options.data.left.formatter(d);
|
|
6083
7055
|
}
|
|
6084
7056
|
|
|
6085
7057
|
return d;
|
|
@@ -6116,8 +7088,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6116
7088
|
|
|
6117
7089
|
if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
|
|
6118
7090
|
this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
6119
|
-
if (
|
|
6120
|
-
d =
|
|
7091
|
+
if (_this41.options.data.right.formatter) {
|
|
7092
|
+
d = _this41.options.data.right.formatter(d);
|
|
6121
7093
|
}
|
|
6122
7094
|
|
|
6123
7095
|
return d;
|
|
@@ -6143,16 +7115,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6143
7115
|
|
|
6144
7116
|
this.options.data.series.forEach(function (series, index) {
|
|
6145
7117
|
if (!series.key) {
|
|
6146
|
-
series.key =
|
|
7118
|
+
series.key = _this41.createIdentity();
|
|
6147
7119
|
}
|
|
6148
7120
|
|
|
6149
7121
|
if (!series.color) {
|
|
6150
|
-
series.color =
|
|
7122
|
+
series.color = _this41.options.colors[index % _this41.options.colors.length];
|
|
6151
7123
|
}
|
|
6152
7124
|
|
|
6153
|
-
|
|
7125
|
+
_this41["render".concat(series.type || 'bar')](series, index);
|
|
6154
7126
|
|
|
6155
|
-
|
|
7127
|
+
_this41.renderLabels(series, index);
|
|
6156
7128
|
});
|
|
6157
7129
|
}
|
|
6158
7130
|
}
|
|
@@ -6160,17 +7132,17 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6160
7132
|
}, {
|
|
6161
7133
|
key: "renderarea",
|
|
6162
7134
|
value: function renderarea(series, index) {
|
|
6163
|
-
var
|
|
7135
|
+
var _this42 = this;
|
|
6164
7136
|
|
|
6165
7137
|
/* global d3 series index */
|
|
6166
7138
|
var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
|
|
6167
7139
|
return d3.area().x(function (d) {
|
|
6168
|
-
return
|
|
7140
|
+
return _this42[xAxis](_this42.parseX(d.x.value));
|
|
6169
7141
|
}).y0(function (d) {
|
|
6170
|
-
return
|
|
7142
|
+
return _this42[yAxis](0);
|
|
6171
7143
|
}).y1(function (d) {
|
|
6172
|
-
return
|
|
6173
|
-
}).curve(d3[curveStyle ||
|
|
7144
|
+
return _this42[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
7145
|
+
}).curve(d3[curveStyle || _this42.options.curveStyle]);
|
|
6174
7146
|
};
|
|
6175
7147
|
|
|
6176
7148
|
var xAxis = 'bottomAxis';
|
|
@@ -6273,15 +7245,21 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6273
7245
|
}
|
|
6274
7246
|
|
|
6275
7247
|
bars.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
6276
|
-
bars.attr('width', getBarWidth.bind(this)).attr('height', getBarHeight.bind(this)).attr('x', getBarX.bind(this)).attr('y', getBarY.bind(this)).transition(this.transition).attr('fill',
|
|
7248
|
+
bars.attr('width', getBarWidth.bind(this)).attr('height', getBarHeight.bind(this)).attr('x', getBarX.bind(this)).attr('y', getBarY.bind(this)).transition(this.transition).attr('fill', function (d) {
|
|
7249
|
+
return d.color || series.color;
|
|
7250
|
+
});
|
|
6277
7251
|
bars.enter().append('rect').attr('width', getBarWidth.bind(this)).attr('height', getBarHeight.bind(this)).attr('x', getBarX.bind(this)).attr('y', getBarY.bind(this)) // .transition(this.transition)
|
|
6278
|
-
.attr('fill',
|
|
7252
|
+
.attr('fill', function (d) {
|
|
7253
|
+
return d.color || series.color;
|
|
7254
|
+
}).attr('class', function (d) {
|
|
6279
7255
|
return "bar bar_".concat(series.key);
|
|
6280
7256
|
});
|
|
6281
7257
|
}
|
|
6282
7258
|
}, {
|
|
6283
7259
|
key: "renderLabels",
|
|
6284
7260
|
value: function renderLabels(series, index) {
|
|
7261
|
+
var _this43 = this;
|
|
7262
|
+
|
|
6285
7263
|
/* global series index d3 WebsyDesigns */
|
|
6286
7264
|
var xAxis = 'bottomAxis';
|
|
6287
7265
|
var yAxis = 'leftAxis';
|
|
@@ -6298,10 +7276,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6298
7276
|
// We currently only support 'Auto'
|
|
6299
7277
|
var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
|
|
6300
7278
|
labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
6301
|
-
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")).style('fill',
|
|
7279
|
+
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")).style('fill', function (d) {
|
|
7280
|
+
return _this43.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.color || series.color);
|
|
7281
|
+
}).transition(this.transition).text(function (d) {
|
|
6302
7282
|
return d.y.label || d.y.value;
|
|
6303
7283
|
});
|
|
6304
|
-
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")).style('fill',
|
|
7284
|
+
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")).style('fill', function (d) {
|
|
7285
|
+
return _this43.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.color || series.color);
|
|
7286
|
+
}).text(function (d) {
|
|
6305
7287
|
return d.y.label || d.y.value;
|
|
6306
7288
|
}).each(function (d, i) {
|
|
6307
7289
|
if (that.options.orientation === 'horizontal') {
|
|
@@ -6345,15 +7327,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6345
7327
|
}, {
|
|
6346
7328
|
key: "renderline",
|
|
6347
7329
|
value: function renderline(series, index) {
|
|
6348
|
-
var
|
|
7330
|
+
var _this44 = this;
|
|
6349
7331
|
|
|
6350
7332
|
/* global series index d3 */
|
|
6351
7333
|
var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
|
|
6352
7334
|
return d3.line().x(function (d) {
|
|
6353
|
-
return
|
|
7335
|
+
return _this44[xAxis](_this44.parseX(d.x.value));
|
|
6354
7336
|
}).y(function (d) {
|
|
6355
|
-
return
|
|
6356
|
-
}).curve(d3[curveStyle ||
|
|
7337
|
+
return _this44[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
7338
|
+
}).curve(d3[curveStyle || _this44.options.curveStyle]);
|
|
6357
7339
|
};
|
|
6358
7340
|
|
|
6359
7341
|
var xAxis = 'bottomAxis';
|
|
@@ -6391,14 +7373,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6391
7373
|
}, {
|
|
6392
7374
|
key: "rendersymbol",
|
|
6393
7375
|
value: function rendersymbol(series, index) {
|
|
6394
|
-
var
|
|
7376
|
+
var _this45 = this;
|
|
6395
7377
|
|
|
6396
7378
|
/* global d3 series index series.key */
|
|
6397
7379
|
var drawSymbol = function drawSymbol(size) {
|
|
6398
7380
|
return d3.symbol() // .type(d => {
|
|
6399
7381
|
// return d3.symbols[0]
|
|
6400
7382
|
// })
|
|
6401
|
-
.size(size ||
|
|
7383
|
+
.size(size || _this45.options.symbolSize);
|
|
6402
7384
|
};
|
|
6403
7385
|
|
|
6404
7386
|
var xAxis = 'bottomAxis';
|
|
@@ -6416,7 +7398,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6416
7398
|
symbols.attr('d', function (d) {
|
|
6417
7399
|
return drawSymbol(d.y.size || series.symbolSize)(d);
|
|
6418
7400
|
}).transition(this.transition).attr('fill', 'white').attr('stroke', series.color).attr('transform', function (d) {
|
|
6419
|
-
return "translate(".concat(
|
|
7401
|
+
return "translate(".concat(_this45[xAxis](_this45.parseX(d.x.value)), ", ").concat(_this45[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
6420
7402
|
}); // Enter
|
|
6421
7403
|
|
|
6422
7404
|
symbols.enter().append('path').attr('d', function (d) {
|
|
@@ -6425,7 +7407,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6425
7407
|
.attr('fill', 'white').attr('stroke', series.color).attr('class', function (d) {
|
|
6426
7408
|
return "symbol symbol_".concat(series.key);
|
|
6427
7409
|
}).attr('transform', function (d) {
|
|
6428
|
-
return "translate(".concat(
|
|
7410
|
+
return "translate(".concat(_this45[xAxis](_this45.parseX(d.x.value)), ", ").concat(_this45[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
6429
7411
|
});
|
|
6430
7412
|
}
|
|
6431
7413
|
}, {
|
|
@@ -6580,7 +7562,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
6580
7562
|
}, {
|
|
6581
7563
|
key: "resize",
|
|
6582
7564
|
value: function resize() {
|
|
6583
|
-
var
|
|
7565
|
+
var _this46 = this;
|
|
6584
7566
|
|
|
6585
7567
|
var el = document.getElementById(this.elementId);
|
|
6586
7568
|
|
|
@@ -6593,7 +7575,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
6593
7575
|
// }
|
|
6594
7576
|
var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
|
|
6595
7577
|
html += this._data.map(function (d, i) {
|
|
6596
|
-
return
|
|
7578
|
+
return _this46.getLegendItemHTML(d);
|
|
6597
7579
|
}).join('');
|
|
6598
7580
|
html += "\n <div>\n ";
|
|
6599
7581
|
el.innerHTML = html;
|
|
@@ -6765,7 +7747,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
6765
7747
|
}, {
|
|
6766
7748
|
key: "render",
|
|
6767
7749
|
value: function render() {
|
|
6768
|
-
var
|
|
7750
|
+
var _this47 = this;
|
|
6769
7751
|
|
|
6770
7752
|
var mapEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
6771
7753
|
var legendEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
@@ -6774,7 +7756,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
6774
7756
|
var legendData = this.options.data.polygons.map(function (s, i) {
|
|
6775
7757
|
return {
|
|
6776
7758
|
value: s.label || s.key,
|
|
6777
|
-
color: s.color ||
|
|
7759
|
+
color: s.color || _this47.options.colors[i % _this47.options.colors.length]
|
|
6778
7760
|
};
|
|
6779
7761
|
});
|
|
6780
7762
|
var longestValue = legendData.map(function (s) {
|
|
@@ -6838,7 +7820,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
6838
7820
|
|
|
6839
7821
|
if (this.polygons) {
|
|
6840
7822
|
this.polygons.forEach(function (p) {
|
|
6841
|
-
return
|
|
7823
|
+
return _this47.map.removeLayer(p);
|
|
6842
7824
|
});
|
|
6843
7825
|
}
|
|
6844
7826
|
|
|
@@ -6896,18 +7878,18 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
6896
7878
|
}
|
|
6897
7879
|
|
|
6898
7880
|
if (!p.options.color) {
|
|
6899
|
-
p.options.color =
|
|
7881
|
+
p.options.color = _this47.options.colors[i % _this47.options.colors.length];
|
|
6900
7882
|
}
|
|
6901
7883
|
|
|
6902
7884
|
var pol = L.polygon(p.data.map(function (c) {
|
|
6903
7885
|
return c.map(function (d) {
|
|
6904
7886
|
return [d.Latitude, d.Longitude];
|
|
6905
7887
|
});
|
|
6906
|
-
}), p.options).addTo(
|
|
7888
|
+
}), p.options).addTo(_this47.map);
|
|
6907
7889
|
|
|
6908
|
-
|
|
7890
|
+
_this47.polygons.push(pol);
|
|
6909
7891
|
|
|
6910
|
-
|
|
7892
|
+
_this47.map.fitBounds(pol.getBounds());
|
|
6911
7893
|
});
|
|
6912
7894
|
} // if (this.data.markers.length > 0) {
|
|
6913
7895
|
// el.classList.remove('hidden')
|
|
@@ -7028,6 +8010,8 @@ var WebsyDesigns = {
|
|
|
7028
8010
|
Form: WebsyForm,
|
|
7029
8011
|
WebsyDatePicker: WebsyDatePicker,
|
|
7030
8012
|
DatePicker: WebsyDatePicker,
|
|
8013
|
+
WebsyDragDrop: WebsyDragDrop,
|
|
8014
|
+
DragDrop: WebsyDragDrop,
|
|
7031
8015
|
WebsyDropdown: WebsyDropdown,
|
|
7032
8016
|
Dropdown: WebsyDropdown,
|
|
7033
8017
|
WebsyResultList: WebsyResultList,
|
|
@@ -7040,8 +8024,10 @@ var WebsyDesigns = {
|
|
|
7040
8024
|
Router: WebsyRouter,
|
|
7041
8025
|
WebsyTable: WebsyTable,
|
|
7042
8026
|
WebsyTable2: WebsyTable2,
|
|
8027
|
+
WebsyTable3: WebsyTable3,
|
|
7043
8028
|
Table: WebsyTable,
|
|
7044
8029
|
Table2: WebsyTable2,
|
|
8030
|
+
Table3: WebsyTable3,
|
|
7045
8031
|
WebsyChart: WebsyChart,
|
|
7046
8032
|
Chart: WebsyChart,
|
|
7047
8033
|
WebsyChartTooltip: WebsyChartTooltip,
|
|
@@ -7067,5 +8053,6 @@ var WebsyDesigns = {
|
|
|
7067
8053
|
WebsyIcons: WebsyIcons
|
|
7068
8054
|
};
|
|
7069
8055
|
WebsyDesigns.service = new WebsyDesigns.APIService('');
|
|
8056
|
+
window.GlobalPubSub = new WebsyPubSub('empty', {});
|
|
7070
8057
|
var _default = WebsyDesigns;
|
|
7071
8058
|
exports["default"] = _default;
|