@websy/websy-designs 1.2.32 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/helpers/v1/pgHelper.js +13 -5
- package/dist/server/routes/v1/api.js +11 -1
- package/dist/websy-designs-es6.debug.js +972 -44
- package/dist/websy-designs-es6.js +1224 -161
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +1024 -45
- package/dist/websy-designs.js +1289 -169
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -470,7 +470,8 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
470
470
|
value: function floorDate(d) {
|
|
471
471
|
if (typeof d === 'number') {
|
|
472
472
|
d = new Date(d);
|
|
473
|
-
}
|
|
473
|
+
} // d.setTime(d.getTime() + d.getTimezoneOffset() * 60000)
|
|
474
|
+
|
|
474
475
|
|
|
475
476
|
return new Date(d.setHours(0, 0, 0, 0));
|
|
476
477
|
}
|
|
@@ -489,11 +490,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
489
490
|
var index = event.target.getAttribute('data-index');
|
|
490
491
|
this.selectRange(index);
|
|
491
492
|
this.updateRange(index);
|
|
492
|
-
} else if (event.target.classList.contains('websy-dp-date')) {//
|
|
493
|
-
// return
|
|
494
|
-
// }
|
|
495
|
-
// const timestamp = event.target.id.split('_')[0]
|
|
496
|
-
// this.selectDate(+timestamp)
|
|
493
|
+
} else if (event.target.classList.contains('websy-dp-date')) {//
|
|
497
494
|
} else if (event.target.classList.contains('websy-dp-confirm')) {
|
|
498
495
|
this.close(true);
|
|
499
496
|
} else if (event.target.classList.contains('websy-dp-cancel')) {
|
|
@@ -527,7 +524,8 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
527
524
|
value: function handleMouseDown(event) {
|
|
528
525
|
if (this.shiftPressed === true && this.currentselection.length > 0) {
|
|
529
526
|
this.mouseDownId = this.currentselection[this.currentselection.length - 1];
|
|
530
|
-
|
|
527
|
+
var dateId = event.target.getAttribute('data-id');
|
|
528
|
+
this.selectDate(+dateId);
|
|
531
529
|
} else {
|
|
532
530
|
this.mouseDown = true;
|
|
533
531
|
this.dragging = false;
|
|
@@ -542,7 +540,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
542
540
|
this.customRangeSelected = false;
|
|
543
541
|
}
|
|
544
542
|
|
|
545
|
-
this.mouseDownId = +event.target.
|
|
543
|
+
this.mouseDownId = +event.target.getAttribute('data-id');
|
|
546
544
|
this.selectDate(this.mouseDownId);
|
|
547
545
|
}
|
|
548
546
|
}
|
|
@@ -556,9 +554,11 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
556
554
|
return;
|
|
557
555
|
}
|
|
558
556
|
|
|
559
|
-
|
|
557
|
+
var dateId = +event.target.getAttribute('data-id');
|
|
558
|
+
|
|
559
|
+
if (dateId !== this.mouseDownId) {
|
|
560
560
|
this.dragging = true;
|
|
561
|
-
this.selectDate(
|
|
561
|
+
this.selectDate(dateId);
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
564
|
}
|
|
@@ -614,6 +614,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
614
614
|
|
|
615
615
|
if (this.options.mode === 'date') {
|
|
616
616
|
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + _i * this.oneDay));
|
|
617
|
+
d.setHours(0, 0, 0, 0);
|
|
617
618
|
d = d.getTime();
|
|
618
619
|
rangeStart = this.selectedRangeDates[0].getTime();
|
|
619
620
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime();
|
|
@@ -906,7 +907,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
906
907
|
}
|
|
907
908
|
|
|
908
909
|
html += months[key].map(function (d) {
|
|
909
|
-
return "<li id='".concat(_this4.elementId, "_").concat(d.id, "_date' class='websy-dp-date ").concat(d.disabled === true ? 'websy-disabled-date' : '', "'>").concat(d.dayOfMonth, "</li>");
|
|
910
|
+
return "<li id='".concat(_this4.elementId, "_").concat(d.id, "_date' data-id='").concat(d.id, "' class='websy-dp-date ").concat(d.disabled === true ? 'websy-disabled-date' : '', "'>").concat(d.dayOfMonth, "</li>");
|
|
910
911
|
}).join('');
|
|
911
912
|
html += "\n </ul>\n </div>\n ";
|
|
912
913
|
}
|
|
@@ -1043,7 +1044,9 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
1043
1044
|
|
|
1044
1045
|
if (this.options.ranges[this.options.mode][index]) {
|
|
1045
1046
|
this.selectedRangeDates = _toConsumableArray(this.options.ranges[this.options.mode][index].range);
|
|
1046
|
-
this.currentselection =
|
|
1047
|
+
this.currentselection = this.options.ranges[this.options.mode][index].range.map(function (d) {
|
|
1048
|
+
return d.getTime();
|
|
1049
|
+
});
|
|
1047
1050
|
this.selectedRange = +index;
|
|
1048
1051
|
var el = document.getElementById("".concat(this.elementId, "_header"));
|
|
1049
1052
|
|
|
@@ -1238,12 +1241,322 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
1238
1241
|
Date.prototype.floor = function () {
|
|
1239
1242
|
return new Date("".concat(this.getMonth() + 1, "/").concat(this.getDate(), "/").concat(this.getFullYear()));
|
|
1240
1243
|
};
|
|
1244
|
+
/* global WebsyDesigns GlobalPubSub */
|
|
1245
|
+
|
|
1246
|
+
|
|
1247
|
+
var WebsyDragDrop = /*#__PURE__*/function () {
|
|
1248
|
+
function WebsyDragDrop(elementId, options) {
|
|
1249
|
+
_classCallCheck(this, WebsyDragDrop);
|
|
1250
|
+
|
|
1251
|
+
var DEFAULTS = {
|
|
1252
|
+
items: [],
|
|
1253
|
+
orientation: 'horizontal',
|
|
1254
|
+
dropPlaceholder: 'Drop item here'
|
|
1255
|
+
};
|
|
1256
|
+
this.busy = false;
|
|
1257
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
1258
|
+
this.elementId = elementId;
|
|
1259
|
+
|
|
1260
|
+
if (!elementId) {
|
|
1261
|
+
console.log('No element Id provided for Websy DragDrop');
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
var el = document.getElementById(elementId);
|
|
1266
|
+
|
|
1267
|
+
if (el) {
|
|
1268
|
+
el.innerHTML = "\n <div id='".concat(this.elementId, "_container' class='websy-drag-drop-container ").concat(this.options.orientation, "'>\n <div>\n </div>\n ");
|
|
1269
|
+
el.addEventListener('click', this.handleClick.bind(this));
|
|
1270
|
+
el.addEventListener('dragstart', this.handleDragStart.bind(this));
|
|
1271
|
+
el.addEventListener('dragover', this.handleDragOver.bind(this));
|
|
1272
|
+
el.addEventListener('dragleave', this.handleDragLeave.bind(this));
|
|
1273
|
+
el.addEventListener('drop', this.handleDrop.bind(this));
|
|
1274
|
+
window.addEventListener('dragend', this.handleDragEnd.bind(this));
|
|
1275
|
+
} else {
|
|
1276
|
+
console.error("No element found with ID ".concat(this.elementId));
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
GlobalPubSub.subscribe(this.elementId, 'requestForDDItem', this.handleRequestForItem.bind(this));
|
|
1280
|
+
GlobalPubSub.subscribe(this.elementId, 'add', this.addItem.bind(this));
|
|
1281
|
+
this.render();
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
_createClass(WebsyDragDrop, [{
|
|
1285
|
+
key: "addItem",
|
|
1286
|
+
value: function addItem(data) {
|
|
1287
|
+
if (data.target === this.elementId && this.busy === false) {
|
|
1288
|
+
this.busy = true;
|
|
1289
|
+
console.log('adding item to dd'); // check that an item with the same id doesn't already exist
|
|
1290
|
+
|
|
1291
|
+
var index = this.getItemIndex(data.item.id);
|
|
1292
|
+
|
|
1293
|
+
if (index === -1) {
|
|
1294
|
+
this.options.items.splice(data.index, 0, data.item);
|
|
1295
|
+
var startEl = document.getElementById("".concat(this.elementId, "start_item"));
|
|
1296
|
+
|
|
1297
|
+
if (startEl) {
|
|
1298
|
+
if (this.options.items.length === 0) {
|
|
1299
|
+
startEl.classList.add('empty');
|
|
1300
|
+
} else {
|
|
1301
|
+
startEl.classList.remove('empty');
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
if (this.options.onItemAdded) {
|
|
1306
|
+
this.options.onItemAdded();
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
this.busy = false;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
}, {
|
|
1314
|
+
key: "createItemHtml",
|
|
1315
|
+
value: function createItemHtml(elementId, index, item) {
|
|
1316
|
+
if (!item.id) {
|
|
1317
|
+
item.id = WebsyDesigns.Utils.createIdentity();
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
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 ");
|
|
1321
|
+
|
|
1322
|
+
if (item.component) {
|
|
1323
|
+
html += "<div id='".concat(item.id, "_component'></div>");
|
|
1324
|
+
} else {
|
|
1325
|
+
html += "".concat(item.html || item.label || '');
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
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 ");
|
|
1329
|
+
return html;
|
|
1330
|
+
}
|
|
1331
|
+
}, {
|
|
1332
|
+
key: "getItemIndex",
|
|
1333
|
+
value: function getItemIndex(id) {
|
|
1334
|
+
for (var i = 0; i < this.options.items.length; i++) {
|
|
1335
|
+
if (this.options.items[i].id === id) {
|
|
1336
|
+
return i;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
return -1;
|
|
1341
|
+
}
|
|
1342
|
+
}, {
|
|
1343
|
+
key: "handleClick",
|
|
1344
|
+
value: function handleClick(event) {}
|
|
1345
|
+
}, {
|
|
1346
|
+
key: "handleDragStart",
|
|
1347
|
+
value: function handleDragStart(event) {
|
|
1348
|
+
this.draggedId = event.target.getAttribute('data-id');
|
|
1349
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
1350
|
+
event.dataTransfer.setData('application/wd-item', JSON.stringify({
|
|
1351
|
+
el: event.target.id,
|
|
1352
|
+
id: this.elementId,
|
|
1353
|
+
itemId: this.draggedId
|
|
1354
|
+
})); // console.log('drag start', event)
|
|
1355
|
+
|
|
1356
|
+
event.target.style.opacity = 0.5;
|
|
1357
|
+
this.dragging = true;
|
|
1358
|
+
}
|
|
1359
|
+
}, {
|
|
1360
|
+
key: "handleDragOver",
|
|
1361
|
+
value: function handleDragOver(event) {
|
|
1362
|
+
// console.log('drag over', event.target.classList)
|
|
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
|
+
if (!event.target.classList.contains('droppable')) {
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
event.target.classList.remove('drag-over'); // let side = event.target.getAttribute('data-side')
|
|
1382
|
+
// let id = event.target.getAttribute('data-id')
|
|
1383
|
+
// let droppedItem = this.options.items[id]
|
|
1384
|
+
// this.removeExpandedDrop(side, id, droppedItem)
|
|
1385
|
+
}
|
|
1386
|
+
}, {
|
|
1387
|
+
key: "handleDrop",
|
|
1388
|
+
value: function handleDrop(event) {
|
|
1389
|
+
// console.log('drag drop')
|
|
1390
|
+
// console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1391
|
+
var data = JSON.parse(event.dataTransfer.getData('application/wd-item'));
|
|
1392
|
+
|
|
1393
|
+
if (event.preventDefault) {
|
|
1394
|
+
event.preventDefault();
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
if (!event.target.classList.contains('droppable')) {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
var side = event.target.getAttribute('data-side');
|
|
1402
|
+
var id = event.target.getAttribute('data-id');
|
|
1403
|
+
var index = this.getItemIndex(id);
|
|
1404
|
+
var draggedIndex = this.getItemIndex(data.id);
|
|
1405
|
+
var droppedItem = this.options.items[index];
|
|
1406
|
+
|
|
1407
|
+
if (side === 'right') {
|
|
1408
|
+
index += 1;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
if (draggedIndex === -1) {
|
|
1412
|
+
// console.log('requestForDDItem')
|
|
1413
|
+
GlobalPubSub.publish(data.id, 'requestForDDItem', {
|
|
1414
|
+
group: this.options.group,
|
|
1415
|
+
source: data.id,
|
|
1416
|
+
target: this.elementId,
|
|
1417
|
+
index: index,
|
|
1418
|
+
id: data.itemId
|
|
1419
|
+
});
|
|
1420
|
+
} else if (index > draggedIndex) {
|
|
1421
|
+
// insert and then remove
|
|
1422
|
+
this.options.items.splice(index, 0, droppedItem);
|
|
1423
|
+
this.options.items.splice(draggedIndex, 1);
|
|
1424
|
+
|
|
1425
|
+
if (this.options.onOrderUpdated) {
|
|
1426
|
+
this.options.onOrderUpdated();
|
|
1427
|
+
}
|
|
1428
|
+
} else {
|
|
1429
|
+
// remove and then insert
|
|
1430
|
+
this.options.items.splice(draggedIndex, 1);
|
|
1431
|
+
this.options.items.splice(index, 0, droppedItem);
|
|
1432
|
+
|
|
1433
|
+
if (this.options.onOrderUpdated) {
|
|
1434
|
+
this.options.onOrderUpdated();
|
|
1435
|
+
}
|
|
1436
|
+
} // this.removeExpandedDrop(side, id, droppedItem)
|
|
1437
|
+
// const draggedEl = document.getElementById(`${this.elementId}_${this.draggedId}_item`)
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
var draggedEl = document.getElementById(data.el);
|
|
1441
|
+
var droppedEl = document.getElementById("".concat(id, "_item"));
|
|
1442
|
+
|
|
1443
|
+
if (draggedEl) {
|
|
1444
|
+
droppedEl.insertAdjacentElement('afterend', draggedEl);
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
var dragOverEl = droppedEl.querySelector('.drag-over');
|
|
1448
|
+
|
|
1449
|
+
if (dragOverEl) {
|
|
1450
|
+
dragOverEl.classList.remove('drag-over');
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}, {
|
|
1454
|
+
key: "handleDragEnd",
|
|
1455
|
+
value: function handleDragEnd(event) {
|
|
1456
|
+
// console.log('drag end')
|
|
1457
|
+
event.target.style.opacity = 1;
|
|
1458
|
+
this.draggedId = null;
|
|
1459
|
+
this.dragging = false;
|
|
1460
|
+
var startEl = document.getElementById("".concat(this.elementId, "start_item"));
|
|
1461
|
+
|
|
1462
|
+
if (startEl) {
|
|
1463
|
+
if (this.options.items.length === 0) {
|
|
1464
|
+
startEl.classList.add('empty');
|
|
1465
|
+
} else {
|
|
1466
|
+
startEl.classList.remove('empty');
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}, {
|
|
1471
|
+
key: "handleRequestForItem",
|
|
1472
|
+
value: function handleRequestForItem(data) {
|
|
1473
|
+
if (data.group === this.options.group) {
|
|
1474
|
+
var index = this.getItemIndex(data.id);
|
|
1475
|
+
|
|
1476
|
+
if (index !== -1) {
|
|
1477
|
+
var itemToAdd = this.options.items.splice(index, 1);
|
|
1478
|
+
GlobalPubSub.publish(data.target, 'add', {
|
|
1479
|
+
target: data.target,
|
|
1480
|
+
index: data.index,
|
|
1481
|
+
item: itemToAdd[0]
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
}, {
|
|
1487
|
+
key: "measureItems",
|
|
1488
|
+
value: function measureItems() {
|
|
1489
|
+
var el = document.getElementById("".concat(this.elementId, "_container"));
|
|
1490
|
+
this.options.items.forEach(function (d) {});
|
|
1491
|
+
} // removeExpandedDrop (side, id, droppedItem) {
|
|
1492
|
+
// let dropEl
|
|
1493
|
+
// const dropImageEl = document.getElementById(`${id}_itemInner`)
|
|
1494
|
+
// // const placeholderEl = document.getElementById(`${this.elementId}_${id}_dropZonePlaceholder`)
|
|
1495
|
+
// if (side === 'left') {
|
|
1496
|
+
// dropEl = document.getElementById(`${this.elementId}_${id}_dropZoneLeft`)
|
|
1497
|
+
// dropImageEl.style.left = `0px`
|
|
1498
|
+
// }
|
|
1499
|
+
// else if (side === 'right') {
|
|
1500
|
+
// dropEl = document.getElementById(`${this.elementId}_${id}_dropZoneRight`)
|
|
1501
|
+
// }
|
|
1502
|
+
// else {
|
|
1503
|
+
// dropEl = document.getElementById(`${this.elementId}_${id}_dropZoneEnd`)
|
|
1504
|
+
// }
|
|
1505
|
+
// if (dropEl) {
|
|
1506
|
+
// const dropElSize = dropEl.getBoundingClientRect()
|
|
1507
|
+
// dropEl.style.width = `${(dropElSize.width / 2)}px`
|
|
1508
|
+
// dropEl.style.marginLeft = null
|
|
1509
|
+
// dropEl.style.border = null
|
|
1510
|
+
// }
|
|
1511
|
+
// if (placeholderEl) {
|
|
1512
|
+
// placeholderEl.classList.remove('active')
|
|
1513
|
+
// placeholderEl.style.left = null
|
|
1514
|
+
// placeholderEl.style.right = null
|
|
1515
|
+
// placeholderEl.style.width = null
|
|
1516
|
+
// placeholderEl.style.height = null
|
|
1517
|
+
// }
|
|
1518
|
+
// }
|
|
1519
|
+
|
|
1520
|
+
}, {
|
|
1521
|
+
key: "removeItem",
|
|
1522
|
+
value: function removeItem(id) {}
|
|
1523
|
+
}, {
|
|
1524
|
+
key: "render",
|
|
1525
|
+
value: function render() {
|
|
1526
|
+
var _this8 = this;
|
|
1527
|
+
|
|
1528
|
+
var el = document.getElementById("".concat(this.elementId, "_container"));
|
|
1529
|
+
|
|
1530
|
+
if (el) {
|
|
1531
|
+
this.measureItems();
|
|
1532
|
+
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 ");
|
|
1533
|
+
html += this.options.items.map(function (d, i) {
|
|
1534
|
+
return _this8.createItemHtml(_this8.elementId, i, d);
|
|
1535
|
+
}).join('');
|
|
1536
|
+
el.innerHTML = html;
|
|
1537
|
+
this.options.items.forEach(function (item, i) {
|
|
1538
|
+
if (item.component) {
|
|
1539
|
+
if (item.isQlikPlugin && WebsyDesigns.QlikPlugin[item.component]) {
|
|
1540
|
+
item.instance = new WebsyDesigns.QlikPlugin[item.component]("".concat(item.id, "_component"), item.options);
|
|
1541
|
+
} else if (WebsyDesigns[item.component]) {
|
|
1542
|
+
item.instance = new WebsyDesigns[item.component]("".concat(item.id, "_component"), item.options);
|
|
1543
|
+
} else {
|
|
1544
|
+
console.error("Component ".concat(item.component, " not found."));
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
}]);
|
|
1551
|
+
|
|
1552
|
+
return WebsyDragDrop;
|
|
1553
|
+
}();
|
|
1241
1554
|
/* global WebsyUtils */
|
|
1242
1555
|
|
|
1243
1556
|
|
|
1244
1557
|
var WebsyDropdown = /*#__PURE__*/function () {
|
|
1245
1558
|
function WebsyDropdown(elementId, options) {
|
|
1246
|
-
var
|
|
1559
|
+
var _this9 = this;
|
|
1247
1560
|
|
|
1248
1561
|
_classCallCheck(this, WebsyDropdown);
|
|
1249
1562
|
|
|
@@ -1291,10 +1604,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1291
1604
|
el.addEventListener('mouseout', this.handleMouseOut.bind(this));
|
|
1292
1605
|
el.addEventListener('mousemove', this.handleMouseMove.bind(this));
|
|
1293
1606
|
var headerLabel = this.selectedItems.map(function (s) {
|
|
1294
|
-
return
|
|
1607
|
+
return _this9.options.items[s].label || _this9.options.items[s].value;
|
|
1295
1608
|
}).join(this.options.multiValueDelimiter);
|
|
1296
1609
|
var headerValue = this.selectedItems.map(function (s) {
|
|
1297
|
-
return
|
|
1610
|
+
return _this9.options.items[s].value || _this9.options.items[s].label;
|
|
1298
1611
|
}).join(this.options.multiValueDelimiter);
|
|
1299
1612
|
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
1613
|
|
|
@@ -1577,10 +1890,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1577
1890
|
}, {
|
|
1578
1891
|
key: "renderItems",
|
|
1579
1892
|
value: function renderItems() {
|
|
1580
|
-
var
|
|
1893
|
+
var _this10 = this;
|
|
1581
1894
|
|
|
1582
1895
|
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(
|
|
1896
|
+
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
1897
|
}).join('');
|
|
1585
1898
|
var el = document.getElementById("".concat(this.elementId, "_items"));
|
|
1586
1899
|
|
|
@@ -1599,14 +1912,17 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1599
1912
|
}, {
|
|
1600
1913
|
key: "updateHeader",
|
|
1601
1914
|
value: function updateHeader(item) {
|
|
1602
|
-
var _this10 = this;
|
|
1603
|
-
|
|
1604
1915
|
var el = document.getElementById(this.elementId);
|
|
1605
1916
|
var headerEl = document.getElementById("".concat(this.elementId, "_header"));
|
|
1606
1917
|
var headerLabelEl = document.getElementById("".concat(this.elementId, "_headerLabel"));
|
|
1607
1918
|
var labelEl = document.getElementById("".concat(this.elementId, "_selectedItems"));
|
|
1608
1919
|
var inputEl = document.getElementById("".concat(this.elementId, "_input"));
|
|
1609
1920
|
var itemEls = el.querySelectorAll(".websy-dropdown-item");
|
|
1921
|
+
var dataToUse = this._originalData;
|
|
1922
|
+
|
|
1923
|
+
if (this.options.onSearch) {
|
|
1924
|
+
dataToUse = this.options.items;
|
|
1925
|
+
}
|
|
1610
1926
|
|
|
1611
1927
|
for (var i = 0; i < itemEls.length; i++) {
|
|
1612
1928
|
itemEls[i].classList.remove('active');
|
|
@@ -1646,17 +1962,17 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1646
1962
|
} else if (this.selectedItems.length > 1) {
|
|
1647
1963
|
if (this.options.showCompleteSelectedList === true) {
|
|
1648
1964
|
var selectedLabels = this.selectedItems.map(function (s) {
|
|
1649
|
-
return
|
|
1965
|
+
return dataToUse[s].label || dataToUse[s].value;
|
|
1650
1966
|
}).join(this.options.multiValueDelimiter);
|
|
1651
1967
|
var selectedValues = this.selectedItems.map(function (s) {
|
|
1652
|
-
return
|
|
1968
|
+
return dataToUse[s].value || dataToUse[s].label;
|
|
1653
1969
|
}).join(this.options.multiValueDelimiter);
|
|
1654
1970
|
labelEl.innerHTML = selectedLabels;
|
|
1655
1971
|
labelEl.setAttribute('data-info', selectedLabels);
|
|
1656
1972
|
inputEl.value = selectedValues;
|
|
1657
1973
|
} else {
|
|
1658
1974
|
var _selectedValues = this.selectedItems.map(function (s) {
|
|
1659
|
-
return
|
|
1975
|
+
return dataToUse[s].value || dataToUse[s].label;
|
|
1660
1976
|
}).join(this.options.multiValueDelimiter);
|
|
1661
1977
|
|
|
1662
1978
|
labelEl.innerHTML = "".concat(this.selectedItems.length, " selected");
|
|
@@ -1673,6 +1989,12 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1673
1989
|
}, {
|
|
1674
1990
|
key: "updateSelected",
|
|
1675
1991
|
value: function updateSelected(index) {
|
|
1992
|
+
var dataToUse = this._originalData && this._originalData.length > 0 ? this._originalData : this.options.items;
|
|
1993
|
+
|
|
1994
|
+
if (this.options.onSearch) {
|
|
1995
|
+
dataToUse = this.options.items;
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1676
1998
|
if (typeof index !== 'undefined' && index !== null) {
|
|
1677
1999
|
var pos = this.selectedItems.indexOf(index);
|
|
1678
2000
|
|
|
@@ -1685,13 +2007,14 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1685
2007
|
this.selectedItems.push(index);
|
|
1686
2008
|
}
|
|
1687
2009
|
}
|
|
1688
|
-
}
|
|
2010
|
+
} // const item = this.options.items[index]
|
|
1689
2011
|
|
|
1690
|
-
|
|
2012
|
+
|
|
2013
|
+
var item = dataToUse[index];
|
|
1691
2014
|
this.updateHeader(item);
|
|
1692
2015
|
|
|
1693
2016
|
if (item && this.options.onItemSelected) {
|
|
1694
|
-
this.options.onItemSelected(item, this.selectedItems,
|
|
2017
|
+
this.options.onItemSelected(item, this.selectedItems, dataToUse, this.options);
|
|
1695
2018
|
}
|
|
1696
2019
|
|
|
1697
2020
|
if (this.options.closeAfterSelection === true) {
|
|
@@ -1711,20 +2034,29 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1711
2034
|
d.index = i;
|
|
1712
2035
|
}
|
|
1713
2036
|
|
|
2037
|
+
d.currentIndex = i;
|
|
1714
2038
|
return d;
|
|
1715
2039
|
});
|
|
2040
|
+
var headerEl = document.getElementById("".concat(this.elementId, "_header"));
|
|
2041
|
+
|
|
2042
|
+
if (headerEl) {
|
|
2043
|
+
headerEl.classList["".concat(this.options.allowClear === true ? 'add' : 'remove')]('allow-clear');
|
|
2044
|
+
}
|
|
2045
|
+
|
|
1716
2046
|
var el = document.getElementById("".concat(this.elementId, "_items"));
|
|
1717
2047
|
|
|
1718
|
-
if (el
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
this.options.items
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
2048
|
+
if (el) {
|
|
2049
|
+
if (el.childElementCount === 0) {
|
|
2050
|
+
this.render();
|
|
2051
|
+
} else {
|
|
2052
|
+
if (this.options.items.length === 0) {
|
|
2053
|
+
this.options.items = [{
|
|
2054
|
+
label: this.options.noItemsText || 'No Items'
|
|
2055
|
+
}];
|
|
2056
|
+
}
|
|
1726
2057
|
|
|
1727
|
-
|
|
2058
|
+
this.renderItems();
|
|
2059
|
+
}
|
|
1728
2060
|
}
|
|
1729
2061
|
},
|
|
1730
2062
|
get: function get() {
|
|
@@ -2711,21 +3043,37 @@ var WebsyPubSub = /*#__PURE__*/function () {
|
|
|
2711
3043
|
|
|
2712
3044
|
_createClass(WebsyPubSub, [{
|
|
2713
3045
|
key: "publish",
|
|
2714
|
-
value: function publish(method, data) {
|
|
2715
|
-
if (
|
|
2716
|
-
this.subscriptions[method]
|
|
2717
|
-
|
|
2718
|
-
}
|
|
3046
|
+
value: function publish(id, method, data) {
|
|
3047
|
+
if (arguments.length === 3) {
|
|
3048
|
+
if (this.subscriptions[id] && this.subscriptions[id][method]) {
|
|
3049
|
+
this.subscriptions[id][method](data);
|
|
3050
|
+
}
|
|
3051
|
+
} else {
|
|
3052
|
+
if (this.subscriptions[id]) {
|
|
3053
|
+
this.subscriptions[id].forEach(function (fn) {
|
|
3054
|
+
fn(method);
|
|
3055
|
+
});
|
|
3056
|
+
}
|
|
2719
3057
|
}
|
|
2720
3058
|
}
|
|
2721
3059
|
}, {
|
|
2722
3060
|
key: "subscribe",
|
|
2723
|
-
value: function subscribe(method, fn) {
|
|
2724
|
-
if (
|
|
2725
|
-
this.subscriptions[
|
|
2726
|
-
|
|
3061
|
+
value: function subscribe(id, method, fn) {
|
|
3062
|
+
if (arguments.length === 3) {
|
|
3063
|
+
if (!this.subscriptions[id]) {
|
|
3064
|
+
this.subscriptions[id] = {};
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
if (!this.subscriptions[id][method]) {
|
|
3068
|
+
this.subscriptions[id][method] = fn;
|
|
3069
|
+
}
|
|
3070
|
+
} else {
|
|
3071
|
+
if (!this.subscriptions[id]) {
|
|
3072
|
+
this.subscriptions[id] = [];
|
|
3073
|
+
}
|
|
2727
3074
|
|
|
2728
|
-
|
|
3075
|
+
this.subscriptions[id].push(method);
|
|
3076
|
+
}
|
|
2729
3077
|
}
|
|
2730
3078
|
}]);
|
|
2731
3079
|
|
|
@@ -4178,6 +4526,7 @@ var WebsyUtils = {
|
|
|
4178
4526
|
var red = 0;
|
|
4179
4527
|
var green = 0;
|
|
4180
4528
|
var blue = 0;
|
|
4529
|
+
var alpha = 1;
|
|
4181
4530
|
|
|
4182
4531
|
if (backgroundColor.indexOf('#') !== -1) {
|
|
4183
4532
|
// hex color
|
|
@@ -4189,14 +4538,16 @@ var WebsyUtils = {
|
|
|
4189
4538
|
blue = parseInt(colorParts[4] + colorParts[5], 16);
|
|
4190
4539
|
} else if (backgroundColor.toLowerCase().indexOf('rgb') !== -1) {
|
|
4191
4540
|
// rgb color
|
|
4192
|
-
colorParts = backgroundColor.replace(/
|
|
4541
|
+
colorParts = backgroundColor.replace(/rgba\(/gi, '').replace(/\)/gi, '');
|
|
4542
|
+
colorParts = colorParts.replace(/rgb\(/gi, '');
|
|
4193
4543
|
colorParts = colorParts.split(',');
|
|
4194
4544
|
red = colorParts[0];
|
|
4195
4545
|
green = colorParts[1];
|
|
4196
4546
|
blue = colorParts[2];
|
|
4547
|
+
alpha = colorParts[3] || 1;
|
|
4197
4548
|
}
|
|
4198
4549
|
|
|
4199
|
-
return red * 0.299 + green * 0.587 + blue * 0.114 > 186 ? darkColor : lightColor;
|
|
4550
|
+
return (red * 0.299 + green * 0.587 + blue * 0.114) / alpha > 186 ? darkColor : lightColor;
|
|
4200
4551
|
},
|
|
4201
4552
|
measureText: function measureText(text) {
|
|
4202
4553
|
var rotation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
@@ -4668,7 +5019,17 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4668
5019
|
|
|
4669
5020
|
var headHTML = '<tr>' + this.options.columns.map(function (c, i) {
|
|
4670
5021
|
if (c.show !== false) {
|
|
4671
|
-
|
|
5022
|
+
var style = '';
|
|
5023
|
+
|
|
5024
|
+
if (c.style) {
|
|
5025
|
+
style += c.style;
|
|
5026
|
+
}
|
|
5027
|
+
|
|
5028
|
+
if (c.width) {
|
|
5029
|
+
style += "width: ".concat(c.width || 'auto', ";");
|
|
5030
|
+
}
|
|
5031
|
+
|
|
5032
|
+
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-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 ? _this30.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
|
|
4672
5033
|
}
|
|
4673
5034
|
}).join('') + '</tr>';
|
|
4674
5035
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
@@ -5077,7 +5438,11 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5077
5438
|
}, {
|
|
5078
5439
|
key: "hideLoading",
|
|
5079
5440
|
value: function hideLoading() {
|
|
5080
|
-
this.
|
|
5441
|
+
if (this.options.onLoading) {
|
|
5442
|
+
this.options.onLoading(false);
|
|
5443
|
+
} else {
|
|
5444
|
+
this.loadingDialog.hide();
|
|
5445
|
+
}
|
|
5081
5446
|
}
|
|
5082
5447
|
}, {
|
|
5083
5448
|
key: "internalSort",
|
|
@@ -5159,7 +5524,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5159
5524
|
style += "width: ".concat(c.width || 'auto', "; ");
|
|
5160
5525
|
}
|
|
5161
5526
|
|
|
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 ? _this33.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
|
|
5527
|
+
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 ? _this33.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
|
|
5163
5528
|
}
|
|
5164
5529
|
}).join('') + '</tr>';
|
|
5165
5530
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
@@ -5274,7 +5639,11 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5274
5639
|
}, {
|
|
5275
5640
|
key: "showLoading",
|
|
5276
5641
|
value: function showLoading(options) {
|
|
5277
|
-
this.
|
|
5642
|
+
if (this.options.onLoading) {
|
|
5643
|
+
this.options.onLoading(true);
|
|
5644
|
+
} else {
|
|
5645
|
+
this.loadingDialog.show(options);
|
|
5646
|
+
}
|
|
5278
5647
|
}
|
|
5279
5648
|
}, {
|
|
5280
5649
|
key: "getColumnParameters",
|
|
@@ -5335,85 +5704,764 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5335
5704
|
|
|
5336
5705
|
return WebsyTable2;
|
|
5337
5706
|
}();
|
|
5338
|
-
/* global
|
|
5339
|
-
|
|
5707
|
+
/* global WebsyDesigns */
|
|
5340
5708
|
|
|
5341
|
-
var WebsyChart = /*#__PURE__*/function () {
|
|
5342
|
-
function WebsyChart(elementId, options) {
|
|
5343
|
-
var _this35 = this;
|
|
5344
5709
|
|
|
5345
|
-
|
|
5710
|
+
var WebsyTable3 = /*#__PURE__*/function () {
|
|
5711
|
+
function WebsyTable3(elementId, options) {
|
|
5712
|
+
_classCallCheck(this, WebsyTable3);
|
|
5346
5713
|
|
|
5714
|
+
this.elementId = elementId;
|
|
5347
5715
|
var DEFAULTS = {
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
axisLeft: 0,
|
|
5355
|
-
axisRight: 0,
|
|
5356
|
-
axisTop: 0,
|
|
5357
|
-
legendBottom: 0,
|
|
5358
|
-
legendLeft: 0,
|
|
5359
|
-
legendRight: 0,
|
|
5360
|
-
legendTop: 0
|
|
5361
|
-
},
|
|
5362
|
-
axis: {},
|
|
5363
|
-
orientation: 'vertical',
|
|
5364
|
-
colors: ['#5e4fa2', '#3288bd', '#66c2a5', '#abdda4', '#e6f598', '#fee08b', '#fdae61', '#f46d43', '#d53e4f', '#9e0142'],
|
|
5365
|
-
transitionDuration: 650,
|
|
5366
|
-
curveStyle: 'curveLinear',
|
|
5367
|
-
lineWidth: 2,
|
|
5368
|
-
forceZero: true,
|
|
5369
|
-
fontSize: 14,
|
|
5370
|
-
symbolSize: 20,
|
|
5371
|
-
showTrackingLine: true,
|
|
5372
|
-
showTooltip: true,
|
|
5373
|
-
showLegend: false,
|
|
5374
|
-
legendPosition: 'bottom',
|
|
5375
|
-
tooltipWidth: 200
|
|
5716
|
+
virtualScroll: false,
|
|
5717
|
+
showTotalsAbove: true,
|
|
5718
|
+
minHandleSize: 20,
|
|
5719
|
+
maxColWidth: '50%',
|
|
5720
|
+
allowPivoting: false,
|
|
5721
|
+
searchIcon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><title>ionicons-v5-f</title><path d=\"M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z\" style=\"fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px\"/><line x1=\"338.29\" y1=\"338.29\" x2=\"448\" y2=\"448\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px\"/></svg>"
|
|
5376
5722
|
};
|
|
5377
|
-
this.elementId = elementId;
|
|
5378
5723
|
this.options = _extends({}, DEFAULTS, options);
|
|
5379
|
-
this.
|
|
5380
|
-
this.
|
|
5381
|
-
this.
|
|
5382
|
-
this.
|
|
5724
|
+
this.sizes = {};
|
|
5725
|
+
this.scrollDragging = false;
|
|
5726
|
+
this.cellDragging = false;
|
|
5727
|
+
this.vScrollRequired = false;
|
|
5728
|
+
this.hScrollRequired = false;
|
|
5729
|
+
this.pinnedColumns = 0;
|
|
5730
|
+
this.startRow = 0;
|
|
5731
|
+
this.endRow = 0;
|
|
5732
|
+
this.startCol = 0;
|
|
5733
|
+
this.endCol = 0;
|
|
5734
|
+
this.mouseYStart = 0;
|
|
5735
|
+
this.mouseYStart = 0;
|
|
5383
5736
|
|
|
5384
5737
|
if (!elementId) {
|
|
5385
|
-
console.log('No element Id provided for Websy
|
|
5738
|
+
console.log('No element Id provided for Websy Table');
|
|
5386
5739
|
return;
|
|
5387
5740
|
}
|
|
5388
5741
|
|
|
5389
|
-
|
|
5390
|
-
var xAxis = 'bottomAxis';
|
|
5391
|
-
|
|
5392
|
-
if (_this35.options.orientation === 'horizontal') {
|
|
5393
|
-
xAxis = 'leftAxis';
|
|
5394
|
-
}
|
|
5395
|
-
|
|
5396
|
-
var width = _this35[xAxis].step();
|
|
5397
|
-
|
|
5398
|
-
var output;
|
|
5742
|
+
var el = document.getElementById(this.elementId);
|
|
5399
5743
|
|
|
5400
|
-
|
|
5744
|
+
if (el) {
|
|
5745
|
+
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 ");
|
|
5401
5746
|
|
|
5402
|
-
if (
|
|
5403
|
-
|
|
5747
|
+
if (this.options.paging === 'pages') {
|
|
5748
|
+
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 ");
|
|
5404
5749
|
}
|
|
5405
5750
|
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5751
|
+
el.innerHTML = html;
|
|
5752
|
+
el.addEventListener('click', this.handleClick.bind(this));
|
|
5753
|
+
el.addEventListener('mousedown', this.handleMouseDown.bind(this));
|
|
5754
|
+
window.addEventListener('mousemove', this.handleMouseMove.bind(this));
|
|
5755
|
+
window.addEventListener('mouseup', this.handleMouseUp.bind(this));
|
|
5756
|
+
var scrollEl = document.getElementById("".concat(this.elementId, "_tableBody"));
|
|
5409
5757
|
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
break;
|
|
5413
|
-
}
|
|
5758
|
+
if (scrollEl) {
|
|
5759
|
+
scrollEl.addEventListener('wheel', this.handleScrollWheel.bind(this));
|
|
5414
5760
|
}
|
|
5415
5761
|
|
|
5416
|
-
|
|
5762
|
+
this.loadingDialog = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loadingContainer"));
|
|
5763
|
+
this.render(this.options.data);
|
|
5764
|
+
} else {
|
|
5765
|
+
console.error("No element found with ID ".concat(this.elementId));
|
|
5766
|
+
}
|
|
5767
|
+
}
|
|
5768
|
+
|
|
5769
|
+
_createClass(WebsyTable3, [{
|
|
5770
|
+
key: "appendRows",
|
|
5771
|
+
value: function appendRows(data) {
|
|
5772
|
+
this.hideError();
|
|
5773
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody"));
|
|
5774
|
+
|
|
5775
|
+
if (bodyEl) {
|
|
5776
|
+
if (this.options.virtualScroll === true) {
|
|
5777
|
+
bodyEl.innerHTML = this.buildBodyHtml(data, true);
|
|
5778
|
+
} else {
|
|
5779
|
+
bodyEl.innerHTML += this.buildBodyHtml(data, true);
|
|
5780
|
+
}
|
|
5781
|
+
} // this.data = this.data.concat(data)
|
|
5782
|
+
// this.rowCount = this.data.length
|
|
5783
|
+
|
|
5784
|
+
}
|
|
5785
|
+
}, {
|
|
5786
|
+
key: "buildBodyHtml",
|
|
5787
|
+
value: function buildBodyHtml() {
|
|
5788
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
5789
|
+
var useWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
5790
|
+
|
|
5791
|
+
if (data.length === 0) {
|
|
5792
|
+
return '';
|
|
5793
|
+
}
|
|
5794
|
+
|
|
5795
|
+
var bodyHtml = "";
|
|
5796
|
+
var sizingColumns = this.options.columns[this.options.columns.length - 1];
|
|
5797
|
+
|
|
5798
|
+
if (useWidths === true) {
|
|
5799
|
+
bodyHtml += '<colgroup>';
|
|
5800
|
+
bodyHtml += sizingColumns.map(function (c) {
|
|
5801
|
+
return "\n <col\n style='width: ".concat(c.width || c.actualWidth, "px!important'\n ></col>\n ");
|
|
5802
|
+
}).join('');
|
|
5803
|
+
bodyHtml += '</colgroup>';
|
|
5804
|
+
}
|
|
5805
|
+
|
|
5806
|
+
data.forEach(function (row) {
|
|
5807
|
+
bodyHtml += "<tr class=\"websy-table-row\">";
|
|
5808
|
+
row.forEach(function (cell, cellIndex) {
|
|
5809
|
+
var style = '';
|
|
5810
|
+
|
|
5811
|
+
if (cell.style) {
|
|
5812
|
+
style += cell.style;
|
|
5813
|
+
}
|
|
5814
|
+
|
|
5815
|
+
if (cell.backgroundColor) {
|
|
5816
|
+
style += "background-color: ".concat(cell.backgroundColor, "; ");
|
|
5817
|
+
|
|
5818
|
+
if (!cell.color) {
|
|
5819
|
+
style += "color: ".concat(WebsyDesigns.Utils.getLightDark(cell.backgroundColor), "; ");
|
|
5820
|
+
}
|
|
5821
|
+
}
|
|
5822
|
+
|
|
5823
|
+
if (cell.color) {
|
|
5824
|
+
style += "color: ".concat(cell.color, "; ");
|
|
5825
|
+
}
|
|
5826
|
+
|
|
5827
|
+
bodyHtml += "<td \n class='websy-table-cell'\n style='".concat(style, "'\n data-info='").concat(cell.value, "'\n colspan='").concat(cell.colspan || 1, "'\n rowspan='").concat(cell.rowspan || 1, "'\n "); // if (useWidths === true) {
|
|
5828
|
+
// bodyHtml += `
|
|
5829
|
+
// style='width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important'
|
|
5830
|
+
// width='${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}'
|
|
5831
|
+
// `
|
|
5832
|
+
// }
|
|
5833
|
+
|
|
5834
|
+
bodyHtml += "\n >\n ".concat(cell.value, "\n </td>");
|
|
5835
|
+
});
|
|
5836
|
+
bodyHtml += "</tr>";
|
|
5837
|
+
}); // bodyHtml += `</div>`
|
|
5838
|
+
|
|
5839
|
+
return bodyHtml;
|
|
5840
|
+
}
|
|
5841
|
+
}, {
|
|
5842
|
+
key: "buildHeaderHtml",
|
|
5843
|
+
value: function buildHeaderHtml() {
|
|
5844
|
+
var _this35 = this;
|
|
5845
|
+
|
|
5846
|
+
var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
5847
|
+
var headerHtml = '';
|
|
5848
|
+
var sizingColumns = this.options.columns[this.options.columns.length - 1];
|
|
5849
|
+
|
|
5850
|
+
if (useWidths === true) {
|
|
5851
|
+
headerHtml += '<colgroup>';
|
|
5852
|
+
headerHtml += sizingColumns.map(function (c) {
|
|
5853
|
+
return "\n <col\n style='width: ".concat(c.width || c.actualWidth, "px!important'\n ></col>\n ");
|
|
5854
|
+
}).join('');
|
|
5855
|
+
headerHtml += '</colgroup>';
|
|
5856
|
+
}
|
|
5857
|
+
|
|
5858
|
+
this.options.columns.forEach(function (row, rowIndex) {
|
|
5859
|
+
if (useWidths === false && rowIndex !== _this35.options.columns.length - 1) {
|
|
5860
|
+
// if we're calculating the size we only want to render the last row of column headers
|
|
5861
|
+
return;
|
|
5862
|
+
}
|
|
5863
|
+
|
|
5864
|
+
headerHtml += "<tr class=\"websy-table-row websy-table-header-row\">";
|
|
5865
|
+
row.forEach(function (col, colIndex) {
|
|
5866
|
+
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) {
|
|
5867
|
+
// headerHtml += `
|
|
5868
|
+
// style='width: ${col.width || col.actualWidth}px'
|
|
5869
|
+
// width='${col.width || col.actualWidth}'
|
|
5870
|
+
// `
|
|
5871
|
+
// }
|
|
5872
|
+
|
|
5873
|
+
headerHtml += " \n >\n <div>\n ".concat(col.name, "\n ").concat(col.searchable === true ? _this35.buildSearchIcon(col, colIndex) : '', "\n </div>\n </td>");
|
|
5874
|
+
});
|
|
5875
|
+
headerHtml += "</tr>";
|
|
5876
|
+
});
|
|
5877
|
+
var dropdownEl = document.getElementById("".concat(this.elementId, "_dropdownContainer"));
|
|
5878
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (c, i) {
|
|
5879
|
+
if (c.searchable && c.isExternalSearch === true) {
|
|
5880
|
+
var testEl = document.getElementById("".concat(_this35.elementId, "_columnSearch_").concat(c.dimId || i));
|
|
5881
|
+
|
|
5882
|
+
if (!testEl) {
|
|
5883
|
+
var newE = document.createElement('div');
|
|
5884
|
+
newE.id = "".concat(_this35.elementId, "_columnSearch_").concat(c.dimId || i);
|
|
5885
|
+
newE.className = 'websy-modal-dropdown';
|
|
5886
|
+
dropdownEl.appendChild(newE);
|
|
5887
|
+
}
|
|
5888
|
+
}
|
|
5889
|
+
});
|
|
5890
|
+
return headerHtml;
|
|
5891
|
+
}
|
|
5892
|
+
}, {
|
|
5893
|
+
key: "buildSearchIcon",
|
|
5894
|
+
value: function buildSearchIcon(col, index) {
|
|
5895
|
+
return "\n <div class=\"websy-table-search-icon\" data-col-id=\"".concat(col.dimId, "\" data-col-index=\"").concat(index, "\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><title>ionicons-v5-f</title><path d=\"M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z\" style=\"fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px\"/><line x1=\"338.29\" y1=\"338.29\" x2=\"448\" y2=\"448\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px\"/></svg>\n </div>\n ");
|
|
5896
|
+
}
|
|
5897
|
+
}, {
|
|
5898
|
+
key: "buildTotalHtml",
|
|
5899
|
+
value: function buildTotalHtml() {
|
|
5900
|
+
var _this36 = this;
|
|
5901
|
+
|
|
5902
|
+
var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
5903
|
+
|
|
5904
|
+
if (!this.options.totals) {
|
|
5905
|
+
return '';
|
|
5906
|
+
}
|
|
5907
|
+
|
|
5908
|
+
var totalHtml = "<tr class=\"websy-table-row websy-table-total-row\">";
|
|
5909
|
+
this.options.totals.forEach(function (col, colIndex) {
|
|
5910
|
+
totalHtml += "<td \n class='websy-table-cell'\n colspan='".concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n ");
|
|
5911
|
+
|
|
5912
|
+
if (useWidths === true) {
|
|
5913
|
+
totalHtml += "\n style='width: ".concat(_this36.options.columns[_this36.options.columns.length - 1][colIndex].width || _this36.options.columns[_this36.options.columns.length - 1][colIndex].actualWidth, "px'\n width='").concat(col.width || col.actualWidth, "'\n ");
|
|
5914
|
+
}
|
|
5915
|
+
|
|
5916
|
+
totalHtml += " \n >\n ".concat(col.value, "\n </td>");
|
|
5917
|
+
});
|
|
5918
|
+
totalHtml += "</tr>";
|
|
5919
|
+
return totalHtml;
|
|
5920
|
+
}
|
|
5921
|
+
}, {
|
|
5922
|
+
key: "calculateSizes",
|
|
5923
|
+
value: function calculateSizes() {
|
|
5924
|
+
var _this37 = this;
|
|
5925
|
+
|
|
5926
|
+
var sample = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
5927
|
+
var totalRowCount = arguments.length > 1 ? arguments[1] : undefined;
|
|
5928
|
+
var totalColumnCount = arguments.length > 2 ? arguments[2] : undefined;
|
|
5929
|
+
var pinnedColumns = arguments.length > 3 ? arguments[3] : undefined;
|
|
5930
|
+
this.totalRowCount = totalRowCount; // probably need some error handling here if no value is passed in
|
|
5931
|
+
|
|
5932
|
+
this.totalColumnCount = totalColumnCount; // probably need some error handling here if no value is passed in
|
|
5933
|
+
|
|
5934
|
+
this.pinnedColumns = pinnedColumns; // probably need some error handling here if no value is passed in
|
|
5935
|
+
|
|
5936
|
+
var outerEl = document.getElementById(this.elementId);
|
|
5937
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
5938
|
+
var headEl = document.getElementById("".concat(this.elementId, "_tableHeader"));
|
|
5939
|
+
headEl.style.width = 'auto';
|
|
5940
|
+
headEl.innerHTML = this.buildHeaderHtml();
|
|
5941
|
+
this.sizes.outer = outerEl.getBoundingClientRect();
|
|
5942
|
+
this.sizes.table = tableEl.getBoundingClientRect();
|
|
5943
|
+
this.sizes.header = headEl.getBoundingClientRect();
|
|
5944
|
+
var maxWidth;
|
|
5945
|
+
|
|
5946
|
+
if (typeof this.options.maxColWidth === 'number') {
|
|
5947
|
+
maxWidth = this.options.maxColWidth;
|
|
5948
|
+
} else if (this.options.maxColWidth.indexOf('%') !== -1) {
|
|
5949
|
+
maxWidth = this.sizes.outer.width * (+this.options.maxColWidth.replace('%', '') / 100);
|
|
5950
|
+
} else if (this.options.maxColWidth.indexOf('px') !== -1) {
|
|
5951
|
+
maxWidth = +this.options.maxColWidth.replace('px', '');
|
|
5952
|
+
}
|
|
5953
|
+
|
|
5954
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody"));
|
|
5955
|
+
bodyEl.style.width = 'auto';
|
|
5956
|
+
bodyEl.innerHTML = this.buildBodyHtml([sample]);
|
|
5957
|
+
var footerEl = document.getElementById("".concat(this.elementId, "_tableFooter"));
|
|
5958
|
+
footerEl.innerHTML = this.buildTotalHtml();
|
|
5959
|
+
this.sizes.total = footerEl.getBoundingClientRect();
|
|
5960
|
+
var rows = Array.from(tableEl.querySelectorAll('.websy-table-row'));
|
|
5961
|
+
var totalWidth = 0;
|
|
5962
|
+
this.sizes.scrollableWidth = this.sizes.outer.width;
|
|
5963
|
+
rows.forEach(function (row, rowIndex) {
|
|
5964
|
+
Array.from(row.children).forEach(function (col, colIndex) {
|
|
5965
|
+
var colSize = col.getBoundingClientRect();
|
|
5966
|
+
_this37.sizes.cellHeight = colSize.height;
|
|
5967
|
+
|
|
5968
|
+
if (_this37.options.columns[_this37.options.columns.length - 1][colIndex]) {
|
|
5969
|
+
if (!_this37.options.columns[_this37.options.columns.length - 1][colIndex].actualWidth) {
|
|
5970
|
+
_this37.options.columns[_this37.options.columns.length - 1][colIndex].actualWidth = 0;
|
|
5971
|
+
}
|
|
5972
|
+
|
|
5973
|
+
_this37.options.columns[_this37.options.columns.length - 1][colIndex].actualWidth = Math.min(Math.max(_this37.options.columns[_this37.options.columns.length - 1][colIndex].actualWidth, colSize.width), maxWidth);
|
|
5974
|
+
_this37.options.columns[_this37.options.columns.length - 1][colIndex].cellHeight = colSize.height;
|
|
5975
|
+
}
|
|
5976
|
+
});
|
|
5977
|
+
});
|
|
5978
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
|
|
5979
|
+
if (colIndex < _this37.pinnedColumns) {
|
|
5980
|
+
_this37.sizes.scrollableWidth -= col.actualWidth;
|
|
5981
|
+
}
|
|
5982
|
+
});
|
|
5983
|
+
this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce(function (a, b) {
|
|
5984
|
+
return a + (b.width || b.actualWidth);
|
|
5985
|
+
}, 0);
|
|
5986
|
+
var outerSize = outerEl.getBoundingClientRect();
|
|
5987
|
+
|
|
5988
|
+
if (this.sizes.totalWidth < outerSize.width) {
|
|
5989
|
+
this.sizes.totalWidth = 0;
|
|
5990
|
+
var equalWidth = outerSize.width / this.options.columns[this.options.columns.length - 1].length;
|
|
5991
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (c, i) {
|
|
5992
|
+
if (!c.width) {
|
|
5993
|
+
if (c.actualWidth < equalWidth) {
|
|
5994
|
+
// adjust the width
|
|
5995
|
+
c.actualWidth = equalWidth;
|
|
5996
|
+
}
|
|
5997
|
+
}
|
|
5998
|
+
|
|
5999
|
+
_this37.sizes.totalWidth += c.width || c.actualWidth;
|
|
6000
|
+
equalWidth = (outerSize.width - _this37.sizes.totalWidth) / (_this37.options.columns[_this37.options.columns.length - 1].length - (i + 1));
|
|
6001
|
+
});
|
|
6002
|
+
} // take the height of the last cell as the official height for data cells
|
|
6003
|
+
// this.sizes.dataCellHeight = this.options.columns[this.options.columns.length - 1].cellHeight
|
|
6004
|
+
|
|
6005
|
+
|
|
6006
|
+
headEl.innerHTML = '';
|
|
6007
|
+
bodyEl.innerHTML = '';
|
|
6008
|
+
footerEl.innerHTML = '';
|
|
6009
|
+
headEl.style.width = 'initial';
|
|
6010
|
+
bodyEl.style.width = 'initial';
|
|
6011
|
+
this.sizes.bodyHeight = this.sizes.table.height - (this.sizes.header.height + this.sizes.total.height);
|
|
6012
|
+
this.sizes.rowsToRender = Math.ceil(this.sizes.bodyHeight / this.sizes.cellHeight);
|
|
6013
|
+
this.sizes.rowsToRenderPrecise = this.sizes.bodyHeight / this.sizes.cellHeight;
|
|
6014
|
+
this.startRow = 0;
|
|
6015
|
+
this.endRow = this.sizes.rowsToRender;
|
|
6016
|
+
this.startCol = 0;
|
|
6017
|
+
this.endCol = this.options.columns[this.options.columns.length - 1].length;
|
|
6018
|
+
|
|
6019
|
+
if (this.sizes.rowsToRender < this.totalRowCount) {
|
|
6020
|
+
this.vScrollRequired = true;
|
|
6021
|
+
}
|
|
6022
|
+
|
|
6023
|
+
if (this.sizes.totalWidth > this.sizes.outer.width) {
|
|
6024
|
+
this.hScrollRequired = true;
|
|
6025
|
+
}
|
|
6026
|
+
|
|
6027
|
+
this.options.allColumns = this.options.columns.map(function (c) {
|
|
6028
|
+
return c;
|
|
6029
|
+
});
|
|
6030
|
+
console.log('sizes', this.sizes);
|
|
6031
|
+
return this.sizes;
|
|
6032
|
+
}
|
|
6033
|
+
}, {
|
|
6034
|
+
key: "createSample",
|
|
6035
|
+
value: function createSample(data) {
|
|
6036
|
+
var output = [];
|
|
6037
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
|
|
6038
|
+
if (col.maxLength) {
|
|
6039
|
+
output.push({
|
|
6040
|
+
value: new Array(col.maxLength).fill('W').join('')
|
|
6041
|
+
});
|
|
6042
|
+
} else if (data) {
|
|
6043
|
+
var longest = '';
|
|
6044
|
+
|
|
6045
|
+
for (var i = 0; i < Math.min(data.length, 1000); i++) {
|
|
6046
|
+
if (longest.length < data[i][colIndex].value.length) {
|
|
6047
|
+
longest = data[i][colIndex].value;
|
|
6048
|
+
}
|
|
6049
|
+
}
|
|
6050
|
+
|
|
6051
|
+
output.push({
|
|
6052
|
+
value: longest
|
|
6053
|
+
});
|
|
6054
|
+
} else {
|
|
6055
|
+
output.push({
|
|
6056
|
+
value: ''
|
|
6057
|
+
});
|
|
6058
|
+
}
|
|
6059
|
+
});
|
|
6060
|
+
return output;
|
|
6061
|
+
}
|
|
6062
|
+
}, {
|
|
6063
|
+
key: "handleClick",
|
|
6064
|
+
value: function handleClick(event) {
|
|
6065
|
+
if (event.target.classList.contains('websy-table-search-icon')) {
|
|
6066
|
+
console.log('clicked on search icon');
|
|
6067
|
+
var colIndex = +event.target.getAttribute('data-col-index');
|
|
6068
|
+
|
|
6069
|
+
if (this.options.columns[this.options.columns.length - 1][colIndex].onSearch) {
|
|
6070
|
+
this.options.columns[this.options.columns.length - 1][colIndex].onSearch(event, this.options.columns[this.options.columns.length - 1][colIndex]);
|
|
6071
|
+
}
|
|
6072
|
+
}
|
|
6073
|
+
}
|
|
6074
|
+
}, {
|
|
6075
|
+
key: "handleMouseDown",
|
|
6076
|
+
value: function handleMouseDown(event) {
|
|
6077
|
+
if (event.target.classList.contains('websy-scroll-handle-y')) {
|
|
6078
|
+
// set up the scroll start values
|
|
6079
|
+
this.scrollDragging = true;
|
|
6080
|
+
this.scrollDirection = 'y';
|
|
6081
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
6082
|
+
this.handleYStart = scrollHandleEl.offsetTop;
|
|
6083
|
+
this.mouseYStart = event.pageY;
|
|
6084
|
+
console.log('mouse down', this.handleYStart, this.mouseYStart);
|
|
6085
|
+
console.log(scrollHandleEl.offsetTop);
|
|
6086
|
+
} else if (event.target.classList.contains('websy-scroll-handle-x')) {
|
|
6087
|
+
this.scrollDragging = true;
|
|
6088
|
+
this.scrollDirection = 'x';
|
|
6089
|
+
|
|
6090
|
+
var _scrollHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
6091
|
+
|
|
6092
|
+
this.handleXStart = _scrollHandleEl.offsetLeft;
|
|
6093
|
+
this.mouseXStart = event.pageX;
|
|
6094
|
+
}
|
|
6095
|
+
}
|
|
6096
|
+
}, {
|
|
6097
|
+
key: "handleMouseMove",
|
|
6098
|
+
value: function handleMouseMove(event) {
|
|
6099
|
+
// event.preventDefault()
|
|
6100
|
+
if (this.scrollDragging === true) {
|
|
6101
|
+
if (this.scrollDirection === 'y') {
|
|
6102
|
+
var diff = event.pageY - this.mouseYStart;
|
|
6103
|
+
this.scrollY(diff);
|
|
6104
|
+
} else if (this.scrollDirection === 'x') {
|
|
6105
|
+
var _diff = event.pageX - this.mouseXStart;
|
|
6106
|
+
|
|
6107
|
+
this.scrollX(_diff);
|
|
6108
|
+
}
|
|
6109
|
+
}
|
|
6110
|
+
}
|
|
6111
|
+
}, {
|
|
6112
|
+
key: "handleMouseUp",
|
|
6113
|
+
value: function handleMouseUp(event) {
|
|
6114
|
+
this.scrollDragging = false;
|
|
6115
|
+
this.cellDragging = false;
|
|
6116
|
+
this.handleYStart = null;
|
|
6117
|
+
this.mouseYStart = null;
|
|
6118
|
+
this.handleXStart = null;
|
|
6119
|
+
this.mouseXStart = null;
|
|
6120
|
+
}
|
|
6121
|
+
}, {
|
|
6122
|
+
key: "handleScrollWheel",
|
|
6123
|
+
value: function handleScrollWheel(event) {
|
|
6124
|
+
event.preventDefault();
|
|
6125
|
+
console.log('scrollwheel', event);
|
|
6126
|
+
|
|
6127
|
+
if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
|
|
6128
|
+
this.scrollX(Math.max(-5, Math.min(5, event.deltaX)));
|
|
6129
|
+
} else {
|
|
6130
|
+
this.scrollY(Math.max(-5, Math.min(5, event.deltaY)));
|
|
6131
|
+
}
|
|
6132
|
+
}
|
|
6133
|
+
}, {
|
|
6134
|
+
key: "hideError",
|
|
6135
|
+
value: function hideError() {
|
|
6136
|
+
var el = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
6137
|
+
|
|
6138
|
+
if (el) {
|
|
6139
|
+
el.classList.remove('has-error');
|
|
6140
|
+
}
|
|
6141
|
+
|
|
6142
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_tableInner"));
|
|
6143
|
+
tableEl.classList.remove('hidden');
|
|
6144
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
6145
|
+
|
|
6146
|
+
if (containerEl) {
|
|
6147
|
+
containerEl.classList.remove('active');
|
|
6148
|
+
}
|
|
6149
|
+
}
|
|
6150
|
+
}, {
|
|
6151
|
+
key: "hideLoading",
|
|
6152
|
+
value: function hideLoading() {
|
|
6153
|
+
this.loadingDialog.hide();
|
|
6154
|
+
}
|
|
6155
|
+
}, {
|
|
6156
|
+
key: "render",
|
|
6157
|
+
value: function render(data) {
|
|
6158
|
+
var calcSizes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
6159
|
+
|
|
6160
|
+
if (!this.options.columns) {
|
|
6161
|
+
console.log("No columns provided for table with ID ".concat(this.elementId));
|
|
6162
|
+
return;
|
|
6163
|
+
}
|
|
6164
|
+
|
|
6165
|
+
if (this.options.columns.length === 0) {
|
|
6166
|
+
console.log("No columns provided for table with ID ".concat(this.elementId));
|
|
6167
|
+
return;
|
|
6168
|
+
} // this.data = []
|
|
6169
|
+
// Adjust the sizing of the header/body/footer
|
|
6170
|
+
|
|
6171
|
+
|
|
6172
|
+
if (calcSizes === true) {
|
|
6173
|
+
var sample = this.createSample(data);
|
|
6174
|
+
this.calculateSizes(sample, data.length, (data[0] || []).length, 0);
|
|
6175
|
+
}
|
|
6176
|
+
|
|
6177
|
+
console.log(this.options.columns);
|
|
6178
|
+
var tableInnerEl = document.getElementById("".concat(this.elementId, "_tableInner"));
|
|
6179
|
+
|
|
6180
|
+
if (tableInnerEl) {
|
|
6181
|
+
tableInnerEl.style.width = "".concat(this.sizes.totalWidth, "px");
|
|
6182
|
+
}
|
|
6183
|
+
|
|
6184
|
+
this.renderColumnHeaders();
|
|
6185
|
+
this.renderTotals();
|
|
6186
|
+
|
|
6187
|
+
if (data) {
|
|
6188
|
+
this.appendRows(data);
|
|
6189
|
+
}
|
|
6190
|
+
|
|
6191
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody")); // bodyEl.innerHTML = this.buildBodyHtml(data, true)
|
|
6192
|
+
|
|
6193
|
+
bodyEl.style.height = "calc(100% - ".concat(this.sizes.header.height, "px - ").concat(this.sizes.total.height, "px)");
|
|
6194
|
+
|
|
6195
|
+
if (this.options.virtualScroll === true) {
|
|
6196
|
+
// set the scroll element positions
|
|
6197
|
+
var vScrollEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
|
|
6198
|
+
var vHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
6199
|
+
|
|
6200
|
+
if (this.vScrollRequired === true) {
|
|
6201
|
+
vScrollEl.style.top = "".concat(this.sizes.header.height + this.sizes.total.height, "px");
|
|
6202
|
+
vScrollEl.style.height = "".concat(this.sizes.bodyHeight, "px");
|
|
6203
|
+
vHandleEl.style.height = Math.max(this.options.minHandleSize, this.sizes.bodyHeight * (this.sizes.rowsToRenderPrecise / this.totalRowCount)) + 'px';
|
|
6204
|
+
} else {
|
|
6205
|
+
vHandleEl.style.height = '0px';
|
|
6206
|
+
}
|
|
6207
|
+
|
|
6208
|
+
var hScrollEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
|
|
6209
|
+
var hHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
6210
|
+
|
|
6211
|
+
if (this.hScrollRequired === true) {
|
|
6212
|
+
hScrollEl.style.left = "".concat(this.sizes.table.width - this.sizes.scrollableWidth, "px");
|
|
6213
|
+
hScrollEl.style.width = "".concat(this.sizes.scrollableWidth - 20, "px");
|
|
6214
|
+
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalWidth)) + 'px';
|
|
6215
|
+
} else {
|
|
6216
|
+
hHandleEl.style.height = '0px';
|
|
6217
|
+
}
|
|
6218
|
+
}
|
|
6219
|
+
}
|
|
6220
|
+
}, {
|
|
6221
|
+
key: "renderColumnHeaders",
|
|
6222
|
+
value: function renderColumnHeaders() {
|
|
6223
|
+
var headEl = document.getElementById("".concat(this.elementId, "_tableHeader"));
|
|
6224
|
+
|
|
6225
|
+
if (headEl) {
|
|
6226
|
+
headEl.innerHTML = this.buildHeaderHtml(true);
|
|
6227
|
+
}
|
|
6228
|
+
}
|
|
6229
|
+
}, {
|
|
6230
|
+
key: "renderTotals",
|
|
6231
|
+
value: function renderTotals() {
|
|
6232
|
+
var headEl = document.getElementById("".concat(this.elementId, "_tableHeader"));
|
|
6233
|
+
var totalHtml = this.buildTotalHtml(true);
|
|
6234
|
+
|
|
6235
|
+
if (this.options.showTotalsAbove === true) {
|
|
6236
|
+
headEl.innerHTML += totalHtml;
|
|
6237
|
+
} else {
|
|
6238
|
+
var footerEl = document.getElementById("".concat(this.elementId, "_tableFooter"));
|
|
6239
|
+
|
|
6240
|
+
if (footerEl) {
|
|
6241
|
+
footerEl.innerHTML = totalHtml;
|
|
6242
|
+
}
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6245
|
+
}, {
|
|
6246
|
+
key: "resize",
|
|
6247
|
+
value: function resize() {}
|
|
6248
|
+
}, {
|
|
6249
|
+
key: "showError",
|
|
6250
|
+
value: function showError(options) {
|
|
6251
|
+
var el = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
6252
|
+
|
|
6253
|
+
if (el) {
|
|
6254
|
+
el.classList.add('has-error');
|
|
6255
|
+
}
|
|
6256
|
+
|
|
6257
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_tableInner"));
|
|
6258
|
+
tableEl.classList.add('hidden');
|
|
6259
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
6260
|
+
|
|
6261
|
+
if (containerEl) {
|
|
6262
|
+
containerEl.classList.add('active');
|
|
6263
|
+
}
|
|
6264
|
+
|
|
6265
|
+
if (options.title) {
|
|
6266
|
+
var titleEl = document.getElementById("".concat(this.elementId, "_errorTitle"));
|
|
6267
|
+
|
|
6268
|
+
if (titleEl) {
|
|
6269
|
+
titleEl.innerHTML = options.title;
|
|
6270
|
+
}
|
|
6271
|
+
}
|
|
6272
|
+
|
|
6273
|
+
if (options.message) {
|
|
6274
|
+
var messageEl = document.getElementById("".concat(this.elementId, "_errorMessage"));
|
|
6275
|
+
|
|
6276
|
+
if (messageEl) {
|
|
6277
|
+
messageEl.innerHTML = options.message;
|
|
6278
|
+
}
|
|
6279
|
+
}
|
|
6280
|
+
}
|
|
6281
|
+
}, {
|
|
6282
|
+
key: "scrollX",
|
|
6283
|
+
value: function scrollX(diff) {
|
|
6284
|
+
var scrollContainerEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
|
|
6285
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
6286
|
+
var handlePos;
|
|
6287
|
+
|
|
6288
|
+
if (typeof this.handleXStart !== 'undefined' && this.handleXStart !== null) {
|
|
6289
|
+
handlePos = this.handleXStart + diff;
|
|
6290
|
+
} else {
|
|
6291
|
+
handlePos = scrollHandleEl.offsetLeft + diff;
|
|
6292
|
+
}
|
|
6293
|
+
|
|
6294
|
+
var scrollableSpace = scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width;
|
|
6295
|
+
console.log('dragging x', diff, scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width);
|
|
6296
|
+
scrollHandleEl.style.left = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px';
|
|
6297
|
+
|
|
6298
|
+
if (this.options.onScroll) {
|
|
6299
|
+
var actualLeft = (this.sizes.totalWidth - this.sizes.scrollableWidth) * (Math.min(scrollableSpace, Math.max(0, handlePos)) / scrollableSpace);
|
|
6300
|
+
var cumulativeWidth = 0;
|
|
6301
|
+
this.startCol = 0;
|
|
6302
|
+
this.endCol = 0;
|
|
6303
|
+
|
|
6304
|
+
for (var i = 0; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
6305
|
+
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth;
|
|
6306
|
+
console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth);
|
|
6307
|
+
|
|
6308
|
+
if (actualLeft < cumulativeWidth) {
|
|
6309
|
+
this.startCol = i;
|
|
6310
|
+
break;
|
|
6311
|
+
}
|
|
6312
|
+
}
|
|
6313
|
+
|
|
6314
|
+
cumulativeWidth = 0;
|
|
6315
|
+
|
|
6316
|
+
for (var _i10 = this.startCol; _i10 < this.options.allColumns[this.options.allColumns.length - 1].length; _i10++) {
|
|
6317
|
+
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][_i10].actualWidth;
|
|
6318
|
+
|
|
6319
|
+
if (cumulativeWidth < this.sizes.scrollableWidth) {
|
|
6320
|
+
this.endCol = _i10;
|
|
6321
|
+
}
|
|
6322
|
+
}
|
|
6323
|
+
|
|
6324
|
+
if (this.endCol < this.options.allColumns[this.options.allColumns.length - 1].length - 1) {
|
|
6325
|
+
this.endCol += 1;
|
|
6326
|
+
}
|
|
6327
|
+
|
|
6328
|
+
if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.totalWidth) {
|
|
6329
|
+
this.startCol += 1;
|
|
6330
|
+
}
|
|
6331
|
+
|
|
6332
|
+
this.endCol = Math.max(this.startCol, this.endCol);
|
|
6333
|
+
this.options.onScroll('y', this.startRow, this.endRow, this.startCol, this.endCol);
|
|
6334
|
+
}
|
|
6335
|
+
}
|
|
6336
|
+
}, {
|
|
6337
|
+
key: "scrollY",
|
|
6338
|
+
value: function scrollY(diff) {
|
|
6339
|
+
var scrollContainerEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
|
|
6340
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
6341
|
+
var handlePos;
|
|
6342
|
+
|
|
6343
|
+
if (typeof this.handleYStart !== 'undefined' && this.handleYStart !== null) {
|
|
6344
|
+
handlePos = this.handleYStart + diff;
|
|
6345
|
+
} else {
|
|
6346
|
+
console.log('appending not resetting');
|
|
6347
|
+
handlePos = scrollHandleEl.offsetTop + diff;
|
|
6348
|
+
}
|
|
6349
|
+
|
|
6350
|
+
var scrollableSpace = scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height;
|
|
6351
|
+
console.log('dragging y', diff, scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height);
|
|
6352
|
+
scrollHandleEl.style.top = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px';
|
|
6353
|
+
|
|
6354
|
+
if (this.options.onScroll) {
|
|
6355
|
+
this.startRow = Math.min(this.totalRowCount - this.sizes.rowsToRender, Math.max(0, Math.round((this.totalRowCount - this.sizes.rowsToRender) * (handlePos / scrollableSpace))));
|
|
6356
|
+
this.endRow = this.startRow + this.sizes.rowsToRender;
|
|
6357
|
+
|
|
6358
|
+
if (this.endRow === this.totalRowCount) {
|
|
6359
|
+
this.startRow += 1;
|
|
6360
|
+
}
|
|
6361
|
+
|
|
6362
|
+
this.options.onScroll('y', this.startRow, this.endRow, this.startCol, this.endCol);
|
|
6363
|
+
}
|
|
6364
|
+
}
|
|
6365
|
+
}, {
|
|
6366
|
+
key: "showLoading",
|
|
6367
|
+
value: function showLoading(options) {
|
|
6368
|
+
this.loadingDialog.show(options);
|
|
6369
|
+
}
|
|
6370
|
+
}, {
|
|
6371
|
+
key: "columns",
|
|
6372
|
+
set: function set(columns) {
|
|
6373
|
+
this.options.columns = columns;
|
|
6374
|
+
this.renderColumnHeaders();
|
|
6375
|
+
}
|
|
6376
|
+
}, {
|
|
6377
|
+
key: "totals",
|
|
6378
|
+
set: function set(totals) {
|
|
6379
|
+
this.options.totals = totals;
|
|
6380
|
+
this.renderTotals();
|
|
6381
|
+
}
|
|
6382
|
+
}]);
|
|
6383
|
+
|
|
6384
|
+
return WebsyTable3;
|
|
6385
|
+
}();
|
|
6386
|
+
/* global d3 include WebsyDesigns */
|
|
6387
|
+
|
|
6388
|
+
|
|
6389
|
+
var WebsyChart = /*#__PURE__*/function () {
|
|
6390
|
+
function WebsyChart(elementId, options) {
|
|
6391
|
+
var _this38 = this;
|
|
6392
|
+
|
|
6393
|
+
_classCallCheck(this, WebsyChart);
|
|
6394
|
+
|
|
6395
|
+
var DEFAULTS = {
|
|
6396
|
+
margin: {
|
|
6397
|
+
top: 10,
|
|
6398
|
+
left: 3,
|
|
6399
|
+
bottom: 3,
|
|
6400
|
+
right: 3,
|
|
6401
|
+
axisBottom: 0,
|
|
6402
|
+
axisLeft: 0,
|
|
6403
|
+
axisRight: 0,
|
|
6404
|
+
axisTop: 0,
|
|
6405
|
+
legendBottom: 0,
|
|
6406
|
+
legendLeft: 0,
|
|
6407
|
+
legendRight: 0,
|
|
6408
|
+
legendTop: 0
|
|
6409
|
+
},
|
|
6410
|
+
axis: {},
|
|
6411
|
+
orientation: 'vertical',
|
|
6412
|
+
colors: ['#5e4fa2', '#3288bd', '#66c2a5', '#abdda4', '#e6f598', '#fee08b', '#fdae61', '#f46d43', '#d53e4f', '#9e0142'],
|
|
6413
|
+
transitionDuration: 650,
|
|
6414
|
+
curveStyle: 'curveLinear',
|
|
6415
|
+
lineWidth: 2,
|
|
6416
|
+
forceZero: true,
|
|
6417
|
+
fontSize: 14,
|
|
6418
|
+
symbolSize: 20,
|
|
6419
|
+
showTrackingLine: true,
|
|
6420
|
+
showTooltip: true,
|
|
6421
|
+
showLegend: false,
|
|
6422
|
+
legendPosition: 'bottom',
|
|
6423
|
+
tooltipWidth: 200
|
|
6424
|
+
};
|
|
6425
|
+
this.elementId = elementId;
|
|
6426
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
6427
|
+
this.leftAxis = null;
|
|
6428
|
+
this.rightAxis = null;
|
|
6429
|
+
this.topAxis = null;
|
|
6430
|
+
this.bottomAxis = null;
|
|
6431
|
+
|
|
6432
|
+
if (!elementId) {
|
|
6433
|
+
console.log('No element Id provided for Websy Chart');
|
|
6434
|
+
return;
|
|
6435
|
+
}
|
|
6436
|
+
|
|
6437
|
+
this.invertOverride = function (input, input2) {
|
|
6438
|
+
var xAxis = 'bottomAxis';
|
|
6439
|
+
|
|
6440
|
+
if (_this38.options.orientation === 'horizontal') {
|
|
6441
|
+
xAxis = 'leftAxis';
|
|
6442
|
+
}
|
|
6443
|
+
|
|
6444
|
+
var width = _this38[xAxis].step();
|
|
6445
|
+
|
|
6446
|
+
var output;
|
|
6447
|
+
|
|
6448
|
+
var domain = _toConsumableArray(_this38[xAxis].domain());
|
|
6449
|
+
|
|
6450
|
+
if (_this38.options.orientation === 'horizontal') {
|
|
6451
|
+
domain = domain.reverse();
|
|
6452
|
+
}
|
|
6453
|
+
|
|
6454
|
+
for (var j = 0; j < domain.length; j++) {
|
|
6455
|
+
var breakA = _this38[xAxis](domain[j]) - width / 2;
|
|
6456
|
+
var breakB = breakA + width;
|
|
6457
|
+
|
|
6458
|
+
if (input > breakA && input <= breakB) {
|
|
6459
|
+
output = j;
|
|
6460
|
+
break;
|
|
6461
|
+
}
|
|
6462
|
+
}
|
|
6463
|
+
|
|
6464
|
+
return output;
|
|
5417
6465
|
};
|
|
5418
6466
|
|
|
5419
6467
|
var el = document.getElementById(this.elementId);
|
|
@@ -5504,10 +6552,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5504
6552
|
}, {
|
|
5505
6553
|
key: "handleEventMouseMove",
|
|
5506
6554
|
value: function handleEventMouseMove(event, d) {
|
|
5507
|
-
var
|
|
6555
|
+
var _this39 = this;
|
|
5508
6556
|
|
|
5509
6557
|
var bisectDate = d3.bisector(function (d) {
|
|
5510
|
-
return
|
|
6558
|
+
return _this39.parseX(d.x.value);
|
|
5511
6559
|
}).left;
|
|
5512
6560
|
|
|
5513
6561
|
if (this.options.showTrackingLine === true && d3.pointer(event)) {
|
|
@@ -5546,8 +6594,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5546
6594
|
}
|
|
5547
6595
|
|
|
5548
6596
|
this.options.data.series.forEach(function (s) {
|
|
5549
|
-
if (
|
|
5550
|
-
xPoint =
|
|
6597
|
+
if (_this39.options.data[xData].scale !== 'Time') {
|
|
6598
|
+
xPoint = _this39[xAxis](_this39.parseX(xLabel));
|
|
5551
6599
|
s.data.forEach(function (d) {
|
|
5552
6600
|
if (d.x.value === xLabel) {
|
|
5553
6601
|
if (!tooltipTitle) {
|
|
@@ -5566,13 +6614,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5566
6614
|
var pointA = s.data[index - 1];
|
|
5567
6615
|
var pointB = s.data[index];
|
|
5568
6616
|
|
|
5569
|
-
if (
|
|
6617
|
+
if (_this39.options.orientation === 'horizontal') {
|
|
5570
6618
|
pointA = _toConsumableArray(s.data).reverse()[index - 1];
|
|
5571
6619
|
pointB = _toConsumableArray(s.data).reverse()[index];
|
|
5572
6620
|
}
|
|
5573
6621
|
|
|
5574
6622
|
if (pointA && !pointB) {
|
|
5575
|
-
xPoint =
|
|
6623
|
+
xPoint = _this39[xAxis](_this39.parseX(pointA.x.value));
|
|
5576
6624
|
tooltipTitle = pointA.x.value;
|
|
5577
6625
|
|
|
5578
6626
|
if (!pointA.y.color) {
|
|
@@ -5582,12 +6630,12 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5582
6630
|
tooltipData.push(pointA.y);
|
|
5583
6631
|
|
|
5584
6632
|
if (typeof pointA.x.value.getTime !== 'undefined') {
|
|
5585
|
-
tooltipTitle = d3.timeFormat(
|
|
6633
|
+
tooltipTitle = d3.timeFormat(_this39.options.dateFormat || _this39.options.calculatedTimeFormatPattern)(pointA.x.value);
|
|
5586
6634
|
}
|
|
5587
6635
|
}
|
|
5588
6636
|
|
|
5589
6637
|
if (pointB && !pointA) {
|
|
5590
|
-
xPoint =
|
|
6638
|
+
xPoint = _this39[xAxis](_this39.parseX(pointB.x.value));
|
|
5591
6639
|
tooltipTitle = pointB.x.value;
|
|
5592
6640
|
|
|
5593
6641
|
if (!pointB.y.color) {
|
|
@@ -5597,14 +6645,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5597
6645
|
tooltipData.push(pointB.y);
|
|
5598
6646
|
|
|
5599
6647
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
5600
|
-
tooltipTitle = d3.timeFormat(
|
|
6648
|
+
tooltipTitle = d3.timeFormat(_this39.options.dateFormat || _this39.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
5601
6649
|
}
|
|
5602
6650
|
}
|
|
5603
6651
|
|
|
5604
6652
|
if (pointA && pointB) {
|
|
5605
|
-
var d0 =
|
|
6653
|
+
var d0 = _this39[xAxis](_this39.parseX(pointA.x.value));
|
|
5606
6654
|
|
|
5607
|
-
var d1 =
|
|
6655
|
+
var d1 = _this39[xAxis](_this39.parseX(pointB.x.value));
|
|
5608
6656
|
|
|
5609
6657
|
var mid = Math.abs(d0 - d1) / 2;
|
|
5610
6658
|
|
|
@@ -5613,7 +6661,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5613
6661
|
tooltipTitle = pointB.x.value;
|
|
5614
6662
|
|
|
5615
6663
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
5616
|
-
tooltipTitle = d3.timeFormat(
|
|
6664
|
+
tooltipTitle = d3.timeFormat(_this39.options.dateFormat || _this39.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
5617
6665
|
}
|
|
5618
6666
|
|
|
5619
6667
|
if (!pointB.y.color) {
|
|
@@ -5626,7 +6674,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5626
6674
|
tooltipTitle = pointA.x.value;
|
|
5627
6675
|
|
|
5628
6676
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
5629
|
-
tooltipTitle = d3.timeFormat(
|
|
6677
|
+
tooltipTitle = d3.timeFormat(_this39.options.dateFormat || _this39.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
5630
6678
|
}
|
|
5631
6679
|
|
|
5632
6680
|
if (!pointA.y.color) {
|
|
@@ -5731,7 +6779,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5731
6779
|
}, {
|
|
5732
6780
|
key: "render",
|
|
5733
6781
|
value: function render(options) {
|
|
5734
|
-
var
|
|
6782
|
+
var _this40 = this;
|
|
5735
6783
|
|
|
5736
6784
|
/* global d3 options WebsyUtils */
|
|
5737
6785
|
if (typeof options !== 'undefined') {
|
|
@@ -5800,7 +6848,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5800
6848
|
var legendData = this.options.data.series.map(function (s, i) {
|
|
5801
6849
|
return {
|
|
5802
6850
|
value: s.label || s.key,
|
|
5803
|
-
color: s.color ||
|
|
6851
|
+
color: s.color || _this40.options.colors[i % _this40.options.colors.length]
|
|
5804
6852
|
};
|
|
5805
6853
|
});
|
|
5806
6854
|
|
|
@@ -6052,7 +7100,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6052
7100
|
|
|
6053
7101
|
if (this.options.data.bottom.formatter) {
|
|
6054
7102
|
bAxisFunc.tickFormat(function (d) {
|
|
6055
|
-
return
|
|
7103
|
+
return _this40.options.data.bottom.formatter(d);
|
|
6056
7104
|
});
|
|
6057
7105
|
}
|
|
6058
7106
|
|
|
@@ -6078,8 +7126,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6078
7126
|
|
|
6079
7127
|
if (this.options.margin.axisLeft > 0) {
|
|
6080
7128
|
this.leftAxisLayer.call(d3.axisLeft(this.leftAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
6081
|
-
if (
|
|
6082
|
-
d =
|
|
7129
|
+
if (_this40.options.data.left.formatter) {
|
|
7130
|
+
d = _this40.options.data.left.formatter(d);
|
|
6083
7131
|
}
|
|
6084
7132
|
|
|
6085
7133
|
return d;
|
|
@@ -6116,8 +7164,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6116
7164
|
|
|
6117
7165
|
if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
|
|
6118
7166
|
this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
6119
|
-
if (
|
|
6120
|
-
d =
|
|
7167
|
+
if (_this40.options.data.right.formatter) {
|
|
7168
|
+
d = _this40.options.data.right.formatter(d);
|
|
6121
7169
|
}
|
|
6122
7170
|
|
|
6123
7171
|
return d;
|
|
@@ -6143,16 +7191,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6143
7191
|
|
|
6144
7192
|
this.options.data.series.forEach(function (series, index) {
|
|
6145
7193
|
if (!series.key) {
|
|
6146
|
-
series.key =
|
|
7194
|
+
series.key = _this40.createIdentity();
|
|
6147
7195
|
}
|
|
6148
7196
|
|
|
6149
7197
|
if (!series.color) {
|
|
6150
|
-
series.color =
|
|
7198
|
+
series.color = _this40.options.colors[index % _this40.options.colors.length];
|
|
6151
7199
|
}
|
|
6152
7200
|
|
|
6153
|
-
|
|
7201
|
+
_this40["render".concat(series.type || 'bar')](series, index);
|
|
6154
7202
|
|
|
6155
|
-
|
|
7203
|
+
_this40.renderLabels(series, index);
|
|
6156
7204
|
});
|
|
6157
7205
|
}
|
|
6158
7206
|
}
|
|
@@ -6160,17 +7208,17 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6160
7208
|
}, {
|
|
6161
7209
|
key: "renderarea",
|
|
6162
7210
|
value: function renderarea(series, index) {
|
|
6163
|
-
var
|
|
7211
|
+
var _this41 = this;
|
|
6164
7212
|
|
|
6165
7213
|
/* global d3 series index */
|
|
6166
7214
|
var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
|
|
6167
7215
|
return d3.area().x(function (d) {
|
|
6168
|
-
return
|
|
7216
|
+
return _this41[xAxis](_this41.parseX(d.x.value));
|
|
6169
7217
|
}).y0(function (d) {
|
|
6170
|
-
return
|
|
7218
|
+
return _this41[yAxis](0);
|
|
6171
7219
|
}).y1(function (d) {
|
|
6172
|
-
return
|
|
6173
|
-
}).curve(d3[curveStyle ||
|
|
7220
|
+
return _this41[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
7221
|
+
}).curve(d3[curveStyle || _this41.options.curveStyle]);
|
|
6174
7222
|
};
|
|
6175
7223
|
|
|
6176
7224
|
var xAxis = 'bottomAxis';
|
|
@@ -6273,15 +7321,21 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6273
7321
|
}
|
|
6274
7322
|
|
|
6275
7323
|
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',
|
|
7324
|
+
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) {
|
|
7325
|
+
return d.color || series.color;
|
|
7326
|
+
});
|
|
6277
7327
|
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',
|
|
7328
|
+
.attr('fill', function (d) {
|
|
7329
|
+
return d.color || series.color;
|
|
7330
|
+
}).attr('class', function (d) {
|
|
6279
7331
|
return "bar bar_".concat(series.key);
|
|
6280
7332
|
});
|
|
6281
7333
|
}
|
|
6282
7334
|
}, {
|
|
6283
7335
|
key: "renderLabels",
|
|
6284
7336
|
value: function renderLabels(series, index) {
|
|
7337
|
+
var _this42 = this;
|
|
7338
|
+
|
|
6285
7339
|
/* global series index d3 WebsyDesigns */
|
|
6286
7340
|
var xAxis = 'bottomAxis';
|
|
6287
7341
|
var yAxis = 'leftAxis';
|
|
@@ -6298,10 +7352,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6298
7352
|
// We currently only support 'Auto'
|
|
6299
7353
|
var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
|
|
6300
7354
|
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',
|
|
7355
|
+
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) {
|
|
7356
|
+
return _this42.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.color || series.color);
|
|
7357
|
+
}).transition(this.transition).text(function (d) {
|
|
6302
7358
|
return d.y.label || d.y.value;
|
|
6303
7359
|
});
|
|
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',
|
|
7360
|
+
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) {
|
|
7361
|
+
return _this42.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.color || series.color);
|
|
7362
|
+
}).text(function (d) {
|
|
6305
7363
|
return d.y.label || d.y.value;
|
|
6306
7364
|
}).each(function (d, i) {
|
|
6307
7365
|
if (that.options.orientation === 'horizontal') {
|
|
@@ -6345,15 +7403,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6345
7403
|
}, {
|
|
6346
7404
|
key: "renderline",
|
|
6347
7405
|
value: function renderline(series, index) {
|
|
6348
|
-
var
|
|
7406
|
+
var _this43 = this;
|
|
6349
7407
|
|
|
6350
7408
|
/* global series index d3 */
|
|
6351
7409
|
var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
|
|
6352
7410
|
return d3.line().x(function (d) {
|
|
6353
|
-
return
|
|
7411
|
+
return _this43[xAxis](_this43.parseX(d.x.value));
|
|
6354
7412
|
}).y(function (d) {
|
|
6355
|
-
return
|
|
6356
|
-
}).curve(d3[curveStyle ||
|
|
7413
|
+
return _this43[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
7414
|
+
}).curve(d3[curveStyle || _this43.options.curveStyle]);
|
|
6357
7415
|
};
|
|
6358
7416
|
|
|
6359
7417
|
var xAxis = 'bottomAxis';
|
|
@@ -6391,14 +7449,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6391
7449
|
}, {
|
|
6392
7450
|
key: "rendersymbol",
|
|
6393
7451
|
value: function rendersymbol(series, index) {
|
|
6394
|
-
var
|
|
7452
|
+
var _this44 = this;
|
|
6395
7453
|
|
|
6396
7454
|
/* global d3 series index series.key */
|
|
6397
7455
|
var drawSymbol = function drawSymbol(size) {
|
|
6398
7456
|
return d3.symbol() // .type(d => {
|
|
6399
7457
|
// return d3.symbols[0]
|
|
6400
7458
|
// })
|
|
6401
|
-
.size(size ||
|
|
7459
|
+
.size(size || _this44.options.symbolSize);
|
|
6402
7460
|
};
|
|
6403
7461
|
|
|
6404
7462
|
var xAxis = 'bottomAxis';
|
|
@@ -6416,7 +7474,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6416
7474
|
symbols.attr('d', function (d) {
|
|
6417
7475
|
return drawSymbol(d.y.size || series.symbolSize)(d);
|
|
6418
7476
|
}).transition(this.transition).attr('fill', 'white').attr('stroke', series.color).attr('transform', function (d) {
|
|
6419
|
-
return "translate(".concat(
|
|
7477
|
+
return "translate(".concat(_this44[xAxis](_this44.parseX(d.x.value)), ", ").concat(_this44[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
6420
7478
|
}); // Enter
|
|
6421
7479
|
|
|
6422
7480
|
symbols.enter().append('path').attr('d', function (d) {
|
|
@@ -6425,7 +7483,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6425
7483
|
.attr('fill', 'white').attr('stroke', series.color).attr('class', function (d) {
|
|
6426
7484
|
return "symbol symbol_".concat(series.key);
|
|
6427
7485
|
}).attr('transform', function (d) {
|
|
6428
|
-
return "translate(".concat(
|
|
7486
|
+
return "translate(".concat(_this44[xAxis](_this44.parseX(d.x.value)), ", ").concat(_this44[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
6429
7487
|
});
|
|
6430
7488
|
}
|
|
6431
7489
|
}, {
|
|
@@ -6580,7 +7638,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
6580
7638
|
}, {
|
|
6581
7639
|
key: "resize",
|
|
6582
7640
|
value: function resize() {
|
|
6583
|
-
var
|
|
7641
|
+
var _this45 = this;
|
|
6584
7642
|
|
|
6585
7643
|
var el = document.getElementById(this.elementId);
|
|
6586
7644
|
|
|
@@ -6593,7 +7651,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
6593
7651
|
// }
|
|
6594
7652
|
var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
|
|
6595
7653
|
html += this._data.map(function (d, i) {
|
|
6596
|
-
return
|
|
7654
|
+
return _this45.getLegendItemHTML(d);
|
|
6597
7655
|
}).join('');
|
|
6598
7656
|
html += "\n <div>\n ";
|
|
6599
7657
|
el.innerHTML = html;
|
|
@@ -6765,7 +7823,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
6765
7823
|
}, {
|
|
6766
7824
|
key: "render",
|
|
6767
7825
|
value: function render() {
|
|
6768
|
-
var
|
|
7826
|
+
var _this46 = this;
|
|
6769
7827
|
|
|
6770
7828
|
var mapEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
6771
7829
|
var legendEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
@@ -6774,7 +7832,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
6774
7832
|
var legendData = this.options.data.polygons.map(function (s, i) {
|
|
6775
7833
|
return {
|
|
6776
7834
|
value: s.label || s.key,
|
|
6777
|
-
color: s.color ||
|
|
7835
|
+
color: s.color || _this46.options.colors[i % _this46.options.colors.length]
|
|
6778
7836
|
};
|
|
6779
7837
|
});
|
|
6780
7838
|
var longestValue = legendData.map(function (s) {
|
|
@@ -6838,7 +7896,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
6838
7896
|
|
|
6839
7897
|
if (this.polygons) {
|
|
6840
7898
|
this.polygons.forEach(function (p) {
|
|
6841
|
-
return
|
|
7899
|
+
return _this46.map.removeLayer(p);
|
|
6842
7900
|
});
|
|
6843
7901
|
}
|
|
6844
7902
|
|
|
@@ -6896,18 +7954,18 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
6896
7954
|
}
|
|
6897
7955
|
|
|
6898
7956
|
if (!p.options.color) {
|
|
6899
|
-
p.options.color =
|
|
7957
|
+
p.options.color = _this46.options.colors[i % _this46.options.colors.length];
|
|
6900
7958
|
}
|
|
6901
7959
|
|
|
6902
7960
|
var pol = L.polygon(p.data.map(function (c) {
|
|
6903
7961
|
return c.map(function (d) {
|
|
6904
7962
|
return [d.Latitude, d.Longitude];
|
|
6905
7963
|
});
|
|
6906
|
-
}), p.options).addTo(
|
|
7964
|
+
}), p.options).addTo(_this46.map);
|
|
6907
7965
|
|
|
6908
|
-
|
|
7966
|
+
_this46.polygons.push(pol);
|
|
6909
7967
|
|
|
6910
|
-
|
|
7968
|
+
_this46.map.fitBounds(pol.getBounds());
|
|
6911
7969
|
});
|
|
6912
7970
|
} // if (this.data.markers.length > 0) {
|
|
6913
7971
|
// el.classList.remove('hidden')
|
|
@@ -7028,6 +8086,8 @@ var WebsyDesigns = {
|
|
|
7028
8086
|
Form: WebsyForm,
|
|
7029
8087
|
WebsyDatePicker: WebsyDatePicker,
|
|
7030
8088
|
DatePicker: WebsyDatePicker,
|
|
8089
|
+
WebsyDragDrop: WebsyDragDrop,
|
|
8090
|
+
DragDrop: WebsyDragDrop,
|
|
7031
8091
|
WebsyDropdown: WebsyDropdown,
|
|
7032
8092
|
Dropdown: WebsyDropdown,
|
|
7033
8093
|
WebsyResultList: WebsyResultList,
|
|
@@ -7040,8 +8100,10 @@ var WebsyDesigns = {
|
|
|
7040
8100
|
Router: WebsyRouter,
|
|
7041
8101
|
WebsyTable: WebsyTable,
|
|
7042
8102
|
WebsyTable2: WebsyTable2,
|
|
8103
|
+
WebsyTable3: WebsyTable3,
|
|
7043
8104
|
Table: WebsyTable,
|
|
7044
8105
|
Table2: WebsyTable2,
|
|
8106
|
+
Table3: WebsyTable3,
|
|
7045
8107
|
WebsyChart: WebsyChart,
|
|
7046
8108
|
Chart: WebsyChart,
|
|
7047
8109
|
WebsyChartTooltip: WebsyChartTooltip,
|
|
@@ -7067,5 +8129,6 @@ var WebsyDesigns = {
|
|
|
7067
8129
|
WebsyIcons: WebsyIcons
|
|
7068
8130
|
};
|
|
7069
8131
|
WebsyDesigns.service = new WebsyDesigns.APIService('');
|
|
8132
|
+
window.GlobalPubSub = new WebsyPubSub('empty', {});
|
|
7070
8133
|
var _default = WebsyDesigns;
|
|
7071
8134
|
exports["default"] = _default;
|