@websy/websy-designs 1.2.32 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/helpers/v1/pgHelper.js +13 -5
- package/dist/server/routes/v1/api.js +11 -1
- package/dist/websy-designs-es6.debug.js +972 -44
- package/dist/websy-designs-es6.js +1224 -161
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +1024 -45
- package/dist/websy-designs.js +1289 -169
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/index.js +1 -0
- package/package.json +1 -1
package/dist/websy-designs.js
CHANGED
|
@@ -35,6 +35,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
35
35
|
WebsyResultList
|
|
36
36
|
WebsyTable
|
|
37
37
|
WebsyTable2
|
|
38
|
+
WebsyTable3
|
|
38
39
|
WebsyIcons
|
|
39
40
|
WebsyChart
|
|
40
41
|
WebsyChartTooltip
|
|
@@ -51,6 +52,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
51
52
|
WebsyLogin
|
|
52
53
|
WebsySignup
|
|
53
54
|
ResponsiveText
|
|
55
|
+
WebsyDragDrop
|
|
56
|
+
WebsySearch
|
|
54
57
|
Pager
|
|
55
58
|
*/
|
|
56
59
|
|
|
@@ -682,7 +685,8 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
682
685
|
value: function floorDate(d) {
|
|
683
686
|
if (typeof d === 'number') {
|
|
684
687
|
d = new Date(d);
|
|
685
|
-
}
|
|
688
|
+
} // d.setTime(d.getTime() + d.getTimezoneOffset() * 60000)
|
|
689
|
+
|
|
686
690
|
|
|
687
691
|
return new Date(d.setHours(0, 0, 0, 0));
|
|
688
692
|
}
|
|
@@ -701,11 +705,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
701
705
|
var index = event.target.getAttribute('data-index');
|
|
702
706
|
this.selectRange(index);
|
|
703
707
|
this.updateRange(index);
|
|
704
|
-
} else if (event.target.classList.contains('websy-dp-date')) {//
|
|
705
|
-
// return
|
|
706
|
-
// }
|
|
707
|
-
// const timestamp = event.target.id.split('_')[0]
|
|
708
|
-
// this.selectDate(+timestamp)
|
|
708
|
+
} else if (event.target.classList.contains('websy-dp-date')) {//
|
|
709
709
|
} else if (event.target.classList.contains('websy-dp-confirm')) {
|
|
710
710
|
this.close(true);
|
|
711
711
|
} else if (event.target.classList.contains('websy-dp-cancel')) {
|
|
@@ -739,7 +739,8 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
739
739
|
value: function handleMouseDown(event) {
|
|
740
740
|
if (this.shiftPressed === true && this.currentselection.length > 0) {
|
|
741
741
|
this.mouseDownId = this.currentselection[this.currentselection.length - 1];
|
|
742
|
-
|
|
742
|
+
var dateId = event.target.getAttribute('data-id');
|
|
743
|
+
this.selectDate(+dateId);
|
|
743
744
|
} else {
|
|
744
745
|
this.mouseDown = true;
|
|
745
746
|
this.dragging = false;
|
|
@@ -754,7 +755,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
754
755
|
this.customRangeSelected = false;
|
|
755
756
|
}
|
|
756
757
|
|
|
757
|
-
this.mouseDownId = +event.target.
|
|
758
|
+
this.mouseDownId = +event.target.getAttribute('data-id');
|
|
758
759
|
this.selectDate(this.mouseDownId);
|
|
759
760
|
}
|
|
760
761
|
}
|
|
@@ -768,9 +769,11 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
768
769
|
return;
|
|
769
770
|
}
|
|
770
771
|
|
|
771
|
-
|
|
772
|
+
var dateId = +event.target.getAttribute('data-id');
|
|
773
|
+
|
|
774
|
+
if (dateId !== this.mouseDownId) {
|
|
772
775
|
this.dragging = true;
|
|
773
|
-
this.selectDate(
|
|
776
|
+
this.selectDate(dateId);
|
|
774
777
|
}
|
|
775
778
|
}
|
|
776
779
|
}
|
|
@@ -826,6 +829,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
826
829
|
|
|
827
830
|
if (this.options.mode === 'date') {
|
|
828
831
|
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + _i * this.oneDay));
|
|
832
|
+
d.setHours(0, 0, 0, 0);
|
|
829
833
|
d = d.getTime();
|
|
830
834
|
rangeStart = this.selectedRangeDates[0].getTime();
|
|
831
835
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime();
|
|
@@ -1118,7 +1122,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
1118
1122
|
}
|
|
1119
1123
|
|
|
1120
1124
|
html += months[key].map(function (d) {
|
|
1121
|
-
return "<li id='".concat(_this6.elementId, "_").concat(d.id, "_date' class='websy-dp-date ").concat(d.disabled === true ? 'websy-disabled-date' : '', "'>").concat(d.dayOfMonth, "</li>");
|
|
1125
|
+
return "<li id='".concat(_this6.elementId, "_").concat(d.id, "_date' data-id='").concat(d.id, "' class='websy-dp-date ").concat(d.disabled === true ? 'websy-disabled-date' : '', "'>").concat(d.dayOfMonth, "</li>");
|
|
1122
1126
|
}).join('');
|
|
1123
1127
|
html += "\n </ul>\n </div>\n ";
|
|
1124
1128
|
}
|
|
@@ -1255,7 +1259,9 @@ var WebsyDatePicker = /*#__PURE__*/function () {
|
|
|
1255
1259
|
|
|
1256
1260
|
if (this.options.ranges[this.options.mode][index]) {
|
|
1257
1261
|
this.selectedRangeDates = _toConsumableArray(this.options.ranges[this.options.mode][index].range);
|
|
1258
|
-
this.currentselection =
|
|
1262
|
+
this.currentselection = this.options.ranges[this.options.mode][index].range.map(function (d) {
|
|
1263
|
+
return d.getTime();
|
|
1264
|
+
});
|
|
1259
1265
|
this.selectedRange = +index;
|
|
1260
1266
|
var el = document.getElementById("".concat(this.elementId, "_header"));
|
|
1261
1267
|
|
|
@@ -1811,14 +1817,17 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1811
1817
|
}, {
|
|
1812
1818
|
key: "updateHeader",
|
|
1813
1819
|
value: function updateHeader(item) {
|
|
1814
|
-
var _this12 = this;
|
|
1815
|
-
|
|
1816
1820
|
var el = document.getElementById(this.elementId);
|
|
1817
1821
|
var headerEl = document.getElementById("".concat(this.elementId, "_header"));
|
|
1818
1822
|
var headerLabelEl = document.getElementById("".concat(this.elementId, "_headerLabel"));
|
|
1819
1823
|
var labelEl = document.getElementById("".concat(this.elementId, "_selectedItems"));
|
|
1820
1824
|
var inputEl = document.getElementById("".concat(this.elementId, "_input"));
|
|
1821
1825
|
var itemEls = el.querySelectorAll(".websy-dropdown-item");
|
|
1826
|
+
var dataToUse = this._originalData;
|
|
1827
|
+
|
|
1828
|
+
if (this.options.onSearch) {
|
|
1829
|
+
dataToUse = this.options.items;
|
|
1830
|
+
}
|
|
1822
1831
|
|
|
1823
1832
|
for (var i = 0; i < itemEls.length; i++) {
|
|
1824
1833
|
itemEls[i].classList.remove('active');
|
|
@@ -1858,17 +1867,17 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1858
1867
|
} else if (this.selectedItems.length > 1) {
|
|
1859
1868
|
if (this.options.showCompleteSelectedList === true) {
|
|
1860
1869
|
var selectedLabels = this.selectedItems.map(function (s) {
|
|
1861
|
-
return
|
|
1870
|
+
return dataToUse[s].label || dataToUse[s].value;
|
|
1862
1871
|
}).join(this.options.multiValueDelimiter);
|
|
1863
1872
|
var selectedValues = this.selectedItems.map(function (s) {
|
|
1864
|
-
return
|
|
1873
|
+
return dataToUse[s].value || dataToUse[s].label;
|
|
1865
1874
|
}).join(this.options.multiValueDelimiter);
|
|
1866
1875
|
labelEl.innerHTML = selectedLabels;
|
|
1867
1876
|
labelEl.setAttribute('data-info', selectedLabels);
|
|
1868
1877
|
inputEl.value = selectedValues;
|
|
1869
1878
|
} else {
|
|
1870
1879
|
var _selectedValues = this.selectedItems.map(function (s) {
|
|
1871
|
-
return
|
|
1880
|
+
return dataToUse[s].value || dataToUse[s].label;
|
|
1872
1881
|
}).join(this.options.multiValueDelimiter);
|
|
1873
1882
|
|
|
1874
1883
|
labelEl.innerHTML = "".concat(this.selectedItems.length, " selected");
|
|
@@ -1885,6 +1894,12 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1885
1894
|
}, {
|
|
1886
1895
|
key: "updateSelected",
|
|
1887
1896
|
value: function updateSelected(index) {
|
|
1897
|
+
var dataToUse = this._originalData && this._originalData.length > 0 ? this._originalData : this.options.items;
|
|
1898
|
+
|
|
1899
|
+
if (this.options.onSearch) {
|
|
1900
|
+
dataToUse = this.options.items;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1888
1903
|
if (typeof index !== 'undefined' && index !== null) {
|
|
1889
1904
|
var pos = this.selectedItems.indexOf(index);
|
|
1890
1905
|
|
|
@@ -1897,13 +1912,14 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1897
1912
|
this.selectedItems.push(index);
|
|
1898
1913
|
}
|
|
1899
1914
|
}
|
|
1900
|
-
}
|
|
1915
|
+
} // const item = this.options.items[index]
|
|
1901
1916
|
|
|
1902
|
-
|
|
1917
|
+
|
|
1918
|
+
var item = dataToUse[index];
|
|
1903
1919
|
this.updateHeader(item);
|
|
1904
1920
|
|
|
1905
1921
|
if (item && this.options.onItemSelected) {
|
|
1906
|
-
this.options.onItemSelected(item, this.selectedItems,
|
|
1922
|
+
this.options.onItemSelected(item, this.selectedItems, dataToUse, this.options);
|
|
1907
1923
|
}
|
|
1908
1924
|
|
|
1909
1925
|
if (this.options.closeAfterSelection === true) {
|
|
@@ -1923,20 +1939,29 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1923
1939
|
d.index = i;
|
|
1924
1940
|
}
|
|
1925
1941
|
|
|
1942
|
+
d.currentIndex = i;
|
|
1926
1943
|
return d;
|
|
1927
1944
|
});
|
|
1945
|
+
var headerEl = document.getElementById("".concat(this.elementId, "_header"));
|
|
1946
|
+
|
|
1947
|
+
if (headerEl) {
|
|
1948
|
+
headerEl.classList["".concat(this.options.allowClear === true ? 'add' : 'remove')]('allow-clear');
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1928
1951
|
var el = document.getElementById("".concat(this.elementId, "_items"));
|
|
1929
1952
|
|
|
1930
|
-
if (el
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
this.options.items
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1953
|
+
if (el) {
|
|
1954
|
+
if (el.childElementCount === 0) {
|
|
1955
|
+
this.render();
|
|
1956
|
+
} else {
|
|
1957
|
+
if (this.options.items.length === 0) {
|
|
1958
|
+
this.options.items = [{
|
|
1959
|
+
label: this.options.noItemsText || 'No Items'
|
|
1960
|
+
}];
|
|
1961
|
+
}
|
|
1938
1962
|
|
|
1939
|
-
|
|
1963
|
+
this.renderItems();
|
|
1964
|
+
}
|
|
1940
1965
|
}
|
|
1941
1966
|
},
|
|
1942
1967
|
get: function get() {
|
|
@@ -1946,6 +1971,316 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1946
1971
|
|
|
1947
1972
|
return WebsyDropdown;
|
|
1948
1973
|
}();
|
|
1974
|
+
/* global WebsyDesigns GlobalPubSub */
|
|
1975
|
+
|
|
1976
|
+
|
|
1977
|
+
var WebsyDragDrop = /*#__PURE__*/function () {
|
|
1978
|
+
function WebsyDragDrop(elementId, options) {
|
|
1979
|
+
_classCallCheck(this, WebsyDragDrop);
|
|
1980
|
+
|
|
1981
|
+
var DEFAULTS = {
|
|
1982
|
+
items: [],
|
|
1983
|
+
orientation: 'horizontal',
|
|
1984
|
+
dropPlaceholder: 'Drop item here'
|
|
1985
|
+
};
|
|
1986
|
+
this.busy = false;
|
|
1987
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
1988
|
+
this.elementId = elementId;
|
|
1989
|
+
|
|
1990
|
+
if (!elementId) {
|
|
1991
|
+
console.log('No element Id provided for Websy DragDrop');
|
|
1992
|
+
return;
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
var el = document.getElementById(elementId);
|
|
1996
|
+
|
|
1997
|
+
if (el) {
|
|
1998
|
+
el.innerHTML = "\n <div id='".concat(this.elementId, "_container' class='websy-drag-drop-container ").concat(this.options.orientation, "'>\n <div>\n </div>\n ");
|
|
1999
|
+
el.addEventListener('click', this.handleClick.bind(this));
|
|
2000
|
+
el.addEventListener('dragstart', this.handleDragStart.bind(this));
|
|
2001
|
+
el.addEventListener('dragover', this.handleDragOver.bind(this));
|
|
2002
|
+
el.addEventListener('dragleave', this.handleDragLeave.bind(this));
|
|
2003
|
+
el.addEventListener('drop', this.handleDrop.bind(this));
|
|
2004
|
+
window.addEventListener('dragend', this.handleDragEnd.bind(this));
|
|
2005
|
+
} else {
|
|
2006
|
+
console.error("No element found with ID ".concat(this.elementId));
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
GlobalPubSub.subscribe(this.elementId, 'requestForDDItem', this.handleRequestForItem.bind(this));
|
|
2010
|
+
GlobalPubSub.subscribe(this.elementId, 'add', this.addItem.bind(this));
|
|
2011
|
+
this.render();
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
_createClass(WebsyDragDrop, [{
|
|
2015
|
+
key: "addItem",
|
|
2016
|
+
value: function addItem(data) {
|
|
2017
|
+
if (data.target === this.elementId && this.busy === false) {
|
|
2018
|
+
this.busy = true;
|
|
2019
|
+
console.log('adding item to dd'); // check that an item with the same id doesn't already exist
|
|
2020
|
+
|
|
2021
|
+
var index = this.getItemIndex(data.item.id);
|
|
2022
|
+
|
|
2023
|
+
if (index === -1) {
|
|
2024
|
+
this.options.items.splice(data.index, 0, data.item);
|
|
2025
|
+
var startEl = document.getElementById("".concat(this.elementId, "start_item"));
|
|
2026
|
+
|
|
2027
|
+
if (startEl) {
|
|
2028
|
+
if (this.options.items.length === 0) {
|
|
2029
|
+
startEl.classList.add('empty');
|
|
2030
|
+
} else {
|
|
2031
|
+
startEl.classList.remove('empty');
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
if (this.options.onItemAdded) {
|
|
2036
|
+
this.options.onItemAdded();
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
this.busy = false;
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
}, {
|
|
2044
|
+
key: "createItemHtml",
|
|
2045
|
+
value: function createItemHtml(elementId, index, item) {
|
|
2046
|
+
if (!item.id) {
|
|
2047
|
+
item.id = WebsyDesigns.Utils.createIdentity();
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
var html = "\n <div id='".concat(item.id, "_item' class='websy-dragdrop-item' draggable='true' data-id='").concat(item.id, "'> \n <div id='").concat(item.id, "_itemInner' class='websy-dragdrop-item-inner' data-id='").concat(item.id, "'>\n ");
|
|
2051
|
+
|
|
2052
|
+
if (item.component) {
|
|
2053
|
+
html += "<div id='".concat(item.id, "_component'></div>");
|
|
2054
|
+
} else {
|
|
2055
|
+
html += "".concat(item.html || item.label || '');
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
html += "\n </div>\n <div id='".concat(item.id, "_dropZone' class='websy-drop-zone droppable' data-index='").concat(item.id, "' data-side='right' data-id='").concat(item.id, "' data-placeholder='").concat(this.options.dropPlaceholder, "'></div> \n </div>\n ");
|
|
2059
|
+
return html;
|
|
2060
|
+
}
|
|
2061
|
+
}, {
|
|
2062
|
+
key: "getItemIndex",
|
|
2063
|
+
value: function getItemIndex(id) {
|
|
2064
|
+
for (var i = 0; i < this.options.items.length; i++) {
|
|
2065
|
+
if (this.options.items[i].id === id) {
|
|
2066
|
+
return i;
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
return -1;
|
|
2071
|
+
}
|
|
2072
|
+
}, {
|
|
2073
|
+
key: "handleClick",
|
|
2074
|
+
value: function handleClick(event) {}
|
|
2075
|
+
}, {
|
|
2076
|
+
key: "handleDragStart",
|
|
2077
|
+
value: function handleDragStart(event) {
|
|
2078
|
+
this.draggedId = event.target.getAttribute('data-id');
|
|
2079
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
2080
|
+
event.dataTransfer.setData('application/wd-item', JSON.stringify({
|
|
2081
|
+
el: event.target.id,
|
|
2082
|
+
id: this.elementId,
|
|
2083
|
+
itemId: this.draggedId
|
|
2084
|
+
})); // console.log('drag start', event)
|
|
2085
|
+
|
|
2086
|
+
event.target.style.opacity = 0.5;
|
|
2087
|
+
this.dragging = true;
|
|
2088
|
+
}
|
|
2089
|
+
}, {
|
|
2090
|
+
key: "handleDragOver",
|
|
2091
|
+
value: function handleDragOver(event) {
|
|
2092
|
+
// console.log('drag over', event.target.classList)
|
|
2093
|
+
if (event.preventDefault) {
|
|
2094
|
+
event.preventDefault();
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
if (!event.target.classList.contains('droppable')) {
|
|
2098
|
+
return;
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
event.target.classList.add('drag-over');
|
|
2102
|
+
}
|
|
2103
|
+
}, {
|
|
2104
|
+
key: "handleDragLeave",
|
|
2105
|
+
value: function handleDragLeave(event) {
|
|
2106
|
+
// console.log('drag leave', event.target.classList)
|
|
2107
|
+
if (!event.target.classList.contains('droppable')) {
|
|
2108
|
+
return;
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
event.target.classList.remove('drag-over'); // let side = event.target.getAttribute('data-side')
|
|
2112
|
+
// let id = event.target.getAttribute('data-id')
|
|
2113
|
+
// let droppedItem = this.options.items[id]
|
|
2114
|
+
// this.removeExpandedDrop(side, id, droppedItem)
|
|
2115
|
+
}
|
|
2116
|
+
}, {
|
|
2117
|
+
key: "handleDrop",
|
|
2118
|
+
value: function handleDrop(event) {
|
|
2119
|
+
// console.log('drag drop')
|
|
2120
|
+
// console.log(event.dataTransfer.getData('application/wd-item'))
|
|
2121
|
+
var data = JSON.parse(event.dataTransfer.getData('application/wd-item'));
|
|
2122
|
+
|
|
2123
|
+
if (event.preventDefault) {
|
|
2124
|
+
event.preventDefault();
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
if (!event.target.classList.contains('droppable')) {
|
|
2128
|
+
return;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
var side = event.target.getAttribute('data-side');
|
|
2132
|
+
var id = event.target.getAttribute('data-id');
|
|
2133
|
+
var index = this.getItemIndex(id);
|
|
2134
|
+
var draggedIndex = this.getItemIndex(data.id);
|
|
2135
|
+
var droppedItem = this.options.items[index];
|
|
2136
|
+
|
|
2137
|
+
if (side === 'right') {
|
|
2138
|
+
index += 1;
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
if (draggedIndex === -1) {
|
|
2142
|
+
// console.log('requestForDDItem')
|
|
2143
|
+
GlobalPubSub.publish(data.id, 'requestForDDItem', {
|
|
2144
|
+
group: this.options.group,
|
|
2145
|
+
source: data.id,
|
|
2146
|
+
target: this.elementId,
|
|
2147
|
+
index: index,
|
|
2148
|
+
id: data.itemId
|
|
2149
|
+
});
|
|
2150
|
+
} else if (index > draggedIndex) {
|
|
2151
|
+
// insert and then remove
|
|
2152
|
+
this.options.items.splice(index, 0, droppedItem);
|
|
2153
|
+
this.options.items.splice(draggedIndex, 1);
|
|
2154
|
+
|
|
2155
|
+
if (this.options.onOrderUpdated) {
|
|
2156
|
+
this.options.onOrderUpdated();
|
|
2157
|
+
}
|
|
2158
|
+
} else {
|
|
2159
|
+
// remove and then insert
|
|
2160
|
+
this.options.items.splice(draggedIndex, 1);
|
|
2161
|
+
this.options.items.splice(index, 0, droppedItem);
|
|
2162
|
+
|
|
2163
|
+
if (this.options.onOrderUpdated) {
|
|
2164
|
+
this.options.onOrderUpdated();
|
|
2165
|
+
}
|
|
2166
|
+
} // this.removeExpandedDrop(side, id, droppedItem)
|
|
2167
|
+
// const draggedEl = document.getElementById(`${this.elementId}_${this.draggedId}_item`)
|
|
2168
|
+
|
|
2169
|
+
|
|
2170
|
+
var draggedEl = document.getElementById(data.el);
|
|
2171
|
+
var droppedEl = document.getElementById("".concat(id, "_item"));
|
|
2172
|
+
|
|
2173
|
+
if (draggedEl) {
|
|
2174
|
+
droppedEl.insertAdjacentElement('afterend', draggedEl);
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
var dragOverEl = droppedEl.querySelector('.drag-over');
|
|
2178
|
+
|
|
2179
|
+
if (dragOverEl) {
|
|
2180
|
+
dragOverEl.classList.remove('drag-over');
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
}, {
|
|
2184
|
+
key: "handleDragEnd",
|
|
2185
|
+
value: function handleDragEnd(event) {
|
|
2186
|
+
// console.log('drag end')
|
|
2187
|
+
event.target.style.opacity = 1;
|
|
2188
|
+
this.draggedId = null;
|
|
2189
|
+
this.dragging = false;
|
|
2190
|
+
var startEl = document.getElementById("".concat(this.elementId, "start_item"));
|
|
2191
|
+
|
|
2192
|
+
if (startEl) {
|
|
2193
|
+
if (this.options.items.length === 0) {
|
|
2194
|
+
startEl.classList.add('empty');
|
|
2195
|
+
} else {
|
|
2196
|
+
startEl.classList.remove('empty');
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
}, {
|
|
2201
|
+
key: "handleRequestForItem",
|
|
2202
|
+
value: function handleRequestForItem(data) {
|
|
2203
|
+
if (data.group === this.options.group) {
|
|
2204
|
+
var index = this.getItemIndex(data.id);
|
|
2205
|
+
|
|
2206
|
+
if (index !== -1) {
|
|
2207
|
+
var itemToAdd = this.options.items.splice(index, 1);
|
|
2208
|
+
GlobalPubSub.publish(data.target, 'add', {
|
|
2209
|
+
target: data.target,
|
|
2210
|
+
index: data.index,
|
|
2211
|
+
item: itemToAdd[0]
|
|
2212
|
+
});
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
}, {
|
|
2217
|
+
key: "measureItems",
|
|
2218
|
+
value: function measureItems() {
|
|
2219
|
+
var el = document.getElementById("".concat(this.elementId, "_container"));
|
|
2220
|
+
this.options.items.forEach(function (d) {});
|
|
2221
|
+
} // removeExpandedDrop (side, id, droppedItem) {
|
|
2222
|
+
// let dropEl
|
|
2223
|
+
// const dropImageEl = document.getElementById(`${id}_itemInner`)
|
|
2224
|
+
// // const placeholderEl = document.getElementById(`${this.elementId}_${id}_dropZonePlaceholder`)
|
|
2225
|
+
// if (side === 'left') {
|
|
2226
|
+
// dropEl = document.getElementById(`${this.elementId}_${id}_dropZoneLeft`)
|
|
2227
|
+
// dropImageEl.style.left = `0px`
|
|
2228
|
+
// }
|
|
2229
|
+
// else if (side === 'right') {
|
|
2230
|
+
// dropEl = document.getElementById(`${this.elementId}_${id}_dropZoneRight`)
|
|
2231
|
+
// }
|
|
2232
|
+
// else {
|
|
2233
|
+
// dropEl = document.getElementById(`${this.elementId}_${id}_dropZoneEnd`)
|
|
2234
|
+
// }
|
|
2235
|
+
// if (dropEl) {
|
|
2236
|
+
// const dropElSize = dropEl.getBoundingClientRect()
|
|
2237
|
+
// dropEl.style.width = `${(dropElSize.width / 2)}px`
|
|
2238
|
+
// dropEl.style.marginLeft = null
|
|
2239
|
+
// dropEl.style.border = null
|
|
2240
|
+
// }
|
|
2241
|
+
// if (placeholderEl) {
|
|
2242
|
+
// placeholderEl.classList.remove('active')
|
|
2243
|
+
// placeholderEl.style.left = null
|
|
2244
|
+
// placeholderEl.style.right = null
|
|
2245
|
+
// placeholderEl.style.width = null
|
|
2246
|
+
// placeholderEl.style.height = null
|
|
2247
|
+
// }
|
|
2248
|
+
// }
|
|
2249
|
+
|
|
2250
|
+
}, {
|
|
2251
|
+
key: "removeItem",
|
|
2252
|
+
value: function removeItem(id) {}
|
|
2253
|
+
}, {
|
|
2254
|
+
key: "render",
|
|
2255
|
+
value: function render() {
|
|
2256
|
+
var _this12 = this;
|
|
2257
|
+
|
|
2258
|
+
var el = document.getElementById("".concat(this.elementId, "_container"));
|
|
2259
|
+
|
|
2260
|
+
if (el) {
|
|
2261
|
+
this.measureItems();
|
|
2262
|
+
var html = "\n <div id='".concat(this.elementId, "start_item' class='websy-dragdrop-item ").concat(this.options.items.length === 0 ? 'empty' : '', "' data-id='").concat(this.elementId, "start'>\n <div id='").concat(this.elementId, "start_dropZone' class='websy-drop-zone droppable' data-index='start' data-side='start' data-id='").concat(this.elementId, "start' data-placeholder='").concat(this.options.dropPlaceholder, "'></div>\n </div>\n ");
|
|
2263
|
+
html += this.options.items.map(function (d, i) {
|
|
2264
|
+
return _this12.createItemHtml(_this12.elementId, i, d);
|
|
2265
|
+
}).join('');
|
|
2266
|
+
el.innerHTML = html;
|
|
2267
|
+
this.options.items.forEach(function (item, i) {
|
|
2268
|
+
if (item.component) {
|
|
2269
|
+
if (item.isQlikPlugin && WebsyDesigns.QlikPlugin[item.component]) {
|
|
2270
|
+
item.instance = new WebsyDesigns.QlikPlugin[item.component]("".concat(item.id, "_component"), item.options);
|
|
2271
|
+
} else if (WebsyDesigns[item.component]) {
|
|
2272
|
+
item.instance = new WebsyDesigns[item.component]("".concat(item.id, "_component"), item.options);
|
|
2273
|
+
} else {
|
|
2274
|
+
console.error("Component ".concat(item.component, " not found."));
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
}]);
|
|
2281
|
+
|
|
2282
|
+
return WebsyDragDrop;
|
|
2283
|
+
}();
|
|
1949
2284
|
/* global WebsyDesigns FormData grecaptcha ENVIRONMENT GlobalPubSub */
|
|
1950
2285
|
|
|
1951
2286
|
|
|
@@ -2990,21 +3325,37 @@ var WebsyPubSub = /*#__PURE__*/function () {
|
|
|
2990
3325
|
|
|
2991
3326
|
_createClass(WebsyPubSub, [{
|
|
2992
3327
|
key: "publish",
|
|
2993
|
-
value: function publish(method, data) {
|
|
2994
|
-
if (
|
|
2995
|
-
this.subscriptions[method]
|
|
2996
|
-
|
|
2997
|
-
}
|
|
3328
|
+
value: function publish(id, method, data) {
|
|
3329
|
+
if (arguments.length === 3) {
|
|
3330
|
+
if (this.subscriptions[id] && this.subscriptions[id][method]) {
|
|
3331
|
+
this.subscriptions[id][method](data);
|
|
3332
|
+
}
|
|
3333
|
+
} else {
|
|
3334
|
+
if (this.subscriptions[id]) {
|
|
3335
|
+
this.subscriptions[id].forEach(function (fn) {
|
|
3336
|
+
fn(method);
|
|
3337
|
+
});
|
|
3338
|
+
}
|
|
2998
3339
|
}
|
|
2999
3340
|
}
|
|
3000
3341
|
}, {
|
|
3001
3342
|
key: "subscribe",
|
|
3002
|
-
value: function subscribe(method, fn) {
|
|
3003
|
-
if (
|
|
3004
|
-
this.subscriptions[
|
|
3005
|
-
|
|
3343
|
+
value: function subscribe(id, method, fn) {
|
|
3344
|
+
if (arguments.length === 3) {
|
|
3345
|
+
if (!this.subscriptions[id]) {
|
|
3346
|
+
this.subscriptions[id] = {};
|
|
3347
|
+
}
|
|
3348
|
+
|
|
3349
|
+
if (!this.subscriptions[id][method]) {
|
|
3350
|
+
this.subscriptions[id][method] = fn;
|
|
3351
|
+
}
|
|
3352
|
+
} else {
|
|
3353
|
+
if (!this.subscriptions[id]) {
|
|
3354
|
+
this.subscriptions[id] = [];
|
|
3355
|
+
}
|
|
3006
3356
|
|
|
3007
|
-
|
|
3357
|
+
this.subscriptions[id].push(method);
|
|
3358
|
+
}
|
|
3008
3359
|
}
|
|
3009
3360
|
}]);
|
|
3010
3361
|
|
|
@@ -4176,6 +4527,59 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
4176
4527
|
|
|
4177
4528
|
return WebsyRouter;
|
|
4178
4529
|
}();
|
|
4530
|
+
|
|
4531
|
+
var WebsySearch = /*#__PURE__*/function () {
|
|
4532
|
+
function WebsySearch(elementId, options) {
|
|
4533
|
+
_classCallCheck(this, WebsySearch);
|
|
4534
|
+
|
|
4535
|
+
this.elementId = elementId;
|
|
4536
|
+
var DEFAULTS = {
|
|
4537
|
+
searchIcon: "<svg class='search' width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><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>",
|
|
4538
|
+
clearIcon: "<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>",
|
|
4539
|
+
placeholder: 'Search',
|
|
4540
|
+
searchTimeout: 500,
|
|
4541
|
+
minLength: 2
|
|
4542
|
+
};
|
|
4543
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
4544
|
+
this.searchTimeoutFn = null;
|
|
4545
|
+
var el = document.getElementById(elementId);
|
|
4546
|
+
|
|
4547
|
+
if (el) {
|
|
4548
|
+
// el.addEventListener('click', this.handleClick.bind(this))
|
|
4549
|
+
el.addEventListener('keyup', this.handleKeyUp.bind(this));
|
|
4550
|
+
el.innerHTML = "\n <div class='websy-search-input-container'>\n ".concat(this.options.searchIcon, "\n <input id='").concat(this.elementId, "_search' class='websy-search-input' placeholder='").concat(this.options.placeholder || 'Search', "'>\n ").concat(this.options.clearIcon, "\n </div>\n ");
|
|
4551
|
+
} else {
|
|
4552
|
+
console.log('No element found with Id', elementId);
|
|
4553
|
+
}
|
|
4554
|
+
}
|
|
4555
|
+
|
|
4556
|
+
_createClass(WebsySearch, [{
|
|
4557
|
+
key: "handleKeyUp",
|
|
4558
|
+
value: function handleKeyUp(event) {
|
|
4559
|
+
var _this28 = this;
|
|
4560
|
+
|
|
4561
|
+
if (event.target.classList.contains('websy-search-input')) {
|
|
4562
|
+
if (this.searchTimeoutFn) {
|
|
4563
|
+
clearTimeout(this.searchTimeoutFn);
|
|
4564
|
+
}
|
|
4565
|
+
|
|
4566
|
+
if (event.target.value.length >= this.options.minLength) {
|
|
4567
|
+
this.searchTimeoutFn = setTimeout(function () {
|
|
4568
|
+
if (_this28.options.onSearch) {
|
|
4569
|
+
_this28.options.onSearch(event.target.value);
|
|
4570
|
+
}
|
|
4571
|
+
}, this.options.searchTimeout);
|
|
4572
|
+
} else {
|
|
4573
|
+
if (this.options.onSearch) {
|
|
4574
|
+
this.options.onSearch('');
|
|
4575
|
+
}
|
|
4576
|
+
}
|
|
4577
|
+
}
|
|
4578
|
+
}
|
|
4579
|
+
}]);
|
|
4580
|
+
|
|
4581
|
+
return WebsySearch;
|
|
4582
|
+
}();
|
|
4179
4583
|
/* global WebsyDesigns ENVIRONMENT */
|
|
4180
4584
|
|
|
4181
4585
|
|
|
@@ -4313,7 +4717,7 @@ var Switch = /*#__PURE__*/function () {
|
|
|
4313
4717
|
|
|
4314
4718
|
var WebsyTemplate = /*#__PURE__*/function () {
|
|
4315
4719
|
function WebsyTemplate(elementId, options) {
|
|
4316
|
-
var
|
|
4720
|
+
var _this29 = this;
|
|
4317
4721
|
|
|
4318
4722
|
_classCallCheck(this, WebsyTemplate);
|
|
4319
4723
|
|
|
@@ -4339,9 +4743,9 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
4339
4743
|
|
|
4340
4744
|
if (_typeof(options.template) === 'object' && options.template.url) {
|
|
4341
4745
|
this.templateService.get(options.template.url).then(function (templateString) {
|
|
4342
|
-
|
|
4746
|
+
_this29.options.template = templateString;
|
|
4343
4747
|
|
|
4344
|
-
|
|
4748
|
+
_this29.render();
|
|
4345
4749
|
});
|
|
4346
4750
|
} else {
|
|
4347
4751
|
this.render();
|
|
@@ -4351,7 +4755,7 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
4351
4755
|
_createClass(WebsyTemplate, [{
|
|
4352
4756
|
key: "buildHTML",
|
|
4353
4757
|
value: function buildHTML() {
|
|
4354
|
-
var
|
|
4758
|
+
var _this30 = this;
|
|
4355
4759
|
|
|
4356
4760
|
var html = "";
|
|
4357
4761
|
|
|
@@ -4413,14 +4817,14 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
4413
4817
|
}
|
|
4414
4818
|
|
|
4415
4819
|
if (polarity === true) {
|
|
4416
|
-
if (typeof
|
|
4820
|
+
if (typeof _this30.options.data[parts[0]] !== 'undefined' && _this30.options.data[parts[0]] === parts[1]) {
|
|
4417
4821
|
// remove the <if> tags
|
|
4418
4822
|
removeAll = false;
|
|
4419
4823
|
} else if (parts[0] === parts[1]) {
|
|
4420
4824
|
removeAll = false;
|
|
4421
4825
|
}
|
|
4422
4826
|
} else if (polarity === false) {
|
|
4423
|
-
if (typeof
|
|
4827
|
+
if (typeof _this30.options.data[parts[0]] !== 'undefined' && _this30.options.data[parts[0]] !== parts[1]) {
|
|
4424
4828
|
// remove the <if> tags
|
|
4425
4829
|
removeAll = false;
|
|
4426
4830
|
}
|
|
@@ -4516,6 +4920,7 @@ var WebsyUtils = {
|
|
|
4516
4920
|
var red = 0;
|
|
4517
4921
|
var green = 0;
|
|
4518
4922
|
var blue = 0;
|
|
4923
|
+
var alpha = 1;
|
|
4519
4924
|
|
|
4520
4925
|
if (backgroundColor.indexOf('#') !== -1) {
|
|
4521
4926
|
// hex color
|
|
@@ -4527,14 +4932,16 @@ var WebsyUtils = {
|
|
|
4527
4932
|
blue = parseInt(colorParts[4] + colorParts[5], 16);
|
|
4528
4933
|
} else if (backgroundColor.toLowerCase().indexOf('rgb') !== -1) {
|
|
4529
4934
|
// rgb color
|
|
4530
|
-
colorParts = backgroundColor.replace(/
|
|
4935
|
+
colorParts = backgroundColor.replace(/rgba\(/gi, '').replace(/\)/gi, '');
|
|
4936
|
+
colorParts = colorParts.replace(/rgb\(/gi, '');
|
|
4531
4937
|
colorParts = colorParts.split(',');
|
|
4532
4938
|
red = colorParts[0];
|
|
4533
4939
|
green = colorParts[1];
|
|
4534
4940
|
blue = colorParts[2];
|
|
4941
|
+
alpha = colorParts[3] || 1;
|
|
4535
4942
|
}
|
|
4536
4943
|
|
|
4537
|
-
return red * 0.299 + green * 0.587 + blue * 0.114 > 186 ? darkColor : lightColor;
|
|
4944
|
+
return (red * 0.299 + green * 0.587 + blue * 0.114) / alpha > 186 ? darkColor : lightColor;
|
|
4538
4945
|
},
|
|
4539
4946
|
measureText: function measureText(text) {
|
|
4540
4947
|
var rotation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
@@ -4707,7 +5114,7 @@ var WebsyUtils = {
|
|
|
4707
5114
|
|
|
4708
5115
|
var WebsyTable = /*#__PURE__*/function () {
|
|
4709
5116
|
function WebsyTable(elementId, options) {
|
|
4710
|
-
var
|
|
5117
|
+
var _this31 = this;
|
|
4711
5118
|
|
|
4712
5119
|
_classCallCheck(this, WebsyTable);
|
|
4713
5120
|
|
|
@@ -4745,8 +5152,8 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4745
5152
|
allowClear: false,
|
|
4746
5153
|
disableSearch: true,
|
|
4747
5154
|
onItemSelected: function onItemSelected(selectedItem) {
|
|
4748
|
-
if (
|
|
4749
|
-
|
|
5155
|
+
if (_this31.options.onChangePageSize) {
|
|
5156
|
+
_this31.options.onChangePageSize(selectedItem.value);
|
|
4750
5157
|
}
|
|
4751
5158
|
}
|
|
4752
5159
|
});
|
|
@@ -4767,7 +5174,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4767
5174
|
_createClass(WebsyTable, [{
|
|
4768
5175
|
key: "appendRows",
|
|
4769
5176
|
value: function appendRows(data) {
|
|
4770
|
-
var
|
|
5177
|
+
var _this32 = this;
|
|
4771
5178
|
|
|
4772
5179
|
this.hideError();
|
|
4773
5180
|
var bodyHTML = '';
|
|
@@ -4775,15 +5182,15 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4775
5182
|
if (data) {
|
|
4776
5183
|
bodyHTML += data.map(function (r, rowIndex) {
|
|
4777
5184
|
return '<tr>' + r.map(function (c, i) {
|
|
4778
|
-
if (
|
|
5185
|
+
if (_this32.options.columns[i].show !== false) {
|
|
4779
5186
|
var style = '';
|
|
4780
5187
|
|
|
4781
5188
|
if (c.style) {
|
|
4782
5189
|
style += c.style;
|
|
4783
5190
|
}
|
|
4784
5191
|
|
|
4785
|
-
if (
|
|
4786
|
-
style += "width: ".concat(
|
|
5192
|
+
if (_this32.options.columns[i].width) {
|
|
5193
|
+
style += "width: ".concat(_this32.options.columns[i].width, "; ");
|
|
4787
5194
|
}
|
|
4788
5195
|
|
|
4789
5196
|
if (c.backgroundColor) {
|
|
@@ -4798,18 +5205,18 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4798
5205
|
style += "color: ".concat(c.color, "; ");
|
|
4799
5206
|
}
|
|
4800
5207
|
|
|
4801
|
-
if (
|
|
4802
|
-
return "\n <td \n data-row-index='".concat(
|
|
4803
|
-
} else if ((
|
|
4804
|
-
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(
|
|
5208
|
+
if (_this32.options.columns[i].showAsLink === true && c.value.trim() !== '') {
|
|
5209
|
+
return "\n <td \n data-row-index='".concat(_this32.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this32.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(_this32.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this32.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
|
|
5210
|
+
} else if ((_this32.options.columns[i].showAsNavigatorLink === true || _this32.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
|
|
5211
|
+
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this32.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this32.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this32.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this32.options.columns[i].linkText || c.value, "</td>\n ");
|
|
4805
5212
|
} else {
|
|
4806
5213
|
var info = c.value;
|
|
4807
5214
|
|
|
4808
|
-
if (
|
|
5215
|
+
if (_this32.options.columns[i].showAsImage === true) {
|
|
4809
5216
|
c.value = "\n <img src='".concat(c.value, "'>\n ");
|
|
4810
5217
|
}
|
|
4811
5218
|
|
|
4812
|
-
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(
|
|
5219
|
+
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this32.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this32.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 ");
|
|
4813
5220
|
}
|
|
4814
5221
|
}
|
|
4815
5222
|
}).join('') + '</tr>';
|
|
@@ -4981,7 +5388,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4981
5388
|
}, {
|
|
4982
5389
|
key: "render",
|
|
4983
5390
|
value: function render(data) {
|
|
4984
|
-
var
|
|
5391
|
+
var _this33 = this;
|
|
4985
5392
|
|
|
4986
5393
|
if (!this.options.columns) {
|
|
4987
5394
|
return;
|
|
@@ -5006,7 +5413,17 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5006
5413
|
|
|
5007
5414
|
var headHTML = '<tr>' + this.options.columns.map(function (c, i) {
|
|
5008
5415
|
if (c.show !== false) {
|
|
5009
|
-
|
|
5416
|
+
var style = '';
|
|
5417
|
+
|
|
5418
|
+
if (c.style) {
|
|
5419
|
+
style += c.style;
|
|
5420
|
+
}
|
|
5421
|
+
|
|
5422
|
+
if (c.width) {
|
|
5423
|
+
style += "width: ".concat(c.width || 'auto', ";");
|
|
5424
|
+
}
|
|
5425
|
+
|
|
5426
|
+
return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-index=\"").concat(i, "\" \n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n <!--").concat(c.searchable === true ? _this33.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
|
|
5010
5427
|
}
|
|
5011
5428
|
}).join('') + '</tr>';
|
|
5012
5429
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
@@ -5025,7 +5442,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5025
5442
|
|
|
5026
5443
|
if (pagingEl) {
|
|
5027
5444
|
var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
|
|
5028
|
-
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(
|
|
5445
|
+
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this33.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
5029
5446
|
});
|
|
5030
5447
|
var startIndex = 0;
|
|
5031
5448
|
|
|
@@ -5093,7 +5510,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5093
5510
|
|
|
5094
5511
|
var WebsyTable2 = /*#__PURE__*/function () {
|
|
5095
5512
|
function WebsyTable2(elementId, options) {
|
|
5096
|
-
var
|
|
5513
|
+
var _this34 = this;
|
|
5097
5514
|
|
|
5098
5515
|
_classCallCheck(this, WebsyTable2);
|
|
5099
5516
|
|
|
@@ -5134,8 +5551,8 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5134
5551
|
allowClear: false,
|
|
5135
5552
|
disableSearch: true,
|
|
5136
5553
|
onItemSelected: function onItemSelected(selectedItem) {
|
|
5137
|
-
if (
|
|
5138
|
-
|
|
5554
|
+
if (_this34.options.onChangePageSize) {
|
|
5555
|
+
_this34.options.onChangePageSize(selectedItem.value);
|
|
5139
5556
|
}
|
|
5140
5557
|
}
|
|
5141
5558
|
});
|
|
@@ -5159,7 +5576,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5159
5576
|
_createClass(WebsyTable2, [{
|
|
5160
5577
|
key: "appendRows",
|
|
5161
5578
|
value: function appendRows(data) {
|
|
5162
|
-
var
|
|
5579
|
+
var _this35 = this;
|
|
5163
5580
|
|
|
5164
5581
|
this.hideError();
|
|
5165
5582
|
var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
|
|
@@ -5168,15 +5585,15 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5168
5585
|
if (data) {
|
|
5169
5586
|
bodyHTML += data.map(function (r, rowIndex) {
|
|
5170
5587
|
return '<tr>' + r.map(function (c, i) {
|
|
5171
|
-
if (
|
|
5172
|
-
var style = "height: ".concat(
|
|
5588
|
+
if (_this35.options.columns[i].show !== false) {
|
|
5589
|
+
var style = "height: ".concat(_this35.options.cellSize, "px; line-height: ").concat(_this35.options.cellSize, "px;");
|
|
5173
5590
|
|
|
5174
5591
|
if (c.style) {
|
|
5175
5592
|
style += c.style;
|
|
5176
5593
|
}
|
|
5177
5594
|
|
|
5178
|
-
if (
|
|
5179
|
-
style += "width: ".concat(
|
|
5595
|
+
if (_this35.options.columns[i].width) {
|
|
5596
|
+
style += "width: ".concat(_this35.options.columns[i].width, "; ");
|
|
5180
5597
|
}
|
|
5181
5598
|
|
|
5182
5599
|
if (c.backgroundColor) {
|
|
@@ -5191,18 +5608,18 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5191
5608
|
style += "color: ".concat(c.color, "; ");
|
|
5192
5609
|
}
|
|
5193
5610
|
|
|
5194
|
-
if (
|
|
5195
|
-
return "\n <td \n data-row-index='".concat(
|
|
5196
|
-
} else if ((
|
|
5197
|
-
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(
|
|
5611
|
+
if (_this35.options.columns[i].showAsLink === true && c.value.trim() !== '') {
|
|
5612
|
+
return "\n <td \n data-row-index='".concat(_this35.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this35.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(_this35.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this35.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
|
|
5613
|
+
} else if ((_this35.options.columns[i].showAsNavigatorLink === true || _this35.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
|
|
5614
|
+
return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this35.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this35.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this35.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this35.options.columns[i].linkText || c.value, "</td>\n ");
|
|
5198
5615
|
} else {
|
|
5199
5616
|
var info = c.value;
|
|
5200
5617
|
|
|
5201
|
-
if (
|
|
5618
|
+
if (_this35.options.columns[i].showAsImage === true) {
|
|
5202
5619
|
c.value = "\n <img src='".concat(c.value, "'>\n ");
|
|
5203
5620
|
}
|
|
5204
5621
|
|
|
5205
|
-
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(
|
|
5622
|
+
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this35.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this35.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 ");
|
|
5206
5623
|
}
|
|
5207
5624
|
}
|
|
5208
5625
|
}).join('') + '</tr>';
|
|
@@ -5415,7 +5832,11 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5415
5832
|
}, {
|
|
5416
5833
|
key: "hideLoading",
|
|
5417
5834
|
value: function hideLoading() {
|
|
5418
|
-
this.
|
|
5835
|
+
if (this.options.onLoading) {
|
|
5836
|
+
this.options.onLoading(false);
|
|
5837
|
+
} else {
|
|
5838
|
+
this.loadingDialog.hide();
|
|
5839
|
+
}
|
|
5419
5840
|
}
|
|
5420
5841
|
}, {
|
|
5421
5842
|
key: "internalSort",
|
|
@@ -5461,7 +5882,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5461
5882
|
}, {
|
|
5462
5883
|
key: "render",
|
|
5463
5884
|
value: function render(data) {
|
|
5464
|
-
var
|
|
5885
|
+
var _this36 = this;
|
|
5465
5886
|
|
|
5466
5887
|
if (!this.options.columns) {
|
|
5467
5888
|
return;
|
|
@@ -5497,7 +5918,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5497
5918
|
style += "width: ".concat(c.width || 'auto', "; ");
|
|
5498
5919
|
}
|
|
5499
5920
|
|
|
5500
|
-
return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-sort-index=\"").concat(c.sortIndex || i, "\"\n data-index=\"").concat(i, "\"\n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n ").concat(c.searchable === true ?
|
|
5921
|
+
return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-sort-index=\"").concat(c.sortIndex || i, "\"\n data-index=\"").concat(i, "\"\n data-sort=\"").concat(c.sort, "\"\n style=\"").concat(c.style || '', "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n ").concat(c.searchable === true ? _this36.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
|
|
5501
5922
|
}
|
|
5502
5923
|
}).join('') + '</tr>';
|
|
5503
5924
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
@@ -5508,7 +5929,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5508
5929
|
var dropdownHTML = "";
|
|
5509
5930
|
this.options.columns.forEach(function (c, i) {
|
|
5510
5931
|
if (c.searchable && c.searchField) {
|
|
5511
|
-
dropdownHTML += "\n <div id=\"".concat(
|
|
5932
|
+
dropdownHTML += "\n <div id=\"".concat(_this36.elementId, "_columnSearch_").concat(i, "\" class=\"websy-modal-dropdown\"></div>\n ");
|
|
5512
5933
|
}
|
|
5513
5934
|
});
|
|
5514
5935
|
dropdownEl.innerHTML = dropdownHTML;
|
|
@@ -5530,7 +5951,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5530
5951
|
|
|
5531
5952
|
if (pagingEl) {
|
|
5532
5953
|
var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
|
|
5533
|
-
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(
|
|
5954
|
+
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this36.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
5534
5955
|
});
|
|
5535
5956
|
var startIndex = 0;
|
|
5536
5957
|
|
|
@@ -5612,12 +6033,16 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5612
6033
|
}, {
|
|
5613
6034
|
key: "showLoading",
|
|
5614
6035
|
value: function showLoading(options) {
|
|
5615
|
-
this.
|
|
6036
|
+
if (this.options.onLoading) {
|
|
6037
|
+
this.options.onLoading(true);
|
|
6038
|
+
} else {
|
|
6039
|
+
this.loadingDialog.show(options);
|
|
6040
|
+
}
|
|
5616
6041
|
}
|
|
5617
6042
|
}, {
|
|
5618
6043
|
key: "getColumnParameters",
|
|
5619
6044
|
value: function getColumnParameters(values) {
|
|
5620
|
-
var
|
|
6045
|
+
var _this37 = this;
|
|
5621
6046
|
|
|
5622
6047
|
var tableEl = document.getElementById("".concat(this.elementId, "_table"));
|
|
5623
6048
|
tableEl.style.tableLayout = 'auto';
|
|
@@ -5625,10 +6050,10 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5625
6050
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
5626
6051
|
var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
|
|
5627
6052
|
headEl.innerHTML = '<tr style="visibility: hidden;">' + values.map(function (c, i) {
|
|
5628
|
-
return "\n <th>\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField\" \n >\n ".concat(c.value || 'nbsp;', "\n </div>\n </div> \n ").concat(c.searchable === true ?
|
|
6053
|
+
return "\n <th>\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField\" \n >\n ".concat(c.value || 'nbsp;', "\n </div>\n </div> \n ").concat(c.searchable === true ? _this37.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
|
|
5629
6054
|
}).join('') + '</tr>';
|
|
5630
6055
|
bodyEl.innerHTML = '<tr style="visibility: hidden;">' + values.map(function (c) {
|
|
5631
|
-
return "\n <td \n style='height: ".concat(
|
|
6056
|
+
return "\n <td \n style='height: ".concat(_this37.options.cellSize, "px; line-height: ").concat(_this37.options.cellSize, "px; padding: 10px 5px;'\n >").concat(c.value || ' ', "</td>\n ");
|
|
5632
6057
|
}).join('') + '</tr>'; // get height of the first data cell
|
|
5633
6058
|
|
|
5634
6059
|
var cells = bodyEl.querySelectorAll("tr:first-of-type td");
|
|
@@ -5673,37 +6098,716 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5673
6098
|
|
|
5674
6099
|
return WebsyTable2;
|
|
5675
6100
|
}();
|
|
5676
|
-
/* global
|
|
5677
|
-
|
|
6101
|
+
/* global WebsyDesigns */
|
|
5678
6102
|
|
|
5679
|
-
var WebsyChart = /*#__PURE__*/function () {
|
|
5680
|
-
function WebsyChart(elementId, options) {
|
|
5681
|
-
var _this37 = this;
|
|
5682
6103
|
|
|
5683
|
-
|
|
6104
|
+
var WebsyTable3 = /*#__PURE__*/function () {
|
|
6105
|
+
function WebsyTable3(elementId, options) {
|
|
6106
|
+
_classCallCheck(this, WebsyTable3);
|
|
5684
6107
|
|
|
6108
|
+
this.elementId = elementId;
|
|
5685
6109
|
var DEFAULTS = {
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
6110
|
+
virtualScroll: false,
|
|
6111
|
+
showTotalsAbove: true,
|
|
6112
|
+
minHandleSize: 20,
|
|
6113
|
+
maxColWidth: '50%',
|
|
6114
|
+
allowPivoting: false,
|
|
6115
|
+
searchIcon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><title>ionicons-v5-f</title><path d=\"M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z\" style=\"fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px\"/><line x1=\"338.29\" y1=\"338.29\" x2=\"448\" y2=\"448\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px\"/></svg>"
|
|
6116
|
+
};
|
|
6117
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
6118
|
+
this.sizes = {};
|
|
6119
|
+
this.scrollDragging = false;
|
|
6120
|
+
this.cellDragging = false;
|
|
6121
|
+
this.vScrollRequired = false;
|
|
6122
|
+
this.hScrollRequired = false;
|
|
6123
|
+
this.pinnedColumns = 0;
|
|
6124
|
+
this.startRow = 0;
|
|
6125
|
+
this.endRow = 0;
|
|
6126
|
+
this.startCol = 0;
|
|
6127
|
+
this.endCol = 0;
|
|
6128
|
+
this.mouseYStart = 0;
|
|
6129
|
+
this.mouseYStart = 0;
|
|
6130
|
+
|
|
6131
|
+
if (!elementId) {
|
|
6132
|
+
console.log('No element Id provided for Websy Table');
|
|
6133
|
+
return;
|
|
6134
|
+
}
|
|
6135
|
+
|
|
6136
|
+
var el = document.getElementById(this.elementId);
|
|
6137
|
+
|
|
6138
|
+
if (el) {
|
|
6139
|
+
var html = "\n <div id='".concat(this.elementId, "_tableContainer' class='websy-vis-table-3 ").concat(this.options.paging === 'pages' ? 'with-paging' : '', " ").concat(this.options.virtualScroll === true ? 'with-virtual-scroll' : '', "'>\n <!--<div class=\"download-button\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M16 11h5l-9 10-9-10h5v-11h8v11zm1 11h-10v2h10v-2z\"/></svg>\n </div>-->\n <div id=\"").concat(this.elementId, "_tableInner\" class=\"websy-table-inner-container\">\n <table id=\"").concat(this.elementId, "_tableHeader\" class=\"websy-table-header\"></table>\n <table id=\"").concat(this.elementId, "_tableBody\" class=\"websy-table-body\"></table>\n <table id=\"").concat(this.elementId, "_tableFooter\" class=\"websy-table-footer\"></table>\n <div id=\"").concat(this.elementId, "_vScrollContainer\" class=\"websy-v-scroll-container\">\n <div id=\"").concat(this.elementId, "_vScrollHandle\" class=\"websy-scroll-handle websy-scroll-handle-y\"></div>\n </div>\n <div id=\"").concat(this.elementId, "_hScrollContainer\" class=\"websy-h-scroll-container\">\n <div id=\"").concat(this.elementId, "_hScrollHandle\" class=\"websy-scroll-handle websy-scroll-handle-x\"></div>\n </div>\n </div> \n <div id=\"").concat(this.elementId, "_errorContainer\" class='websy-vis-error-container'>\n <div>\n <div id=\"").concat(this.elementId, "_errorTitle\"></div>\n <div id=\"").concat(this.elementId, "_errorMessage\"></div>\n </div> \n </div>\n <div id=\"").concat(this.elementId, "_dropdownContainer\"></div>\n <div id=\"").concat(this.elementId, "_loadingContainer\"></div>\n </div>\n ");
|
|
6140
|
+
|
|
6141
|
+
if (this.options.paging === 'pages') {
|
|
6142
|
+
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 ");
|
|
6143
|
+
}
|
|
6144
|
+
|
|
6145
|
+
el.innerHTML = html;
|
|
6146
|
+
el.addEventListener('click', this.handleClick.bind(this));
|
|
6147
|
+
el.addEventListener('mousedown', this.handleMouseDown.bind(this));
|
|
6148
|
+
window.addEventListener('mousemove', this.handleMouseMove.bind(this));
|
|
6149
|
+
window.addEventListener('mouseup', this.handleMouseUp.bind(this));
|
|
6150
|
+
var scrollEl = document.getElementById("".concat(this.elementId, "_tableBody"));
|
|
6151
|
+
|
|
6152
|
+
if (scrollEl) {
|
|
6153
|
+
scrollEl.addEventListener('wheel', this.handleScrollWheel.bind(this));
|
|
6154
|
+
}
|
|
6155
|
+
|
|
6156
|
+
this.loadingDialog = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loadingContainer"));
|
|
6157
|
+
this.render(this.options.data);
|
|
6158
|
+
} else {
|
|
6159
|
+
console.error("No element found with ID ".concat(this.elementId));
|
|
6160
|
+
}
|
|
6161
|
+
}
|
|
6162
|
+
|
|
6163
|
+
_createClass(WebsyTable3, [{
|
|
6164
|
+
key: "appendRows",
|
|
6165
|
+
value: function appendRows(data) {
|
|
6166
|
+
this.hideError();
|
|
6167
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody"));
|
|
6168
|
+
|
|
6169
|
+
if (bodyEl) {
|
|
6170
|
+
if (this.options.virtualScroll === true) {
|
|
6171
|
+
bodyEl.innerHTML = this.buildBodyHtml(data, true);
|
|
6172
|
+
} else {
|
|
6173
|
+
bodyEl.innerHTML += this.buildBodyHtml(data, true);
|
|
6174
|
+
}
|
|
6175
|
+
} // this.data = this.data.concat(data)
|
|
6176
|
+
// this.rowCount = this.data.length
|
|
6177
|
+
|
|
6178
|
+
}
|
|
6179
|
+
}, {
|
|
6180
|
+
key: "buildBodyHtml",
|
|
6181
|
+
value: function buildBodyHtml() {
|
|
6182
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
6183
|
+
var useWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
6184
|
+
|
|
6185
|
+
if (data.length === 0) {
|
|
6186
|
+
return '';
|
|
6187
|
+
}
|
|
6188
|
+
|
|
6189
|
+
var bodyHtml = "";
|
|
6190
|
+
var sizingColumns = this.options.columns[this.options.columns.length - 1];
|
|
6191
|
+
|
|
6192
|
+
if (useWidths === true) {
|
|
6193
|
+
bodyHtml += '<colgroup>';
|
|
6194
|
+
bodyHtml += sizingColumns.map(function (c) {
|
|
6195
|
+
return "\n <col\n style='width: ".concat(c.width || c.actualWidth, "px!important'\n ></col>\n ");
|
|
6196
|
+
}).join('');
|
|
6197
|
+
bodyHtml += '</colgroup>';
|
|
6198
|
+
}
|
|
6199
|
+
|
|
6200
|
+
data.forEach(function (row) {
|
|
6201
|
+
bodyHtml += "<tr class=\"websy-table-row\">";
|
|
6202
|
+
row.forEach(function (cell, cellIndex) {
|
|
6203
|
+
var style = '';
|
|
6204
|
+
|
|
6205
|
+
if (cell.style) {
|
|
6206
|
+
style += cell.style;
|
|
6207
|
+
}
|
|
6208
|
+
|
|
6209
|
+
if (cell.backgroundColor) {
|
|
6210
|
+
style += "background-color: ".concat(cell.backgroundColor, "; ");
|
|
6211
|
+
|
|
6212
|
+
if (!cell.color) {
|
|
6213
|
+
style += "color: ".concat(WebsyDesigns.Utils.getLightDark(cell.backgroundColor), "; ");
|
|
6214
|
+
}
|
|
6215
|
+
}
|
|
6216
|
+
|
|
6217
|
+
if (cell.color) {
|
|
6218
|
+
style += "color: ".concat(cell.color, "; ");
|
|
6219
|
+
}
|
|
6220
|
+
|
|
6221
|
+
bodyHtml += "<td \n class='websy-table-cell'\n style='".concat(style, "'\n data-info='").concat(cell.value, "'\n colspan='").concat(cell.colspan || 1, "'\n rowspan='").concat(cell.rowspan || 1, "'\n "); // if (useWidths === true) {
|
|
6222
|
+
// bodyHtml += `
|
|
6223
|
+
// style='width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important'
|
|
6224
|
+
// width='${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}'
|
|
6225
|
+
// `
|
|
6226
|
+
// }
|
|
6227
|
+
|
|
6228
|
+
bodyHtml += "\n >\n ".concat(cell.value, "\n </td>");
|
|
6229
|
+
});
|
|
6230
|
+
bodyHtml += "</tr>";
|
|
6231
|
+
}); // bodyHtml += `</div>`
|
|
6232
|
+
|
|
6233
|
+
return bodyHtml;
|
|
6234
|
+
}
|
|
6235
|
+
}, {
|
|
6236
|
+
key: "buildHeaderHtml",
|
|
6237
|
+
value: function buildHeaderHtml() {
|
|
6238
|
+
var _this38 = this;
|
|
6239
|
+
|
|
6240
|
+
var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
6241
|
+
var headerHtml = '';
|
|
6242
|
+
var sizingColumns = this.options.columns[this.options.columns.length - 1];
|
|
6243
|
+
|
|
6244
|
+
if (useWidths === true) {
|
|
6245
|
+
headerHtml += '<colgroup>';
|
|
6246
|
+
headerHtml += sizingColumns.map(function (c) {
|
|
6247
|
+
return "\n <col\n style='width: ".concat(c.width || c.actualWidth, "px!important'\n ></col>\n ");
|
|
6248
|
+
}).join('');
|
|
6249
|
+
headerHtml += '</colgroup>';
|
|
6250
|
+
}
|
|
6251
|
+
|
|
6252
|
+
this.options.columns.forEach(function (row, rowIndex) {
|
|
6253
|
+
if (useWidths === false && rowIndex !== _this38.options.columns.length - 1) {
|
|
6254
|
+
// if we're calculating the size we only want to render the last row of column headers
|
|
6255
|
+
return;
|
|
6256
|
+
}
|
|
6257
|
+
|
|
6258
|
+
headerHtml += "<tr class=\"websy-table-row websy-table-header-row\">";
|
|
6259
|
+
row.forEach(function (col, colIndex) {
|
|
6260
|
+
headerHtml += "<td \n class='websy-table-cell' \n style='".concat(col.style, "' \n colspan='").concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n "); // if (useWidths === true && rowIndex === this.options.columns.length - 1) {
|
|
6261
|
+
// headerHtml += `
|
|
6262
|
+
// style='width: ${col.width || col.actualWidth}px'
|
|
6263
|
+
// width='${col.width || col.actualWidth}'
|
|
6264
|
+
// `
|
|
6265
|
+
// }
|
|
6266
|
+
|
|
6267
|
+
headerHtml += " \n >\n <div>\n ".concat(col.name, "\n ").concat(col.searchable === true ? _this38.buildSearchIcon(col, colIndex) : '', "\n </div>\n </td>");
|
|
6268
|
+
});
|
|
6269
|
+
headerHtml += "</tr>";
|
|
6270
|
+
});
|
|
6271
|
+
var dropdownEl = document.getElementById("".concat(this.elementId, "_dropdownContainer"));
|
|
6272
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (c, i) {
|
|
6273
|
+
if (c.searchable && c.isExternalSearch === true) {
|
|
6274
|
+
var testEl = document.getElementById("".concat(_this38.elementId, "_columnSearch_").concat(c.dimId || i));
|
|
6275
|
+
|
|
6276
|
+
if (!testEl) {
|
|
6277
|
+
var newE = document.createElement('div');
|
|
6278
|
+
newE.id = "".concat(_this38.elementId, "_columnSearch_").concat(c.dimId || i);
|
|
6279
|
+
newE.className = 'websy-modal-dropdown';
|
|
6280
|
+
dropdownEl.appendChild(newE);
|
|
6281
|
+
}
|
|
6282
|
+
}
|
|
6283
|
+
});
|
|
6284
|
+
return headerHtml;
|
|
6285
|
+
}
|
|
6286
|
+
}, {
|
|
6287
|
+
key: "buildSearchIcon",
|
|
6288
|
+
value: function buildSearchIcon(col, index) {
|
|
6289
|
+
return "\n <div class=\"websy-table-search-icon\" data-col-id=\"".concat(col.dimId, "\" data-col-index=\"").concat(index, "\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><title>ionicons-v5-f</title><path d=\"M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z\" style=\"fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px\"/><line x1=\"338.29\" y1=\"338.29\" x2=\"448\" y2=\"448\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px\"/></svg>\n </div>\n ");
|
|
6290
|
+
}
|
|
6291
|
+
}, {
|
|
6292
|
+
key: "buildTotalHtml",
|
|
6293
|
+
value: function buildTotalHtml() {
|
|
6294
|
+
var _this39 = this;
|
|
6295
|
+
|
|
6296
|
+
var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
6297
|
+
|
|
6298
|
+
if (!this.options.totals) {
|
|
6299
|
+
return '';
|
|
6300
|
+
}
|
|
6301
|
+
|
|
6302
|
+
var totalHtml = "<tr class=\"websy-table-row websy-table-total-row\">";
|
|
6303
|
+
this.options.totals.forEach(function (col, colIndex) {
|
|
6304
|
+
totalHtml += "<td \n class='websy-table-cell'\n colspan='".concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n ");
|
|
6305
|
+
|
|
6306
|
+
if (useWidths === true) {
|
|
6307
|
+
totalHtml += "\n style='width: ".concat(_this39.options.columns[_this39.options.columns.length - 1][colIndex].width || _this39.options.columns[_this39.options.columns.length - 1][colIndex].actualWidth, "px'\n width='").concat(col.width || col.actualWidth, "'\n ");
|
|
6308
|
+
}
|
|
6309
|
+
|
|
6310
|
+
totalHtml += " \n >\n ".concat(col.value, "\n </td>");
|
|
6311
|
+
});
|
|
6312
|
+
totalHtml += "</tr>";
|
|
6313
|
+
return totalHtml;
|
|
6314
|
+
}
|
|
6315
|
+
}, {
|
|
6316
|
+
key: "calculateSizes",
|
|
6317
|
+
value: function calculateSizes() {
|
|
6318
|
+
var _this40 = this;
|
|
6319
|
+
|
|
6320
|
+
var sample = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
6321
|
+
var totalRowCount = arguments.length > 1 ? arguments[1] : undefined;
|
|
6322
|
+
var totalColumnCount = arguments.length > 2 ? arguments[2] : undefined;
|
|
6323
|
+
var pinnedColumns = arguments.length > 3 ? arguments[3] : undefined;
|
|
6324
|
+
this.totalRowCount = totalRowCount; // probably need some error handling here if no value is passed in
|
|
6325
|
+
|
|
6326
|
+
this.totalColumnCount = totalColumnCount; // probably need some error handling here if no value is passed in
|
|
6327
|
+
|
|
6328
|
+
this.pinnedColumns = pinnedColumns; // probably need some error handling here if no value is passed in
|
|
6329
|
+
|
|
6330
|
+
var outerEl = document.getElementById(this.elementId);
|
|
6331
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
6332
|
+
var headEl = document.getElementById("".concat(this.elementId, "_tableHeader"));
|
|
6333
|
+
headEl.style.width = 'auto';
|
|
6334
|
+
headEl.innerHTML = this.buildHeaderHtml();
|
|
6335
|
+
this.sizes.outer = outerEl.getBoundingClientRect();
|
|
6336
|
+
this.sizes.table = tableEl.getBoundingClientRect();
|
|
6337
|
+
this.sizes.header = headEl.getBoundingClientRect();
|
|
6338
|
+
var maxWidth;
|
|
6339
|
+
|
|
6340
|
+
if (typeof this.options.maxColWidth === 'number') {
|
|
6341
|
+
maxWidth = this.options.maxColWidth;
|
|
6342
|
+
} else if (this.options.maxColWidth.indexOf('%') !== -1) {
|
|
6343
|
+
maxWidth = this.sizes.outer.width * (+this.options.maxColWidth.replace('%', '') / 100);
|
|
6344
|
+
} else if (this.options.maxColWidth.indexOf('px') !== -1) {
|
|
6345
|
+
maxWidth = +this.options.maxColWidth.replace('px', '');
|
|
6346
|
+
}
|
|
6347
|
+
|
|
6348
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody"));
|
|
6349
|
+
bodyEl.style.width = 'auto';
|
|
6350
|
+
bodyEl.innerHTML = this.buildBodyHtml([sample]);
|
|
6351
|
+
var footerEl = document.getElementById("".concat(this.elementId, "_tableFooter"));
|
|
6352
|
+
footerEl.innerHTML = this.buildTotalHtml();
|
|
6353
|
+
this.sizes.total = footerEl.getBoundingClientRect();
|
|
6354
|
+
var rows = Array.from(tableEl.querySelectorAll('.websy-table-row'));
|
|
6355
|
+
var totalWidth = 0;
|
|
6356
|
+
this.sizes.scrollableWidth = this.sizes.outer.width;
|
|
6357
|
+
rows.forEach(function (row, rowIndex) {
|
|
6358
|
+
Array.from(row.children).forEach(function (col, colIndex) {
|
|
6359
|
+
var colSize = col.getBoundingClientRect();
|
|
6360
|
+
_this40.sizes.cellHeight = colSize.height;
|
|
6361
|
+
|
|
6362
|
+
if (_this40.options.columns[_this40.options.columns.length - 1][colIndex]) {
|
|
6363
|
+
if (!_this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth) {
|
|
6364
|
+
_this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth = 0;
|
|
6365
|
+
}
|
|
6366
|
+
|
|
6367
|
+
_this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth = Math.min(Math.max(_this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth, colSize.width), maxWidth);
|
|
6368
|
+
_this40.options.columns[_this40.options.columns.length - 1][colIndex].cellHeight = colSize.height;
|
|
6369
|
+
}
|
|
6370
|
+
});
|
|
6371
|
+
});
|
|
6372
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
|
|
6373
|
+
if (colIndex < _this40.pinnedColumns) {
|
|
6374
|
+
_this40.sizes.scrollableWidth -= col.actualWidth;
|
|
6375
|
+
}
|
|
6376
|
+
});
|
|
6377
|
+
this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce(function (a, b) {
|
|
6378
|
+
return a + (b.width || b.actualWidth);
|
|
6379
|
+
}, 0);
|
|
6380
|
+
var outerSize = outerEl.getBoundingClientRect();
|
|
6381
|
+
|
|
6382
|
+
if (this.sizes.totalWidth < outerSize.width) {
|
|
6383
|
+
this.sizes.totalWidth = 0;
|
|
6384
|
+
var equalWidth = outerSize.width / this.options.columns[this.options.columns.length - 1].length;
|
|
6385
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (c, i) {
|
|
6386
|
+
if (!c.width) {
|
|
6387
|
+
if (c.actualWidth < equalWidth) {
|
|
6388
|
+
// adjust the width
|
|
6389
|
+
c.actualWidth = equalWidth;
|
|
6390
|
+
}
|
|
6391
|
+
}
|
|
6392
|
+
|
|
6393
|
+
_this40.sizes.totalWidth += c.width || c.actualWidth;
|
|
6394
|
+
equalWidth = (outerSize.width - _this40.sizes.totalWidth) / (_this40.options.columns[_this40.options.columns.length - 1].length - (i + 1));
|
|
6395
|
+
});
|
|
6396
|
+
} // take the height of the last cell as the official height for data cells
|
|
6397
|
+
// this.sizes.dataCellHeight = this.options.columns[this.options.columns.length - 1].cellHeight
|
|
6398
|
+
|
|
6399
|
+
|
|
6400
|
+
headEl.innerHTML = '';
|
|
6401
|
+
bodyEl.innerHTML = '';
|
|
6402
|
+
footerEl.innerHTML = '';
|
|
6403
|
+
headEl.style.width = 'initial';
|
|
6404
|
+
bodyEl.style.width = 'initial';
|
|
6405
|
+
this.sizes.bodyHeight = this.sizes.table.height - (this.sizes.header.height + this.sizes.total.height);
|
|
6406
|
+
this.sizes.rowsToRender = Math.ceil(this.sizes.bodyHeight / this.sizes.cellHeight);
|
|
6407
|
+
this.sizes.rowsToRenderPrecise = this.sizes.bodyHeight / this.sizes.cellHeight;
|
|
6408
|
+
this.startRow = 0;
|
|
6409
|
+
this.endRow = this.sizes.rowsToRender;
|
|
6410
|
+
this.startCol = 0;
|
|
6411
|
+
this.endCol = this.options.columns[this.options.columns.length - 1].length;
|
|
6412
|
+
|
|
6413
|
+
if (this.sizes.rowsToRender < this.totalRowCount) {
|
|
6414
|
+
this.vScrollRequired = true;
|
|
6415
|
+
}
|
|
6416
|
+
|
|
6417
|
+
if (this.sizes.totalWidth > this.sizes.outer.width) {
|
|
6418
|
+
this.hScrollRequired = true;
|
|
6419
|
+
}
|
|
6420
|
+
|
|
6421
|
+
this.options.allColumns = this.options.columns.map(function (c) {
|
|
6422
|
+
return c;
|
|
6423
|
+
});
|
|
6424
|
+
console.log('sizes', this.sizes);
|
|
6425
|
+
return this.sizes;
|
|
6426
|
+
}
|
|
6427
|
+
}, {
|
|
6428
|
+
key: "createSample",
|
|
6429
|
+
value: function createSample(data) {
|
|
6430
|
+
var output = [];
|
|
6431
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
|
|
6432
|
+
if (col.maxLength) {
|
|
6433
|
+
output.push({
|
|
6434
|
+
value: new Array(col.maxLength).fill('W').join('')
|
|
6435
|
+
});
|
|
6436
|
+
} else if (data) {
|
|
6437
|
+
var longest = '';
|
|
6438
|
+
|
|
6439
|
+
for (var i = 0; i < Math.min(data.length, 1000); i++) {
|
|
6440
|
+
if (longest.length < data[i][colIndex].value.length) {
|
|
6441
|
+
longest = data[i][colIndex].value;
|
|
6442
|
+
}
|
|
6443
|
+
}
|
|
6444
|
+
|
|
6445
|
+
output.push({
|
|
6446
|
+
value: longest
|
|
6447
|
+
});
|
|
6448
|
+
} else {
|
|
6449
|
+
output.push({
|
|
6450
|
+
value: ''
|
|
6451
|
+
});
|
|
6452
|
+
}
|
|
6453
|
+
});
|
|
6454
|
+
return output;
|
|
6455
|
+
}
|
|
6456
|
+
}, {
|
|
6457
|
+
key: "handleClick",
|
|
6458
|
+
value: function handleClick(event) {
|
|
6459
|
+
if (event.target.classList.contains('websy-table-search-icon')) {
|
|
6460
|
+
console.log('clicked on search icon');
|
|
6461
|
+
var colIndex = +event.target.getAttribute('data-col-index');
|
|
6462
|
+
|
|
6463
|
+
if (this.options.columns[this.options.columns.length - 1][colIndex].onSearch) {
|
|
6464
|
+
this.options.columns[this.options.columns.length - 1][colIndex].onSearch(event, this.options.columns[this.options.columns.length - 1][colIndex]);
|
|
6465
|
+
}
|
|
6466
|
+
}
|
|
6467
|
+
}
|
|
6468
|
+
}, {
|
|
6469
|
+
key: "handleMouseDown",
|
|
6470
|
+
value: function handleMouseDown(event) {
|
|
6471
|
+
if (event.target.classList.contains('websy-scroll-handle-y')) {
|
|
6472
|
+
// set up the scroll start values
|
|
6473
|
+
this.scrollDragging = true;
|
|
6474
|
+
this.scrollDirection = 'y';
|
|
6475
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
6476
|
+
this.handleYStart = scrollHandleEl.offsetTop;
|
|
6477
|
+
this.mouseYStart = event.pageY;
|
|
6478
|
+
console.log('mouse down', this.handleYStart, this.mouseYStart);
|
|
6479
|
+
console.log(scrollHandleEl.offsetTop);
|
|
6480
|
+
} else if (event.target.classList.contains('websy-scroll-handle-x')) {
|
|
6481
|
+
this.scrollDragging = true;
|
|
6482
|
+
this.scrollDirection = 'x';
|
|
6483
|
+
|
|
6484
|
+
var _scrollHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
6485
|
+
|
|
6486
|
+
this.handleXStart = _scrollHandleEl.offsetLeft;
|
|
6487
|
+
this.mouseXStart = event.pageX;
|
|
6488
|
+
}
|
|
6489
|
+
}
|
|
6490
|
+
}, {
|
|
6491
|
+
key: "handleMouseMove",
|
|
6492
|
+
value: function handleMouseMove(event) {
|
|
6493
|
+
// event.preventDefault()
|
|
6494
|
+
if (this.scrollDragging === true) {
|
|
6495
|
+
if (this.scrollDirection === 'y') {
|
|
6496
|
+
var diff = event.pageY - this.mouseYStart;
|
|
6497
|
+
this.scrollY(diff);
|
|
6498
|
+
} else if (this.scrollDirection === 'x') {
|
|
6499
|
+
var _diff = event.pageX - this.mouseXStart;
|
|
6500
|
+
|
|
6501
|
+
this.scrollX(_diff);
|
|
6502
|
+
}
|
|
6503
|
+
}
|
|
6504
|
+
}
|
|
6505
|
+
}, {
|
|
6506
|
+
key: "handleMouseUp",
|
|
6507
|
+
value: function handleMouseUp(event) {
|
|
6508
|
+
this.scrollDragging = false;
|
|
6509
|
+
this.cellDragging = false;
|
|
6510
|
+
this.handleYStart = null;
|
|
6511
|
+
this.mouseYStart = null;
|
|
6512
|
+
this.handleXStart = null;
|
|
6513
|
+
this.mouseXStart = null;
|
|
6514
|
+
}
|
|
6515
|
+
}, {
|
|
6516
|
+
key: "handleScrollWheel",
|
|
6517
|
+
value: function handleScrollWheel(event) {
|
|
6518
|
+
event.preventDefault();
|
|
6519
|
+
console.log('scrollwheel', event);
|
|
6520
|
+
|
|
6521
|
+
if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
|
|
6522
|
+
this.scrollX(Math.max(-5, Math.min(5, event.deltaX)));
|
|
6523
|
+
} else {
|
|
6524
|
+
this.scrollY(Math.max(-5, Math.min(5, event.deltaY)));
|
|
6525
|
+
}
|
|
6526
|
+
}
|
|
6527
|
+
}, {
|
|
6528
|
+
key: "hideError",
|
|
6529
|
+
value: function hideError() {
|
|
6530
|
+
var el = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
6531
|
+
|
|
6532
|
+
if (el) {
|
|
6533
|
+
el.classList.remove('has-error');
|
|
6534
|
+
}
|
|
6535
|
+
|
|
6536
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_tableInner"));
|
|
6537
|
+
tableEl.classList.remove('hidden');
|
|
6538
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
6539
|
+
|
|
6540
|
+
if (containerEl) {
|
|
6541
|
+
containerEl.classList.remove('active');
|
|
6542
|
+
}
|
|
6543
|
+
}
|
|
6544
|
+
}, {
|
|
6545
|
+
key: "hideLoading",
|
|
6546
|
+
value: function hideLoading() {
|
|
6547
|
+
this.loadingDialog.hide();
|
|
6548
|
+
}
|
|
6549
|
+
}, {
|
|
6550
|
+
key: "render",
|
|
6551
|
+
value: function render(data) {
|
|
6552
|
+
var calcSizes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
6553
|
+
|
|
6554
|
+
if (!this.options.columns) {
|
|
6555
|
+
console.log("No columns provided for table with ID ".concat(this.elementId));
|
|
6556
|
+
return;
|
|
6557
|
+
}
|
|
6558
|
+
|
|
6559
|
+
if (this.options.columns.length === 0) {
|
|
6560
|
+
console.log("No columns provided for table with ID ".concat(this.elementId));
|
|
6561
|
+
return;
|
|
6562
|
+
} // this.data = []
|
|
6563
|
+
// Adjust the sizing of the header/body/footer
|
|
6564
|
+
|
|
6565
|
+
|
|
6566
|
+
if (calcSizes === true) {
|
|
6567
|
+
var sample = this.createSample(data);
|
|
6568
|
+
this.calculateSizes(sample, data.length, (data[0] || []).length, 0);
|
|
6569
|
+
}
|
|
6570
|
+
|
|
6571
|
+
console.log(this.options.columns);
|
|
6572
|
+
var tableInnerEl = document.getElementById("".concat(this.elementId, "_tableInner"));
|
|
6573
|
+
|
|
6574
|
+
if (tableInnerEl) {
|
|
6575
|
+
tableInnerEl.style.width = "".concat(this.sizes.totalWidth, "px");
|
|
6576
|
+
}
|
|
6577
|
+
|
|
6578
|
+
this.renderColumnHeaders();
|
|
6579
|
+
this.renderTotals();
|
|
6580
|
+
|
|
6581
|
+
if (data) {
|
|
6582
|
+
this.appendRows(data);
|
|
6583
|
+
}
|
|
6584
|
+
|
|
6585
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody")); // bodyEl.innerHTML = this.buildBodyHtml(data, true)
|
|
6586
|
+
|
|
6587
|
+
bodyEl.style.height = "calc(100% - ".concat(this.sizes.header.height, "px - ").concat(this.sizes.total.height, "px)");
|
|
6588
|
+
|
|
6589
|
+
if (this.options.virtualScroll === true) {
|
|
6590
|
+
// set the scroll element positions
|
|
6591
|
+
var vScrollEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
|
|
6592
|
+
var vHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
6593
|
+
|
|
6594
|
+
if (this.vScrollRequired === true) {
|
|
6595
|
+
vScrollEl.style.top = "".concat(this.sizes.header.height + this.sizes.total.height, "px");
|
|
6596
|
+
vScrollEl.style.height = "".concat(this.sizes.bodyHeight, "px");
|
|
6597
|
+
vHandleEl.style.height = Math.max(this.options.minHandleSize, this.sizes.bodyHeight * (this.sizes.rowsToRenderPrecise / this.totalRowCount)) + 'px';
|
|
6598
|
+
} else {
|
|
6599
|
+
vHandleEl.style.height = '0px';
|
|
6600
|
+
}
|
|
6601
|
+
|
|
6602
|
+
var hScrollEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
|
|
6603
|
+
var hHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
6604
|
+
|
|
6605
|
+
if (this.hScrollRequired === true) {
|
|
6606
|
+
hScrollEl.style.left = "".concat(this.sizes.table.width - this.sizes.scrollableWidth, "px");
|
|
6607
|
+
hScrollEl.style.width = "".concat(this.sizes.scrollableWidth - 20, "px");
|
|
6608
|
+
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalWidth)) + 'px';
|
|
6609
|
+
} else {
|
|
6610
|
+
hHandleEl.style.height = '0px';
|
|
6611
|
+
}
|
|
6612
|
+
}
|
|
6613
|
+
}
|
|
6614
|
+
}, {
|
|
6615
|
+
key: "renderColumnHeaders",
|
|
6616
|
+
value: function renderColumnHeaders() {
|
|
6617
|
+
var headEl = document.getElementById("".concat(this.elementId, "_tableHeader"));
|
|
6618
|
+
|
|
6619
|
+
if (headEl) {
|
|
6620
|
+
headEl.innerHTML = this.buildHeaderHtml(true);
|
|
6621
|
+
}
|
|
6622
|
+
}
|
|
6623
|
+
}, {
|
|
6624
|
+
key: "renderTotals",
|
|
6625
|
+
value: function renderTotals() {
|
|
6626
|
+
var headEl = document.getElementById("".concat(this.elementId, "_tableHeader"));
|
|
6627
|
+
var totalHtml = this.buildTotalHtml(true);
|
|
6628
|
+
|
|
6629
|
+
if (this.options.showTotalsAbove === true) {
|
|
6630
|
+
headEl.innerHTML += totalHtml;
|
|
6631
|
+
} else {
|
|
6632
|
+
var footerEl = document.getElementById("".concat(this.elementId, "_tableFooter"));
|
|
6633
|
+
|
|
6634
|
+
if (footerEl) {
|
|
6635
|
+
footerEl.innerHTML = totalHtml;
|
|
6636
|
+
}
|
|
6637
|
+
}
|
|
6638
|
+
}
|
|
6639
|
+
}, {
|
|
6640
|
+
key: "resize",
|
|
6641
|
+
value: function resize() {}
|
|
6642
|
+
}, {
|
|
6643
|
+
key: "showError",
|
|
6644
|
+
value: function showError(options) {
|
|
6645
|
+
var el = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
6646
|
+
|
|
6647
|
+
if (el) {
|
|
6648
|
+
el.classList.add('has-error');
|
|
6649
|
+
}
|
|
6650
|
+
|
|
6651
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_tableInner"));
|
|
6652
|
+
tableEl.classList.add('hidden');
|
|
6653
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
6654
|
+
|
|
6655
|
+
if (containerEl) {
|
|
6656
|
+
containerEl.classList.add('active');
|
|
6657
|
+
}
|
|
6658
|
+
|
|
6659
|
+
if (options.title) {
|
|
6660
|
+
var titleEl = document.getElementById("".concat(this.elementId, "_errorTitle"));
|
|
6661
|
+
|
|
6662
|
+
if (titleEl) {
|
|
6663
|
+
titleEl.innerHTML = options.title;
|
|
6664
|
+
}
|
|
6665
|
+
}
|
|
6666
|
+
|
|
6667
|
+
if (options.message) {
|
|
6668
|
+
var messageEl = document.getElementById("".concat(this.elementId, "_errorMessage"));
|
|
6669
|
+
|
|
6670
|
+
if (messageEl) {
|
|
6671
|
+
messageEl.innerHTML = options.message;
|
|
6672
|
+
}
|
|
6673
|
+
}
|
|
6674
|
+
}
|
|
6675
|
+
}, {
|
|
6676
|
+
key: "scrollX",
|
|
6677
|
+
value: function scrollX(diff) {
|
|
6678
|
+
var scrollContainerEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
|
|
6679
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
6680
|
+
var handlePos;
|
|
6681
|
+
|
|
6682
|
+
if (typeof this.handleXStart !== 'undefined' && this.handleXStart !== null) {
|
|
6683
|
+
handlePos = this.handleXStart + diff;
|
|
6684
|
+
} else {
|
|
6685
|
+
handlePos = scrollHandleEl.offsetLeft + diff;
|
|
6686
|
+
}
|
|
6687
|
+
|
|
6688
|
+
var scrollableSpace = scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width;
|
|
6689
|
+
console.log('dragging x', diff, scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width);
|
|
6690
|
+
scrollHandleEl.style.left = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px';
|
|
6691
|
+
|
|
6692
|
+
if (this.options.onScroll) {
|
|
6693
|
+
var actualLeft = (this.sizes.totalWidth - this.sizes.scrollableWidth) * (Math.min(scrollableSpace, Math.max(0, handlePos)) / scrollableSpace);
|
|
6694
|
+
var cumulativeWidth = 0;
|
|
6695
|
+
this.startCol = 0;
|
|
6696
|
+
this.endCol = 0;
|
|
6697
|
+
|
|
6698
|
+
for (var i = 0; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
6699
|
+
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth;
|
|
6700
|
+
console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth);
|
|
6701
|
+
|
|
6702
|
+
if (actualLeft < cumulativeWidth) {
|
|
6703
|
+
this.startCol = i;
|
|
6704
|
+
break;
|
|
6705
|
+
}
|
|
6706
|
+
}
|
|
6707
|
+
|
|
6708
|
+
cumulativeWidth = 0;
|
|
6709
|
+
|
|
6710
|
+
for (var _i10 = this.startCol; _i10 < this.options.allColumns[this.options.allColumns.length - 1].length; _i10++) {
|
|
6711
|
+
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][_i10].actualWidth;
|
|
6712
|
+
|
|
6713
|
+
if (cumulativeWidth < this.sizes.scrollableWidth) {
|
|
6714
|
+
this.endCol = _i10;
|
|
6715
|
+
}
|
|
6716
|
+
}
|
|
6717
|
+
|
|
6718
|
+
if (this.endCol < this.options.allColumns[this.options.allColumns.length - 1].length - 1) {
|
|
6719
|
+
this.endCol += 1;
|
|
6720
|
+
}
|
|
6721
|
+
|
|
6722
|
+
if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.totalWidth) {
|
|
6723
|
+
this.startCol += 1;
|
|
6724
|
+
}
|
|
6725
|
+
|
|
6726
|
+
this.endCol = Math.max(this.startCol, this.endCol);
|
|
6727
|
+
this.options.onScroll('y', this.startRow, this.endRow, this.startCol, this.endCol);
|
|
6728
|
+
}
|
|
6729
|
+
}
|
|
6730
|
+
}, {
|
|
6731
|
+
key: "scrollY",
|
|
6732
|
+
value: function scrollY(diff) {
|
|
6733
|
+
var scrollContainerEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
|
|
6734
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
6735
|
+
var handlePos;
|
|
6736
|
+
|
|
6737
|
+
if (typeof this.handleYStart !== 'undefined' && this.handleYStart !== null) {
|
|
6738
|
+
handlePos = this.handleYStart + diff;
|
|
6739
|
+
} else {
|
|
6740
|
+
console.log('appending not resetting');
|
|
6741
|
+
handlePos = scrollHandleEl.offsetTop + diff;
|
|
6742
|
+
}
|
|
6743
|
+
|
|
6744
|
+
var scrollableSpace = scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height;
|
|
6745
|
+
console.log('dragging y', diff, scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height);
|
|
6746
|
+
scrollHandleEl.style.top = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px';
|
|
6747
|
+
|
|
6748
|
+
if (this.options.onScroll) {
|
|
6749
|
+
this.startRow = Math.min(this.totalRowCount - this.sizes.rowsToRender, Math.max(0, Math.round((this.totalRowCount - this.sizes.rowsToRender) * (handlePos / scrollableSpace))));
|
|
6750
|
+
this.endRow = this.startRow + this.sizes.rowsToRender;
|
|
6751
|
+
|
|
6752
|
+
if (this.endRow === this.totalRowCount) {
|
|
6753
|
+
this.startRow += 1;
|
|
6754
|
+
}
|
|
6755
|
+
|
|
6756
|
+
this.options.onScroll('y', this.startRow, this.endRow, this.startCol, this.endCol);
|
|
6757
|
+
}
|
|
6758
|
+
}
|
|
6759
|
+
}, {
|
|
6760
|
+
key: "showLoading",
|
|
6761
|
+
value: function showLoading(options) {
|
|
6762
|
+
this.loadingDialog.show(options);
|
|
6763
|
+
}
|
|
6764
|
+
}, {
|
|
6765
|
+
key: "columns",
|
|
6766
|
+
set: function set(columns) {
|
|
6767
|
+
this.options.columns = columns;
|
|
6768
|
+
this.renderColumnHeaders();
|
|
6769
|
+
}
|
|
6770
|
+
}, {
|
|
6771
|
+
key: "totals",
|
|
6772
|
+
set: function set(totals) {
|
|
6773
|
+
this.options.totals = totals;
|
|
6774
|
+
this.renderTotals();
|
|
6775
|
+
}
|
|
6776
|
+
}]);
|
|
6777
|
+
|
|
6778
|
+
return WebsyTable3;
|
|
6779
|
+
}();
|
|
6780
|
+
/* global d3 include WebsyDesigns */
|
|
6781
|
+
|
|
6782
|
+
|
|
6783
|
+
var WebsyChart = /*#__PURE__*/function () {
|
|
6784
|
+
function WebsyChart(elementId, options) {
|
|
6785
|
+
var _this41 = this;
|
|
6786
|
+
|
|
6787
|
+
_classCallCheck(this, WebsyChart);
|
|
6788
|
+
|
|
6789
|
+
var DEFAULTS = {
|
|
6790
|
+
margin: {
|
|
6791
|
+
top: 10,
|
|
6792
|
+
left: 3,
|
|
6793
|
+
bottom: 3,
|
|
6794
|
+
right: 3,
|
|
6795
|
+
axisBottom: 0,
|
|
6796
|
+
axisLeft: 0,
|
|
6797
|
+
axisRight: 0,
|
|
6798
|
+
axisTop: 0,
|
|
6799
|
+
legendBottom: 0,
|
|
6800
|
+
legendLeft: 0,
|
|
6801
|
+
legendRight: 0,
|
|
6802
|
+
legendTop: 0
|
|
6803
|
+
},
|
|
6804
|
+
axis: {},
|
|
6805
|
+
orientation: 'vertical',
|
|
6806
|
+
colors: ['#5e4fa2', '#3288bd', '#66c2a5', '#abdda4', '#e6f598', '#fee08b', '#fdae61', '#f46d43', '#d53e4f', '#9e0142'],
|
|
6807
|
+
transitionDuration: 650,
|
|
6808
|
+
curveStyle: 'curveLinear',
|
|
6809
|
+
lineWidth: 2,
|
|
6810
|
+
forceZero: true,
|
|
5707
6811
|
fontSize: 14,
|
|
5708
6812
|
symbolSize: 20,
|
|
5709
6813
|
showTrackingLine: true,
|
|
@@ -5727,22 +6831,22 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5727
6831
|
this.invertOverride = function (input, input2) {
|
|
5728
6832
|
var xAxis = 'bottomAxis';
|
|
5729
6833
|
|
|
5730
|
-
if (
|
|
6834
|
+
if (_this41.options.orientation === 'horizontal') {
|
|
5731
6835
|
xAxis = 'leftAxis';
|
|
5732
6836
|
}
|
|
5733
6837
|
|
|
5734
|
-
var width =
|
|
6838
|
+
var width = _this41[xAxis].step();
|
|
5735
6839
|
|
|
5736
6840
|
var output;
|
|
5737
6841
|
|
|
5738
|
-
var domain = _toConsumableArray(
|
|
6842
|
+
var domain = _toConsumableArray(_this41[xAxis].domain());
|
|
5739
6843
|
|
|
5740
|
-
if (
|
|
6844
|
+
if (_this41.options.orientation === 'horizontal') {
|
|
5741
6845
|
domain = domain.reverse();
|
|
5742
6846
|
}
|
|
5743
6847
|
|
|
5744
6848
|
for (var j = 0; j < domain.length; j++) {
|
|
5745
|
-
var breakA =
|
|
6849
|
+
var breakA = _this41[xAxis](domain[j]) - width / 2;
|
|
5746
6850
|
var breakB = breakA + width;
|
|
5747
6851
|
|
|
5748
6852
|
if (input > breakA && input <= breakB) {
|
|
@@ -5842,10 +6946,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5842
6946
|
}, {
|
|
5843
6947
|
key: "handleEventMouseMove",
|
|
5844
6948
|
value: function handleEventMouseMove(event, d) {
|
|
5845
|
-
var
|
|
6949
|
+
var _this42 = this;
|
|
5846
6950
|
|
|
5847
6951
|
var bisectDate = d3.bisector(function (d) {
|
|
5848
|
-
return
|
|
6952
|
+
return _this42.parseX(d.x.value);
|
|
5849
6953
|
}).left;
|
|
5850
6954
|
|
|
5851
6955
|
if (this.options.showTrackingLine === true && d3.pointer(event)) {
|
|
@@ -5884,8 +6988,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5884
6988
|
}
|
|
5885
6989
|
|
|
5886
6990
|
this.options.data.series.forEach(function (s) {
|
|
5887
|
-
if (
|
|
5888
|
-
xPoint =
|
|
6991
|
+
if (_this42.options.data[xData].scale !== 'Time') {
|
|
6992
|
+
xPoint = _this42[xAxis](_this42.parseX(xLabel));
|
|
5889
6993
|
s.data.forEach(function (d) {
|
|
5890
6994
|
if (d.x.value === xLabel) {
|
|
5891
6995
|
if (!tooltipTitle) {
|
|
@@ -5904,13 +7008,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5904
7008
|
var pointA = s.data[index - 1];
|
|
5905
7009
|
var pointB = s.data[index];
|
|
5906
7010
|
|
|
5907
|
-
if (
|
|
7011
|
+
if (_this42.options.orientation === 'horizontal') {
|
|
5908
7012
|
pointA = _toConsumableArray(s.data).reverse()[index - 1];
|
|
5909
7013
|
pointB = _toConsumableArray(s.data).reverse()[index];
|
|
5910
7014
|
}
|
|
5911
7015
|
|
|
5912
7016
|
if (pointA && !pointB) {
|
|
5913
|
-
xPoint =
|
|
7017
|
+
xPoint = _this42[xAxis](_this42.parseX(pointA.x.value));
|
|
5914
7018
|
tooltipTitle = pointA.x.value;
|
|
5915
7019
|
|
|
5916
7020
|
if (!pointA.y.color) {
|
|
@@ -5920,12 +7024,12 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5920
7024
|
tooltipData.push(pointA.y);
|
|
5921
7025
|
|
|
5922
7026
|
if (typeof pointA.x.value.getTime !== 'undefined') {
|
|
5923
|
-
tooltipTitle = d3.timeFormat(
|
|
7027
|
+
tooltipTitle = d3.timeFormat(_this42.options.dateFormat || _this42.options.calculatedTimeFormatPattern)(pointA.x.value);
|
|
5924
7028
|
}
|
|
5925
7029
|
}
|
|
5926
7030
|
|
|
5927
7031
|
if (pointB && !pointA) {
|
|
5928
|
-
xPoint =
|
|
7032
|
+
xPoint = _this42[xAxis](_this42.parseX(pointB.x.value));
|
|
5929
7033
|
tooltipTitle = pointB.x.value;
|
|
5930
7034
|
|
|
5931
7035
|
if (!pointB.y.color) {
|
|
@@ -5935,14 +7039,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5935
7039
|
tooltipData.push(pointB.y);
|
|
5936
7040
|
|
|
5937
7041
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
5938
|
-
tooltipTitle = d3.timeFormat(
|
|
7042
|
+
tooltipTitle = d3.timeFormat(_this42.options.dateFormat || _this42.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
5939
7043
|
}
|
|
5940
7044
|
}
|
|
5941
7045
|
|
|
5942
7046
|
if (pointA && pointB) {
|
|
5943
|
-
var d0 =
|
|
7047
|
+
var d0 = _this42[xAxis](_this42.parseX(pointA.x.value));
|
|
5944
7048
|
|
|
5945
|
-
var d1 =
|
|
7049
|
+
var d1 = _this42[xAxis](_this42.parseX(pointB.x.value));
|
|
5946
7050
|
|
|
5947
7051
|
var mid = Math.abs(d0 - d1) / 2;
|
|
5948
7052
|
|
|
@@ -5951,7 +7055,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5951
7055
|
tooltipTitle = pointB.x.value;
|
|
5952
7056
|
|
|
5953
7057
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
5954
|
-
tooltipTitle = d3.timeFormat(
|
|
7058
|
+
tooltipTitle = d3.timeFormat(_this42.options.dateFormat || _this42.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
5955
7059
|
}
|
|
5956
7060
|
|
|
5957
7061
|
if (!pointB.y.color) {
|
|
@@ -5964,7 +7068,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5964
7068
|
tooltipTitle = pointA.x.value;
|
|
5965
7069
|
|
|
5966
7070
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
5967
|
-
tooltipTitle = d3.timeFormat(
|
|
7071
|
+
tooltipTitle = d3.timeFormat(_this42.options.dateFormat || _this42.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
5968
7072
|
}
|
|
5969
7073
|
|
|
5970
7074
|
if (!pointA.y.color) {
|
|
@@ -6069,7 +7173,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6069
7173
|
}, {
|
|
6070
7174
|
key: "render",
|
|
6071
7175
|
value: function render(options) {
|
|
6072
|
-
var
|
|
7176
|
+
var _this43 = this;
|
|
6073
7177
|
|
|
6074
7178
|
/* global d3 options WebsyUtils */
|
|
6075
7179
|
if (typeof options !== 'undefined') {
|
|
@@ -6138,7 +7242,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6138
7242
|
var legendData = this.options.data.series.map(function (s, i) {
|
|
6139
7243
|
return {
|
|
6140
7244
|
value: s.label || s.key,
|
|
6141
|
-
color: s.color ||
|
|
7245
|
+
color: s.color || _this43.options.colors[i % _this43.options.colors.length]
|
|
6142
7246
|
};
|
|
6143
7247
|
});
|
|
6144
7248
|
|
|
@@ -6390,7 +7494,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6390
7494
|
|
|
6391
7495
|
if (this.options.data.bottom.formatter) {
|
|
6392
7496
|
bAxisFunc.tickFormat(function (d) {
|
|
6393
|
-
return
|
|
7497
|
+
return _this43.options.data.bottom.formatter(d);
|
|
6394
7498
|
});
|
|
6395
7499
|
}
|
|
6396
7500
|
|
|
@@ -6416,8 +7520,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6416
7520
|
|
|
6417
7521
|
if (this.options.margin.axisLeft > 0) {
|
|
6418
7522
|
this.leftAxisLayer.call(d3.axisLeft(this.leftAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
6419
|
-
if (
|
|
6420
|
-
d =
|
|
7523
|
+
if (_this43.options.data.left.formatter) {
|
|
7524
|
+
d = _this43.options.data.left.formatter(d);
|
|
6421
7525
|
}
|
|
6422
7526
|
|
|
6423
7527
|
return d;
|
|
@@ -6454,8 +7558,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6454
7558
|
|
|
6455
7559
|
if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
|
|
6456
7560
|
this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
6457
|
-
if (
|
|
6458
|
-
d =
|
|
7561
|
+
if (_this43.options.data.right.formatter) {
|
|
7562
|
+
d = _this43.options.data.right.formatter(d);
|
|
6459
7563
|
}
|
|
6460
7564
|
|
|
6461
7565
|
return d;
|
|
@@ -6481,16 +7585,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6481
7585
|
|
|
6482
7586
|
this.options.data.series.forEach(function (series, index) {
|
|
6483
7587
|
if (!series.key) {
|
|
6484
|
-
series.key =
|
|
7588
|
+
series.key = _this43.createIdentity();
|
|
6485
7589
|
}
|
|
6486
7590
|
|
|
6487
7591
|
if (!series.color) {
|
|
6488
|
-
series.color =
|
|
7592
|
+
series.color = _this43.options.colors[index % _this43.options.colors.length];
|
|
6489
7593
|
}
|
|
6490
7594
|
|
|
6491
|
-
|
|
7595
|
+
_this43["render".concat(series.type || 'bar')](series, index);
|
|
6492
7596
|
|
|
6493
|
-
|
|
7597
|
+
_this43.renderLabels(series, index);
|
|
6494
7598
|
});
|
|
6495
7599
|
}
|
|
6496
7600
|
}
|
|
@@ -6498,17 +7602,17 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6498
7602
|
}, {
|
|
6499
7603
|
key: "renderarea",
|
|
6500
7604
|
value: function renderarea(series, index) {
|
|
6501
|
-
var
|
|
7605
|
+
var _this44 = this;
|
|
6502
7606
|
|
|
6503
7607
|
/* global d3 series index */
|
|
6504
7608
|
var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
|
|
6505
7609
|
return d3.area().x(function (d) {
|
|
6506
|
-
return
|
|
7610
|
+
return _this44[xAxis](_this44.parseX(d.x.value));
|
|
6507
7611
|
}).y0(function (d) {
|
|
6508
|
-
return
|
|
7612
|
+
return _this44[yAxis](0);
|
|
6509
7613
|
}).y1(function (d) {
|
|
6510
|
-
return
|
|
6511
|
-
}).curve(d3[curveStyle ||
|
|
7614
|
+
return _this44[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
7615
|
+
}).curve(d3[curveStyle || _this44.options.curveStyle]);
|
|
6512
7616
|
};
|
|
6513
7617
|
|
|
6514
7618
|
var xAxis = 'bottomAxis';
|
|
@@ -6611,15 +7715,21 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6611
7715
|
}
|
|
6612
7716
|
|
|
6613
7717
|
bars.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
6614
|
-
bars.attr('width', getBarWidth.bind(this)).attr('height', getBarHeight.bind(this)).attr('x', getBarX.bind(this)).attr('y', getBarY.bind(this)).transition(this.transition).attr('fill',
|
|
7718
|
+
bars.attr('width', getBarWidth.bind(this)).attr('height', getBarHeight.bind(this)).attr('x', getBarX.bind(this)).attr('y', getBarY.bind(this)).transition(this.transition).attr('fill', function (d) {
|
|
7719
|
+
return d.color || series.color;
|
|
7720
|
+
});
|
|
6615
7721
|
bars.enter().append('rect').attr('width', getBarWidth.bind(this)).attr('height', getBarHeight.bind(this)).attr('x', getBarX.bind(this)).attr('y', getBarY.bind(this)) // .transition(this.transition)
|
|
6616
|
-
.attr('fill',
|
|
7722
|
+
.attr('fill', function (d) {
|
|
7723
|
+
return d.color || series.color;
|
|
7724
|
+
}).attr('class', function (d) {
|
|
6617
7725
|
return "bar bar_".concat(series.key);
|
|
6618
7726
|
});
|
|
6619
7727
|
}
|
|
6620
7728
|
}, {
|
|
6621
7729
|
key: "renderLabels",
|
|
6622
7730
|
value: function renderLabels(series, index) {
|
|
7731
|
+
var _this45 = this;
|
|
7732
|
+
|
|
6623
7733
|
/* global series index d3 WebsyDesigns */
|
|
6624
7734
|
var xAxis = 'bottomAxis';
|
|
6625
7735
|
var yAxis = 'leftAxis';
|
|
@@ -6636,10 +7746,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6636
7746
|
// We currently only support 'Auto'
|
|
6637
7747
|
var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
|
|
6638
7748
|
labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
6639
|
-
labels.attr('x', getLabelX.bind(this)).attr('y', getLabelY.bind(this)).attr('class', "label_".concat(series.key)).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).style('fill',
|
|
7749
|
+
labels.attr('x', getLabelX.bind(this)).attr('y', getLabelY.bind(this)).attr('class', "label_".concat(series.key)).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).style('fill', function (d) {
|
|
7750
|
+
return _this45.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.color || series.color);
|
|
7751
|
+
}).transition(this.transition).text(function (d) {
|
|
6640
7752
|
return d.y.label || d.y.value;
|
|
6641
7753
|
});
|
|
6642
|
-
labels.enter().append('text').attr('class', "label_".concat(series.key)).attr('x', getLabelX.bind(this)).attr('y', getLabelY.bind(this)).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).style('fill',
|
|
7754
|
+
labels.enter().append('text').attr('class', "label_".concat(series.key)).attr('x', getLabelX.bind(this)).attr('y', getLabelY.bind(this)).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).style('fill', function (d) {
|
|
7755
|
+
return _this45.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.color || series.color);
|
|
7756
|
+
}).text(function (d) {
|
|
6643
7757
|
return d.y.label || d.y.value;
|
|
6644
7758
|
}).each(function (d, i) {
|
|
6645
7759
|
if (that.options.orientation === 'horizontal') {
|
|
@@ -6683,15 +7797,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6683
7797
|
}, {
|
|
6684
7798
|
key: "renderline",
|
|
6685
7799
|
value: function renderline(series, index) {
|
|
6686
|
-
var
|
|
7800
|
+
var _this46 = this;
|
|
6687
7801
|
|
|
6688
7802
|
/* global series index d3 */
|
|
6689
7803
|
var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
|
|
6690
7804
|
return d3.line().x(function (d) {
|
|
6691
|
-
return
|
|
7805
|
+
return _this46[xAxis](_this46.parseX(d.x.value));
|
|
6692
7806
|
}).y(function (d) {
|
|
6693
|
-
return
|
|
6694
|
-
}).curve(d3[curveStyle ||
|
|
7807
|
+
return _this46[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
7808
|
+
}).curve(d3[curveStyle || _this46.options.curveStyle]);
|
|
6695
7809
|
};
|
|
6696
7810
|
|
|
6697
7811
|
var xAxis = 'bottomAxis';
|
|
@@ -6729,14 +7843,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6729
7843
|
}, {
|
|
6730
7844
|
key: "rendersymbol",
|
|
6731
7845
|
value: function rendersymbol(series, index) {
|
|
6732
|
-
var
|
|
7846
|
+
var _this47 = this;
|
|
6733
7847
|
|
|
6734
7848
|
/* global d3 series index series.key */
|
|
6735
7849
|
var drawSymbol = function drawSymbol(size) {
|
|
6736
7850
|
return d3.symbol() // .type(d => {
|
|
6737
7851
|
// return d3.symbols[0]
|
|
6738
7852
|
// })
|
|
6739
|
-
.size(size ||
|
|
7853
|
+
.size(size || _this47.options.symbolSize);
|
|
6740
7854
|
};
|
|
6741
7855
|
|
|
6742
7856
|
var xAxis = 'bottomAxis';
|
|
@@ -6754,7 +7868,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6754
7868
|
symbols.attr('d', function (d) {
|
|
6755
7869
|
return drawSymbol(d.y.size || series.symbolSize)(d);
|
|
6756
7870
|
}).transition(this.transition).attr('fill', 'white').attr('stroke', series.color).attr('transform', function (d) {
|
|
6757
|
-
return "translate(".concat(
|
|
7871
|
+
return "translate(".concat(_this47[xAxis](_this47.parseX(d.x.value)), ", ").concat(_this47[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
6758
7872
|
}); // Enter
|
|
6759
7873
|
|
|
6760
7874
|
symbols.enter().append('path').attr('d', function (d) {
|
|
@@ -6763,7 +7877,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6763
7877
|
.attr('fill', 'white').attr('stroke', series.color).attr('class', function (d) {
|
|
6764
7878
|
return "symbol symbol_".concat(series.key);
|
|
6765
7879
|
}).attr('transform', function (d) {
|
|
6766
|
-
return "translate(".concat(
|
|
7880
|
+
return "translate(".concat(_this47[xAxis](_this47.parseX(d.x.value)), ", ").concat(_this47[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
6767
7881
|
});
|
|
6768
7882
|
}
|
|
6769
7883
|
}, {
|
|
@@ -6918,7 +8032,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
6918
8032
|
}, {
|
|
6919
8033
|
key: "resize",
|
|
6920
8034
|
value: function resize() {
|
|
6921
|
-
var
|
|
8035
|
+
var _this48 = this;
|
|
6922
8036
|
|
|
6923
8037
|
var el = document.getElementById(this.elementId);
|
|
6924
8038
|
|
|
@@ -6931,7 +8045,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
6931
8045
|
// }
|
|
6932
8046
|
var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
|
|
6933
8047
|
html += this._data.map(function (d, i) {
|
|
6934
|
-
return
|
|
8048
|
+
return _this48.getLegendItemHTML(d);
|
|
6935
8049
|
}).join('');
|
|
6936
8050
|
html += "\n <div>\n ";
|
|
6937
8051
|
el.innerHTML = html;
|
|
@@ -7103,7 +8217,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
7103
8217
|
}, {
|
|
7104
8218
|
key: "render",
|
|
7105
8219
|
value: function render() {
|
|
7106
|
-
var
|
|
8220
|
+
var _this49 = this;
|
|
7107
8221
|
|
|
7108
8222
|
var mapEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
7109
8223
|
var legendEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
@@ -7112,7 +8226,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
7112
8226
|
var legendData = this.options.data.polygons.map(function (s, i) {
|
|
7113
8227
|
return {
|
|
7114
8228
|
value: s.label || s.key,
|
|
7115
|
-
color: s.color ||
|
|
8229
|
+
color: s.color || _this49.options.colors[i % _this49.options.colors.length]
|
|
7116
8230
|
};
|
|
7117
8231
|
});
|
|
7118
8232
|
var longestValue = legendData.map(function (s) {
|
|
@@ -7176,7 +8290,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
7176
8290
|
|
|
7177
8291
|
if (this.polygons) {
|
|
7178
8292
|
this.polygons.forEach(function (p) {
|
|
7179
|
-
return
|
|
8293
|
+
return _this49.map.removeLayer(p);
|
|
7180
8294
|
});
|
|
7181
8295
|
}
|
|
7182
8296
|
|
|
@@ -7234,18 +8348,18 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
7234
8348
|
}
|
|
7235
8349
|
|
|
7236
8350
|
if (!p.options.color) {
|
|
7237
|
-
p.options.color =
|
|
8351
|
+
p.options.color = _this49.options.colors[i % _this49.options.colors.length];
|
|
7238
8352
|
}
|
|
7239
8353
|
|
|
7240
8354
|
var pol = L.polygon(p.data.map(function (c) {
|
|
7241
8355
|
return c.map(function (d) {
|
|
7242
8356
|
return [d.Latitude, d.Longitude];
|
|
7243
8357
|
});
|
|
7244
|
-
}), p.options).addTo(
|
|
8358
|
+
}), p.options).addTo(_this49.map);
|
|
7245
8359
|
|
|
7246
|
-
|
|
8360
|
+
_this49.polygons.push(pol);
|
|
7247
8361
|
|
|
7248
|
-
|
|
8362
|
+
_this49.map.fitBounds(pol.getBounds());
|
|
7249
8363
|
});
|
|
7250
8364
|
} // if (this.data.markers.length > 0) {
|
|
7251
8365
|
// el.classList.remove('hidden')
|
|
@@ -7378,8 +8492,10 @@ var WebsyDesigns = {
|
|
|
7378
8492
|
Router: WebsyRouter,
|
|
7379
8493
|
WebsyTable: WebsyTable,
|
|
7380
8494
|
WebsyTable2: WebsyTable2,
|
|
8495
|
+
WebsyTable3: WebsyTable3,
|
|
7381
8496
|
Table: WebsyTable,
|
|
7382
8497
|
Table2: WebsyTable2,
|
|
8498
|
+
Table3: WebsyTable3,
|
|
7383
8499
|
WebsyChart: WebsyChart,
|
|
7384
8500
|
Chart: WebsyChart,
|
|
7385
8501
|
WebsyChartTooltip: WebsyChartTooltip,
|
|
@@ -7406,7 +8522,11 @@ var WebsyDesigns = {
|
|
|
7406
8522
|
WebsySignup: WebsySignup,
|
|
7407
8523
|
Signup: WebsySignup,
|
|
7408
8524
|
ResponsiveText: ResponsiveText,
|
|
7409
|
-
WebsyResponsiveText: ResponsiveText
|
|
8525
|
+
WebsyResponsiveText: ResponsiveText,
|
|
8526
|
+
WebsyDragDrop: WebsyDragDrop,
|
|
8527
|
+
DragDrop: WebsyDragDrop,
|
|
8528
|
+
WebsySearch: WebsySearch,
|
|
8529
|
+
Search: WebsySearch
|
|
7410
8530
|
};
|
|
7411
8531
|
WebsyDesigns.service = new WebsyDesigns.APIService('');
|
|
7412
8532
|
var GlobalPubSub = new WebsyPubSub('empty', {});
|