@websy/websy-designs 1.0.4 → 1.1.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/puppeteer-report/examples/package-lock.json +972 -0
- package/dist/server/routes/v1/shop.js +2 -2
- package/dist/websy-designs-es6.debug.js +5724 -0
- package/dist/websy-designs-es6.js +6327 -0
- package/dist/websy-designs-es6.min.js +1 -0
- package/dist/websy-designs.debug.js +1112 -217
- package/dist/websy-designs.js +1260 -312
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
package/dist/websy-designs.js
CHANGED
|
@@ -34,6 +34,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
34
34
|
WebsyRouter
|
|
35
35
|
WebsyResultList
|
|
36
36
|
WebsyTable
|
|
37
|
+
WebsyTable2
|
|
37
38
|
WebsyChart
|
|
38
39
|
WebsyChartTooltip
|
|
39
40
|
WebsyLegend
|
|
@@ -45,6 +46,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
45
46
|
APIService
|
|
46
47
|
ButtonGroup
|
|
47
48
|
WebsyUtils
|
|
49
|
+
Pager
|
|
48
50
|
*/
|
|
49
51
|
|
|
50
52
|
/* global XMLHttpRequest fetch ENV */
|
|
@@ -292,11 +294,16 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
292
294
|
this.oneDay = 1000 * 60 * 60 * 24;
|
|
293
295
|
this.currentselection = [];
|
|
294
296
|
this.validDates = [];
|
|
297
|
+
this.validYears = [];
|
|
298
|
+
this.customRangeSelected = true;
|
|
295
299
|
var DEFAULTS = {
|
|
296
300
|
defaultRange: 0,
|
|
297
301
|
minAllowedDate: this.floorDate(new Date(new Date(new Date().setFullYear(new Date().getFullYear() - 1)).setDate(1))),
|
|
298
302
|
maxAllowedDate: this.floorDate(new Date(new Date())),
|
|
303
|
+
minAllowedYear: 1970,
|
|
304
|
+
maxAllowedYear: new Date().getFullYear(),
|
|
299
305
|
daysOfWeek: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
|
|
306
|
+
mode: 'date',
|
|
300
307
|
monthMap: {
|
|
301
308
|
0: 'Jan',
|
|
302
309
|
1: 'Feb',
|
|
@@ -313,35 +320,49 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
313
320
|
},
|
|
314
321
|
ranges: []
|
|
315
322
|
};
|
|
316
|
-
DEFAULTS.ranges =
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
323
|
+
DEFAULTS.ranges = {
|
|
324
|
+
date: [{
|
|
325
|
+
label: 'All Dates',
|
|
326
|
+
range: [DEFAULTS.minAllowedDate, DEFAULTS.maxAllowedDate]
|
|
327
|
+
}, {
|
|
328
|
+
label: 'Today',
|
|
329
|
+
range: [this.floorDate(new Date())]
|
|
330
|
+
}, {
|
|
331
|
+
label: 'Yesterday',
|
|
332
|
+
range: [this.floorDate(new Date().setDate(new Date().getDate() - 1))]
|
|
333
|
+
}, {
|
|
334
|
+
label: 'Last 7 Days',
|
|
335
|
+
range: [this.floorDate(new Date().setDate(new Date().getDate() - 6)), this.floorDate(new Date())]
|
|
336
|
+
}, {
|
|
337
|
+
label: 'This Month',
|
|
338
|
+
range: [this.floorDate(new Date().setDate(1)), this.floorDate(new Date(new Date().setDate(1)).setMonth(new Date().getMonth() + 1) - this.oneDay)]
|
|
339
|
+
}, {
|
|
340
|
+
label: 'Last Month',
|
|
341
|
+
range: [this.floorDate(new Date(new Date().setDate(1)).setMonth(new Date().getMonth() - 1)), this.floorDate(new Date(new Date().setDate(1)).setMonth(new Date().getMonth()) - this.oneDay)]
|
|
342
|
+
}, {
|
|
343
|
+
label: 'This Year',
|
|
344
|
+
range: [this.floorDate(new Date("1/1/".concat(new Date().getFullYear()))), this.floorDate(new Date("12/31/".concat(new Date().getFullYear())))]
|
|
345
|
+
}, {
|
|
346
|
+
label: 'Last Year',
|
|
347
|
+
range: [this.floorDate(new Date("1/1/".concat(new Date().getFullYear() - 1))), this.floorDate(new Date("12/31/".concat(new Date().getFullYear() - 1)))]
|
|
348
|
+
}],
|
|
349
|
+
year: [{
|
|
350
|
+
label: 'All Years',
|
|
351
|
+
range: [DEFAULTS.minAllowedYear, DEFAULTS.maxAllowedYear]
|
|
352
|
+
}, {
|
|
353
|
+
label: 'Last 5 Years',
|
|
354
|
+
range: [new Date().getFullYear() - 4, DEFAULTS.maxAllowedYear]
|
|
355
|
+
}, {
|
|
356
|
+
label: 'Last 10 Years',
|
|
357
|
+
range: [new Date().getFullYear() - 9, DEFAULTS.maxAllowedYear]
|
|
358
|
+
}]
|
|
359
|
+
};
|
|
341
360
|
this.options = _extends({}, DEFAULTS, options);
|
|
342
361
|
this.selectedRange = this.options.defaultRange || 0;
|
|
343
|
-
this.selectedRangeDates = _toConsumableArray(this.options.ranges[this.options.defaultRange || 0].range);
|
|
362
|
+
this.selectedRangeDates = _toConsumableArray(this.options.ranges[this.options.mode][this.options.defaultRange || 0].range);
|
|
344
363
|
this.priorSelectedDates = null;
|
|
364
|
+
this.priorselection = null;
|
|
365
|
+
this.priorCustomRangeSelected = null;
|
|
345
366
|
|
|
346
367
|
if (!elementId) {
|
|
347
368
|
console.log('No element Id provided');
|
|
@@ -353,7 +374,10 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
353
374
|
if (el) {
|
|
354
375
|
this.elementId = elementId;
|
|
355
376
|
el.addEventListener('click', this.handleClick.bind(this));
|
|
356
|
-
|
|
377
|
+
el.addEventListener('mousedown', this.handleMouseDown.bind(this));
|
|
378
|
+
el.addEventListener('mouseover', this.handleMouseOver.bind(this));
|
|
379
|
+
el.addEventListener('mouseup', this.handleMouseUp.bind(this));
|
|
380
|
+
var html = "\n <div class='websy-date-picker-container'>\n <span class='websy-dropdown-header-label'>".concat(this.options.label || 'Date', "</span>\n <div class='websy-date-picker-header'>\n <span id='").concat(this.elementId, "_selectedRange'>").concat(this.options.ranges[this.options.mode][this.selectedRange].label, "</span>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z\"/></svg>\n </div>\n <div id='").concat(this.elementId, "_mask' class='websy-date-picker-mask'></div>\n <div id='").concat(this.elementId, "_content' class='websy-date-picker-content'>\n <div class='websy-date-picker-ranges'>\n <ul id='").concat(this.elementId, "_rangelist'>\n ").concat(this.renderRanges(), "\n </ul>\n </div><!--\n --><div id='").concat(this.elementId, "_datelist' class='websy-date-picker-custom'>").concat(this.renderDates(), "</div>\n <div class='websy-dp-button-container'>\n <button class='").concat(this.options.cancelBtnClasses || '', " websy-btn websy-dp-cancel'>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"30\" height=\"30\" viewBox=\"0 0 512 512\"><line x1=\"368\" y1=\"368\" x2=\"144\" y2=\"144\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"368\" y1=\"144\" x2=\"144\" y2=\"368\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>\n </button>\n <button class='").concat(this.options.confirmBtnClasses || '', " websy-btn websy-dp-confirm'>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"30\" height=\"30\" viewBox=\"0 0 512 512\"><polyline points=\"416 128 192 384 96 288\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>\n </button>\n </div>\n </div> \n </div>\n ");
|
|
357
381
|
el.innerHTML = html;
|
|
358
382
|
this.render();
|
|
359
383
|
} else {
|
|
@@ -371,13 +395,20 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
371
395
|
|
|
372
396
|
if (confirm === true) {
|
|
373
397
|
if (this.options.onChange) {
|
|
374
|
-
|
|
398
|
+
if (this.customRangeSelected === true) {
|
|
399
|
+
this.options.onChange(this.selectedRangeDates, true);
|
|
400
|
+
} else {
|
|
401
|
+
this.options.onChange(this.currentselection, false);
|
|
402
|
+
}
|
|
375
403
|
}
|
|
376
404
|
|
|
377
405
|
this.updateRange();
|
|
378
406
|
} else {
|
|
379
407
|
this.selectedRangeDates = _toConsumableArray(this.priorSelectedDates);
|
|
380
408
|
this.selectedRange = this.priorSelectedRange;
|
|
409
|
+
this.customRangeSelected = this.priorCustomRangeSelected;
|
|
410
|
+
this.currentselection = _toConsumableArray(this.priorselection);
|
|
411
|
+
this.highlightRange();
|
|
381
412
|
}
|
|
382
413
|
}
|
|
383
414
|
}, {
|
|
@@ -404,22 +435,65 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
404
435
|
var index = event.target.getAttribute('data-index');
|
|
405
436
|
this.selectRange(index);
|
|
406
437
|
this.updateRange(index);
|
|
407
|
-
} else if (event.target.classList.contains('websy-dp-date')) {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
var timestamp = event.target.id.split('_')[0];
|
|
413
|
-
this.selectDate(+timestamp);
|
|
438
|
+
} else if (event.target.classList.contains('websy-dp-date')) {// if (event.target.classList.contains('websy-disabled-date')) {
|
|
439
|
+
// return
|
|
440
|
+
// }
|
|
441
|
+
// const timestamp = event.target.id.split('_')[0]
|
|
442
|
+
// this.selectDate(+timestamp)
|
|
414
443
|
} else if (event.target.classList.contains('websy-dp-confirm')) {
|
|
415
444
|
this.close(true);
|
|
416
445
|
} else if (event.target.classList.contains('websy-dp-cancel')) {
|
|
417
446
|
this.close();
|
|
418
447
|
}
|
|
419
448
|
}
|
|
449
|
+
}, {
|
|
450
|
+
key: "handleMouseDown",
|
|
451
|
+
value: function handleMouseDown(event) {
|
|
452
|
+
this.mouseDown = true;
|
|
453
|
+
this.dragging = false;
|
|
454
|
+
|
|
455
|
+
if (event.target.classList.contains('websy-dp-date')) {
|
|
456
|
+
if (event.target.classList.contains('websy-disabled-date')) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
if (this.customRangeSelected === true) {
|
|
461
|
+
this.currentselection = [];
|
|
462
|
+
this.customRangeSelected = false;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
this.mouseDownId = +event.target.id.split('_')[0];
|
|
466
|
+
this.selectDate(this.mouseDownId);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}, {
|
|
470
|
+
key: "handleMouseOver",
|
|
471
|
+
value: function handleMouseOver(event) {
|
|
472
|
+
if (this.mouseDown === true) {
|
|
473
|
+
if (event.target.classList.contains('websy-dp-date')) {
|
|
474
|
+
if (event.target.classList.contains('websy-disabled-date')) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (event.target.id.split('_')[0] !== this.mouseDownId) {
|
|
479
|
+
this.dragging = true;
|
|
480
|
+
this.selectDate(+event.target.id.split('_')[0]);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}, {
|
|
486
|
+
key: "handleMouseUp",
|
|
487
|
+
value: function handleMouseUp(event) {
|
|
488
|
+
this.mouseDown = false;
|
|
489
|
+
this.dragging = false;
|
|
490
|
+
this.mouseDownId = null;
|
|
491
|
+
}
|
|
420
492
|
}, {
|
|
421
493
|
key: "highlightRange",
|
|
422
494
|
value: function highlightRange() {
|
|
495
|
+
var _this2 = this;
|
|
496
|
+
|
|
423
497
|
var el = document.getElementById("".concat(this.elementId, "_dateList"));
|
|
424
498
|
var dateEls = el.querySelectorAll('.websy-dp-date');
|
|
425
499
|
|
|
@@ -433,27 +507,72 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
433
507
|
return;
|
|
434
508
|
}
|
|
435
509
|
|
|
436
|
-
|
|
510
|
+
if (this.customRangeSelected === true) {
|
|
511
|
+
var diff;
|
|
437
512
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}
|
|
513
|
+
if (this.options.mode === 'date') {
|
|
514
|
+
diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime() - this.selectedRangeDates[0].getTime()) / this.oneDay);
|
|
441
515
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
516
|
+
if (this.selectedRangeDates[0].getMonth() !== this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth()) {
|
|
517
|
+
diff += 1;
|
|
518
|
+
}
|
|
519
|
+
} else if (this.options.mode === 'year') {
|
|
520
|
+
diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0];
|
|
445
521
|
|
|
446
|
-
|
|
447
|
-
|
|
522
|
+
if (this.selectedRangeDates[this.selectedRangeDates.length - 1] !== this.selectedRangeDates[0]) {// diff += 1
|
|
523
|
+
}
|
|
524
|
+
}
|
|
448
525
|
|
|
449
|
-
|
|
450
|
-
|
|
526
|
+
for (var _i = 0; _i < diff + 1; _i++) {
|
|
527
|
+
var d = void 0;
|
|
528
|
+
var rangeStart = void 0;
|
|
529
|
+
var rangeEnd = void 0;
|
|
530
|
+
|
|
531
|
+
if (this.options.mode === 'date') {
|
|
532
|
+
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + _i * this.oneDay));
|
|
533
|
+
d = d.getTime();
|
|
534
|
+
rangeStart = this.selectedRangeDates[0].getTime();
|
|
535
|
+
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime();
|
|
536
|
+
} else if (this.options.mode === 'year') {
|
|
537
|
+
d = this.selectedRangeDates[0] + _i;
|
|
538
|
+
rangeStart = this.selectedRangeDates[0];
|
|
539
|
+
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1];
|
|
451
540
|
}
|
|
452
541
|
|
|
453
|
-
|
|
454
|
-
|
|
542
|
+
var dateEl = void 0;
|
|
543
|
+
|
|
544
|
+
if (this.options.mode === 'date') {
|
|
545
|
+
dateEl = document.getElementById("".concat(d.getTime(), "_date"));
|
|
546
|
+
} else if (this.options.mode === 'year') {
|
|
547
|
+
dateEl = document.getElementById("".concat(d, "_year"));
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if (dateEl) {
|
|
551
|
+
dateEl.classList.add('selected');
|
|
552
|
+
|
|
553
|
+
if (d === rangeStart) {
|
|
554
|
+
dateEl.classList.add("".concat(this.options.sortDirection === 'desc' ? 'last' : 'first'));
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
if (d === rangeEnd) {
|
|
558
|
+
dateEl.classList.add("".concat(this.options.sortDirection === 'desc' ? 'first' : 'last'));
|
|
559
|
+
}
|
|
455
560
|
}
|
|
456
561
|
}
|
|
562
|
+
} else {
|
|
563
|
+
this.currentselection.forEach(function (d) {
|
|
564
|
+
var dateEl;
|
|
565
|
+
|
|
566
|
+
if (_this2.options.mode === 'date') {
|
|
567
|
+
dateEl = document.getElementById("".concat(d, "_date"));
|
|
568
|
+
} else if (_this2.options.mode === 'year') {
|
|
569
|
+
dateEl = document.getElementById("".concat(d, "_year"));
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
dateEl.classList.add('selected');
|
|
573
|
+
dateEl.classList.add('first');
|
|
574
|
+
dateEl.classList.add('last');
|
|
575
|
+
});
|
|
457
576
|
}
|
|
458
577
|
}
|
|
459
578
|
}, {
|
|
@@ -466,6 +585,8 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
466
585
|
contentEl.classList.add('active');
|
|
467
586
|
this.priorSelectedDates = _toConsumableArray(this.selectedRangeDates);
|
|
468
587
|
this.priorSelectedRange = this.selectedRange;
|
|
588
|
+
this.priorselection = _toConsumableArray(this.currentselection);
|
|
589
|
+
this.priorCustomRangeSelected = this.customRangeSelected;
|
|
469
590
|
this.scrollRangeIntoView();
|
|
470
591
|
}
|
|
471
592
|
}, {
|
|
@@ -493,61 +614,111 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
493
614
|
}, {
|
|
494
615
|
key: "renderDates",
|
|
495
616
|
value: function renderDates(disabledDates) {
|
|
617
|
+
var _this3 = this;
|
|
618
|
+
|
|
496
619
|
var disabled = [];
|
|
497
620
|
this.validDates = [];
|
|
621
|
+
this.validYears = [];
|
|
498
622
|
|
|
499
623
|
if (disabledDates) {
|
|
500
624
|
disabled = disabledDates.map(function (d) {
|
|
625
|
+
if (_this3.options.mode === 'date') {
|
|
626
|
+
return d.getTime();
|
|
627
|
+
} else if (_this3.options.mode === 'year') {
|
|
628
|
+
return d;
|
|
629
|
+
}
|
|
630
|
+
|
|
501
631
|
return d.getTime();
|
|
502
632
|
});
|
|
503
633
|
} // first disabled all of the ranges
|
|
504
634
|
|
|
505
635
|
|
|
506
|
-
this.options.ranges.forEach(function (r) {
|
|
636
|
+
this.options.ranges[this.options.mode].forEach(function (r) {
|
|
507
637
|
return r.disabled = true;
|
|
508
638
|
});
|
|
509
|
-
var
|
|
639
|
+
var diff;
|
|
640
|
+
|
|
641
|
+
if (this.options.mode === 'date') {
|
|
642
|
+
diff = Math.ceil((this.options.maxAllowedDate.getTime() - this.options.minAllowedDate.getTime()) / this.oneDay) + 1;
|
|
643
|
+
} else if (this.options.mode === 'year') {
|
|
644
|
+
diff = this.options.maxAllowedYear - this.options.minAllowedYear + 1;
|
|
645
|
+
}
|
|
646
|
+
|
|
510
647
|
var months = {};
|
|
648
|
+
var yearList = [];
|
|
511
649
|
|
|
512
|
-
for (var i = 0; i <
|
|
513
|
-
|
|
514
|
-
|
|
650
|
+
for (var i = 0; i < diff; i++) {
|
|
651
|
+
if (this.options.mode === 'date') {
|
|
652
|
+
var d = this.floorDate(new Date(this.options.minAllowedDate.getTime() + i * this.oneDay));
|
|
653
|
+
var monthYear = "".concat(this.options.monthMap[d.getMonth()], " ").concat(d.getFullYear());
|
|
515
654
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
655
|
+
if (!months[monthYear]) {
|
|
656
|
+
months[monthYear] = [];
|
|
657
|
+
}
|
|
519
658
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
659
|
+
if (disabled.indexOf(d.getTime()) === -1) {
|
|
660
|
+
this.validDates.push(d.getTime());
|
|
661
|
+
}
|
|
523
662
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
663
|
+
months[monthYear].push({
|
|
664
|
+
date: d,
|
|
665
|
+
dayOfMonth: d.getDate(),
|
|
666
|
+
dayOfWeek: d.getDay(),
|
|
667
|
+
id: d.getTime(),
|
|
668
|
+
disabled: disabled.indexOf(d.getTime()) !== -1
|
|
669
|
+
});
|
|
670
|
+
} else if (this.options.mode === 'year') {
|
|
671
|
+
var _d = this.options.minAllowedYear + i;
|
|
672
|
+
|
|
673
|
+
yearList.push({
|
|
674
|
+
year: _d,
|
|
675
|
+
id: _d,
|
|
676
|
+
disabled: disabled.indexOf(_d) !== -1
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
if (disabled.indexOf(_d) === -1) {
|
|
680
|
+
this.validYears.push(_d);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
531
683
|
} // check each range to see if it can be enabled
|
|
532
684
|
|
|
533
685
|
|
|
534
|
-
for (var _i2 = 0; _i2 < this.options.ranges.length; _i2++) {
|
|
535
|
-
var r = this.options.ranges[_i2];
|
|
686
|
+
for (var _i2 = 0; _i2 < this.options.ranges[this.options.mode].length; _i2++) {
|
|
687
|
+
var r = this.options.ranges[this.options.mode][_i2];
|
|
536
688
|
|
|
537
|
-
if (this.
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
// check the last date
|
|
541
|
-
if (this.validDates.indexOf(r.range[1].getTime()) !== -1) {
|
|
689
|
+
if (this.options.mode === 'date') {
|
|
690
|
+
// check the first date
|
|
691
|
+
if (this.validDates.indexOf(r.range[0].getTime()) !== -1) {
|
|
542
692
|
r.disabled = false;
|
|
543
|
-
} else {
|
|
544
|
-
// check the
|
|
545
|
-
|
|
546
|
-
|
|
693
|
+
} else if (r.range[1]) {
|
|
694
|
+
// check the last date
|
|
695
|
+
if (this.validDates.indexOf(r.range[1].getTime()) !== -1) {
|
|
696
|
+
r.disabled = false;
|
|
697
|
+
} else {
|
|
698
|
+
// check the full range until a match is found
|
|
699
|
+
for (var _i3 = r.range[0].getTime(); _i3 <= r.range[1].getTime(); _i3 += this.oneDay) {
|
|
700
|
+
var testDate = this.floorDate(new Date(_i3));
|
|
547
701
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
702
|
+
if (this.validDates.indexOf(testDate.getTime()) !== -1) {
|
|
703
|
+
r.disabled = false;
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
} else if (this.options.mode === 'year') {
|
|
710
|
+
if (this.validYears.indexOf(r.range[0]) !== -1) {
|
|
711
|
+
r.disabled = false;
|
|
712
|
+
} else if (r.range[1]) {
|
|
713
|
+
if (this.validYears.indexOf(r.range[1]) !== -1) {
|
|
714
|
+
r.disabled = false;
|
|
715
|
+
} else {
|
|
716
|
+
// check the full range until a match is found
|
|
717
|
+
for (var _i4 = r.range[0]; _i4 <= r.range[1]; _i4++) {
|
|
718
|
+
if (this.validYears.indexOf(r.range[0] + _i4) !== -1) {
|
|
719
|
+
r.disabled = false;
|
|
720
|
+
break;
|
|
721
|
+
}
|
|
551
722
|
}
|
|
552
723
|
}
|
|
553
724
|
}
|
|
@@ -555,48 +726,73 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
555
726
|
}
|
|
556
727
|
|
|
557
728
|
var html = '';
|
|
558
|
-
html += "\n <ul class='websy-dp-days-header'>\n ";
|
|
559
|
-
html += this.options.daysOfWeek.map(function (d) {
|
|
560
|
-
return "<li>".concat(d, "</li>");
|
|
561
|
-
}).join('');
|
|
562
|
-
html += "\n </ul>\n <div id='".concat(this.elementId, "_dateList' class='websy-dp-date-list'>\n ");
|
|
563
729
|
|
|
564
|
-
|
|
565
|
-
html += "\n <
|
|
730
|
+
if (this.options.mode === 'date') {
|
|
731
|
+
html += "\n <ul class='websy-dp-days-header'>\n ";
|
|
732
|
+
html += this.options.daysOfWeek.map(function (d) {
|
|
733
|
+
return "<li>".concat(d, "</li>");
|
|
734
|
+
}).join('');
|
|
735
|
+
html += "\n </ul> \n <div id='".concat(this.elementId, "_dateList' class='websy-dp-date-list'>\n ");
|
|
736
|
+
|
|
737
|
+
for (var key in months) {
|
|
738
|
+
html += "\n <div class='websy-dp-month-container'>\n <span id='".concat(key.replace(/\s/g, '_'), "'>").concat(key, "</span>\n <ul>\n ");
|
|
739
|
+
|
|
740
|
+
if (months[key][0].dayOfWeek > 0) {
|
|
741
|
+
var paddedDays = [];
|
|
566
742
|
|
|
567
|
-
|
|
568
|
-
|
|
743
|
+
for (var _i5 = 0; _i5 < months[key][0].dayOfWeek; _i5++) {
|
|
744
|
+
paddedDays.push("<li> </li>");
|
|
745
|
+
}
|
|
569
746
|
|
|
570
|
-
|
|
571
|
-
paddedDays.push("<li> </li>");
|
|
747
|
+
html += paddedDays.join('');
|
|
572
748
|
}
|
|
573
749
|
|
|
574
|
-
html +=
|
|
750
|
+
html += months[key].map(function (d) {
|
|
751
|
+
return "<li id='".concat(d.id, "_date' class='websy-dp-date ").concat(d.disabled === true ? 'websy-disabled-date' : '', "'>").concat(d.dayOfMonth, "</li>");
|
|
752
|
+
}).join('');
|
|
753
|
+
html += "\n </ul>\n </div>\n ";
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
html += '</div>';
|
|
757
|
+
} else if (this.options.mode === 'year') {
|
|
758
|
+
if (this.options.sortDirection === 'desc') {
|
|
759
|
+
yearList.reverse();
|
|
575
760
|
}
|
|
576
761
|
|
|
577
|
-
html +=
|
|
578
|
-
|
|
762
|
+
html += "<div id='".concat(this.elementId, "_dateList' class='websy-dp-date-list'><ul>");
|
|
763
|
+
html += yearList.map(function (d) {
|
|
764
|
+
return "<li id='".concat(d.id, "_year' class='websy-dp-date websy-dp-year ").concat(d.disabled === true ? 'websy-disabled-date' : '', "'>").concat(d.year, "</li>");
|
|
579
765
|
}).join('');
|
|
580
|
-
html += "
|
|
766
|
+
html += "</ul></div>";
|
|
581
767
|
}
|
|
582
768
|
|
|
583
|
-
html += '</div>';
|
|
584
769
|
return html;
|
|
585
770
|
}
|
|
586
771
|
}, {
|
|
587
772
|
key: "renderRanges",
|
|
588
773
|
value: function renderRanges() {
|
|
589
|
-
var
|
|
774
|
+
var _this4 = this;
|
|
590
775
|
|
|
591
|
-
return this.options.ranges.map(function (r, i) {
|
|
592
|
-
return "\n <li data-index='".concat(i, "' class='websy-date-picker-range ").concat(i ===
|
|
593
|
-
}).join('');
|
|
776
|
+
return this.options.ranges[this.options.mode].map(function (r, i) {
|
|
777
|
+
return "\n <li data-index='".concat(i, "' class='websy-date-picker-range ").concat(i === _this4.selectedRange ? 'active' : '', " ").concat(r.disabled === true ? 'websy-disabled-range' : '', "'>").concat(r.label, "</li>\n ");
|
|
778
|
+
}).join('') + "<li data-index='-1' class='websy-date-picker-range ".concat(this.selectedRange === -1 ? 'active' : '', "'>Custom</li>");
|
|
594
779
|
}
|
|
595
780
|
}, {
|
|
596
781
|
key: "scrollRangeIntoView",
|
|
597
782
|
value: function scrollRangeIntoView() {
|
|
598
783
|
if (this.selectedRangeDates[0]) {
|
|
599
|
-
var el
|
|
784
|
+
var el;
|
|
785
|
+
|
|
786
|
+
if (this.options.mode === 'date') {
|
|
787
|
+
el = document.getElementById("".concat(this.selectedRangeDates[0].getTime(), "_date"));
|
|
788
|
+
} else if (this.options.mode === 'year') {
|
|
789
|
+
if (this.options.sortDirection === 'desc') {
|
|
790
|
+
el = document.getElementById("".concat(this.selectedRangeDates[this.selectedRangeDates.length - 1], "_year"));
|
|
791
|
+
} else {
|
|
792
|
+
el = document.getElementById("".concat(this.selectedRangeDates[0], "_year"));
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
600
796
|
var parentEl = document.getElementById("".concat(this.elementId, "_dateList"));
|
|
601
797
|
|
|
602
798
|
if (el && parentEl) {
|
|
@@ -610,18 +806,33 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
610
806
|
if (this.currentselection.length === 0) {
|
|
611
807
|
this.currentselection.push(timestamp);
|
|
612
808
|
} else {
|
|
613
|
-
if (
|
|
614
|
-
this.currentselection.
|
|
809
|
+
if (this.dragging === true) {
|
|
810
|
+
this.currentselection = [this.mouseDownId];
|
|
811
|
+
|
|
812
|
+
if (timestamp > this.currentselection[0]) {
|
|
813
|
+
this.currentselection.push(timestamp);
|
|
814
|
+
} else {
|
|
815
|
+
this.currentselection.splice(0, 0, timestamp);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
this.customRangeSelected = true;
|
|
615
819
|
} else {
|
|
616
|
-
this.currentselection.
|
|
820
|
+
this.currentselection.push(timestamp);
|
|
821
|
+
this.currentselection.sort(function (a, b) {
|
|
822
|
+
return a - b;
|
|
823
|
+
});
|
|
824
|
+
this.customRangeSelected = false;
|
|
617
825
|
}
|
|
618
826
|
}
|
|
619
827
|
|
|
620
|
-
|
|
828
|
+
if (this.options.mode === 'date') {
|
|
829
|
+
this.selectedRangeDates = [new Date(this.currentselection[0]), new Date(this.currentselection[1] || this.currentselection[0])];
|
|
830
|
+
} else if (this.options.mode === 'year') {
|
|
831
|
+
this.selectedRangeDates = [this.currentselection[0], this.currentselection[1] || this.currentselection[0]];
|
|
832
|
+
} // if (this.currentselection.length === 2) {
|
|
833
|
+
// this.currentselection = []
|
|
834
|
+
// }
|
|
621
835
|
|
|
622
|
-
if (this.currentselection.length === 2) {
|
|
623
|
-
this.currentselection = [];
|
|
624
|
-
}
|
|
625
836
|
|
|
626
837
|
this.selectedRange = -1;
|
|
627
838
|
this.highlightRange();
|
|
@@ -629,8 +840,9 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
629
840
|
}, {
|
|
630
841
|
key: "selectRange",
|
|
631
842
|
value: function selectRange(index) {
|
|
632
|
-
if (this.options.ranges[index]) {
|
|
633
|
-
this.selectedRangeDates = _toConsumableArray(this.options.ranges[index].range);
|
|
843
|
+
if (this.options.ranges[this.options.mode][index]) {
|
|
844
|
+
this.selectedRangeDates = _toConsumableArray(this.options.ranges[this.options.mode][index].range);
|
|
845
|
+
this.currentselection = _toConsumableArray(this.options.ranges[this.options.mode][index].range);
|
|
634
846
|
this.selectedRange = +index;
|
|
635
847
|
this.highlightRange();
|
|
636
848
|
this.close(true);
|
|
@@ -640,38 +852,69 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
640
852
|
key: "selectCustomRange",
|
|
641
853
|
value: function selectCustomRange(range) {
|
|
642
854
|
this.selectedRange = -1;
|
|
643
|
-
this.selectedRangeDates = range;
|
|
855
|
+
this.selectedRangeDates = range; // check if the custom range matches a configured range
|
|
856
|
+
|
|
857
|
+
for (var i = 0; i < this.options.ranges[this.options.mode].length; i++) {
|
|
858
|
+
if (this.options.ranges[this.options.mode][i].range.length === 1) {
|
|
859
|
+
if (this.options.ranges[this.options.mode][i].range[0] === range[0]) {
|
|
860
|
+
this.selectedRange = i;
|
|
861
|
+
break;
|
|
862
|
+
}
|
|
863
|
+
} else if (this.options.ranges[this.options.mode][i].range.length === 2) {
|
|
864
|
+
if (this.options.ranges[this.options.mode][i].range[0] === range[0] && this.options.ranges[this.options.mode][i].range[1] === range[1]) {
|
|
865
|
+
this.selectedRange = i;
|
|
866
|
+
break;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
|
|
644
871
|
this.highlightRange();
|
|
645
872
|
this.updateRange();
|
|
646
873
|
}
|
|
647
874
|
}, {
|
|
648
875
|
key: "setDateBounds",
|
|
649
876
|
value: function setDateBounds(range) {
|
|
650
|
-
if (this.options.ranges[0].label
|
|
651
|
-
this.options.ranges[0].range = [range[0], range[1] || range[0]];
|
|
877
|
+
if (['All Dates', 'All Years'].indexOf(this.options.ranges[this.options.mode][0].label) !== -1) {
|
|
878
|
+
this.options.ranges[this.options.mode][0].range = [range[0], range[1] || range[0]];
|
|
652
879
|
}
|
|
653
880
|
|
|
654
|
-
this.options.
|
|
655
|
-
|
|
881
|
+
if (this.options.mode === 'date') {
|
|
882
|
+
this.options.minAllowedDate = range[0];
|
|
883
|
+
this.options.maxAllowedDate = range[1] || range[0];
|
|
884
|
+
} else if (this.options.mode === 'year') {
|
|
885
|
+
this.options.minAllowedYear = range[0];
|
|
886
|
+
this.options.maxAllowedYear = range[1] || range[0];
|
|
887
|
+
}
|
|
656
888
|
}
|
|
657
889
|
}, {
|
|
658
890
|
key: "updateRange",
|
|
659
891
|
value: function updateRange() {
|
|
892
|
+
var _this5 = this;
|
|
893
|
+
|
|
660
894
|
var range;
|
|
661
895
|
|
|
662
896
|
if (this.selectedRange === -1) {
|
|
663
|
-
var
|
|
897
|
+
var list = (this.currentselection.length > 0 ? this.currentselection : this.selectedRangeDates).map(function (d) {
|
|
898
|
+
if (_this5.options.mode === 'date') {
|
|
899
|
+
return d.toLocaleDateString();
|
|
900
|
+
} else if (_this5.options.mode === 'year') {
|
|
901
|
+
return d;
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
var start = list[0];
|
|
664
905
|
var end = '';
|
|
665
906
|
|
|
666
|
-
if (this.
|
|
667
|
-
end = " - ".concat(
|
|
907
|
+
if (this.customRangeSelected === true) {
|
|
908
|
+
end = " - ".concat(list[list.length - 1]);
|
|
909
|
+
} else {
|
|
910
|
+
start = "".concat(list.length, " selected");
|
|
668
911
|
}
|
|
669
912
|
|
|
670
913
|
range = {
|
|
671
914
|
label: "".concat(start).concat(end)
|
|
672
915
|
};
|
|
673
916
|
} else {
|
|
674
|
-
range = this.options.ranges[this.selectedRange];
|
|
917
|
+
range = this.options.ranges[this.options.mode][this.selectedRange];
|
|
675
918
|
}
|
|
676
919
|
|
|
677
920
|
var el = document.getElementById(this.elementId);
|
|
@@ -703,6 +946,8 @@ Date.prototype.floor = function () {
|
|
|
703
946
|
|
|
704
947
|
var WebsyDropdown = /*#__PURE__*/function () {
|
|
705
948
|
function WebsyDropdown(elementId, options) {
|
|
949
|
+
var _this6 = this;
|
|
950
|
+
|
|
706
951
|
_classCallCheck(this, WebsyDropdown);
|
|
707
952
|
|
|
708
953
|
var DEFAULTS = {
|
|
@@ -735,6 +980,28 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
735
980
|
el.addEventListener('keyup', this.handleKeyUp.bind(this));
|
|
736
981
|
el.addEventListener('mouseout', this.handleMouseOut.bind(this));
|
|
737
982
|
el.addEventListener('mousemove', this.handleMouseMove.bind(this));
|
|
983
|
+
var headerLabel = this.selectedItems.map(function (s) {
|
|
984
|
+
return _this6.options.items[s].label || _this6.options.items[s].value;
|
|
985
|
+
}).join(this.options.multiValueDelimiter);
|
|
986
|
+
var headerValue = this.selectedItems.map(function (s) {
|
|
987
|
+
return _this6.options.items[s].value || _this6.options.items[s].label;
|
|
988
|
+
}).join(this.options.multiValueDelimiter);
|
|
989
|
+
var html = "\n <div class='websy-dropdown-container ".concat(this.options.disabled ? 'disabled' : '', " ").concat(this.options.disableSearch !== true ? 'with-search' : '', "'>\n <div id='").concat(this.elementId, "_header' class='websy-dropdown-header ").concat(this.selectedItems.length === 1 ? 'one-selected' : '', " ").concat(this.options.allowClear === true ? 'allow-clear' : '', "'>\n <span id='").concat(this.elementId, "_headerLabel' class='websy-dropdown-header-label'>").concat(this.options.label, "</span>\n <span data-info='").concat(headerLabel, "' class='websy-dropdown-header-value' id='").concat(this.elementId, "_selectedItems'>").concat(headerLabel, "</span>\n <input class='dropdown-input' id='").concat(this.elementId, "_input' name='").concat(this.options.field || this.options.label, "' value='").concat(headerValue, "'>\n <svg class='arrow' xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z\"/></svg>\n ");
|
|
990
|
+
|
|
991
|
+
if (this.options.allowClear === true) {
|
|
992
|
+
html += "\n <svg class='clear' xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 512 512\"><title>ionicons-v5-l</title><line x1=\"368\" y1=\"368\" x2=\"144\" y2=\"144\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"368\" y1=\"144\" x2=\"144\" y2=\"368\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>\n ";
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
html += " \n </div>\n <div id='".concat(this.elementId, "_mask' class='websy-dropdown-mask'></div>\n <div id='").concat(this.elementId, "_content' class='websy-dropdown-content'>\n ");
|
|
996
|
+
|
|
997
|
+
if (this.options.disableSearch !== true) {
|
|
998
|
+
html += "\n <input id='".concat(this.elementId, "_search' class='websy-dropdown-search' placeholder='").concat(this.options.searchPlaceholder || 'Search', "'>\n ");
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
html += "\n <div id='".concat(this.elementId, "_itemsContainer' class='websy-dropdown-items'>\n <ul id='").concat(this.elementId, "_items'> \n </ul>\n </div><!--\n --><div class='websy-dropdown-custom'></div>\n </div>\n </div>\n ");
|
|
1002
|
+
el.innerHTML = html;
|
|
1003
|
+
var scrollEl = document.getElementById("".concat(this.elementId, "_itemsContainer"));
|
|
1004
|
+
scrollEl.addEventListener('scroll', this.handleScroll.bind(this));
|
|
738
1005
|
this.render();
|
|
739
1006
|
} else {
|
|
740
1007
|
console.log('No element found with Id', elementId);
|
|
@@ -742,6 +1009,9 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
742
1009
|
}
|
|
743
1010
|
|
|
744
1011
|
_createClass(WebsyDropdown, [{
|
|
1012
|
+
key: "appendRows",
|
|
1013
|
+
value: function appendRows() {}
|
|
1014
|
+
}, {
|
|
745
1015
|
key: "clearSelected",
|
|
746
1016
|
value: function clearSelected() {
|
|
747
1017
|
this.selectedItems = [];
|
|
@@ -864,6 +1134,15 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
864
1134
|
clearTimeout(this.tooltipTimeoutFn);
|
|
865
1135
|
}
|
|
866
1136
|
}
|
|
1137
|
+
}, {
|
|
1138
|
+
key: "handleScroll",
|
|
1139
|
+
value: function handleScroll(event) {
|
|
1140
|
+
if (event.target.classList.contains('websy-dropdown-items')) {
|
|
1141
|
+
if (this.options.onScroll) {
|
|
1142
|
+
this.options.onScroll(event);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
867
1146
|
}, {
|
|
868
1147
|
key: "open",
|
|
869
1148
|
value: function open(options) {
|
|
@@ -888,43 +1167,56 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
888
1167
|
}, {
|
|
889
1168
|
key: "render",
|
|
890
1169
|
value: function render() {
|
|
891
|
-
var _this3 = this;
|
|
892
|
-
|
|
893
1170
|
if (!this.elementId) {
|
|
894
1171
|
console.log('No element Id provided for Websy Dropdown');
|
|
895
1172
|
return;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
if (this.options.allowClear === true) {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
1173
|
+
} // const el = document.getElementById(this.elementId)
|
|
1174
|
+
// const headerLabel = this.selectedItems.map(s => this.options.items[s].label || this.options.items[s].value).join(this.options.multiValueDelimiter)
|
|
1175
|
+
// const headerValue = this.selectedItems.map(s => this.options.items[s].value || this.options.items[s].label).join(this.options.multiValueDelimiter)
|
|
1176
|
+
// let html = `
|
|
1177
|
+
// <div class='websy-dropdown-container ${this.options.disabled ? 'disabled' : ''} ${this.options.disableSearch !== true ? 'with-search' : ''}'>
|
|
1178
|
+
// <div id='${this.elementId}_header' class='websy-dropdown-header ${this.selectedItems.length === 1 ? 'one-selected' : ''} ${this.options.allowClear === true ? 'allow-clear' : ''}'>
|
|
1179
|
+
// <span id='${this.elementId}_headerLabel' class='websy-dropdown-header-label'>${this.options.label}</span>
|
|
1180
|
+
// <span data-info='${headerLabel}' class='websy-dropdown-header-value' id='${this.elementId}_selectedItems'>${headerLabel}</span>
|
|
1181
|
+
// <input class='dropdown-input' id='${this.elementId}_input' name='${this.options.field || this.options.label}' value='${headerValue}'>
|
|
1182
|
+
// <svg class='arrow' xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z"/></svg>
|
|
1183
|
+
// `
|
|
1184
|
+
// if (this.options.allowClear === true) {
|
|
1185
|
+
// html += `
|
|
1186
|
+
// <svg class='clear' xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 512 512"><title>ionicons-v5-l</title><line x1="368" y1="368" x2="144" y2="144" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/><line x1="368" y1="144" x2="144" y2="368" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/></svg>
|
|
1187
|
+
// `
|
|
1188
|
+
// }
|
|
1189
|
+
// html += `
|
|
1190
|
+
// </div>
|
|
1191
|
+
// <div id='${this.elementId}_mask' class='websy-dropdown-mask'></div>
|
|
1192
|
+
// <div id='${this.elementId}_content' class='websy-dropdown-content'>
|
|
1193
|
+
// `
|
|
1194
|
+
// if (this.options.disableSearch !== true) {
|
|
1195
|
+
// html += `
|
|
1196
|
+
// <input id='${this.elementId}_search' class='websy-dropdown-search' placeholder='${this.options.searchPlaceholder || 'Search'}'>
|
|
1197
|
+
// `
|
|
1198
|
+
// }
|
|
1199
|
+
// html += `
|
|
1200
|
+
// <div class='websy-dropdown-items'>
|
|
1201
|
+
// <ul id='${this.elementId}_items'>
|
|
1202
|
+
// </ul>
|
|
1203
|
+
// </div><!--
|
|
1204
|
+
// --><div class='websy-dropdown-custom'></div>
|
|
1205
|
+
// </div>
|
|
1206
|
+
// </div>
|
|
1207
|
+
// `
|
|
1208
|
+
// el.innerHTML = html
|
|
912
1209
|
|
|
913
|
-
if (this.options.disableSearch !== true) {
|
|
914
|
-
html += "\n <input id='".concat(this.elementId, "_search' class='websy-dropdown-search' placeholder='").concat(this.options.searchPlaceholder || 'Search', "'>\n ");
|
|
915
|
-
}
|
|
916
1210
|
|
|
917
|
-
html += "\n <div class='websy-dropdown-items'>\n <ul id='".concat(this.elementId, "_items'> \n </ul>\n </div><!--\n --><div class='websy-dropdown-custom'></div>\n </div>\n </div>\n ");
|
|
918
|
-
el.innerHTML = html;
|
|
919
1211
|
this.renderItems();
|
|
920
1212
|
}
|
|
921
1213
|
}, {
|
|
922
1214
|
key: "renderItems",
|
|
923
1215
|
value: function renderItems() {
|
|
924
|
-
var
|
|
1216
|
+
var _this7 = this;
|
|
925
1217
|
|
|
926
1218
|
var html = this.options.items.map(function (r, i) {
|
|
927
|
-
return "\n <li data-index='".concat(i, "' class='websy-dropdown-item ").concat((r.classes || []).join(' '), " ").concat(
|
|
1219
|
+
return "\n <li data-index='".concat(i, "' class='websy-dropdown-item ").concat((r.classes || []).join(' '), " ").concat(_this7.selectedItems.indexOf(i) !== -1 ? 'active' : '', "'>").concat(r.label, "</li>\n ");
|
|
928
1220
|
}).join('');
|
|
929
1221
|
var el = document.getElementById("".concat(this.elementId, "_items"));
|
|
930
1222
|
|
|
@@ -943,7 +1235,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
943
1235
|
}, {
|
|
944
1236
|
key: "updateHeader",
|
|
945
1237
|
value: function updateHeader(item) {
|
|
946
|
-
var
|
|
1238
|
+
var _this8 = this;
|
|
947
1239
|
|
|
948
1240
|
var el = document.getElementById(this.elementId);
|
|
949
1241
|
var headerEl = document.getElementById("".concat(this.elementId, "_header"));
|
|
@@ -981,23 +1273,25 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
981
1273
|
|
|
982
1274
|
if (labelEl) {
|
|
983
1275
|
if (this.selectedItems.length === 1) {
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1276
|
+
if (item) {
|
|
1277
|
+
labelEl.innerHTML = item.label;
|
|
1278
|
+
labelEl.setAttribute('data-info', item.label);
|
|
1279
|
+
inputEl.value = item.value;
|
|
1280
|
+
}
|
|
987
1281
|
} else if (this.selectedItems.length > 1) {
|
|
988
1282
|
if (this.options.showCompleteSelectedList === true) {
|
|
989
1283
|
var selectedLabels = this.selectedItems.map(function (s) {
|
|
990
|
-
return
|
|
1284
|
+
return _this8.options.items[s].label || _this8.options.items[s].value;
|
|
991
1285
|
}).join(this.options.multiValueDelimiter);
|
|
992
1286
|
var selectedValues = this.selectedItems.map(function (s) {
|
|
993
|
-
return
|
|
1287
|
+
return _this8.options.items[s].value || _this8.options.items[s].label;
|
|
994
1288
|
}).join(this.options.multiValueDelimiter);
|
|
995
1289
|
labelEl.innerHTML = selectedLabels;
|
|
996
1290
|
labelEl.setAttribute('data-info', selectedLabels);
|
|
997
1291
|
inputEl.value = selectedValues;
|
|
998
1292
|
} else {
|
|
999
1293
|
var _selectedValues = this.selectedItems.map(function (s) {
|
|
1000
|
-
return
|
|
1294
|
+
return _this8.options.items[s].value || _this8.options.items[s].label;
|
|
1001
1295
|
}).join(this.options.multiValueDelimiter);
|
|
1002
1296
|
|
|
1003
1297
|
labelEl.innerHTML = "".concat(this.selectedItems.length, " selected");
|
|
@@ -1103,12 +1397,9 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1103
1397
|
var el = document.getElementById(elementId);
|
|
1104
1398
|
|
|
1105
1399
|
if (el) {
|
|
1106
|
-
if (this.options.classes) {
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
});
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1400
|
+
// if (this.options.classes) {
|
|
1401
|
+
// this.options.classes.forEach(c => el.classList.add(c))
|
|
1402
|
+
// }
|
|
1112
1403
|
el.addEventListener('click', this.handleClick.bind(this));
|
|
1113
1404
|
el.addEventListener('keyup', this.handleKeyUp.bind(this));
|
|
1114
1405
|
el.addEventListener('keydown', this.handleKeyDown.bind(this));
|
|
@@ -1129,13 +1420,13 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1129
1420
|
}, {
|
|
1130
1421
|
key: "checkRecaptcha",
|
|
1131
1422
|
value: function checkRecaptcha() {
|
|
1132
|
-
var
|
|
1423
|
+
var _this9 = this;
|
|
1133
1424
|
|
|
1134
1425
|
return new Promise(function (resolve, reject) {
|
|
1135
|
-
if (
|
|
1136
|
-
if (
|
|
1137
|
-
|
|
1138
|
-
grecaptcharesponse:
|
|
1426
|
+
if (_this9.options.useRecaptcha === true) {
|
|
1427
|
+
if (_this9.recaptchaValue) {
|
|
1428
|
+
_this9.apiService.add('/google/checkrecaptcha', JSON.stringify({
|
|
1429
|
+
grecaptcharesponse: _this9.recaptchaValue
|
|
1139
1430
|
})).then(function (response) {
|
|
1140
1431
|
if (response.success && response.success === true) {
|
|
1141
1432
|
resolve(true);
|
|
@@ -1193,14 +1484,14 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1193
1484
|
}, {
|
|
1194
1485
|
key: "processComponents",
|
|
1195
1486
|
value: function processComponents(components, callbackFn) {
|
|
1196
|
-
var
|
|
1487
|
+
var _this10 = this;
|
|
1197
1488
|
|
|
1198
1489
|
if (components.length === 0) {
|
|
1199
1490
|
callbackFn();
|
|
1200
1491
|
} else {
|
|
1201
1492
|
components.forEach(function (c) {
|
|
1202
1493
|
if (typeof WebsyDesigns[c.component] !== 'undefined') {
|
|
1203
|
-
|
|
1494
|
+
c.instance = new WebsyDesigns[c.component]("".concat(_this10.elementId, "_input_").concat(c.field, "_component"), c.options);
|
|
1204
1495
|
} else {// some user feedback here
|
|
1205
1496
|
}
|
|
1206
1497
|
});
|
|
@@ -1221,27 +1512,27 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1221
1512
|
}, {
|
|
1222
1513
|
key: "render",
|
|
1223
1514
|
value: function render(update, data) {
|
|
1224
|
-
var
|
|
1515
|
+
var _this11 = this;
|
|
1225
1516
|
|
|
1226
1517
|
var el = document.getElementById(this.elementId);
|
|
1227
1518
|
var componentsToProcess = [];
|
|
1228
1519
|
|
|
1229
1520
|
if (el) {
|
|
1230
|
-
var html = "\n <form id=\"".concat(this.elementId, "Form\">\n ");
|
|
1521
|
+
var html = "\n <form id=\"".concat(this.elementId, "Form\" class=\"").concat(this.options.classes || '', "\">\n ");
|
|
1231
1522
|
this.options.fields.forEach(function (f, i) {
|
|
1232
1523
|
if (f.component) {
|
|
1233
1524
|
componentsToProcess.push(f);
|
|
1234
|
-
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(
|
|
1525
|
+
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(_this11.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n </div><!--\n ");
|
|
1235
1526
|
} else if (f.type === 'longtext') {
|
|
1236
|
-
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(
|
|
1527
|
+
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(_this11.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n name=\"").concat(f.field, "\" \n class=\"websy-input websy-textarea\"\n ></textarea>\n </div><!--\n ");
|
|
1237
1528
|
} else {
|
|
1238
|
-
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(
|
|
1529
|
+
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(_this11.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat(f.type || 'text', "\" \n class=\"websy-input\" \n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.value || '', "\"\n valueAsDate=\"").concat(f.type === 'date' ? f.value : '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n </div><!--\n ");
|
|
1239
1530
|
}
|
|
1240
1531
|
});
|
|
1241
|
-
html += "\n --><button class=\"websy-btn submit ".concat(this.options.submit.classes, "\">").concat(this.options.submit.text || 'Save', "</button>").concat(this.options.cancel ? '<!--' : '', "\n ");
|
|
1532
|
+
html += "\n --><button class=\"websy-btn submit ".concat(this.options.submit.classes || '', "\">").concat(this.options.submit.text || 'Save', "</button>").concat(this.options.cancel ? '<!--' : '', "\n ");
|
|
1242
1533
|
|
|
1243
1534
|
if (this.options.cancel) {
|
|
1244
|
-
html += "\n --><button class=\"websy-btn cancel ".concat(this.options.cancel.classes, "\">").concat(this.options.cancel.text || 'Cancel', "</button>\n ");
|
|
1535
|
+
html += "\n --><button class=\"websy-btn cancel ".concat(this.options.cancel.classes || '', "\">").concat(this.options.cancel.text || 'Cancel', "</button>\n ");
|
|
1245
1536
|
}
|
|
1246
1537
|
|
|
1247
1538
|
html += " \n </form>\n <div id=\"".concat(this.elementId, "_validationFail\" class=\"websy-validation-failure\"></div>\n ");
|
|
@@ -1252,8 +1543,8 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1252
1543
|
|
|
1253
1544
|
el.innerHTML = html;
|
|
1254
1545
|
this.processComponents(componentsToProcess, function () {
|
|
1255
|
-
if (
|
|
1256
|
-
|
|
1546
|
+
if (_this11.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
|
|
1547
|
+
_this11.recaptchaReady();
|
|
1257
1548
|
}
|
|
1258
1549
|
});
|
|
1259
1550
|
}
|
|
@@ -1261,7 +1552,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1261
1552
|
}, {
|
|
1262
1553
|
key: "submitForm",
|
|
1263
1554
|
value: function submitForm() {
|
|
1264
|
-
var
|
|
1555
|
+
var _this12 = this;
|
|
1265
1556
|
|
|
1266
1557
|
var formEl = document.getElementById("".concat(this.elementId, "Form"));
|
|
1267
1558
|
|
|
@@ -1275,22 +1566,22 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1275
1566
|
data[key] = value;
|
|
1276
1567
|
});
|
|
1277
1568
|
|
|
1278
|
-
if (
|
|
1279
|
-
|
|
1280
|
-
if (
|
|
1569
|
+
if (_this12.options.url) {
|
|
1570
|
+
_this12.apiService.add(_this12.options.url, data).then(function (result) {
|
|
1571
|
+
if (_this12.options.clearAfterSave === true) {
|
|
1281
1572
|
// this.render()
|
|
1282
1573
|
formEl.reset();
|
|
1283
1574
|
}
|
|
1284
1575
|
|
|
1285
|
-
|
|
1576
|
+
_this12.options.onSuccess.call(_this12, result);
|
|
1286
1577
|
}, function (err) {
|
|
1287
1578
|
console.log('Error submitting form data:', err);
|
|
1288
1579
|
|
|
1289
|
-
|
|
1580
|
+
_this12.options.onError.call(_this12, err);
|
|
1290
1581
|
});
|
|
1291
|
-
} else if (
|
|
1292
|
-
|
|
1293
|
-
if (
|
|
1582
|
+
} else if (_this12.options.submitFn) {
|
|
1583
|
+
_this12.options.submitFn(data, function () {
|
|
1584
|
+
if (_this12.options.clearAfterSave === true) {
|
|
1294
1585
|
// this.render()
|
|
1295
1586
|
formEl.reset();
|
|
1296
1587
|
}
|
|
@@ -1310,17 +1601,17 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
1310
1601
|
}, {
|
|
1311
1602
|
key: "data",
|
|
1312
1603
|
set: function set(d) {
|
|
1313
|
-
var
|
|
1604
|
+
var _this13 = this;
|
|
1314
1605
|
|
|
1315
1606
|
if (!this.options.fields) {
|
|
1316
1607
|
this.options.fields = [];
|
|
1317
1608
|
}
|
|
1318
1609
|
|
|
1319
1610
|
var _loop = function _loop(key) {
|
|
1320
|
-
|
|
1611
|
+
_this13.options.fields.forEach(function (f) {
|
|
1321
1612
|
if (f.field === key) {
|
|
1322
1613
|
f.value = d[key];
|
|
1323
|
-
var el = document.getElementById("".concat(
|
|
1614
|
+
var el = document.getElementById("".concat(_this13.elementId, "_input_").concat(f.field));
|
|
1324
1615
|
el.value = f.value;
|
|
1325
1616
|
}
|
|
1326
1617
|
});
|
|
@@ -1520,10 +1811,6 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
1520
1811
|
html += this.renderBlock(this.options.items, 'main', 0);
|
|
1521
1812
|
html += "</div>";
|
|
1522
1813
|
el.innerHTML = html;
|
|
1523
|
-
|
|
1524
|
-
if (this.options.navigator) {
|
|
1525
|
-
this.options.navigator.registerElements(el);
|
|
1526
|
-
}
|
|
1527
1814
|
}
|
|
1528
1815
|
}
|
|
1529
1816
|
}, {
|
|
@@ -1619,6 +1906,122 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
1619
1906
|
|
|
1620
1907
|
return WebsyNavigationMenu;
|
|
1621
1908
|
}();
|
|
1909
|
+
/* global WebsyDesigns */
|
|
1910
|
+
|
|
1911
|
+
|
|
1912
|
+
var Pager = /*#__PURE__*/function () {
|
|
1913
|
+
function Pager(elementId, options) {
|
|
1914
|
+
var _this14 = this;
|
|
1915
|
+
|
|
1916
|
+
_classCallCheck(this, Pager);
|
|
1917
|
+
|
|
1918
|
+
this.elementId = elementId;
|
|
1919
|
+
var DEFAULTS = {
|
|
1920
|
+
pageSizePrefix: 'Show',
|
|
1921
|
+
pageSizeSuffix: 'rows',
|
|
1922
|
+
pageSizeOptions: [{
|
|
1923
|
+
label: '10',
|
|
1924
|
+
value: 10
|
|
1925
|
+
}, {
|
|
1926
|
+
label: '20',
|
|
1927
|
+
value: 20
|
|
1928
|
+
}, {
|
|
1929
|
+
label: '50',
|
|
1930
|
+
value: 50
|
|
1931
|
+
}, {
|
|
1932
|
+
label: '100',
|
|
1933
|
+
value: 100
|
|
1934
|
+
}],
|
|
1935
|
+
selectedPageSize: 20,
|
|
1936
|
+
pageLabel: 'Page',
|
|
1937
|
+
showPageSize: true,
|
|
1938
|
+
activePage: 0,
|
|
1939
|
+
pages: []
|
|
1940
|
+
};
|
|
1941
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
1942
|
+
var el = document.getElementById(this.elementId);
|
|
1943
|
+
|
|
1944
|
+
if (el) {
|
|
1945
|
+
var html = "\n <div class=\"websy-pager-container\">\n ";
|
|
1946
|
+
|
|
1947
|
+
if (this.options.showPageSize === true) {
|
|
1948
|
+
html += "\n ".concat(this.options.pageSizePrefix, " <div id=\"").concat(this.elementId, "_pageSizeSelector\" class=\"websy-page-selector\"></div> ").concat(this.options.pageSizeSuffix, " \n ");
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
html += "\n <ul id=\"".concat(this.elementId, "_pageList\" class=\"websy-page-list\"></ul> \n </div> \n ");
|
|
1952
|
+
el.innerHTML = html;
|
|
1953
|
+
el.addEventListener('click', this.handleClick.bind(this));
|
|
1954
|
+
|
|
1955
|
+
if (this.options.showPageSize === true) {
|
|
1956
|
+
this.pageSizeSelector = new WebsyDesigns.Dropdown("".concat(this.elementId, "_pageSizeSelector"), {
|
|
1957
|
+
selectedItems: [this.options.pageSizeOptions.indexOf(this.options.selectedPageSize)],
|
|
1958
|
+
items: this.pageSizeOptions.map(function (p) {
|
|
1959
|
+
return {
|
|
1960
|
+
label: p.toString(),
|
|
1961
|
+
value: p
|
|
1962
|
+
};
|
|
1963
|
+
}),
|
|
1964
|
+
allowClear: false,
|
|
1965
|
+
disableSearch: true,
|
|
1966
|
+
onItemSelected: function onItemSelected(selectedItem) {
|
|
1967
|
+
if (_this14.options.onChangePageSize) {
|
|
1968
|
+
_this14.options.onChangePageSize(selectedItem.value);
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
this.render();
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
_createClass(Pager, [{
|
|
1979
|
+
key: "handleClick",
|
|
1980
|
+
value: function handleClick(event) {
|
|
1981
|
+
if (event.target.classList.contains('websy-page-num')) {
|
|
1982
|
+
var pageNum = +event.target.getAttribute('data-index');
|
|
1983
|
+
|
|
1984
|
+
if (this.options.onSetPage) {
|
|
1985
|
+
this.options.onSetPage(this.options.pages[pageNum]);
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
}, {
|
|
1990
|
+
key: "render",
|
|
1991
|
+
value: function render() {
|
|
1992
|
+
var _this15 = this;
|
|
1993
|
+
|
|
1994
|
+
var el = document.getElementById("".concat(this.elementId, "_pageList"));
|
|
1995
|
+
|
|
1996
|
+
if (el) {
|
|
1997
|
+
var pages = this.options.pages.map(function (item, index) {
|
|
1998
|
+
return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(_this15.options.activePage === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
1999
|
+
});
|
|
2000
|
+
var startIndex = 0;
|
|
2001
|
+
|
|
2002
|
+
if (this.options.pages.length > 8) {
|
|
2003
|
+
startIndex = Math.max(0, this.options.activePage - 4);
|
|
2004
|
+
pages = pages.splice(startIndex, 10);
|
|
2005
|
+
|
|
2006
|
+
if (startIndex > 0) {
|
|
2007
|
+
pages.splice(0, 0, "<li>".concat(this.options.pageLabel, " </li><li data-page=\"0\" class=\"websy-page-num\">First</li><li>...</li>"));
|
|
2008
|
+
} else {
|
|
2009
|
+
pages.splice(0, 0, "<li>".concat(this.options.pageLabel, " </li>"));
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
if (this.options.activePage < this.options.pages.length - 1) {
|
|
2013
|
+
pages.push('<li>...</li>');
|
|
2014
|
+
pages.push("<li data-page=\"".concat(this.options.pages.length - 1, "\" class=\"websy-page-num\">Last</li>"));
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
el.innerHTML = pages.join('');
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
}]);
|
|
2022
|
+
|
|
2023
|
+
return Pager;
|
|
2024
|
+
}();
|
|
1622
2025
|
/* global WebsyDesigns Blob */
|
|
1623
2026
|
|
|
1624
2027
|
|
|
@@ -1660,58 +2063,58 @@ var WebsyPDFButton = /*#__PURE__*/function () {
|
|
|
1660
2063
|
_createClass(WebsyPDFButton, [{
|
|
1661
2064
|
key: "handleClick",
|
|
1662
2065
|
value: function handleClick(event) {
|
|
1663
|
-
var
|
|
2066
|
+
var _this16 = this;
|
|
1664
2067
|
|
|
1665
2068
|
if (event.target.classList.contains('websy-pdf-button')) {
|
|
1666
2069
|
this.loader.show();
|
|
1667
2070
|
setTimeout(function () {
|
|
1668
|
-
if (
|
|
1669
|
-
var el = document.getElementById(
|
|
2071
|
+
if (_this16.options.targetId) {
|
|
2072
|
+
var el = document.getElementById(_this16.options.targetId);
|
|
1670
2073
|
|
|
1671
2074
|
if (el) {
|
|
1672
2075
|
var pdfData = {
|
|
1673
2076
|
options: {}
|
|
1674
2077
|
};
|
|
1675
2078
|
|
|
1676
|
-
if (
|
|
1677
|
-
pdfData.options = _extends({},
|
|
2079
|
+
if (_this16.options.pdfOptions) {
|
|
2080
|
+
pdfData.options = _extends({}, _this16.options.pdfOptions);
|
|
1678
2081
|
}
|
|
1679
2082
|
|
|
1680
|
-
if (
|
|
1681
|
-
if (
|
|
1682
|
-
var headerEl = document.getElementById(
|
|
2083
|
+
if (_this16.options.header) {
|
|
2084
|
+
if (_this16.options.header.elementId) {
|
|
2085
|
+
var headerEl = document.getElementById(_this16.options.header.elementId);
|
|
1683
2086
|
|
|
1684
2087
|
if (headerEl) {
|
|
1685
2088
|
pdfData.header = headerEl.outerHTML;
|
|
1686
2089
|
|
|
1687
|
-
if (
|
|
1688
|
-
pdfData.options.headerCSS =
|
|
2090
|
+
if (_this16.options.header.css) {
|
|
2091
|
+
pdfData.options.headerCSS = _this16.options.header.css;
|
|
1689
2092
|
}
|
|
1690
2093
|
}
|
|
1691
|
-
} else if (
|
|
1692
|
-
pdfData.header =
|
|
2094
|
+
} else if (_this16.options.header.html) {
|
|
2095
|
+
pdfData.header = _this16.options.header.html;
|
|
1693
2096
|
|
|
1694
|
-
if (
|
|
1695
|
-
pdfData.options.headerCSS =
|
|
2097
|
+
if (_this16.options.header.css) {
|
|
2098
|
+
pdfData.options.headerCSS = _this16.options.header.css;
|
|
1696
2099
|
}
|
|
1697
2100
|
} else {
|
|
1698
|
-
pdfData.header =
|
|
2101
|
+
pdfData.header = _this16.options.header;
|
|
1699
2102
|
}
|
|
1700
2103
|
}
|
|
1701
2104
|
|
|
1702
|
-
if (
|
|
1703
|
-
if (
|
|
1704
|
-
var footerEl = document.getElementById(
|
|
2105
|
+
if (_this16.options.footer) {
|
|
2106
|
+
if (_this16.options.footer.elementId) {
|
|
2107
|
+
var footerEl = document.getElementById(_this16.options.footer.elementId);
|
|
1705
2108
|
|
|
1706
2109
|
if (footerEl) {
|
|
1707
2110
|
pdfData.footer = footerEl.outerHTML;
|
|
1708
2111
|
|
|
1709
|
-
if (
|
|
1710
|
-
pdfData.options.footerCSS =
|
|
2112
|
+
if (_this16.options.footer.css) {
|
|
2113
|
+
pdfData.options.footerCSS = _this16.options.footer.css;
|
|
1711
2114
|
}
|
|
1712
2115
|
}
|
|
1713
2116
|
} else {
|
|
1714
|
-
pdfData.footer =
|
|
2117
|
+
pdfData.footer = _this16.options.footer;
|
|
1715
2118
|
}
|
|
1716
2119
|
}
|
|
1717
2120
|
|
|
@@ -1720,23 +2123,23 @@ var WebsyPDFButton = /*#__PURE__*/function () {
|
|
|
1720
2123
|
// document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
|
|
1721
2124
|
// document.getElementById(`${this.elementId}_form`).submit()
|
|
1722
2125
|
|
|
1723
|
-
|
|
2126
|
+
_this16.service.add('', pdfData, {
|
|
1724
2127
|
responseType: 'blob'
|
|
1725
2128
|
}).then(function (response) {
|
|
1726
|
-
|
|
2129
|
+
_this16.loader.hide();
|
|
1727
2130
|
|
|
1728
2131
|
var blob = new Blob([response], {
|
|
1729
2132
|
type: 'application/pdf'
|
|
1730
2133
|
});
|
|
1731
2134
|
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 ");
|
|
1732
2135
|
|
|
1733
|
-
if (
|
|
1734
|
-
msg += "download='".concat(
|
|
2136
|
+
if (_this16.options.directDownload === true) {
|
|
2137
|
+
msg += "download='".concat(_this16.options.fileName || 'Export', ".pdf'");
|
|
1735
2138
|
}
|
|
1736
2139
|
|
|
1737
|
-
msg += "\n >\n <button class='websy-btn download-pdf'>".concat(
|
|
2140
|
+
msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this16.options.buttonText, "</button>\n </a>\n </div>\n ");
|
|
1738
2141
|
|
|
1739
|
-
|
|
2142
|
+
_this16.popup.show({
|
|
1740
2143
|
message: msg,
|
|
1741
2144
|
mask: true
|
|
1742
2145
|
});
|
|
@@ -1921,7 +2324,7 @@ var WebsyPubSub = /*#__PURE__*/function () {
|
|
|
1921
2324
|
|
|
1922
2325
|
var WebsyResultList = /*#__PURE__*/function () {
|
|
1923
2326
|
function WebsyResultList(elementId, options) {
|
|
1924
|
-
var
|
|
2327
|
+
var _this17 = this;
|
|
1925
2328
|
|
|
1926
2329
|
_classCallCheck(this, WebsyResultList);
|
|
1927
2330
|
|
|
@@ -1949,9 +2352,9 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
1949
2352
|
|
|
1950
2353
|
if (_typeof(options.template) === 'object' && options.template.url) {
|
|
1951
2354
|
this.templateService.get(options.template.url).then(function (templateString) {
|
|
1952
|
-
|
|
2355
|
+
_this17.options.template = templateString;
|
|
1953
2356
|
|
|
1954
|
-
|
|
2357
|
+
_this17.render();
|
|
1955
2358
|
});
|
|
1956
2359
|
} else {
|
|
1957
2360
|
this.render();
|
|
@@ -1970,7 +2373,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
1970
2373
|
}, {
|
|
1971
2374
|
key: "buildHTML",
|
|
1972
2375
|
value: function buildHTML(d) {
|
|
1973
|
-
var
|
|
2376
|
+
var _this18 = this;
|
|
1974
2377
|
|
|
1975
2378
|
var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1976
2379
|
var html = "";
|
|
@@ -1978,7 +2381,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
1978
2381
|
if (this.options.template) {
|
|
1979
2382
|
if (d.length > 0) {
|
|
1980
2383
|
d.forEach(function (row, ix) {
|
|
1981
|
-
var template = "".concat(ix > 0 ? '-->' : '').concat(
|
|
2384
|
+
var template = "".concat(ix > 0 ? '-->' : '').concat(_this18.options.template).concat(ix < d.length - 1 ? '<!--' : ''); // find conditional elements
|
|
1982
2385
|
|
|
1983
2386
|
var ifMatches = _toConsumableArray(template.matchAll(/<\s*if[^>]*>([\s\S]*?)<\s*\/\s*if>/g));
|
|
1984
2387
|
|
|
@@ -2098,7 +2501,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
2098
2501
|
}, {
|
|
2099
2502
|
key: "handleClick",
|
|
2100
2503
|
value: function handleClick(event) {
|
|
2101
|
-
var
|
|
2504
|
+
var _this19 = this;
|
|
2102
2505
|
|
|
2103
2506
|
if (event.target.classList.contains('clickable')) {
|
|
2104
2507
|
var l = event.target.getAttribute('data-event');
|
|
@@ -2116,8 +2519,8 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
2116
2519
|
l = l[0];
|
|
2117
2520
|
params = params.map(function (p) {
|
|
2118
2521
|
if (typeof p !== 'string' && typeof p !== 'number') {
|
|
2119
|
-
if (
|
|
2120
|
-
p =
|
|
2522
|
+
if (_this19.rows[+id]) {
|
|
2523
|
+
p = _this19.rows[+id][p];
|
|
2121
2524
|
}
|
|
2122
2525
|
} else if (typeof p === 'string') {
|
|
2123
2526
|
p = p.replace(/"/g, '').replace(/'/g, '');
|
|
@@ -2139,13 +2542,13 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
2139
2542
|
}, {
|
|
2140
2543
|
key: "render",
|
|
2141
2544
|
value: function render() {
|
|
2142
|
-
var
|
|
2545
|
+
var _this20 = this;
|
|
2143
2546
|
|
|
2144
2547
|
if (this.options.entity) {
|
|
2145
2548
|
this.apiService.get(this.options.entity).then(function (results) {
|
|
2146
|
-
|
|
2549
|
+
_this20.rows = results.rows;
|
|
2147
2550
|
|
|
2148
|
-
|
|
2551
|
+
_this20.resize();
|
|
2149
2552
|
});
|
|
2150
2553
|
} else {
|
|
2151
2554
|
this.resize();
|
|
@@ -2224,7 +2627,7 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
2224
2627
|
_createClass(WebsyRouter, [{
|
|
2225
2628
|
key: "addGroup",
|
|
2226
2629
|
value: function addGroup(group) {
|
|
2227
|
-
var
|
|
2630
|
+
var _this21 = this;
|
|
2228
2631
|
|
|
2229
2632
|
if (!this.groups[group]) {
|
|
2230
2633
|
var els = document.querySelectorAll(".websy-view[data-group=\"".concat(group, "\"]"));
|
|
@@ -2232,7 +2635,7 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
2232
2635
|
if (els) {
|
|
2233
2636
|
console.log('els', els);
|
|
2234
2637
|
this.getClosestParent(els[0], function (parent) {
|
|
2235
|
-
|
|
2638
|
+
_this21.groups[group] = {
|
|
2236
2639
|
activeView: '',
|
|
2237
2640
|
views: [],
|
|
2238
2641
|
parent: parent.getAttribute('data-view')
|
|
@@ -2553,12 +2956,12 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
2553
2956
|
}, {
|
|
2554
2957
|
key: "showComponents",
|
|
2555
2958
|
value: function showComponents(view) {
|
|
2556
|
-
var
|
|
2959
|
+
var _this22 = this;
|
|
2557
2960
|
|
|
2558
2961
|
if (this.options.views && this.options.views[view] && this.options.views[view].components) {
|
|
2559
2962
|
this.options.views[view].components.forEach(function (c) {
|
|
2560
2963
|
if (typeof c.instance === 'undefined') {
|
|
2561
|
-
|
|
2964
|
+
_this22.prepComponent(c.elementId, c.options);
|
|
2562
2965
|
|
|
2563
2966
|
c.instance = new c.Component(c.elementId, c.options);
|
|
2564
2967
|
} else if (c.instance.render) {
|
|
@@ -2925,7 +3328,7 @@ var Switch = /*#__PURE__*/function () {
|
|
|
2925
3328
|
|
|
2926
3329
|
var WebsyTemplate = /*#__PURE__*/function () {
|
|
2927
3330
|
function WebsyTemplate(elementId, options) {
|
|
2928
|
-
var
|
|
3331
|
+
var _this23 = this;
|
|
2929
3332
|
|
|
2930
3333
|
_classCallCheck(this, WebsyTemplate);
|
|
2931
3334
|
|
|
@@ -2951,9 +3354,9 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
2951
3354
|
|
|
2952
3355
|
if (_typeof(options.template) === 'object' && options.template.url) {
|
|
2953
3356
|
this.templateService.get(options.template.url).then(function (templateString) {
|
|
2954
|
-
|
|
3357
|
+
_this23.options.template = templateString;
|
|
2955
3358
|
|
|
2956
|
-
|
|
3359
|
+
_this23.render();
|
|
2957
3360
|
});
|
|
2958
3361
|
} else {
|
|
2959
3362
|
this.render();
|
|
@@ -2963,7 +3366,7 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
2963
3366
|
_createClass(WebsyTemplate, [{
|
|
2964
3367
|
key: "buildHTML",
|
|
2965
3368
|
value: function buildHTML() {
|
|
2966
|
-
var
|
|
3369
|
+
var _this24 = this;
|
|
2967
3370
|
|
|
2968
3371
|
var html = "";
|
|
2969
3372
|
|
|
@@ -3025,14 +3428,14 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
3025
3428
|
}
|
|
3026
3429
|
|
|
3027
3430
|
if (polarity === true) {
|
|
3028
|
-
if (typeof
|
|
3431
|
+
if (typeof _this24.options.data[parts[0]] !== 'undefined' && _this24.options.data[parts[0]] === parts[1]) {
|
|
3029
3432
|
// remove the <if> tags
|
|
3030
3433
|
removeAll = false;
|
|
3031
3434
|
} else if (parts[0] === parts[1]) {
|
|
3032
3435
|
removeAll = false;
|
|
3033
3436
|
}
|
|
3034
3437
|
} else if (polarity === false) {
|
|
3035
|
-
if (typeof
|
|
3438
|
+
if (typeof _this24.options.data[parts[0]] !== 'undefined' && _this24.options.data[parts[0]] !== parts[1]) {
|
|
3036
3439
|
// remove the <if> tags
|
|
3037
3440
|
removeAll = false;
|
|
3038
3441
|
}
|
|
@@ -3259,10 +3662,10 @@ var WebsyUtils = {
|
|
|
3259
3662
|
var s = '';
|
|
3260
3663
|
var d = 1; // let out
|
|
3261
3664
|
|
|
3262
|
-
for (var
|
|
3263
|
-
if (n >= ranges[
|
|
3264
|
-
d = ranges[
|
|
3265
|
-
s = ranges[
|
|
3665
|
+
for (var _i6 = 0; _i6 < ranges.length; _i6++) {
|
|
3666
|
+
if (n >= ranges[_i6].divider) {
|
|
3667
|
+
d = ranges[_i6].divider;
|
|
3668
|
+
s = ranges[_i6].suffix; // out = (n / ranges[i].divider).toFixed(decimals).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$100,')
|
|
3266
3669
|
|
|
3267
3670
|
break;
|
|
3268
3671
|
}
|
|
@@ -3300,7 +3703,7 @@ var WebsyUtils = {
|
|
|
3300
3703
|
|
|
3301
3704
|
var WebsyTable = /*#__PURE__*/function () {
|
|
3302
3705
|
function WebsyTable(elementId, options) {
|
|
3303
|
-
var
|
|
3706
|
+
var _this25 = this;
|
|
3304
3707
|
|
|
3305
3708
|
_classCallCheck(this, WebsyTable);
|
|
3306
3709
|
|
|
@@ -3338,8 +3741,8 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
3338
3741
|
allowClear: false,
|
|
3339
3742
|
disableSearch: true,
|
|
3340
3743
|
onItemSelected: function onItemSelected(selectedItem) {
|
|
3341
|
-
if (
|
|
3342
|
-
|
|
3744
|
+
if (_this25.options.onChangePageSize) {
|
|
3745
|
+
_this25.options.onChangePageSize(selectedItem.value);
|
|
3343
3746
|
}
|
|
3344
3747
|
}
|
|
3345
3748
|
});
|
|
@@ -3360,7 +3763,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
3360
3763
|
_createClass(WebsyTable, [{
|
|
3361
3764
|
key: "appendRows",
|
|
3362
3765
|
value: function appendRows(data) {
|
|
3363
|
-
var
|
|
3766
|
+
var _this26 = this;
|
|
3364
3767
|
|
|
3365
3768
|
this.hideError();
|
|
3366
3769
|
var bodyHTML = '';
|
|
@@ -3368,37 +3771,41 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
3368
3771
|
if (data) {
|
|
3369
3772
|
bodyHTML += data.map(function (r, rowIndex) {
|
|
3370
3773
|
return '<tr>' + r.map(function (c, i) {
|
|
3371
|
-
if (
|
|
3774
|
+
if (_this26.options.columns[i].show !== false) {
|
|
3372
3775
|
var style = '';
|
|
3373
3776
|
|
|
3374
3777
|
if (c.style) {
|
|
3375
3778
|
style += c.style;
|
|
3376
3779
|
}
|
|
3377
3780
|
|
|
3378
|
-
if (
|
|
3379
|
-
style += "width: ".concat(
|
|
3781
|
+
if (_this26.options.columns[i].width) {
|
|
3782
|
+
style += "width: ".concat(_this26.options.columns[i].width, "; ");
|
|
3380
3783
|
}
|
|
3381
3784
|
|
|
3382
3785
|
if (c.backgroundColor) {
|
|
3383
3786
|
style += "background-color: ".concat(c.backgroundColor, "; ");
|
|
3787
|
+
|
|
3788
|
+
if (!c.color) {
|
|
3789
|
+
style += "color: ".concat(WebsyDesigns.Utils.getLightDark(c.backgroundColor), "; ");
|
|
3790
|
+
}
|
|
3384
3791
|
}
|
|
3385
3792
|
|
|
3386
3793
|
if (c.color) {
|
|
3387
3794
|
style += "color: ".concat(c.color, "; ");
|
|
3388
3795
|
}
|
|
3389
3796
|
|
|
3390
|
-
if (
|
|
3391
|
-
return "\n <td \n data-row-index='".concat(
|
|
3392
|
-
} else if ((
|
|
3393
|
-
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(
|
|
3797
|
+
if (_this26.options.columns[i].showAsLink === true && c.value.trim() !== '') {
|
|
3798
|
+
return "\n <td \n data-row-index='".concat(_this26.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this26.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(_this26.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this26.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
|
|
3799
|
+
} else if ((_this26.options.columns[i].showAsNavigatorLink === true || _this26.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
|
|
3800
|
+
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this26.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='trigger-item ").concat(_this26.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this26.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this26.options.columns[i].linkText || c.value, "</td>\n ");
|
|
3394
3801
|
} else {
|
|
3395
3802
|
var info = c.value;
|
|
3396
3803
|
|
|
3397
|
-
if (
|
|
3804
|
+
if (_this26.options.columns[i].showAsImage === true) {
|
|
3398
3805
|
c.value = "\n <img src='".concat(c.value, "'>\n ");
|
|
3399
3806
|
}
|
|
3400
3807
|
|
|
3401
|
-
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(
|
|
3808
|
+
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this26.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this26.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 ");
|
|
3402
3809
|
}
|
|
3403
3810
|
}
|
|
3404
3811
|
}).join('') + '</tr>';
|
|
@@ -3557,7 +3964,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
3557
3964
|
}, {
|
|
3558
3965
|
key: "render",
|
|
3559
3966
|
value: function render(data) {
|
|
3560
|
-
var
|
|
3967
|
+
var _this27 = this;
|
|
3561
3968
|
|
|
3562
3969
|
if (!this.options.columns) {
|
|
3563
3970
|
return;
|
|
@@ -3582,7 +3989,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
3582
3989
|
|
|
3583
3990
|
var headHTML = '<tr>' + this.options.columns.map(function (c, i) {
|
|
3584
3991
|
if (c.show !== false) {
|
|
3585
|
-
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 ?
|
|
3992
|
+
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 ? _this27.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
|
|
3586
3993
|
}
|
|
3587
3994
|
}).join('') + '</tr>';
|
|
3588
3995
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
@@ -3601,7 +4008,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
3601
4008
|
|
|
3602
4009
|
if (pagingEl) {
|
|
3603
4010
|
var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
|
|
3604
|
-
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(
|
|
4011
|
+
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this27.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
3605
4012
|
});
|
|
3606
4013
|
var startIndex = 0;
|
|
3607
4014
|
|
|
@@ -3664,12 +4071,550 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
3664
4071
|
|
|
3665
4072
|
return WebsyTable;
|
|
3666
4073
|
}();
|
|
4074
|
+
/* global WebsyDesigns */
|
|
4075
|
+
|
|
4076
|
+
|
|
4077
|
+
var WebsyTable2 = /*#__PURE__*/function () {
|
|
4078
|
+
function WebsyTable2(elementId, options) {
|
|
4079
|
+
var _this28 = this;
|
|
4080
|
+
|
|
4081
|
+
_classCallCheck(this, WebsyTable2);
|
|
4082
|
+
|
|
4083
|
+
var DEFAULTS = {
|
|
4084
|
+
pageSize: 20,
|
|
4085
|
+
paging: 'scroll',
|
|
4086
|
+
cellSize: 35,
|
|
4087
|
+
virtualScroll: false,
|
|
4088
|
+
leftColumns: 0
|
|
4089
|
+
};
|
|
4090
|
+
this.elementId = elementId;
|
|
4091
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
4092
|
+
this.rowCount = 0;
|
|
4093
|
+
this.busy = false;
|
|
4094
|
+
this.tooltipTimeoutFn = null;
|
|
4095
|
+
this.data = [];
|
|
4096
|
+
var el = document.getElementById(this.elementId);
|
|
4097
|
+
|
|
4098
|
+
if (el) {
|
|
4099
|
+
var html = "\n <div id='".concat(this.elementId, "_tableContainer' class='websy-vis-table ").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 <table id=\"").concat(this.elementId, "_table\"> \n <thead id=\"").concat(this.elementId, "_head\">\n </thead>\n <tbody id=\"").concat(this.elementId, "_body\">\n </tbody>\n <tfoot id=\"").concat(this.elementId, "_foot\">\n </tfoot>\n </table> \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, "_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 id=\"").concat(this.elementId, "_dropdownContainer\"></div>\n <div id=\"").concat(this.elementId, "_loadingContainer\"></div>\n </div>\n ");
|
|
4100
|
+
|
|
4101
|
+
if (this.options.paging === 'pages') {
|
|
4102
|
+
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 ");
|
|
4103
|
+
}
|
|
4104
|
+
|
|
4105
|
+
var pageOptions = [10, 20, 50, 100, 200];
|
|
4106
|
+
el.innerHTML = html;
|
|
4107
|
+
|
|
4108
|
+
if (this.options.paging === 'pages') {
|
|
4109
|
+
this.pageSizeSelector = new WebsyDesigns.Dropdown("".concat(this.elementId, "_pageSizeSelector"), {
|
|
4110
|
+
selectedItems: [pageOptions.indexOf(this.options.pageSize)],
|
|
4111
|
+
items: pageOptions.map(function (p) {
|
|
4112
|
+
return {
|
|
4113
|
+
label: p.toString(),
|
|
4114
|
+
value: p
|
|
4115
|
+
};
|
|
4116
|
+
}),
|
|
4117
|
+
allowClear: false,
|
|
4118
|
+
disableSearch: true,
|
|
4119
|
+
onItemSelected: function onItemSelected(selectedItem) {
|
|
4120
|
+
if (_this28.options.onChangePageSize) {
|
|
4121
|
+
_this28.options.onChangePageSize(selectedItem.value);
|
|
4122
|
+
}
|
|
4123
|
+
}
|
|
4124
|
+
});
|
|
4125
|
+
}
|
|
4126
|
+
|
|
4127
|
+
el.addEventListener('click', this.handleClick.bind(this));
|
|
4128
|
+
el.addEventListener('mouseout', this.handleMouseOut.bind(this));
|
|
4129
|
+
el.addEventListener('mousemove', this.handleMouseMove.bind(this));
|
|
4130
|
+
el.addEventListener('mousedown', this.handleMouseDown.bind(this));
|
|
4131
|
+
el.addEventListener('mouseup', this.handleMouseUp.bind(this));
|
|
4132
|
+
document.addEventListener('mouseup', this.handleGlobalMouseUp.bind(this));
|
|
4133
|
+
var scrollEl = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
4134
|
+
scrollEl.addEventListener('scroll', this.handleScroll.bind(this));
|
|
4135
|
+
this.loadingDialog = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loadingContainer"));
|
|
4136
|
+
this.render();
|
|
4137
|
+
} else {
|
|
4138
|
+
console.error("No element found with ID ".concat(this.elementId));
|
|
4139
|
+
}
|
|
4140
|
+
}
|
|
4141
|
+
|
|
4142
|
+
_createClass(WebsyTable2, [{
|
|
4143
|
+
key: "appendRows",
|
|
4144
|
+
value: function appendRows(data) {
|
|
4145
|
+
var _this29 = this;
|
|
4146
|
+
|
|
4147
|
+
this.hideError();
|
|
4148
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
|
|
4149
|
+
var bodyHTML = '';
|
|
4150
|
+
|
|
4151
|
+
if (data) {
|
|
4152
|
+
bodyHTML += data.map(function (r, rowIndex) {
|
|
4153
|
+
return '<tr>' + r.map(function (c, i) {
|
|
4154
|
+
if (_this29.options.columns[i].show !== false) {
|
|
4155
|
+
var style = "height: ".concat(_this29.options.cellSize, "px; line-height: ").concat(_this29.options.cellSize, "px;");
|
|
4156
|
+
|
|
4157
|
+
if (c.style) {
|
|
4158
|
+
style += c.style;
|
|
4159
|
+
}
|
|
4160
|
+
|
|
4161
|
+
if (_this29.options.columns[i].width) {
|
|
4162
|
+
style += "width: ".concat(_this29.options.columns[i].width, "; ");
|
|
4163
|
+
}
|
|
4164
|
+
|
|
4165
|
+
if (c.backgroundColor) {
|
|
4166
|
+
style += "background-color: ".concat(c.backgroundColor, "; ");
|
|
4167
|
+
}
|
|
4168
|
+
|
|
4169
|
+
if (c.color) {
|
|
4170
|
+
style += "color: ".concat(c.color, "; ");
|
|
4171
|
+
}
|
|
4172
|
+
|
|
4173
|
+
if (_this29.options.columns[i].showAsLink === true && c.value.trim() !== '') {
|
|
4174
|
+
return "\n <td \n data-row-index='".concat(_this29.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this29.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(_this29.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this29.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
|
|
4175
|
+
} else if ((_this29.options.columns[i].showAsNavigatorLink === true || _this29.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
|
|
4176
|
+
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this29.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='trigger-item ").concat(_this29.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this29.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this29.options.columns[i].linkText || c.value, "</td>\n ");
|
|
4177
|
+
} else {
|
|
4178
|
+
var info = c.value;
|
|
4179
|
+
|
|
4180
|
+
if (_this29.options.columns[i].showAsImage === true) {
|
|
4181
|
+
c.value = "\n <img src='".concat(c.value, "'>\n ");
|
|
4182
|
+
}
|
|
4183
|
+
|
|
4184
|
+
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this29.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this29.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 ");
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
}).join('') + '</tr>';
|
|
4188
|
+
}).join('');
|
|
4189
|
+
this.data = this.data.concat(data);
|
|
4190
|
+
this.rowCount = this.data.length;
|
|
4191
|
+
}
|
|
4192
|
+
|
|
4193
|
+
bodyEl.innerHTML += bodyHTML;
|
|
4194
|
+
|
|
4195
|
+
if (this.options.virtualScroll === true) {
|
|
4196
|
+
// get height of the thead
|
|
4197
|
+
if (this.options.paging !== 'pages') {
|
|
4198
|
+
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
4199
|
+
var vScrollContainerEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
|
|
4200
|
+
vScrollContainerEl.style.top = "".concat(headEl.clientHeight, "px");
|
|
4201
|
+
}
|
|
4202
|
+
|
|
4203
|
+
var hScrollContainerEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
|
|
4204
|
+
var left = 0;
|
|
4205
|
+
var cells = bodyEl.querySelectorAll("tr:first-of-type td");
|
|
4206
|
+
|
|
4207
|
+
for (var i = 0; i < this.options.leftColumns; i++) {
|
|
4208
|
+
left += cells[i].offsetWidth || cells[i].clientWidth;
|
|
4209
|
+
}
|
|
4210
|
+
|
|
4211
|
+
hScrollContainerEl.style.left = "".concat(left, "px");
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
}, {
|
|
4215
|
+
key: "buildSearchIcon",
|
|
4216
|
+
value: function buildSearchIcon(columnIndex) {
|
|
4217
|
+
return "\n <div class=\"websy-table-search-icon\" data-col-index=\"".concat(columnIndex, "\">\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 ");
|
|
4218
|
+
}
|
|
4219
|
+
}, {
|
|
4220
|
+
key: "handleClick",
|
|
4221
|
+
value: function handleClick(event) {
|
|
4222
|
+
if (event.target.classList.contains('download-button')) {
|
|
4223
|
+
window.viewManager.dataExportController.exportData(this.options.model);
|
|
4224
|
+
}
|
|
4225
|
+
|
|
4226
|
+
if (event.target.classList.contains('sortable-column')) {
|
|
4227
|
+
var colIndex = +event.target.getAttribute('data-index');
|
|
4228
|
+
var column = this.options.columns[colIndex];
|
|
4229
|
+
|
|
4230
|
+
if (this.options.onSort) {
|
|
4231
|
+
this.options.onSort(event, column, colIndex);
|
|
4232
|
+
} else {
|
|
4233
|
+
this.internalSort(column, colIndex);
|
|
4234
|
+
} // const colIndex = +event.target.getAttribute('data-index')
|
|
4235
|
+
// const dimIndex = +event.target.getAttribute('data-dim-index')
|
|
4236
|
+
// const expIndex = +event.target.getAttribute('data-exp-index')
|
|
4237
|
+
// const reverse = event.target.getAttribute('data-reverse') === 'true'
|
|
4238
|
+
// const patchDefs = [{
|
|
4239
|
+
// qOp: 'replace',
|
|
4240
|
+
// qPath: '/qHyperCubeDef/qInterColumnSortOrder',
|
|
4241
|
+
// qValue: JSON.stringify([colIndex])
|
|
4242
|
+
// }]
|
|
4243
|
+
// patchDefs.push({
|
|
4244
|
+
// qOp: 'replace',
|
|
4245
|
+
// qPath: `/qHyperCubeDef/${dimIndex > -1 ? 'qDimensions' : 'qMeasures'}/${dimIndex > -1 ? dimIndex : expIndex}/qDef/qReverseSort`,
|
|
4246
|
+
// qValue: JSON.stringify(reverse)
|
|
4247
|
+
// })
|
|
4248
|
+
// this.options.model.applyPatches(patchDefs) // .then(() => this.render())
|
|
4249
|
+
|
|
4250
|
+
} else if (event.target.classList.contains('websy-table-search-icon')) {
|
|
4251
|
+
// let field = event.target.getAttribute('data-field')
|
|
4252
|
+
// window.viewManager.views.global.objects[1].instance.show(field, { x: event.pageX, y: event.pageY }, () => {
|
|
4253
|
+
// event.target.classList.remove('active')
|
|
4254
|
+
// })
|
|
4255
|
+
var _colIndex2 = +event.target.getAttribute('data-col-index');
|
|
4256
|
+
|
|
4257
|
+
if (this.options.columns[_colIndex2].onSearch) {
|
|
4258
|
+
this.options.columns[_colIndex2].onSearch(event, this.options.columns[_colIndex2]);
|
|
4259
|
+
}
|
|
4260
|
+
} else if (event.target.classList.contains('clickable')) {
|
|
4261
|
+
var _colIndex3 = +event.target.getAttribute('data-col-index');
|
|
4262
|
+
|
|
4263
|
+
var rowIndex = +event.target.getAttribute('data-row-index');
|
|
4264
|
+
|
|
4265
|
+
if (this.options.onClick) {
|
|
4266
|
+
this.options.onClick(event, this.data[rowIndex][_colIndex3], this.data[rowIndex], this.options.columns[_colIndex3]);
|
|
4267
|
+
}
|
|
4268
|
+
} else if (event.target.classList.contains('websy-page-num')) {
|
|
4269
|
+
var pageNum = +event.target.getAttribute('data-page');
|
|
4270
|
+
|
|
4271
|
+
if (this.options.onSetPage) {
|
|
4272
|
+
this.options.onSetPage(pageNum);
|
|
4273
|
+
}
|
|
4274
|
+
}
|
|
4275
|
+
}
|
|
4276
|
+
}, {
|
|
4277
|
+
key: "handleMouseDown",
|
|
4278
|
+
value: function handleMouseDown(event) {
|
|
4279
|
+
if (event.target.classList.contains('websy-scroll-handle')) {
|
|
4280
|
+
this.scrolling = true;
|
|
4281
|
+
var el = document.getElementById(this.elementId);
|
|
4282
|
+
el.classList.add('scrolling');
|
|
4283
|
+
}
|
|
4284
|
+
|
|
4285
|
+
if (event.target.classList.contains('websy-scroll-handle-x')) {
|
|
4286
|
+
var handleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
4287
|
+
this.handleXStart = handleEl.offsetLeft;
|
|
4288
|
+
this.scrollXStart = event.clientX;
|
|
4289
|
+
this.scrollDirection = 'X';
|
|
4290
|
+
}
|
|
4291
|
+
}
|
|
4292
|
+
}, {
|
|
4293
|
+
key: "handleGlobalMouseUp",
|
|
4294
|
+
value: function handleGlobalMouseUp(event) {
|
|
4295
|
+
this.scrolling = false;
|
|
4296
|
+
var el = document.getElementById(this.elementId);
|
|
4297
|
+
el.classList.remove('scrolling');
|
|
4298
|
+
}
|
|
4299
|
+
}, {
|
|
4300
|
+
key: "handleMouseUp",
|
|
4301
|
+
value: function handleMouseUp(event) {
|
|
4302
|
+
this.scrolling = false;
|
|
4303
|
+
var el = document.getElementById(this.elementId);
|
|
4304
|
+
el.classList.remove('scrolling');
|
|
4305
|
+
}
|
|
4306
|
+
}, {
|
|
4307
|
+
key: "handleMouseMove",
|
|
4308
|
+
value: function handleMouseMove(event) {
|
|
4309
|
+
if (this.tooltipTimeoutFn) {
|
|
4310
|
+
event.target.classList.remove('websy-delayed-info');
|
|
4311
|
+
clearTimeout(this.tooltipTimeoutFn);
|
|
4312
|
+
}
|
|
4313
|
+
|
|
4314
|
+
if (event.target.tagName === 'TD') {
|
|
4315
|
+
this.tooltipTimeoutFn = setTimeout(function () {
|
|
4316
|
+
event.target.classList.add('websy-delayed-info');
|
|
4317
|
+
}, 500);
|
|
4318
|
+
}
|
|
4319
|
+
|
|
4320
|
+
if (this.scrolling === true && this.options.virtualScroll === true) {
|
|
4321
|
+
var tableContainerEl = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
4322
|
+
|
|
4323
|
+
if (this.scrollDirection === 'X') {
|
|
4324
|
+
var handleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle")); // console.log(this.handleXStart + handleEl.offsetWidth + (event.clientX - this.scrollXStart), this.columnParameters.scrollableWidth)
|
|
4325
|
+
|
|
4326
|
+
var startPoint = 0;
|
|
4327
|
+
|
|
4328
|
+
if (this.handleXStart + (event.clientX - this.scrollXStart) < this.columnParameters.scrollableWidth - handleEl.offsetWidth) {
|
|
4329
|
+
handleEl.style.left = "".concat(this.handleXStart + (event.clientX - this.scrollXStart), "px");
|
|
4330
|
+
startPoint = this.handleXStart + (event.clientX - this.scrollXStart);
|
|
4331
|
+
} else {
|
|
4332
|
+
startPoint = this.columnParameters.scrollableWidth - handleEl.offsetWidth;
|
|
4333
|
+
}
|
|
4334
|
+
|
|
4335
|
+
if (this.handleXStart + (event.clientX - this.scrollXStart) < 0) {
|
|
4336
|
+
handleEl.style.left = 0;
|
|
4337
|
+
startPoint = 0;
|
|
4338
|
+
}
|
|
4339
|
+
|
|
4340
|
+
if (this.options.onScrollX) {
|
|
4341
|
+
this.options.onScrollX(startPoint);
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
}, {
|
|
4347
|
+
key: "handleMouseOut",
|
|
4348
|
+
value: function handleMouseOut(event) {
|
|
4349
|
+
if (this.tooltipTimeoutFn) {
|
|
4350
|
+
event.target.classList.remove('websy-delayed-info');
|
|
4351
|
+
clearTimeout(this.tooltipTimeoutFn);
|
|
4352
|
+
}
|
|
4353
|
+
}
|
|
4354
|
+
}, {
|
|
4355
|
+
key: "handleScroll",
|
|
4356
|
+
value: function handleScroll(event) {
|
|
4357
|
+
if (this.options.onScroll && this.options.paging === 'scroll') {
|
|
4358
|
+
this.options.onScroll(event);
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
}, {
|
|
4362
|
+
key: "hideError",
|
|
4363
|
+
value: function hideError() {
|
|
4364
|
+
var el = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
4365
|
+
|
|
4366
|
+
if (el) {
|
|
4367
|
+
el.classList.remove('has-error');
|
|
4368
|
+
}
|
|
4369
|
+
|
|
4370
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_table"));
|
|
4371
|
+
tableEl.classList.remove('hidden');
|
|
4372
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
4373
|
+
|
|
4374
|
+
if (containerEl) {
|
|
4375
|
+
containerEl.classList.remove('active');
|
|
4376
|
+
}
|
|
4377
|
+
}
|
|
4378
|
+
}, {
|
|
4379
|
+
key: "hideLoading",
|
|
4380
|
+
value: function hideLoading() {
|
|
4381
|
+
this.loadingDialog.hide();
|
|
4382
|
+
}
|
|
4383
|
+
}, {
|
|
4384
|
+
key: "internalSort",
|
|
4385
|
+
value: function internalSort(column, colIndex) {
|
|
4386
|
+
this.options.columns.forEach(function (c, i) {
|
|
4387
|
+
c.activeSort = i === colIndex;
|
|
4388
|
+
});
|
|
4389
|
+
|
|
4390
|
+
if (column.sortFunction) {
|
|
4391
|
+
this.data = column.sortFunction(this.data, column);
|
|
4392
|
+
} else {
|
|
4393
|
+
var sortProp = 'value';
|
|
4394
|
+
var sortOrder = column.sort === 'asc' ? 'desc' : 'asc';
|
|
4395
|
+
column.sort = sortOrder;
|
|
4396
|
+
var sortType = column.sortType || 'alphanumeric';
|
|
4397
|
+
|
|
4398
|
+
if (column.sortProp) {
|
|
4399
|
+
sortProp = column.sortProp;
|
|
4400
|
+
}
|
|
4401
|
+
|
|
4402
|
+
this.data.sort(function (a, b) {
|
|
4403
|
+
switch (sortType) {
|
|
4404
|
+
case 'numeric':
|
|
4405
|
+
if (sortOrder === 'asc') {
|
|
4406
|
+
return a[colIndex][sortProp] - b[colIndex][sortProp];
|
|
4407
|
+
} else {
|
|
4408
|
+
return b[colIndex][sortProp] - a[colIndex][sortProp];
|
|
4409
|
+
}
|
|
4410
|
+
|
|
4411
|
+
default:
|
|
4412
|
+
if (sortOrder === 'asc') {
|
|
4413
|
+
return a[colIndex][sortProp] > b[colIndex][sortProp] ? 1 : -1;
|
|
4414
|
+
} else {
|
|
4415
|
+
return a[colIndex][sortProp] < b[colIndex][sortProp] ? 1 : -1;
|
|
4416
|
+
}
|
|
4417
|
+
|
|
4418
|
+
}
|
|
4419
|
+
});
|
|
4420
|
+
}
|
|
4421
|
+
|
|
4422
|
+
this.render(this.data);
|
|
4423
|
+
}
|
|
4424
|
+
}, {
|
|
4425
|
+
key: "render",
|
|
4426
|
+
value: function render(data) {
|
|
4427
|
+
var _this30 = this;
|
|
4428
|
+
|
|
4429
|
+
if (!this.options.columns) {
|
|
4430
|
+
return;
|
|
4431
|
+
}
|
|
4432
|
+
|
|
4433
|
+
this.hideError();
|
|
4434
|
+
this.data = [];
|
|
4435
|
+
this.rowCount = 0;
|
|
4436
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
|
|
4437
|
+
bodyEl.innerHTML = '';
|
|
4438
|
+
|
|
4439
|
+
if (this.options.allowDownload === true) {
|
|
4440
|
+
// doesn't do anything yet
|
|
4441
|
+
var el = document.getElementById(this.elementId);
|
|
4442
|
+
|
|
4443
|
+
if (el) {
|
|
4444
|
+
el.classList.add('allow-download');
|
|
4445
|
+
} else {
|
|
4446
|
+
el.classList.remove('allow-download');
|
|
4447
|
+
}
|
|
4448
|
+
} // let colGroupHTML = this.options.columns.map(c => `<col style="${c.width ? 'width: ' + c.width : ''}"></col>`)
|
|
4449
|
+
|
|
4450
|
+
|
|
4451
|
+
var headHTML = '<tr>' + this.options.columns.map(function (c, i) {
|
|
4452
|
+
if (c.show !== false) {
|
|
4453
|
+
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 ? _this30.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
|
|
4454
|
+
}
|
|
4455
|
+
}).join('') + '</tr>';
|
|
4456
|
+
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
4457
|
+
headEl.innerHTML = headHTML;
|
|
4458
|
+
var dropdownHTML = "";
|
|
4459
|
+
this.options.columns.forEach(function (c, i) {
|
|
4460
|
+
if (c.searchable && c.searchField) {
|
|
4461
|
+
dropdownHTML += "\n <div id=\"".concat(_this30.elementId, "_columnSearch_").concat(i, "\" class=\"websy-modal-dropdown\"></div>\n ");
|
|
4462
|
+
}
|
|
4463
|
+
});
|
|
4464
|
+
var dropdownEl = document.getElementById("".concat(this.elementId, "_dropdownContainer"));
|
|
4465
|
+
dropdownEl.innerHTML = dropdownHTML; // const colGroupEl = document.getElementById(`${this.elementId}_cols`)
|
|
4466
|
+
// colGroupEl.innerHTML = colGroupHTML
|
|
4467
|
+
// let footHTML = '<tr>' + this.options.columns.map((c, i) => {
|
|
4468
|
+
// if (c.show !== false) {
|
|
4469
|
+
// return `
|
|
4470
|
+
// <th></th>
|
|
4471
|
+
// `
|
|
4472
|
+
// }
|
|
4473
|
+
// }).join('') + '</tr>'
|
|
4474
|
+
// const footEl = document.getElementById(`${this.elementId}_foot`)
|
|
4475
|
+
// footEl.innerHTML = footHTML
|
|
4476
|
+
|
|
4477
|
+
if (this.options.paging === 'pages') {
|
|
4478
|
+
var pagingEl = document.getElementById("".concat(this.elementId, "_pageList"));
|
|
4479
|
+
|
|
4480
|
+
if (pagingEl) {
|
|
4481
|
+
var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
|
|
4482
|
+
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this30.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
4483
|
+
});
|
|
4484
|
+
var startIndex = 0;
|
|
4485
|
+
|
|
4486
|
+
if (this.options.pageCount > 8) {
|
|
4487
|
+
startIndex = Math.max(0, this.options.pageNum - 4);
|
|
4488
|
+
pages = pages.splice(startIndex, 10);
|
|
4489
|
+
|
|
4490
|
+
if (startIndex > 0) {
|
|
4491
|
+
pages.splice(0, 0, "<li>Page </li><li data-page=\"0\" class=\"websy-page-num\">First</li><li>...</li>");
|
|
4492
|
+
} else {
|
|
4493
|
+
pages.splice(0, 0, '<li>Page </li>');
|
|
4494
|
+
}
|
|
4495
|
+
|
|
4496
|
+
if (this.options.pageNum < this.options.pageCount - 1) {
|
|
4497
|
+
pages.push('<li>...</li>');
|
|
4498
|
+
pages.push("<li data-page=\"".concat(this.options.pageCount - 1, "\" class=\"websy-page-num\">Last</li>"));
|
|
4499
|
+
}
|
|
4500
|
+
}
|
|
4501
|
+
|
|
4502
|
+
pagingEl.innerHTML = pages.join('');
|
|
4503
|
+
}
|
|
4504
|
+
}
|
|
4505
|
+
|
|
4506
|
+
if (data) {
|
|
4507
|
+
this.appendRows(data);
|
|
4508
|
+
}
|
|
4509
|
+
}
|
|
4510
|
+
}, {
|
|
4511
|
+
key: "showError",
|
|
4512
|
+
value: function showError(options) {
|
|
4513
|
+
var el = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
4514
|
+
|
|
4515
|
+
if (el) {
|
|
4516
|
+
el.classList.add('has-error');
|
|
4517
|
+
}
|
|
4518
|
+
|
|
4519
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_table"));
|
|
4520
|
+
tableEl.classList.add('hidden');
|
|
4521
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
4522
|
+
|
|
4523
|
+
if (containerEl) {
|
|
4524
|
+
containerEl.classList.add('active');
|
|
4525
|
+
}
|
|
4526
|
+
|
|
4527
|
+
if (options.title) {
|
|
4528
|
+
var titleEl = document.getElementById("".concat(this.elementId, "_errorTitle"));
|
|
4529
|
+
|
|
4530
|
+
if (titleEl) {
|
|
4531
|
+
titleEl.innerHTML = options.title;
|
|
4532
|
+
}
|
|
4533
|
+
}
|
|
4534
|
+
|
|
4535
|
+
if (options.message) {
|
|
4536
|
+
var messageEl = document.getElementById("".concat(this.elementId, "_errorMessage"));
|
|
4537
|
+
|
|
4538
|
+
if (messageEl) {
|
|
4539
|
+
messageEl.innerHTML = options.message;
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
}
|
|
4543
|
+
}, {
|
|
4544
|
+
key: "setHorizontalScroll",
|
|
4545
|
+
value: function setHorizontalScroll(options) {
|
|
4546
|
+
var el = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
4547
|
+
|
|
4548
|
+
if (options.width) {
|
|
4549
|
+
el.style.width = "".concat(options.width, "px");
|
|
4550
|
+
}
|
|
4551
|
+
}
|
|
4552
|
+
}, {
|
|
4553
|
+
key: "setWidth",
|
|
4554
|
+
value: function setWidth(width) {
|
|
4555
|
+
var el = document.getElementById("".concat(this.elementId, "_table"));
|
|
4556
|
+
|
|
4557
|
+
if (el) {
|
|
4558
|
+
el.style.width = "".concat(width, "px");
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4561
|
+
}, {
|
|
4562
|
+
key: "showLoading",
|
|
4563
|
+
value: function showLoading(options) {
|
|
4564
|
+
this.loadingDialog.show(options);
|
|
4565
|
+
}
|
|
4566
|
+
}, {
|
|
4567
|
+
key: "getColumnParameters",
|
|
4568
|
+
value: function getColumnParameters(values) {
|
|
4569
|
+
var _this31 = this;
|
|
4570
|
+
|
|
4571
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_table"));
|
|
4572
|
+
tableEl.style.tableLayout = 'auto';
|
|
4573
|
+
tableEl.style.width = 'auto';
|
|
4574
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
|
|
4575
|
+
bodyEl.innerHTML = '<tr>' + values.map(function (c) {
|
|
4576
|
+
return "\n <td \n style='height: ".concat(_this31.options.cellSize, "px; line-height: ").concat(_this31.options.cellSize, "px;'\n >").concat(c.value || ' ', "</td>\n ");
|
|
4577
|
+
}).join('') + '</tr>'; // get height of the first data cell
|
|
4578
|
+
|
|
4579
|
+
var cells = bodyEl.querySelectorAll("tr:first-of-type td");
|
|
4580
|
+
var tableContainerEl = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
4581
|
+
var cellHeight = cells[0].offsetHeight || cells[0].clientHeight;
|
|
4582
|
+
var cellWidths = [];
|
|
4583
|
+
var nonScrollableWidth = 0;
|
|
4584
|
+
|
|
4585
|
+
for (var i = 0; i < cells.length; i++) {
|
|
4586
|
+
if (i < this.options.leftColumns) {
|
|
4587
|
+
nonScrollableWidth += values[i].width || cells[i].offsetWidth || cells[i].clientWidth;
|
|
4588
|
+
}
|
|
4589
|
+
|
|
4590
|
+
cellWidths.push(values[i].width || cells[i].offsetWidth || cells[i].clientWidth);
|
|
4591
|
+
} // const cellWidth = firstDataCell.offsetWidth || firstDataCell.clientWidth
|
|
4592
|
+
// tableEl.style.width = ''
|
|
4593
|
+
|
|
4594
|
+
|
|
4595
|
+
this.columnParameters = {
|
|
4596
|
+
cellHeight: cellHeight,
|
|
4597
|
+
cellWidths: cellWidths,
|
|
4598
|
+
availableHeight: tableContainerEl.offsetHeight || tableContainerEl.clientHeight,
|
|
4599
|
+
availableWidth: tableContainerEl.offsetWidth || tableContainerEl.clientWidth,
|
|
4600
|
+
nonScrollableWidth: nonScrollableWidth,
|
|
4601
|
+
scrollableWidth: (tableContainerEl.offsetWidth || tableContainerEl.clientWidth) - nonScrollableWidth
|
|
4602
|
+
};
|
|
4603
|
+
bodyEl.innerHTML = '';
|
|
4604
|
+
tableEl.style.tableLayout = '';
|
|
4605
|
+
tableEl.style.width = '';
|
|
4606
|
+
return this.columnParameters;
|
|
4607
|
+
}
|
|
4608
|
+
}]);
|
|
4609
|
+
|
|
4610
|
+
return WebsyTable2;
|
|
4611
|
+
}();
|
|
3667
4612
|
/* global d3 include WebsyDesigns */
|
|
3668
4613
|
|
|
3669
4614
|
|
|
3670
4615
|
var WebsyChart = /*#__PURE__*/function () {
|
|
3671
4616
|
function WebsyChart(elementId, options) {
|
|
3672
|
-
var
|
|
4617
|
+
var _this32 = this;
|
|
3673
4618
|
|
|
3674
4619
|
_classCallCheck(this, WebsyChart);
|
|
3675
4620
|
|
|
@@ -3717,22 +4662,22 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3717
4662
|
this.invertOverride = function (input, input2) {
|
|
3718
4663
|
var xAxis = 'bottomAxis';
|
|
3719
4664
|
|
|
3720
|
-
if (
|
|
4665
|
+
if (_this32.options.orientation === 'horizontal') {
|
|
3721
4666
|
xAxis = 'leftAxis';
|
|
3722
4667
|
}
|
|
3723
4668
|
|
|
3724
|
-
var width =
|
|
4669
|
+
var width = _this32[xAxis].step();
|
|
3725
4670
|
|
|
3726
4671
|
var output;
|
|
3727
4672
|
|
|
3728
|
-
var domain = _toConsumableArray(
|
|
4673
|
+
var domain = _toConsumableArray(_this32[xAxis].domain());
|
|
3729
4674
|
|
|
3730
|
-
if (
|
|
4675
|
+
if (_this32.options.orientation === 'horizontal') {
|
|
3731
4676
|
domain = domain.reverse();
|
|
3732
4677
|
}
|
|
3733
4678
|
|
|
3734
4679
|
for (var j = 0; j < domain.length; j++) {
|
|
3735
|
-
var breakA =
|
|
4680
|
+
var breakA = _this32[xAxis](domain[j]) - width / 2;
|
|
3736
4681
|
var breakB = breakA + width;
|
|
3737
4682
|
|
|
3738
4683
|
if (input > breakA && input <= breakB) {
|
|
@@ -3832,10 +4777,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3832
4777
|
}, {
|
|
3833
4778
|
key: "handleEventMouseMove",
|
|
3834
4779
|
value: function handleEventMouseMove(event, d) {
|
|
3835
|
-
var
|
|
4780
|
+
var _this33 = this;
|
|
3836
4781
|
|
|
3837
4782
|
var bisectDate = d3.bisector(function (d) {
|
|
3838
|
-
return
|
|
4783
|
+
return _this33.parseX(d.x.value);
|
|
3839
4784
|
}).left;
|
|
3840
4785
|
|
|
3841
4786
|
if (this.options.showTrackingLine === true && d3.pointer(event)) {
|
|
@@ -3874,8 +4819,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3874
4819
|
}
|
|
3875
4820
|
|
|
3876
4821
|
this.options.data.series.forEach(function (s) {
|
|
3877
|
-
if (
|
|
3878
|
-
xPoint =
|
|
4822
|
+
if (_this33.options.data[xData].scale !== 'Time') {
|
|
4823
|
+
xPoint = _this33[xAxis](_this33.parseX(xLabel));
|
|
3879
4824
|
s.data.forEach(function (d) {
|
|
3880
4825
|
if (d.x.value === xLabel) {
|
|
3881
4826
|
if (!d.y.color) {
|
|
@@ -3890,13 +4835,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3890
4835
|
var pointA = s.data[index - 1];
|
|
3891
4836
|
var pointB = s.data[index];
|
|
3892
4837
|
|
|
3893
|
-
if (
|
|
4838
|
+
if (_this33.options.orientation === 'horizontal') {
|
|
3894
4839
|
pointA = _toConsumableArray(s.data).reverse()[index - 1];
|
|
3895
4840
|
pointB = _toConsumableArray(s.data).reverse()[index];
|
|
3896
4841
|
}
|
|
3897
4842
|
|
|
3898
4843
|
if (pointA && !pointB) {
|
|
3899
|
-
xPoint =
|
|
4844
|
+
xPoint = _this33[xAxis](_this33.parseX(pointA.x.value));
|
|
3900
4845
|
tooltipTitle = pointA.x.value;
|
|
3901
4846
|
|
|
3902
4847
|
if (!pointA.y.color) {
|
|
@@ -3906,12 +4851,12 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3906
4851
|
tooltipData.push(pointA.y);
|
|
3907
4852
|
|
|
3908
4853
|
if (typeof pointA.x.value.getTime !== 'undefined') {
|
|
3909
|
-
tooltipTitle = d3.timeFormat(
|
|
4854
|
+
tooltipTitle = d3.timeFormat(_this33.options.dateFormat || _this33.options.calculatedTimeFormatPattern)(pointA.x.value);
|
|
3910
4855
|
}
|
|
3911
4856
|
}
|
|
3912
4857
|
|
|
3913
4858
|
if (pointB && !pointA) {
|
|
3914
|
-
xPoint =
|
|
4859
|
+
xPoint = _this33[xAxis](_this33.parseX(pointB.x.value));
|
|
3915
4860
|
tooltipTitle = pointB.x.value;
|
|
3916
4861
|
|
|
3917
4862
|
if (!pointB.y.color) {
|
|
@@ -3921,14 +4866,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3921
4866
|
tooltipData.push(pointB.y);
|
|
3922
4867
|
|
|
3923
4868
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
3924
|
-
tooltipTitle = d3.timeFormat(
|
|
4869
|
+
tooltipTitle = d3.timeFormat(_this33.options.dateFormat || _this33.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
3925
4870
|
}
|
|
3926
4871
|
}
|
|
3927
4872
|
|
|
3928
4873
|
if (pointA && pointB) {
|
|
3929
|
-
var d0 =
|
|
4874
|
+
var d0 = _this33[xAxis](_this33.parseX(pointA.x.value));
|
|
3930
4875
|
|
|
3931
|
-
var d1 =
|
|
4876
|
+
var d1 = _this33[xAxis](_this33.parseX(pointB.x.value));
|
|
3932
4877
|
|
|
3933
4878
|
var mid = Math.abs(d0 - d1) / 2;
|
|
3934
4879
|
|
|
@@ -3937,7 +4882,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3937
4882
|
tooltipTitle = pointB.x.value;
|
|
3938
4883
|
|
|
3939
4884
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
3940
|
-
tooltipTitle = d3.timeFormat(
|
|
4885
|
+
tooltipTitle = d3.timeFormat(_this33.options.dateFormat || _this33.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
3941
4886
|
}
|
|
3942
4887
|
|
|
3943
4888
|
if (!pointB.y.color) {
|
|
@@ -3950,7 +4895,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
3950
4895
|
tooltipTitle = pointA.x.value;
|
|
3951
4896
|
|
|
3952
4897
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
3953
|
-
tooltipTitle = d3.timeFormat(
|
|
4898
|
+
tooltipTitle = d3.timeFormat(_this33.options.dateFormat || _this33.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
3954
4899
|
}
|
|
3955
4900
|
|
|
3956
4901
|
if (!pointA.y.color) {
|
|
@@ -4005,7 +4950,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4005
4950
|
}
|
|
4006
4951
|
|
|
4007
4952
|
this.tooltip.setHeight(this.plotHeight);
|
|
4008
|
-
this.tooltip.show(tooltipTitle, tooltipHTML, posOptions); // }
|
|
4953
|
+
this.options.showTooltip && this.tooltip.show(tooltipTitle, tooltipHTML, posOptions); // }
|
|
4009
4954
|
// else {
|
|
4010
4955
|
// xPoint = x0
|
|
4011
4956
|
// }
|
|
@@ -4055,7 +5000,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4055
5000
|
}, {
|
|
4056
5001
|
key: "render",
|
|
4057
5002
|
value: function render(options) {
|
|
4058
|
-
var
|
|
5003
|
+
var _this34 = this;
|
|
4059
5004
|
|
|
4060
5005
|
/* global d3 options */
|
|
4061
5006
|
if (typeof options !== 'undefined') {
|
|
@@ -4124,7 +5069,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4124
5069
|
var legendData = this.options.data.series.map(function (s, i) {
|
|
4125
5070
|
return {
|
|
4126
5071
|
value: s.label || s.key,
|
|
4127
|
-
color: s.color ||
|
|
5072
|
+
color: s.color || _this34.options.colors[i % _this34.options.colors.length]
|
|
4128
5073
|
};
|
|
4129
5074
|
});
|
|
4130
5075
|
|
|
@@ -4363,7 +5308,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4363
5308
|
|
|
4364
5309
|
if (this.options.data.bottom.formatter) {
|
|
4365
5310
|
bAxisFunc.tickFormat(function (d) {
|
|
4366
|
-
return
|
|
5311
|
+
return _this34.options.data.bottom.formatter(d);
|
|
4367
5312
|
});
|
|
4368
5313
|
}
|
|
4369
5314
|
|
|
@@ -4390,8 +5335,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4390
5335
|
|
|
4391
5336
|
if (this.options.margin.axisLeft > 0) {
|
|
4392
5337
|
this.leftAxisLayer.call(d3.axisLeft(this.leftAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
4393
|
-
if (
|
|
4394
|
-
d =
|
|
5338
|
+
if (_this34.options.data.left.formatter) {
|
|
5339
|
+
d = _this34.options.data.left.formatter(d);
|
|
4395
5340
|
}
|
|
4396
5341
|
|
|
4397
5342
|
return d;
|
|
@@ -4428,8 +5373,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4428
5373
|
|
|
4429
5374
|
if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
|
|
4430
5375
|
this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
4431
|
-
if (
|
|
4432
|
-
d =
|
|
5376
|
+
if (_this34.options.data.right.formatter) {
|
|
5377
|
+
d = _this34.options.data.right.formatter(d);
|
|
4433
5378
|
}
|
|
4434
5379
|
|
|
4435
5380
|
return d;
|
|
@@ -4455,16 +5400,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4455
5400
|
|
|
4456
5401
|
this.options.data.series.forEach(function (series, index) {
|
|
4457
5402
|
if (!series.key) {
|
|
4458
|
-
series.key =
|
|
5403
|
+
series.key = _this34.createIdentity();
|
|
4459
5404
|
}
|
|
4460
5405
|
|
|
4461
5406
|
if (!series.color) {
|
|
4462
|
-
series.color =
|
|
5407
|
+
series.color = _this34.options.colors[index % _this34.options.colors.length];
|
|
4463
5408
|
}
|
|
4464
5409
|
|
|
4465
|
-
|
|
5410
|
+
_this34["render".concat(series.type || 'bar')](series, index);
|
|
4466
5411
|
|
|
4467
|
-
|
|
5412
|
+
_this34.renderLabels(series, index);
|
|
4468
5413
|
});
|
|
4469
5414
|
}
|
|
4470
5415
|
}
|
|
@@ -4472,17 +5417,17 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4472
5417
|
}, {
|
|
4473
5418
|
key: "renderarea",
|
|
4474
5419
|
value: function renderarea(series, index) {
|
|
4475
|
-
var
|
|
5420
|
+
var _this35 = this;
|
|
4476
5421
|
|
|
4477
5422
|
/* global d3 series index */
|
|
4478
5423
|
var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
|
|
4479
5424
|
return d3.area().x(function (d) {
|
|
4480
|
-
return
|
|
5425
|
+
return _this35[xAxis](_this35.parseX(d.x.value));
|
|
4481
5426
|
}).y0(function (d) {
|
|
4482
|
-
return
|
|
5427
|
+
return _this35[yAxis](0);
|
|
4483
5428
|
}).y1(function (d) {
|
|
4484
|
-
return
|
|
4485
|
-
}).curve(d3[curveStyle ||
|
|
5429
|
+
return _this35[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
5430
|
+
}).curve(d3[curveStyle || _this35.options.curveStyle]);
|
|
4486
5431
|
};
|
|
4487
5432
|
|
|
4488
5433
|
var xAxis = 'bottomAxis';
|
|
@@ -4560,7 +5505,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4560
5505
|
return 0;
|
|
4561
5506
|
}
|
|
4562
5507
|
} else {
|
|
4563
|
-
if (this.options.grouping
|
|
5508
|
+
if (this.options.grouping !== 'stacked') {
|
|
4564
5509
|
return this[xAxis](this.parseX(d.x.value));
|
|
4565
5510
|
} else {
|
|
4566
5511
|
return this[xAxis](this.parseX(d.x.value)) + i * barWidth;
|
|
@@ -4570,7 +5515,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4570
5515
|
|
|
4571
5516
|
function getBarY(d, i) {
|
|
4572
5517
|
if (this.options.orientation === 'horizontal') {
|
|
4573
|
-
if (this.options.grouping
|
|
5518
|
+
if (this.options.grouping !== 'stacked') {
|
|
4574
5519
|
return this[xAxis](this.parseX(d.x.value));
|
|
4575
5520
|
} else {
|
|
4576
5521
|
return this[xAxis](this.parseX(d.x.value)) + (d.y.index || i) * barWidth;
|
|
@@ -4655,15 +5600,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4655
5600
|
}, {
|
|
4656
5601
|
key: "renderline",
|
|
4657
5602
|
value: function renderline(series, index) {
|
|
4658
|
-
var
|
|
5603
|
+
var _this36 = this;
|
|
4659
5604
|
|
|
4660
5605
|
/* global series index d3 */
|
|
4661
5606
|
var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
|
|
4662
5607
|
return d3.line().x(function (d) {
|
|
4663
|
-
return
|
|
5608
|
+
return _this36[xAxis](_this36.parseX(d.x.value));
|
|
4664
5609
|
}).y(function (d) {
|
|
4665
|
-
return
|
|
4666
|
-
}).curve(d3[curveStyle ||
|
|
5610
|
+
return _this36[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
5611
|
+
}).curve(d3[curveStyle || _this36.options.curveStyle]);
|
|
4667
5612
|
};
|
|
4668
5613
|
|
|
4669
5614
|
var xAxis = 'bottomAxis';
|
|
@@ -4701,14 +5646,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4701
5646
|
}, {
|
|
4702
5647
|
key: "rendersymbol",
|
|
4703
5648
|
value: function rendersymbol(series, index) {
|
|
4704
|
-
var
|
|
5649
|
+
var _this37 = this;
|
|
4705
5650
|
|
|
4706
5651
|
/* global d3 series index series.key */
|
|
4707
5652
|
var drawSymbol = function drawSymbol(size) {
|
|
4708
5653
|
return d3.symbol() // .type(d => {
|
|
4709
5654
|
// return d3.symbols[0]
|
|
4710
5655
|
// })
|
|
4711
|
-
.size(size ||
|
|
5656
|
+
.size(size || _this37.options.symbolSize);
|
|
4712
5657
|
};
|
|
4713
5658
|
|
|
4714
5659
|
var xAxis = 'bottomAxis';
|
|
@@ -4726,7 +5671,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4726
5671
|
symbols.attr('d', function (d) {
|
|
4727
5672
|
return drawSymbol(d.y.size || series.symbolSize)(d);
|
|
4728
5673
|
}).transition(this.transition).attr('fill', 'white').attr('stroke', series.color).attr('transform', function (d) {
|
|
4729
|
-
return "translate(".concat(
|
|
5674
|
+
return "translate(".concat(_this37[xAxis](_this37.parseX(d.x.value)), ", ").concat(_this37[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
4730
5675
|
}); // Enter
|
|
4731
5676
|
|
|
4732
5677
|
symbols.enter().append('path').attr('d', function (d) {
|
|
@@ -4735,7 +5680,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
4735
5680
|
.attr('fill', 'white').attr('stroke', series.color).attr('class', function (d) {
|
|
4736
5681
|
return "symbol symbol_".concat(series.key);
|
|
4737
5682
|
}).attr('transform', function (d) {
|
|
4738
|
-
return "translate(".concat(
|
|
5683
|
+
return "translate(".concat(_this37[xAxis](_this37.parseX(d.x.value)), ", ").concat(_this37[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
4739
5684
|
});
|
|
4740
5685
|
}
|
|
4741
5686
|
}, {
|
|
@@ -4890,7 +5835,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
4890
5835
|
}, {
|
|
4891
5836
|
key: "resize",
|
|
4892
5837
|
value: function resize() {
|
|
4893
|
-
var
|
|
5838
|
+
var _this38 = this;
|
|
4894
5839
|
|
|
4895
5840
|
var el = document.getElementById(this.elementId);
|
|
4896
5841
|
|
|
@@ -4903,7 +5848,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
4903
5848
|
// }
|
|
4904
5849
|
var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
|
|
4905
5850
|
html += this._data.map(function (d, i) {
|
|
4906
|
-
return
|
|
5851
|
+
return _this38.getLegendItemHTML(d);
|
|
4907
5852
|
}).join('');
|
|
4908
5853
|
html += "\n <div>\n ";
|
|
4909
5854
|
el.innerHTML = html;
|
|
@@ -5076,7 +6021,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
5076
6021
|
}, {
|
|
5077
6022
|
key: "render",
|
|
5078
6023
|
value: function render() {
|
|
5079
|
-
var
|
|
6024
|
+
var _this39 = this;
|
|
5080
6025
|
|
|
5081
6026
|
var mapEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
5082
6027
|
var legendEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
@@ -5085,7 +6030,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
5085
6030
|
var legendData = this.options.data.polygons.map(function (s, i) {
|
|
5086
6031
|
return {
|
|
5087
6032
|
value: s.label || s.key,
|
|
5088
|
-
color: s.color ||
|
|
6033
|
+
color: s.color || _this39.options.colors[i % _this39.options.colors.length]
|
|
5089
6034
|
};
|
|
5090
6035
|
});
|
|
5091
6036
|
var longestValue = legendData.map(function (s) {
|
|
@@ -5149,7 +6094,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
5149
6094
|
|
|
5150
6095
|
if (this.polygons) {
|
|
5151
6096
|
this.polygons.forEach(function (p) {
|
|
5152
|
-
return
|
|
6097
|
+
return _this39.map.removeLayer(p);
|
|
5153
6098
|
});
|
|
5154
6099
|
}
|
|
5155
6100
|
|
|
@@ -5207,18 +6152,18 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
5207
6152
|
}
|
|
5208
6153
|
|
|
5209
6154
|
if (!p.options.color) {
|
|
5210
|
-
p.options.color =
|
|
6155
|
+
p.options.color = _this39.options.colors[i % _this39.options.colors.length];
|
|
5211
6156
|
}
|
|
5212
6157
|
|
|
5213
6158
|
var pol = L.polygon(p.data.map(function (c) {
|
|
5214
6159
|
return c.map(function (d) {
|
|
5215
6160
|
return [d.Latitude, d.Longitude];
|
|
5216
6161
|
});
|
|
5217
|
-
}), p.options).addTo(
|
|
6162
|
+
}), p.options).addTo(_this39.map);
|
|
5218
6163
|
|
|
5219
|
-
|
|
6164
|
+
_this39.polygons.push(pol);
|
|
5220
6165
|
|
|
5221
|
-
|
|
6166
|
+
_this39.map.fitBounds(pol.getBounds());
|
|
5222
6167
|
});
|
|
5223
6168
|
} // if (this.data.markers.length > 0) {
|
|
5224
6169
|
// el.classList.remove('hidden')
|
|
@@ -5350,7 +6295,9 @@ var WebsyDesigns = {
|
|
|
5350
6295
|
WebsyRouter: WebsyRouter,
|
|
5351
6296
|
Router: WebsyRouter,
|
|
5352
6297
|
WebsyTable: WebsyTable,
|
|
6298
|
+
WebsyTable2: WebsyTable2,
|
|
5353
6299
|
Table: WebsyTable,
|
|
6300
|
+
Table2: WebsyTable2,
|
|
5354
6301
|
WebsyChart: WebsyChart,
|
|
5355
6302
|
Chart: WebsyChart,
|
|
5356
6303
|
WebsyChartTooltip: WebsyChartTooltip,
|
|
@@ -5367,6 +6314,7 @@ var WebsyDesigns = {
|
|
|
5367
6314
|
Utils: WebsyUtils,
|
|
5368
6315
|
ButtonGroup: ButtonGroup,
|
|
5369
6316
|
WebsySwitch: Switch,
|
|
6317
|
+
Pager: Pager,
|
|
5370
6318
|
Switch: Switch
|
|
5371
6319
|
};
|
|
5372
6320
|
WebsyDesigns.service = new WebsyDesigns.APIService('');
|