@websy/websy-designs 1.2.32 → 1.2.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/websy-designs-es6.debug.js +880 -19
- package/dist/websy-designs-es6.js +1187 -200
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +880 -20
- package/dist/websy-designs.js +1180 -192
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
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,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
51
52
|
WebsyLogin
|
|
52
53
|
WebsySignup
|
|
53
54
|
ResponsiveText
|
|
55
|
+
WebsyDragDrop
|
|
54
56
|
Pager
|
|
55
57
|
*/
|
|
56
58
|
|
|
@@ -1897,13 +1899,14 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1897
1899
|
this.selectedItems.push(index);
|
|
1898
1900
|
}
|
|
1899
1901
|
}
|
|
1900
|
-
}
|
|
1902
|
+
} // const item = this.options.items[index]
|
|
1903
|
+
|
|
1901
1904
|
|
|
1902
|
-
var item = this.options.items[index];
|
|
1905
|
+
var item = this._originalData[index] || this.options.items[index];
|
|
1903
1906
|
this.updateHeader(item);
|
|
1904
1907
|
|
|
1905
1908
|
if (item && this.options.onItemSelected) {
|
|
1906
|
-
this.options.onItemSelected(item, this.selectedItems, this.options.items, this.options);
|
|
1909
|
+
this.options.onItemSelected(item, this.selectedItems, this._originalData || this.options.items, this.options);
|
|
1907
1910
|
}
|
|
1908
1911
|
|
|
1909
1912
|
if (this.options.closeAfterSelection === true) {
|
|
@@ -1925,6 +1928,12 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1925
1928
|
|
|
1926
1929
|
return d;
|
|
1927
1930
|
});
|
|
1931
|
+
var headerEl = document.getElementById("".concat(this.elementId, "_header"));
|
|
1932
|
+
|
|
1933
|
+
if (headerEl) {
|
|
1934
|
+
headerEl.classList["".concat(this.options.allowClear === true ? 'add' : 'remove')]('allow-clear');
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1928
1937
|
var el = document.getElementById("".concat(this.elementId, "_items"));
|
|
1929
1938
|
|
|
1930
1939
|
if (el.childElementCount === 0) {
|
|
@@ -1946,6 +1955,320 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1946
1955
|
|
|
1947
1956
|
return WebsyDropdown;
|
|
1948
1957
|
}();
|
|
1958
|
+
/* global WebsyDesigns GlobalPubSub */
|
|
1959
|
+
|
|
1960
|
+
|
|
1961
|
+
var WebsyDragDrop = /*#__PURE__*/function () {
|
|
1962
|
+
function WebsyDragDrop(elementId, options) {
|
|
1963
|
+
_classCallCheck(this, WebsyDragDrop);
|
|
1964
|
+
|
|
1965
|
+
var DEFAULTS = {
|
|
1966
|
+
items: [],
|
|
1967
|
+
orientation: 'horizontal',
|
|
1968
|
+
dropPlaceholder: 'Drop item here'
|
|
1969
|
+
};
|
|
1970
|
+
this.busy = false;
|
|
1971
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
1972
|
+
this.elementId = elementId;
|
|
1973
|
+
|
|
1974
|
+
if (!elementId) {
|
|
1975
|
+
console.log('No element Id provided for Websy DragDrop');
|
|
1976
|
+
return;
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
var el = document.getElementById(elementId);
|
|
1980
|
+
|
|
1981
|
+
if (el) {
|
|
1982
|
+
el.innerHTML = "\n <div id='".concat(this.elementId, "_container' class='websy-drag-drop-container ").concat(this.options.orientation, "'>\n <div>\n </div>\n ");
|
|
1983
|
+
el.addEventListener('click', this.handleClick.bind(this));
|
|
1984
|
+
el.addEventListener('dragstart', this.handleDragStart.bind(this));
|
|
1985
|
+
el.addEventListener('dragover', this.handleDragOver.bind(this));
|
|
1986
|
+
el.addEventListener('dragleave', this.handleDragLeave.bind(this));
|
|
1987
|
+
el.addEventListener('drop', this.handleDrop.bind(this));
|
|
1988
|
+
window.addEventListener('dragend', this.handleDragEnd.bind(this));
|
|
1989
|
+
} else {
|
|
1990
|
+
console.error("No element found with ID ".concat(this.elementId));
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
GlobalPubSub.subscribe(this.elementId, 'requestForDDItem', this.handleRequestForItem.bind(this));
|
|
1994
|
+
console.log('constructor dd');
|
|
1995
|
+
console.trace();
|
|
1996
|
+
GlobalPubSub.subscribe(this.elementId, 'add', this.addItem.bind(this));
|
|
1997
|
+
this.render();
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
_createClass(WebsyDragDrop, [{
|
|
2001
|
+
key: "addItem",
|
|
2002
|
+
value: function addItem(data) {
|
|
2003
|
+
if (data.target === this.elementId && this.busy === false) {
|
|
2004
|
+
this.busy = true;
|
|
2005
|
+
console.log('adding item to dd'); // check that an item with the same id doesn't already exist
|
|
2006
|
+
|
|
2007
|
+
var index = this.getItemIndex(data.item.id);
|
|
2008
|
+
|
|
2009
|
+
if (index === -1) {
|
|
2010
|
+
this.options.items.splice(data.index, 0, data.item);
|
|
2011
|
+
var startEl = document.getElementById("".concat(this.elementId, "start_item"));
|
|
2012
|
+
|
|
2013
|
+
if (startEl) {
|
|
2014
|
+
if (this.options.items.length === 0) {
|
|
2015
|
+
startEl.classList.add('empty');
|
|
2016
|
+
} else {
|
|
2017
|
+
startEl.classList.remove('empty');
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
if (this.options.onItemAdded) {
|
|
2022
|
+
this.options.onItemAdded();
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
this.busy = false;
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
}, {
|
|
2030
|
+
key: "createItemHtml",
|
|
2031
|
+
value: function createItemHtml(elementId, index, item) {
|
|
2032
|
+
if (!item.id) {
|
|
2033
|
+
item.id = WebsyDesigns.Utils.createIdentity();
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
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 ");
|
|
2037
|
+
|
|
2038
|
+
if (item.component) {
|
|
2039
|
+
html += "<div id='".concat(item.id, "_component'></div>");
|
|
2040
|
+
} else {
|
|
2041
|
+
html += "".concat(item.html || item.label || '');
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
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 ");
|
|
2045
|
+
return html;
|
|
2046
|
+
}
|
|
2047
|
+
}, {
|
|
2048
|
+
key: "getItemIndex",
|
|
2049
|
+
value: function getItemIndex(id) {
|
|
2050
|
+
for (var i = 0; i < this.options.items.length; i++) {
|
|
2051
|
+
if (this.options.items[i].id === id) {
|
|
2052
|
+
return i;
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
return -1;
|
|
2057
|
+
}
|
|
2058
|
+
}, {
|
|
2059
|
+
key: "handleClick",
|
|
2060
|
+
value: function handleClick(event) {}
|
|
2061
|
+
}, {
|
|
2062
|
+
key: "handleDragStart",
|
|
2063
|
+
value: function handleDragStart(event) {
|
|
2064
|
+
this.draggedId = event.target.getAttribute('data-id');
|
|
2065
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
2066
|
+
event.dataTransfer.setData('application/wd-item', JSON.stringify({
|
|
2067
|
+
el: event.target.id,
|
|
2068
|
+
id: this.elementId,
|
|
2069
|
+
itemId: this.draggedId
|
|
2070
|
+
}));
|
|
2071
|
+
console.log('drag start', event);
|
|
2072
|
+
event.target.style.opacity = 0.5;
|
|
2073
|
+
this.dragging = true;
|
|
2074
|
+
}
|
|
2075
|
+
}, {
|
|
2076
|
+
key: "handleDragOver",
|
|
2077
|
+
value: function handleDragOver(event) {
|
|
2078
|
+
console.log('drag over', event.target.classList);
|
|
2079
|
+
|
|
2080
|
+
if (event.preventDefault) {
|
|
2081
|
+
event.preventDefault();
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
if (!event.target.classList.contains('droppable')) {
|
|
2085
|
+
return;
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
event.target.classList.add('drag-over');
|
|
2089
|
+
}
|
|
2090
|
+
}, {
|
|
2091
|
+
key: "handleDragLeave",
|
|
2092
|
+
value: function handleDragLeave(event) {
|
|
2093
|
+
console.log('drag leave', event.target.classList);
|
|
2094
|
+
|
|
2095
|
+
if (!event.target.classList.contains('droppable')) {
|
|
2096
|
+
return;
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
event.target.classList.remove('drag-over'); // let side = event.target.getAttribute('data-side')
|
|
2100
|
+
// let id = event.target.getAttribute('data-id')
|
|
2101
|
+
// let droppedItem = this.options.items[id]
|
|
2102
|
+
// this.removeExpandedDrop(side, id, droppedItem)
|
|
2103
|
+
}
|
|
2104
|
+
}, {
|
|
2105
|
+
key: "handleDrop",
|
|
2106
|
+
value: function handleDrop(event) {
|
|
2107
|
+
console.log('drag drop');
|
|
2108
|
+
console.log(event.dataTransfer.getData('application/wd-item'));
|
|
2109
|
+
var data = JSON.parse(event.dataTransfer.getData('application/wd-item'));
|
|
2110
|
+
|
|
2111
|
+
if (event.preventDefault) {
|
|
2112
|
+
event.preventDefault();
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
if (!event.target.classList.contains('droppable')) {
|
|
2116
|
+
return;
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
var side = event.target.getAttribute('data-side');
|
|
2120
|
+
var id = event.target.getAttribute('data-id');
|
|
2121
|
+
var index = this.getItemIndex(id);
|
|
2122
|
+
var draggedIndex = this.getItemIndex(data.id);
|
|
2123
|
+
var droppedItem = this.options.items[index];
|
|
2124
|
+
|
|
2125
|
+
if (side === 'right') {
|
|
2126
|
+
index += 1;
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
if (draggedIndex === -1) {
|
|
2130
|
+
console.log('requestForDDItem');
|
|
2131
|
+
GlobalPubSub.publish(data.id, 'requestForDDItem', {
|
|
2132
|
+
group: this.options.group,
|
|
2133
|
+
source: data.id,
|
|
2134
|
+
target: this.elementId,
|
|
2135
|
+
index: index,
|
|
2136
|
+
id: data.itemId
|
|
2137
|
+
});
|
|
2138
|
+
} else if (index > draggedIndex) {
|
|
2139
|
+
// insert and then remove
|
|
2140
|
+
this.options.items.splice(index, 0, droppedItem);
|
|
2141
|
+
this.options.items.splice(draggedIndex, 1);
|
|
2142
|
+
|
|
2143
|
+
if (this.options.onOrderUpdated) {
|
|
2144
|
+
this.options.onOrderUpdated();
|
|
2145
|
+
}
|
|
2146
|
+
} else {
|
|
2147
|
+
// remove and then insert
|
|
2148
|
+
this.options.items.splice(draggedIndex, 1);
|
|
2149
|
+
this.options.items.splice(index, 0, droppedItem);
|
|
2150
|
+
|
|
2151
|
+
if (this.options.onOrderUpdated) {
|
|
2152
|
+
this.options.onOrderUpdated();
|
|
2153
|
+
}
|
|
2154
|
+
} // this.removeExpandedDrop(side, id, droppedItem)
|
|
2155
|
+
// const draggedEl = document.getElementById(`${this.elementId}_${this.draggedId}_item`)
|
|
2156
|
+
|
|
2157
|
+
|
|
2158
|
+
var draggedEl = document.getElementById(data.el);
|
|
2159
|
+
var droppedEl = document.getElementById("".concat(id, "_item"));
|
|
2160
|
+
|
|
2161
|
+
if (draggedEl) {
|
|
2162
|
+
droppedEl.insertAdjacentElement('afterend', draggedEl);
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
var dragOverEl = droppedEl.querySelector('.drag-over');
|
|
2166
|
+
|
|
2167
|
+
if (dragOverEl) {
|
|
2168
|
+
dragOverEl.classList.remove('drag-over');
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
}, {
|
|
2172
|
+
key: "handleDragEnd",
|
|
2173
|
+
value: function handleDragEnd(event) {
|
|
2174
|
+
console.log('drag end');
|
|
2175
|
+
event.target.style.opacity = 1;
|
|
2176
|
+
this.draggedId = null;
|
|
2177
|
+
this.dragging = false;
|
|
2178
|
+
var startEl = document.getElementById("".concat(this.elementId, "start_item"));
|
|
2179
|
+
|
|
2180
|
+
if (startEl) {
|
|
2181
|
+
if (this.options.items.length === 0) {
|
|
2182
|
+
startEl.classList.add('empty');
|
|
2183
|
+
} else {
|
|
2184
|
+
startEl.classList.remove('empty');
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
}, {
|
|
2189
|
+
key: "handleRequestForItem",
|
|
2190
|
+
value: function handleRequestForItem(data) {
|
|
2191
|
+
if (data.group === this.options.group) {
|
|
2192
|
+
var index = this.getItemIndex(data.id);
|
|
2193
|
+
|
|
2194
|
+
if (index !== -1) {
|
|
2195
|
+
var itemToAdd = this.options.items.splice(index, 1);
|
|
2196
|
+
GlobalPubSub.publish(data.target, 'add', {
|
|
2197
|
+
target: data.target,
|
|
2198
|
+
index: data.index,
|
|
2199
|
+
item: itemToAdd[0]
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
}, {
|
|
2205
|
+
key: "measureItems",
|
|
2206
|
+
value: function measureItems() {
|
|
2207
|
+
var el = document.getElementById("".concat(this.elementId, "_container"));
|
|
2208
|
+
this.options.items.forEach(function (d) {});
|
|
2209
|
+
} // removeExpandedDrop (side, id, droppedItem) {
|
|
2210
|
+
// let dropEl
|
|
2211
|
+
// const dropImageEl = document.getElementById(`${id}_itemInner`)
|
|
2212
|
+
// // const placeholderEl = document.getElementById(`${this.elementId}_${id}_dropZonePlaceholder`)
|
|
2213
|
+
// if (side === 'left') {
|
|
2214
|
+
// dropEl = document.getElementById(`${this.elementId}_${id}_dropZoneLeft`)
|
|
2215
|
+
// dropImageEl.style.left = `0px`
|
|
2216
|
+
// }
|
|
2217
|
+
// else if (side === 'right') {
|
|
2218
|
+
// dropEl = document.getElementById(`${this.elementId}_${id}_dropZoneRight`)
|
|
2219
|
+
// }
|
|
2220
|
+
// else {
|
|
2221
|
+
// dropEl = document.getElementById(`${this.elementId}_${id}_dropZoneEnd`)
|
|
2222
|
+
// }
|
|
2223
|
+
// if (dropEl) {
|
|
2224
|
+
// const dropElSize = dropEl.getBoundingClientRect()
|
|
2225
|
+
// dropEl.style.width = `${(dropElSize.width / 2)}px`
|
|
2226
|
+
// dropEl.style.marginLeft = null
|
|
2227
|
+
// dropEl.style.border = null
|
|
2228
|
+
// }
|
|
2229
|
+
// if (placeholderEl) {
|
|
2230
|
+
// placeholderEl.classList.remove('active')
|
|
2231
|
+
// placeholderEl.style.left = null
|
|
2232
|
+
// placeholderEl.style.right = null
|
|
2233
|
+
// placeholderEl.style.width = null
|
|
2234
|
+
// placeholderEl.style.height = null
|
|
2235
|
+
// }
|
|
2236
|
+
// }
|
|
2237
|
+
|
|
2238
|
+
}, {
|
|
2239
|
+
key: "removeItem",
|
|
2240
|
+
value: function removeItem(id) {}
|
|
2241
|
+
}, {
|
|
2242
|
+
key: "render",
|
|
2243
|
+
value: function render() {
|
|
2244
|
+
var _this13 = this;
|
|
2245
|
+
|
|
2246
|
+
var el = document.getElementById("".concat(this.elementId, "_container"));
|
|
2247
|
+
|
|
2248
|
+
if (el) {
|
|
2249
|
+
this.measureItems();
|
|
2250
|
+
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 ");
|
|
2251
|
+
html += this.options.items.map(function (d, i) {
|
|
2252
|
+
return _this13.createItemHtml(_this13.elementId, i, d);
|
|
2253
|
+
}).join('');
|
|
2254
|
+
el.innerHTML = html;
|
|
2255
|
+
this.options.items.forEach(function (item, i) {
|
|
2256
|
+
if (item.component) {
|
|
2257
|
+
if (item.isQlikPlugin && WebsyDesigns.QlikPlugin[item.component]) {
|
|
2258
|
+
item.instance = new WebsyDesigns.QlikPlugin[item.component]("".concat(item.id, "_component"), item.options);
|
|
2259
|
+
} else if (WebsyDesigns[item.component]) {
|
|
2260
|
+
item.instance = new WebsyDesigns[item.component]("".concat(item.id, "_component"), item.options);
|
|
2261
|
+
} else {
|
|
2262
|
+
console.error("Component ".concat(item.component, " not found."));
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
}]);
|
|
2269
|
+
|
|
2270
|
+
return WebsyDragDrop;
|
|
2271
|
+
}();
|
|
1949
2272
|
/* global WebsyDesigns FormData grecaptcha ENVIRONMENT GlobalPubSub */
|
|
1950
2273
|
|
|
1951
2274
|
|
|
@@ -2005,16 +2328,16 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2005
2328
|
}, {
|
|
2006
2329
|
key: "checkRecaptcha",
|
|
2007
2330
|
value: function checkRecaptcha() {
|
|
2008
|
-
var
|
|
2331
|
+
var _this14 = this;
|
|
2009
2332
|
|
|
2010
2333
|
return new Promise(function (resolve, reject) {
|
|
2011
|
-
if (
|
|
2334
|
+
if (_this14.options.useRecaptcha === true) {
|
|
2012
2335
|
// if (this.recaptchaValue) {
|
|
2013
2336
|
grecaptcha.ready(function () {
|
|
2014
2337
|
grecaptcha.execute(ENVIRONMENT.RECAPTCHA_KEY, {
|
|
2015
2338
|
action: 'submit'
|
|
2016
2339
|
}).then(function (token) {
|
|
2017
|
-
|
|
2340
|
+
_this14.apiService.add('google/checkrecaptcha', {
|
|
2018
2341
|
grecaptcharesponse: token
|
|
2019
2342
|
}).then(function (response) {
|
|
2020
2343
|
if (response.success && response.success === true) {
|
|
@@ -2077,14 +2400,14 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2077
2400
|
}, {
|
|
2078
2401
|
key: "processComponents",
|
|
2079
2402
|
value: function processComponents(components, callbackFn) {
|
|
2080
|
-
var
|
|
2403
|
+
var _this15 = this;
|
|
2081
2404
|
|
|
2082
2405
|
if (components.length === 0) {
|
|
2083
2406
|
callbackFn();
|
|
2084
2407
|
} else {
|
|
2085
2408
|
components.forEach(function (c) {
|
|
2086
2409
|
if (typeof WebsyDesigns[c.component] !== 'undefined') {
|
|
2087
|
-
c.instance = new WebsyDesigns[c.component]("".concat(
|
|
2410
|
+
c.instance = new WebsyDesigns[c.component]("".concat(_this15.elementId, "_input_").concat(c.field, "_component"), c.options);
|
|
2088
2411
|
} else {// some user feedback here
|
|
2089
2412
|
}
|
|
2090
2413
|
});
|
|
@@ -2105,7 +2428,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2105
2428
|
}, {
|
|
2106
2429
|
key: "render",
|
|
2107
2430
|
value: function render(update, data) {
|
|
2108
|
-
var
|
|
2431
|
+
var _this16 = this;
|
|
2109
2432
|
|
|
2110
2433
|
var el = document.getElementById(this.elementId);
|
|
2111
2434
|
var componentsToProcess = [];
|
|
@@ -2115,11 +2438,11 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2115
2438
|
this.options.fields.forEach(function (f, i) {
|
|
2116
2439
|
if (f.component) {
|
|
2117
2440
|
componentsToProcess.push(f);
|
|
2118
|
-
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <div id='").concat(
|
|
2441
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <div id='").concat(_this16.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n </div><!--\n ");
|
|
2119
2442
|
} else if (f.type === 'longtext') {
|
|
2120
|
-
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <textarea\n id=\"").concat(
|
|
2443
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <textarea\n id=\"").concat(_this16.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n name=\"").concat(f.field, "\" \n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea\"\n ></textarea>\n </div><!--\n ");
|
|
2121
2444
|
} else {
|
|
2122
|
-
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <input \n id=\"").concat(
|
|
2445
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <input \n id=\"").concat(_this16.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat(f.type || 'text', "\" \n class=\"websy-input\" \n ").concat((f.attributes || []).join(' '), "\n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.value || '', "\"\n valueAsDate=\"").concat(f.type === 'date' ? f.value : '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n </div><!--\n ");
|
|
2123
2446
|
}
|
|
2124
2447
|
});
|
|
2125
2448
|
html += "\n --><button class=\"websy-btn submit ".concat(this.options.submit.classes || '', "\">").concat(this.options.submit.text || 'Save', "</button>").concat(this.options.cancel ? '<!--' : '', "\n ");
|
|
@@ -2136,7 +2459,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2136
2459
|
|
|
2137
2460
|
el.innerHTML = html;
|
|
2138
2461
|
this.processComponents(componentsToProcess, function () {
|
|
2139
|
-
if (
|
|
2462
|
+
if (_this16.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {// this.recaptchaReady()
|
|
2140
2463
|
}
|
|
2141
2464
|
});
|
|
2142
2465
|
}
|
|
@@ -2144,7 +2467,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2144
2467
|
}, {
|
|
2145
2468
|
key: "submitForm",
|
|
2146
2469
|
value: function submitForm() {
|
|
2147
|
-
var
|
|
2470
|
+
var _this17 = this;
|
|
2148
2471
|
|
|
2149
2472
|
var formEl = document.getElementById("".concat(this.elementId, "Form"));
|
|
2150
2473
|
|
|
@@ -2158,32 +2481,32 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2158
2481
|
data[key] = value;
|
|
2159
2482
|
});
|
|
2160
2483
|
|
|
2161
|
-
if (
|
|
2162
|
-
var
|
|
2484
|
+
if (_this17.options.url) {
|
|
2485
|
+
var _this17$apiService;
|
|
2163
2486
|
|
|
2164
|
-
var params = [
|
|
2487
|
+
var params = [_this17.options.url];
|
|
2165
2488
|
|
|
2166
|
-
if (
|
|
2167
|
-
params.push(
|
|
2489
|
+
if (_this17.options.mode === 'update') {
|
|
2490
|
+
params.push(_this17.options.id);
|
|
2168
2491
|
}
|
|
2169
2492
|
|
|
2170
2493
|
params.push(data);
|
|
2171
2494
|
|
|
2172
|
-
(
|
|
2173
|
-
if (
|
|
2495
|
+
(_this17$apiService = _this17.apiService)[_this17.options.mode].apply(_this17$apiService, params).then(function (result) {
|
|
2496
|
+
if (_this17.options.clearAfterSave === true) {
|
|
2174
2497
|
// this.render()
|
|
2175
2498
|
formEl.reset();
|
|
2176
2499
|
}
|
|
2177
2500
|
|
|
2178
|
-
|
|
2501
|
+
_this17.options.onSuccess.call(_this17, result);
|
|
2179
2502
|
}, function (err) {
|
|
2180
2503
|
console.log('Error submitting form data:', err);
|
|
2181
2504
|
|
|
2182
|
-
|
|
2505
|
+
_this17.options.onError.call(_this17, err);
|
|
2183
2506
|
});
|
|
2184
|
-
} else if (
|
|
2185
|
-
|
|
2186
|
-
if (
|
|
2507
|
+
} else if (_this17.options.submitFn) {
|
|
2508
|
+
_this17.options.submitFn(data, function () {
|
|
2509
|
+
if (_this17.options.clearAfterSave === true) {
|
|
2187
2510
|
// this.render()
|
|
2188
2511
|
formEl.reset();
|
|
2189
2512
|
}
|
|
@@ -2203,17 +2526,17 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2203
2526
|
}, {
|
|
2204
2527
|
key: "data",
|
|
2205
2528
|
set: function set(d) {
|
|
2206
|
-
var
|
|
2529
|
+
var _this18 = this;
|
|
2207
2530
|
|
|
2208
2531
|
if (!this.options.fields) {
|
|
2209
2532
|
this.options.fields = [];
|
|
2210
2533
|
}
|
|
2211
2534
|
|
|
2212
2535
|
var _loop = function _loop(key) {
|
|
2213
|
-
|
|
2536
|
+
_this18.options.fields.forEach(function (f) {
|
|
2214
2537
|
if (f.field === key) {
|
|
2215
2538
|
f.value = d[key];
|
|
2216
|
-
var el = document.getElementById("".concat(
|
|
2539
|
+
var el = document.getElementById("".concat(_this18.elementId, "_input_").concat(f.field));
|
|
2217
2540
|
el.value = f.value;
|
|
2218
2541
|
}
|
|
2219
2542
|
});
|
|
@@ -2592,7 +2915,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
2592
2915
|
|
|
2593
2916
|
var Pager = /*#__PURE__*/function () {
|
|
2594
2917
|
function Pager(elementId, options) {
|
|
2595
|
-
var
|
|
2918
|
+
var _this19 = this;
|
|
2596
2919
|
|
|
2597
2920
|
_classCallCheck(this, Pager);
|
|
2598
2921
|
|
|
@@ -2645,8 +2968,8 @@ var Pager = /*#__PURE__*/function () {
|
|
|
2645
2968
|
allowClear: false,
|
|
2646
2969
|
disableSearch: true,
|
|
2647
2970
|
onItemSelected: function onItemSelected(selectedItem) {
|
|
2648
|
-
if (
|
|
2649
|
-
|
|
2971
|
+
if (_this19.options.onChangePageSize) {
|
|
2972
|
+
_this19.options.onChangePageSize(selectedItem.value);
|
|
2650
2973
|
}
|
|
2651
2974
|
}
|
|
2652
2975
|
});
|
|
@@ -2670,13 +2993,13 @@ var Pager = /*#__PURE__*/function () {
|
|
|
2670
2993
|
}, {
|
|
2671
2994
|
key: "render",
|
|
2672
2995
|
value: function render() {
|
|
2673
|
-
var
|
|
2996
|
+
var _this20 = this;
|
|
2674
2997
|
|
|
2675
2998
|
var el = document.getElementById("".concat(this.elementId, "_pageList"));
|
|
2676
2999
|
|
|
2677
3000
|
if (el) {
|
|
2678
3001
|
var pages = this.options.pages.map(function (item, index) {
|
|
2679
|
-
return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(
|
|
3002
|
+
return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(_this20.options.activePage === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
2680
3003
|
});
|
|
2681
3004
|
var startIndex = 0;
|
|
2682
3005
|
|
|
@@ -2744,58 +3067,58 @@ var WebsyPDFButton = /*#__PURE__*/function () {
|
|
|
2744
3067
|
_createClass(WebsyPDFButton, [{
|
|
2745
3068
|
key: "handleClick",
|
|
2746
3069
|
value: function handleClick(event) {
|
|
2747
|
-
var
|
|
3070
|
+
var _this21 = this;
|
|
2748
3071
|
|
|
2749
3072
|
if (event.target.classList.contains('websy-pdf-button')) {
|
|
2750
3073
|
this.loader.show();
|
|
2751
3074
|
setTimeout(function () {
|
|
2752
|
-
if (
|
|
2753
|
-
var el = document.getElementById(
|
|
3075
|
+
if (_this21.options.targetId) {
|
|
3076
|
+
var el = document.getElementById(_this21.options.targetId);
|
|
2754
3077
|
|
|
2755
3078
|
if (el) {
|
|
2756
3079
|
var pdfData = {
|
|
2757
3080
|
options: {}
|
|
2758
3081
|
};
|
|
2759
3082
|
|
|
2760
|
-
if (
|
|
2761
|
-
pdfData.options = _extends({},
|
|
3083
|
+
if (_this21.options.pdfOptions) {
|
|
3084
|
+
pdfData.options = _extends({}, _this21.options.pdfOptions);
|
|
2762
3085
|
}
|
|
2763
3086
|
|
|
2764
|
-
if (
|
|
2765
|
-
if (
|
|
2766
|
-
var headerEl = document.getElementById(
|
|
3087
|
+
if (_this21.options.header) {
|
|
3088
|
+
if (_this21.options.header.elementId) {
|
|
3089
|
+
var headerEl = document.getElementById(_this21.options.header.elementId);
|
|
2767
3090
|
|
|
2768
3091
|
if (headerEl) {
|
|
2769
3092
|
pdfData.header = headerEl.outerHTML;
|
|
2770
3093
|
|
|
2771
|
-
if (
|
|
2772
|
-
pdfData.options.headerCSS =
|
|
3094
|
+
if (_this21.options.header.css) {
|
|
3095
|
+
pdfData.options.headerCSS = _this21.options.header.css;
|
|
2773
3096
|
}
|
|
2774
3097
|
}
|
|
2775
|
-
} else if (
|
|
2776
|
-
pdfData.header =
|
|
3098
|
+
} else if (_this21.options.header.html) {
|
|
3099
|
+
pdfData.header = _this21.options.header.html;
|
|
2777
3100
|
|
|
2778
|
-
if (
|
|
2779
|
-
pdfData.options.headerCSS =
|
|
3101
|
+
if (_this21.options.header.css) {
|
|
3102
|
+
pdfData.options.headerCSS = _this21.options.header.css;
|
|
2780
3103
|
}
|
|
2781
3104
|
} else {
|
|
2782
|
-
pdfData.header =
|
|
3105
|
+
pdfData.header = _this21.options.header;
|
|
2783
3106
|
}
|
|
2784
3107
|
}
|
|
2785
3108
|
|
|
2786
|
-
if (
|
|
2787
|
-
if (
|
|
2788
|
-
var footerEl = document.getElementById(
|
|
3109
|
+
if (_this21.options.footer) {
|
|
3110
|
+
if (_this21.options.footer.elementId) {
|
|
3111
|
+
var footerEl = document.getElementById(_this21.options.footer.elementId);
|
|
2789
3112
|
|
|
2790
3113
|
if (footerEl) {
|
|
2791
3114
|
pdfData.footer = footerEl.outerHTML;
|
|
2792
3115
|
|
|
2793
|
-
if (
|
|
2794
|
-
pdfData.options.footerCSS =
|
|
3116
|
+
if (_this21.options.footer.css) {
|
|
3117
|
+
pdfData.options.footerCSS = _this21.options.footer.css;
|
|
2795
3118
|
}
|
|
2796
3119
|
}
|
|
2797
3120
|
} else {
|
|
2798
|
-
pdfData.footer =
|
|
3121
|
+
pdfData.footer = _this21.options.footer;
|
|
2799
3122
|
}
|
|
2800
3123
|
}
|
|
2801
3124
|
|
|
@@ -2804,31 +3127,31 @@ var WebsyPDFButton = /*#__PURE__*/function () {
|
|
|
2804
3127
|
// document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
|
|
2805
3128
|
// document.getElementById(`${this.elementId}_form`).submit()
|
|
2806
3129
|
|
|
2807
|
-
|
|
3130
|
+
_this21.service.add('', pdfData, {
|
|
2808
3131
|
responseType: 'blob'
|
|
2809
3132
|
}).then(function (response) {
|
|
2810
|
-
|
|
3133
|
+
_this21.loader.hide();
|
|
2811
3134
|
|
|
2812
3135
|
var blob = new Blob([response], {
|
|
2813
3136
|
type: 'application/pdf'
|
|
2814
3137
|
});
|
|
2815
3138
|
var msg = "\n <div class='text-center websy-pdf-download'>\n <div>Your file is ready to download</div>\n <a href='".concat(URL.createObjectURL(blob), "' target='_blank'\n ");
|
|
2816
3139
|
|
|
2817
|
-
if (
|
|
3140
|
+
if (_this21.options.directDownload === true) {
|
|
2818
3141
|
var fileName;
|
|
2819
3142
|
|
|
2820
|
-
if (typeof
|
|
2821
|
-
fileName =
|
|
3143
|
+
if (typeof _this21.options.fileName === 'function') {
|
|
3144
|
+
fileName = _this21.options.fileName() || 'Export';
|
|
2822
3145
|
} else {
|
|
2823
|
-
fileName =
|
|
3146
|
+
fileName = _this21.options.fileName || 'Export';
|
|
2824
3147
|
}
|
|
2825
3148
|
|
|
2826
3149
|
msg += "download='".concat(fileName, ".pdf'");
|
|
2827
3150
|
}
|
|
2828
3151
|
|
|
2829
|
-
msg += "\n >\n <button class='websy-btn download-pdf'>".concat(
|
|
3152
|
+
msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this21.options.buttonText, "</button>\n </a>\n </div>\n ");
|
|
2830
3153
|
|
|
2831
|
-
|
|
3154
|
+
_this21.popup.show({
|
|
2832
3155
|
message: msg,
|
|
2833
3156
|
mask: true
|
|
2834
3157
|
});
|
|
@@ -2990,21 +3313,37 @@ var WebsyPubSub = /*#__PURE__*/function () {
|
|
|
2990
3313
|
|
|
2991
3314
|
_createClass(WebsyPubSub, [{
|
|
2992
3315
|
key: "publish",
|
|
2993
|
-
value: function publish(method, data) {
|
|
2994
|
-
if (
|
|
2995
|
-
this.subscriptions[method]
|
|
2996
|
-
|
|
2997
|
-
}
|
|
3316
|
+
value: function publish(id, method, data) {
|
|
3317
|
+
if (arguments.length === 3) {
|
|
3318
|
+
if (this.subscriptions[id] && this.subscriptions[id][method]) {
|
|
3319
|
+
this.subscriptions[id][method](data);
|
|
3320
|
+
}
|
|
3321
|
+
} else {
|
|
3322
|
+
if (this.subscriptions[method]) {
|
|
3323
|
+
this.subscriptions[method].forEach(function (fn) {
|
|
3324
|
+
fn(data);
|
|
3325
|
+
});
|
|
3326
|
+
}
|
|
2998
3327
|
}
|
|
2999
3328
|
}
|
|
3000
3329
|
}, {
|
|
3001
3330
|
key: "subscribe",
|
|
3002
|
-
value: function subscribe(method, fn) {
|
|
3003
|
-
if (
|
|
3004
|
-
this.subscriptions[
|
|
3005
|
-
|
|
3331
|
+
value: function subscribe(id, method, fn) {
|
|
3332
|
+
if (arguments.length === 3) {
|
|
3333
|
+
if (!this.subscriptions[id]) {
|
|
3334
|
+
this.subscriptions[id] = {};
|
|
3335
|
+
}
|
|
3006
3336
|
|
|
3007
|
-
|
|
3337
|
+
if (!this.subscriptions[id][method]) {
|
|
3338
|
+
this.subscriptions[id][method] = fn;
|
|
3339
|
+
}
|
|
3340
|
+
} else {
|
|
3341
|
+
if (!this.subscriptions[method]) {
|
|
3342
|
+
this.subscriptions[method] = [];
|
|
3343
|
+
}
|
|
3344
|
+
|
|
3345
|
+
this.subscriptions[method].push(fn);
|
|
3346
|
+
}
|
|
3008
3347
|
}
|
|
3009
3348
|
}]);
|
|
3010
3349
|
|
|
@@ -3013,7 +3352,7 @@ var WebsyPubSub = /*#__PURE__*/function () {
|
|
|
3013
3352
|
|
|
3014
3353
|
var ResponsiveText = /*#__PURE__*/function () {
|
|
3015
3354
|
function ResponsiveText(elementId, options) {
|
|
3016
|
-
var
|
|
3355
|
+
var _this22 = this;
|
|
3017
3356
|
|
|
3018
3357
|
_classCallCheck(this, ResponsiveText);
|
|
3019
3358
|
|
|
@@ -3026,7 +3365,7 @@ var ResponsiveText = /*#__PURE__*/function () {
|
|
|
3026
3365
|
this.elementId = elementId;
|
|
3027
3366
|
this.canvas = document.createElement('canvas');
|
|
3028
3367
|
window.addEventListener('resize', function () {
|
|
3029
|
-
return
|
|
3368
|
+
return _this22.render();
|
|
3030
3369
|
});
|
|
3031
3370
|
var el = document.getElementById(this.elementId);
|
|
3032
3371
|
|
|
@@ -3245,7 +3584,7 @@ var ResponsiveText = /*#__PURE__*/function () {
|
|
|
3245
3584
|
|
|
3246
3585
|
var WebsyResultList = /*#__PURE__*/function () {
|
|
3247
3586
|
function WebsyResultList(elementId, options) {
|
|
3248
|
-
var
|
|
3587
|
+
var _this23 = this;
|
|
3249
3588
|
|
|
3250
3589
|
_classCallCheck(this, WebsyResultList);
|
|
3251
3590
|
|
|
@@ -3273,9 +3612,9 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3273
3612
|
|
|
3274
3613
|
if (_typeof(options.template) === 'object' && options.template.url) {
|
|
3275
3614
|
this.templateService.get(options.template.url).then(function (templateString) {
|
|
3276
|
-
|
|
3615
|
+
_this23.options.template = templateString;
|
|
3277
3616
|
|
|
3278
|
-
|
|
3617
|
+
_this23.render();
|
|
3279
3618
|
});
|
|
3280
3619
|
} else {
|
|
3281
3620
|
this.render();
|
|
@@ -3294,7 +3633,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3294
3633
|
}, {
|
|
3295
3634
|
key: "buildHTML",
|
|
3296
3635
|
value: function buildHTML(d) {
|
|
3297
|
-
var
|
|
3636
|
+
var _this24 = this;
|
|
3298
3637
|
|
|
3299
3638
|
var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
3300
3639
|
var html = "";
|
|
@@ -3302,7 +3641,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3302
3641
|
if (this.options.template) {
|
|
3303
3642
|
if (d.length > 0) {
|
|
3304
3643
|
d.forEach(function (row, ix) {
|
|
3305
|
-
var template = "".concat(ix > 0 ? '-->' : '').concat(
|
|
3644
|
+
var template = "".concat(ix > 0 ? '-->' : '').concat(_this24.options.template).concat(ix < d.length - 1 ? '<!--' : ''); // find conditional elements
|
|
3306
3645
|
|
|
3307
3646
|
var ifMatches = _toConsumableArray(template.matchAll(/<\s*if[^>]*>([\s\S]*?)<\s*\/\s*if>/g));
|
|
3308
3647
|
|
|
@@ -3422,7 +3761,7 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3422
3761
|
}, {
|
|
3423
3762
|
key: "handleClick",
|
|
3424
3763
|
value: function handleClick(event) {
|
|
3425
|
-
var
|
|
3764
|
+
var _this25 = this;
|
|
3426
3765
|
|
|
3427
3766
|
if (event.target.classList.contains('clickable')) {
|
|
3428
3767
|
var l = event.target.getAttribute('data-event');
|
|
@@ -3440,8 +3779,8 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3440
3779
|
l = l[0];
|
|
3441
3780
|
params = params.map(function (p) {
|
|
3442
3781
|
if (typeof p !== 'string' && typeof p !== 'number') {
|
|
3443
|
-
if (
|
|
3444
|
-
p =
|
|
3782
|
+
if (_this25.rows[+id]) {
|
|
3783
|
+
p = _this25.rows[+id][p];
|
|
3445
3784
|
}
|
|
3446
3785
|
} else if (typeof p === 'string') {
|
|
3447
3786
|
p = p.replace(/"/g, '').replace(/'/g, '');
|
|
@@ -3463,13 +3802,13 @@ var WebsyResultList = /*#__PURE__*/function () {
|
|
|
3463
3802
|
}, {
|
|
3464
3803
|
key: "render",
|
|
3465
3804
|
value: function render() {
|
|
3466
|
-
var
|
|
3805
|
+
var _this26 = this;
|
|
3467
3806
|
|
|
3468
3807
|
if (this.options.entity) {
|
|
3469
3808
|
this.apiService.get(this.options.entity).then(function (results) {
|
|
3470
|
-
|
|
3809
|
+
_this26.rows = results.rows;
|
|
3471
3810
|
|
|
3472
|
-
|
|
3811
|
+
_this26.resize();
|
|
3473
3812
|
});
|
|
3474
3813
|
} else {
|
|
3475
3814
|
this.resize();
|
|
@@ -3548,14 +3887,14 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
3548
3887
|
_createClass(WebsyRouter, [{
|
|
3549
3888
|
key: "addGroup",
|
|
3550
3889
|
value: function addGroup(group) {
|
|
3551
|
-
var
|
|
3890
|
+
var _this27 = this;
|
|
3552
3891
|
|
|
3553
3892
|
if (!this.groups[group]) {
|
|
3554
3893
|
var els = document.querySelectorAll(".websy-view[data-group=\"".concat(group, "\"]"));
|
|
3555
3894
|
|
|
3556
3895
|
if (els) {
|
|
3557
3896
|
this.getClosestParent(els[0], function (parent) {
|
|
3558
|
-
|
|
3897
|
+
_this27.groups[group] = {
|
|
3559
3898
|
activeView: '',
|
|
3560
3899
|
views: [],
|
|
3561
3900
|
parent: parent.getAttribute('data-view')
|
|
@@ -3880,12 +4219,12 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
3880
4219
|
}, {
|
|
3881
4220
|
key: "showComponents",
|
|
3882
4221
|
value: function showComponents(view) {
|
|
3883
|
-
var
|
|
4222
|
+
var _this28 = this;
|
|
3884
4223
|
|
|
3885
4224
|
if (this.options.views && this.options.views[view] && this.options.views[view].components) {
|
|
3886
4225
|
this.options.views[view].components.forEach(function (c) {
|
|
3887
4226
|
if (typeof c.instance === 'undefined') {
|
|
3888
|
-
|
|
4227
|
+
_this28.prepComponent(c.elementId, c.options);
|
|
3889
4228
|
|
|
3890
4229
|
c.instance = new c.Component(c.elementId, c.options);
|
|
3891
4230
|
} else if (c.instance.render) {
|
|
@@ -4313,7 +4652,7 @@ var Switch = /*#__PURE__*/function () {
|
|
|
4313
4652
|
|
|
4314
4653
|
var WebsyTemplate = /*#__PURE__*/function () {
|
|
4315
4654
|
function WebsyTemplate(elementId, options) {
|
|
4316
|
-
var
|
|
4655
|
+
var _this29 = this;
|
|
4317
4656
|
|
|
4318
4657
|
_classCallCheck(this, WebsyTemplate);
|
|
4319
4658
|
|
|
@@ -4339,9 +4678,9 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
4339
4678
|
|
|
4340
4679
|
if (_typeof(options.template) === 'object' && options.template.url) {
|
|
4341
4680
|
this.templateService.get(options.template.url).then(function (templateString) {
|
|
4342
|
-
|
|
4681
|
+
_this29.options.template = templateString;
|
|
4343
4682
|
|
|
4344
|
-
|
|
4683
|
+
_this29.render();
|
|
4345
4684
|
});
|
|
4346
4685
|
} else {
|
|
4347
4686
|
this.render();
|
|
@@ -4351,7 +4690,7 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
4351
4690
|
_createClass(WebsyTemplate, [{
|
|
4352
4691
|
key: "buildHTML",
|
|
4353
4692
|
value: function buildHTML() {
|
|
4354
|
-
var
|
|
4693
|
+
var _this30 = this;
|
|
4355
4694
|
|
|
4356
4695
|
var html = "";
|
|
4357
4696
|
|
|
@@ -4413,14 +4752,14 @@ var WebsyTemplate = /*#__PURE__*/function () {
|
|
|
4413
4752
|
}
|
|
4414
4753
|
|
|
4415
4754
|
if (polarity === true) {
|
|
4416
|
-
if (typeof
|
|
4755
|
+
if (typeof _this30.options.data[parts[0]] !== 'undefined' && _this30.options.data[parts[0]] === parts[1]) {
|
|
4417
4756
|
// remove the <if> tags
|
|
4418
4757
|
removeAll = false;
|
|
4419
4758
|
} else if (parts[0] === parts[1]) {
|
|
4420
4759
|
removeAll = false;
|
|
4421
4760
|
}
|
|
4422
4761
|
} else if (polarity === false) {
|
|
4423
|
-
if (typeof
|
|
4762
|
+
if (typeof _this30.options.data[parts[0]] !== 'undefined' && _this30.options.data[parts[0]] !== parts[1]) {
|
|
4424
4763
|
// remove the <if> tags
|
|
4425
4764
|
removeAll = false;
|
|
4426
4765
|
}
|
|
@@ -4707,7 +5046,7 @@ var WebsyUtils = {
|
|
|
4707
5046
|
|
|
4708
5047
|
var WebsyTable = /*#__PURE__*/function () {
|
|
4709
5048
|
function WebsyTable(elementId, options) {
|
|
4710
|
-
var
|
|
5049
|
+
var _this31 = this;
|
|
4711
5050
|
|
|
4712
5051
|
_classCallCheck(this, WebsyTable);
|
|
4713
5052
|
|
|
@@ -4745,8 +5084,8 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4745
5084
|
allowClear: false,
|
|
4746
5085
|
disableSearch: true,
|
|
4747
5086
|
onItemSelected: function onItemSelected(selectedItem) {
|
|
4748
|
-
if (
|
|
4749
|
-
|
|
5087
|
+
if (_this31.options.onChangePageSize) {
|
|
5088
|
+
_this31.options.onChangePageSize(selectedItem.value);
|
|
4750
5089
|
}
|
|
4751
5090
|
}
|
|
4752
5091
|
});
|
|
@@ -4767,7 +5106,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4767
5106
|
_createClass(WebsyTable, [{
|
|
4768
5107
|
key: "appendRows",
|
|
4769
5108
|
value: function appendRows(data) {
|
|
4770
|
-
var
|
|
5109
|
+
var _this32 = this;
|
|
4771
5110
|
|
|
4772
5111
|
this.hideError();
|
|
4773
5112
|
var bodyHTML = '';
|
|
@@ -4775,15 +5114,15 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4775
5114
|
if (data) {
|
|
4776
5115
|
bodyHTML += data.map(function (r, rowIndex) {
|
|
4777
5116
|
return '<tr>' + r.map(function (c, i) {
|
|
4778
|
-
if (
|
|
5117
|
+
if (_this32.options.columns[i].show !== false) {
|
|
4779
5118
|
var style = '';
|
|
4780
5119
|
|
|
4781
5120
|
if (c.style) {
|
|
4782
5121
|
style += c.style;
|
|
4783
5122
|
}
|
|
4784
5123
|
|
|
4785
|
-
if (
|
|
4786
|
-
style += "width: ".concat(
|
|
5124
|
+
if (_this32.options.columns[i].width) {
|
|
5125
|
+
style += "width: ".concat(_this32.options.columns[i].width, "; ");
|
|
4787
5126
|
}
|
|
4788
5127
|
|
|
4789
5128
|
if (c.backgroundColor) {
|
|
@@ -4798,18 +5137,18 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4798
5137
|
style += "color: ".concat(c.color, "; ");
|
|
4799
5138
|
}
|
|
4800
5139
|
|
|
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(
|
|
5140
|
+
if (_this32.options.columns[i].showAsLink === true && c.value.trim() !== '') {
|
|
5141
|
+
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 ");
|
|
5142
|
+
} else if ((_this32.options.columns[i].showAsNavigatorLink === true || _this32.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
|
|
5143
|
+
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
5144
|
} else {
|
|
4806
5145
|
var info = c.value;
|
|
4807
5146
|
|
|
4808
|
-
if (
|
|
5147
|
+
if (_this32.options.columns[i].showAsImage === true) {
|
|
4809
5148
|
c.value = "\n <img src='".concat(c.value, "'>\n ");
|
|
4810
5149
|
}
|
|
4811
5150
|
|
|
4812
|
-
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(
|
|
5151
|
+
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
5152
|
}
|
|
4814
5153
|
}
|
|
4815
5154
|
}).join('') + '</tr>';
|
|
@@ -4981,7 +5320,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
4981
5320
|
}, {
|
|
4982
5321
|
key: "render",
|
|
4983
5322
|
value: function render(data) {
|
|
4984
|
-
var
|
|
5323
|
+
var _this33 = this;
|
|
4985
5324
|
|
|
4986
5325
|
if (!this.options.columns) {
|
|
4987
5326
|
return;
|
|
@@ -5006,7 +5345,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5006
5345
|
|
|
5007
5346
|
var headHTML = '<tr>' + this.options.columns.map(function (c, i) {
|
|
5008
5347
|
if (c.show !== false) {
|
|
5009
|
-
return "\n <th ".concat(c.width ? 'style="width: ' + (c.width || 'auto') + ';"' : '', ">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-index=\"").concat(i, "\" \n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n <!--").concat(c.searchable === true ?
|
|
5348
|
+
return "\n <th ".concat(c.width ? 'style="width: ' + (c.width || 'auto') + ';"' : '', ">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-index=\"").concat(i, "\" \n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n <!--").concat(c.searchable === true ? _this33.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
|
|
5010
5349
|
}
|
|
5011
5350
|
}).join('') + '</tr>';
|
|
5012
5351
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
@@ -5025,7 +5364,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5025
5364
|
|
|
5026
5365
|
if (pagingEl) {
|
|
5027
5366
|
var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
|
|
5028
|
-
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(
|
|
5367
|
+
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this33.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
5029
5368
|
});
|
|
5030
5369
|
var startIndex = 0;
|
|
5031
5370
|
|
|
@@ -5093,7 +5432,7 @@ var WebsyTable = /*#__PURE__*/function () {
|
|
|
5093
5432
|
|
|
5094
5433
|
var WebsyTable2 = /*#__PURE__*/function () {
|
|
5095
5434
|
function WebsyTable2(elementId, options) {
|
|
5096
|
-
var
|
|
5435
|
+
var _this34 = this;
|
|
5097
5436
|
|
|
5098
5437
|
_classCallCheck(this, WebsyTable2);
|
|
5099
5438
|
|
|
@@ -5134,8 +5473,8 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5134
5473
|
allowClear: false,
|
|
5135
5474
|
disableSearch: true,
|
|
5136
5475
|
onItemSelected: function onItemSelected(selectedItem) {
|
|
5137
|
-
if (
|
|
5138
|
-
|
|
5476
|
+
if (_this34.options.onChangePageSize) {
|
|
5477
|
+
_this34.options.onChangePageSize(selectedItem.value);
|
|
5139
5478
|
}
|
|
5140
5479
|
}
|
|
5141
5480
|
});
|
|
@@ -5159,7 +5498,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5159
5498
|
_createClass(WebsyTable2, [{
|
|
5160
5499
|
key: "appendRows",
|
|
5161
5500
|
value: function appendRows(data) {
|
|
5162
|
-
var
|
|
5501
|
+
var _this35 = this;
|
|
5163
5502
|
|
|
5164
5503
|
this.hideError();
|
|
5165
5504
|
var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
|
|
@@ -5168,15 +5507,15 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5168
5507
|
if (data) {
|
|
5169
5508
|
bodyHTML += data.map(function (r, rowIndex) {
|
|
5170
5509
|
return '<tr>' + r.map(function (c, i) {
|
|
5171
|
-
if (
|
|
5172
|
-
var style = "height: ".concat(
|
|
5510
|
+
if (_this35.options.columns[i].show !== false) {
|
|
5511
|
+
var style = "height: ".concat(_this35.options.cellSize, "px; line-height: ").concat(_this35.options.cellSize, "px;");
|
|
5173
5512
|
|
|
5174
5513
|
if (c.style) {
|
|
5175
5514
|
style += c.style;
|
|
5176
5515
|
}
|
|
5177
5516
|
|
|
5178
|
-
if (
|
|
5179
|
-
style += "width: ".concat(
|
|
5517
|
+
if (_this35.options.columns[i].width) {
|
|
5518
|
+
style += "width: ".concat(_this35.options.columns[i].width, "; ");
|
|
5180
5519
|
}
|
|
5181
5520
|
|
|
5182
5521
|
if (c.backgroundColor) {
|
|
@@ -5191,18 +5530,18 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5191
5530
|
style += "color: ".concat(c.color, "; ");
|
|
5192
5531
|
}
|
|
5193
5532
|
|
|
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(
|
|
5533
|
+
if (_this35.options.columns[i].showAsLink === true && c.value.trim() !== '') {
|
|
5534
|
+
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 ");
|
|
5535
|
+
} else if ((_this35.options.columns[i].showAsNavigatorLink === true || _this35.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
|
|
5536
|
+
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
5537
|
} else {
|
|
5199
5538
|
var info = c.value;
|
|
5200
5539
|
|
|
5201
|
-
if (
|
|
5540
|
+
if (_this35.options.columns[i].showAsImage === true) {
|
|
5202
5541
|
c.value = "\n <img src='".concat(c.value, "'>\n ");
|
|
5203
5542
|
}
|
|
5204
5543
|
|
|
5205
|
-
return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(
|
|
5544
|
+
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
5545
|
}
|
|
5207
5546
|
}
|
|
5208
5547
|
}).join('') + '</tr>';
|
|
@@ -5415,7 +5754,11 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5415
5754
|
}, {
|
|
5416
5755
|
key: "hideLoading",
|
|
5417
5756
|
value: function hideLoading() {
|
|
5418
|
-
this.
|
|
5757
|
+
if (this.options.onLoading) {
|
|
5758
|
+
this.options.onLoading(false);
|
|
5759
|
+
} else {
|
|
5760
|
+
this.loadingDialog.hide();
|
|
5761
|
+
}
|
|
5419
5762
|
}
|
|
5420
5763
|
}, {
|
|
5421
5764
|
key: "internalSort",
|
|
@@ -5461,7 +5804,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5461
5804
|
}, {
|
|
5462
5805
|
key: "render",
|
|
5463
5806
|
value: function render(data) {
|
|
5464
|
-
var
|
|
5807
|
+
var _this36 = this;
|
|
5465
5808
|
|
|
5466
5809
|
if (!this.options.columns) {
|
|
5467
5810
|
return;
|
|
@@ -5497,7 +5840,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5497
5840
|
style += "width: ".concat(c.width || 'auto', "; ");
|
|
5498
5841
|
}
|
|
5499
5842
|
|
|
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 ?
|
|
5843
|
+
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
5844
|
}
|
|
5502
5845
|
}).join('') + '</tr>';
|
|
5503
5846
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
@@ -5508,7 +5851,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5508
5851
|
var dropdownHTML = "";
|
|
5509
5852
|
this.options.columns.forEach(function (c, i) {
|
|
5510
5853
|
if (c.searchable && c.searchField) {
|
|
5511
|
-
dropdownHTML += "\n <div id=\"".concat(
|
|
5854
|
+
dropdownHTML += "\n <div id=\"".concat(_this36.elementId, "_columnSearch_").concat(i, "\" class=\"websy-modal-dropdown\"></div>\n ");
|
|
5512
5855
|
}
|
|
5513
5856
|
});
|
|
5514
5857
|
dropdownEl.innerHTML = dropdownHTML;
|
|
@@ -5530,7 +5873,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5530
5873
|
|
|
5531
5874
|
if (pagingEl) {
|
|
5532
5875
|
var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
|
|
5533
|
-
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(
|
|
5876
|
+
return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this36.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
|
|
5534
5877
|
});
|
|
5535
5878
|
var startIndex = 0;
|
|
5536
5879
|
|
|
@@ -5612,12 +5955,16 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5612
5955
|
}, {
|
|
5613
5956
|
key: "showLoading",
|
|
5614
5957
|
value: function showLoading(options) {
|
|
5615
|
-
this.
|
|
5958
|
+
if (this.options.onLoading) {
|
|
5959
|
+
this.options.onLoading(true);
|
|
5960
|
+
} else {
|
|
5961
|
+
this.loadingDialog.show(options);
|
|
5962
|
+
}
|
|
5616
5963
|
}
|
|
5617
5964
|
}, {
|
|
5618
5965
|
key: "getColumnParameters",
|
|
5619
5966
|
value: function getColumnParameters(values) {
|
|
5620
|
-
var
|
|
5967
|
+
var _this37 = this;
|
|
5621
5968
|
|
|
5622
5969
|
var tableEl = document.getElementById("".concat(this.elementId, "_table"));
|
|
5623
5970
|
tableEl.style.tableLayout = 'auto';
|
|
@@ -5625,10 +5972,10 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5625
5972
|
var headEl = document.getElementById("".concat(this.elementId, "_head"));
|
|
5626
5973
|
var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
|
|
5627
5974
|
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 ?
|
|
5975
|
+
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
5976
|
}).join('') + '</tr>';
|
|
5630
5977
|
bodyEl.innerHTML = '<tr style="visibility: hidden;">' + values.map(function (c) {
|
|
5631
|
-
return "\n <td \n style='height: ".concat(
|
|
5978
|
+
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
5979
|
}).join('') + '</tr>'; // get height of the first data cell
|
|
5633
5980
|
|
|
5634
5981
|
var cells = bodyEl.querySelectorAll("tr:first-of-type td");
|
|
@@ -5673,12 +6020,639 @@ var WebsyTable2 = /*#__PURE__*/function () {
|
|
|
5673
6020
|
|
|
5674
6021
|
return WebsyTable2;
|
|
5675
6022
|
}();
|
|
6023
|
+
/* global WebsyDesigns */
|
|
6024
|
+
|
|
6025
|
+
|
|
6026
|
+
var WebsyTable3 = /*#__PURE__*/function () {
|
|
6027
|
+
function WebsyTable3(elementId, options) {
|
|
6028
|
+
_classCallCheck(this, WebsyTable3);
|
|
6029
|
+
|
|
6030
|
+
this.elementId = elementId;
|
|
6031
|
+
var DEFAULTS = {
|
|
6032
|
+
virtualScroll: false,
|
|
6033
|
+
showTotalsAbove: true,
|
|
6034
|
+
minHandleSize: 20,
|
|
6035
|
+
maxColWidth: '50%',
|
|
6036
|
+
allowPivoting: false
|
|
6037
|
+
};
|
|
6038
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
6039
|
+
this.sizes = {};
|
|
6040
|
+
this.scrollDragging = false;
|
|
6041
|
+
this.cellDragging = false;
|
|
6042
|
+
this.vScrollRequired = false;
|
|
6043
|
+
this.hScrollRequired = false;
|
|
6044
|
+
this.pinnedColumns = 0;
|
|
6045
|
+
this.startRow = 0;
|
|
6046
|
+
this.endRow = 0;
|
|
6047
|
+
this.startCol = 0;
|
|
6048
|
+
this.endCol = 0;
|
|
6049
|
+
this.mouseYStart = 0;
|
|
6050
|
+
this.mouseYStart = 0;
|
|
6051
|
+
|
|
6052
|
+
if (!elementId) {
|
|
6053
|
+
console.log('No element Id provided for Websy Table');
|
|
6054
|
+
return;
|
|
6055
|
+
}
|
|
6056
|
+
|
|
6057
|
+
var el = document.getElementById(this.elementId);
|
|
6058
|
+
|
|
6059
|
+
if (el) {
|
|
6060
|
+
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 ");
|
|
6061
|
+
|
|
6062
|
+
if (this.options.paging === 'pages') {
|
|
6063
|
+
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 ");
|
|
6064
|
+
}
|
|
6065
|
+
|
|
6066
|
+
el.innerHTML = html;
|
|
6067
|
+
el.addEventListener('click', this.handleClick.bind(this));
|
|
6068
|
+
el.addEventListener('mousedown', this.handleMouseDown.bind(this));
|
|
6069
|
+
window.addEventListener('mousemove', this.handleMouseMove.bind(this));
|
|
6070
|
+
window.addEventListener('mouseup', this.handleMouseUp.bind(this));
|
|
6071
|
+
var scrollEl = document.getElementById("".concat(this.elementId, "_tableBody"));
|
|
6072
|
+
|
|
6073
|
+
if (scrollEl) {
|
|
6074
|
+
scrollEl.addEventListener('wheel', this.handleScrollWheel.bind(this));
|
|
6075
|
+
}
|
|
6076
|
+
|
|
6077
|
+
this.loadingDialog = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loadingContainer"));
|
|
6078
|
+
this.render(this.options.data);
|
|
6079
|
+
} else {
|
|
6080
|
+
console.error("No element found with ID ".concat(this.elementId));
|
|
6081
|
+
}
|
|
6082
|
+
}
|
|
6083
|
+
|
|
6084
|
+
_createClass(WebsyTable3, [{
|
|
6085
|
+
key: "appendRows",
|
|
6086
|
+
value: function appendRows(data) {
|
|
6087
|
+
this.hideError();
|
|
6088
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody"));
|
|
6089
|
+
|
|
6090
|
+
if (bodyEl) {
|
|
6091
|
+
if (this.options.virtualScroll === true) {
|
|
6092
|
+
bodyEl.innerHTML = this.buildBodyHtml(data, true);
|
|
6093
|
+
} else {
|
|
6094
|
+
bodyEl.innerHTML += this.buildBodyHtml(data, true);
|
|
6095
|
+
}
|
|
6096
|
+
} // this.data = this.data.concat(data)
|
|
6097
|
+
// this.rowCount = this.data.length
|
|
6098
|
+
|
|
6099
|
+
}
|
|
6100
|
+
}, {
|
|
6101
|
+
key: "buildBodyHtml",
|
|
6102
|
+
value: function buildBodyHtml() {
|
|
6103
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
6104
|
+
var useWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
6105
|
+
|
|
6106
|
+
if (data.length === 0) {
|
|
6107
|
+
return '';
|
|
6108
|
+
}
|
|
6109
|
+
|
|
6110
|
+
var bodyHtml = "";
|
|
6111
|
+
var sizingColumns = this.options.columns[this.options.columns.length - 1];
|
|
6112
|
+
|
|
6113
|
+
if (useWidths === true) {
|
|
6114
|
+
bodyHtml += '<colgroup>';
|
|
6115
|
+
bodyHtml += sizingColumns.map(function (c) {
|
|
6116
|
+
return "\n <col\n style='width: ".concat(c.width || c.actualWidth, "px!important'\n ></col>\n ");
|
|
6117
|
+
}).join('');
|
|
6118
|
+
bodyHtml += '</colgroup>';
|
|
6119
|
+
}
|
|
6120
|
+
|
|
6121
|
+
data.forEach(function (row) {
|
|
6122
|
+
bodyHtml += "<tr class=\"websy-table-row\">";
|
|
6123
|
+
row.forEach(function (cell, cellIndex) {
|
|
6124
|
+
bodyHtml += "<td \n class='websy-table-cell'\n style='".concat(cell.style, "'\n data-info='").concat(cell.value, "'\n colspan='").concat(cell.colspan || 1, "'\n rowspan='").concat(cell.rowspan || 1, "'\n "); // if (useWidths === true) {
|
|
6125
|
+
// bodyHtml += `
|
|
6126
|
+
// style='width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important'
|
|
6127
|
+
// width='${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}'
|
|
6128
|
+
// `
|
|
6129
|
+
// }
|
|
6130
|
+
|
|
6131
|
+
bodyHtml += "\n >\n ".concat(cell.value, "\n </td>");
|
|
6132
|
+
});
|
|
6133
|
+
bodyHtml += "</tr>";
|
|
6134
|
+
}); // bodyHtml += `</div>`
|
|
6135
|
+
|
|
6136
|
+
return bodyHtml;
|
|
6137
|
+
}
|
|
6138
|
+
}, {
|
|
6139
|
+
key: "buildHeaderHtml",
|
|
6140
|
+
value: function buildHeaderHtml() {
|
|
6141
|
+
var _this38 = this;
|
|
6142
|
+
|
|
6143
|
+
var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
6144
|
+
var headerHtml = '';
|
|
6145
|
+
var sizingColumns = this.options.columns[this.options.columns.length - 1];
|
|
6146
|
+
|
|
6147
|
+
if (useWidths === true) {
|
|
6148
|
+
headerHtml += '<colgroup>';
|
|
6149
|
+
headerHtml += sizingColumns.map(function (c) {
|
|
6150
|
+
return "\n <col\n style='width: ".concat(c.width || c.actualWidth, "px!important'\n ></col>\n ");
|
|
6151
|
+
}).join('');
|
|
6152
|
+
headerHtml += '</colgroup>';
|
|
6153
|
+
}
|
|
6154
|
+
|
|
6155
|
+
this.options.columns.forEach(function (row, rowIndex) {
|
|
6156
|
+
if (useWidths === false && rowIndex !== _this38.options.columns.length - 1) {
|
|
6157
|
+
// if we're calculating the size we only want to render the last row of column headers
|
|
6158
|
+
return;
|
|
6159
|
+
}
|
|
6160
|
+
|
|
6161
|
+
headerHtml += "<tr class=\"websy-table-row websy-table-header-row\">";
|
|
6162
|
+
row.forEach(function (col) {
|
|
6163
|
+
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) {
|
|
6164
|
+
// headerHtml += `
|
|
6165
|
+
// style='width: ${col.width || col.actualWidth}px'
|
|
6166
|
+
// width='${col.width || col.actualWidth}'
|
|
6167
|
+
// `
|
|
6168
|
+
// }
|
|
6169
|
+
|
|
6170
|
+
headerHtml += " \n >\n ".concat(col.name, "\n </td>");
|
|
6171
|
+
});
|
|
6172
|
+
headerHtml += "</tr>";
|
|
6173
|
+
});
|
|
6174
|
+
return headerHtml;
|
|
6175
|
+
}
|
|
6176
|
+
}, {
|
|
6177
|
+
key: "buildTotalHtml",
|
|
6178
|
+
value: function buildTotalHtml() {
|
|
6179
|
+
var _this39 = this;
|
|
6180
|
+
|
|
6181
|
+
var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
6182
|
+
|
|
6183
|
+
if (!this.options.totals) {
|
|
6184
|
+
return '';
|
|
6185
|
+
}
|
|
6186
|
+
|
|
6187
|
+
var totalHtml = "<tr class=\"websy-table-row websy-table-total-row\">";
|
|
6188
|
+
this.options.totals.forEach(function (col, colIndex) {
|
|
6189
|
+
totalHtml += "<td \n class='websy-table-cell'\n colspan='".concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n ");
|
|
6190
|
+
|
|
6191
|
+
if (useWidths === true) {
|
|
6192
|
+
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 ");
|
|
6193
|
+
}
|
|
6194
|
+
|
|
6195
|
+
totalHtml += " \n >\n ".concat(col.value, "\n </td>");
|
|
6196
|
+
});
|
|
6197
|
+
totalHtml += "</tr>";
|
|
6198
|
+
return totalHtml;
|
|
6199
|
+
}
|
|
6200
|
+
}, {
|
|
6201
|
+
key: "calculateSizes",
|
|
6202
|
+
value: function calculateSizes() {
|
|
6203
|
+
var _this40 = this;
|
|
6204
|
+
|
|
6205
|
+
var sample = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
6206
|
+
var totalRowCount = arguments.length > 1 ? arguments[1] : undefined;
|
|
6207
|
+
var totalColumnCount = arguments.length > 2 ? arguments[2] : undefined;
|
|
6208
|
+
var pinnedColumns = arguments.length > 3 ? arguments[3] : undefined;
|
|
6209
|
+
this.totalRowCount = totalRowCount; // probably need some error handling here if no value is passed in
|
|
6210
|
+
|
|
6211
|
+
this.totalColumnCount = totalColumnCount; // probably need some error handling here if no value is passed in
|
|
6212
|
+
|
|
6213
|
+
this.pinnedColumns = pinnedColumns; // probably need some error handling here if no value is passed in
|
|
6214
|
+
|
|
6215
|
+
var outerEl = document.getElementById(this.elementId);
|
|
6216
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
6217
|
+
var headEl = document.getElementById("".concat(this.elementId, "_tableHeader"));
|
|
6218
|
+
headEl.style.width = 'auto';
|
|
6219
|
+
headEl.innerHTML = this.buildHeaderHtml();
|
|
6220
|
+
this.sizes.outer = outerEl.getBoundingClientRect();
|
|
6221
|
+
this.sizes.table = tableEl.getBoundingClientRect();
|
|
6222
|
+
this.sizes.header = headEl.getBoundingClientRect();
|
|
6223
|
+
var maxWidth;
|
|
6224
|
+
|
|
6225
|
+
if (typeof this.options.maxColWidth === 'number') {
|
|
6226
|
+
maxWidth = this.options.maxColWidth;
|
|
6227
|
+
} else if (this.options.maxColWidth.indexOf('%') !== -1) {
|
|
6228
|
+
maxWidth = this.sizes.outer.width * (+this.options.maxColWidth.replace('%', '') / 100);
|
|
6229
|
+
} else if (this.options.maxColWidth.indexOf('px') !== -1) {
|
|
6230
|
+
maxWidth = +this.options.maxColWidth.replace('px', '');
|
|
6231
|
+
}
|
|
6232
|
+
|
|
6233
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody"));
|
|
6234
|
+
bodyEl.style.width = 'auto';
|
|
6235
|
+
bodyEl.innerHTML = this.buildBodyHtml([sample]);
|
|
6236
|
+
var footerEl = document.getElementById("".concat(this.elementId, "_tableFooter"));
|
|
6237
|
+
footerEl.innerHTML = this.buildTotalHtml();
|
|
6238
|
+
this.sizes.total = footerEl.getBoundingClientRect();
|
|
6239
|
+
var rows = Array.from(tableEl.querySelectorAll('.websy-table-row'));
|
|
6240
|
+
var totalWidth = 0;
|
|
6241
|
+
this.sizes.scrollableWidth = this.sizes.outer.width;
|
|
6242
|
+
rows.forEach(function (row, rowIndex) {
|
|
6243
|
+
Array.from(row.children).forEach(function (col, colIndex) {
|
|
6244
|
+
var colSize = col.getBoundingClientRect();
|
|
6245
|
+
_this40.sizes.cellHeight = colSize.height;
|
|
6246
|
+
|
|
6247
|
+
if (_this40.options.columns[_this40.options.columns.length - 1][colIndex]) {
|
|
6248
|
+
if (!_this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth) {
|
|
6249
|
+
_this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth = 0;
|
|
6250
|
+
}
|
|
6251
|
+
|
|
6252
|
+
_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);
|
|
6253
|
+
_this40.options.columns[_this40.options.columns.length - 1][colIndex].cellHeight = colSize.height;
|
|
6254
|
+
}
|
|
6255
|
+
});
|
|
6256
|
+
});
|
|
6257
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
|
|
6258
|
+
if (colIndex < _this40.pinnedColumns) {
|
|
6259
|
+
_this40.sizes.scrollableWidth -= col.actualWidth;
|
|
6260
|
+
}
|
|
6261
|
+
});
|
|
6262
|
+
this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce(function (a, b) {
|
|
6263
|
+
return a + (b.width || b.actualWidth);
|
|
6264
|
+
}, 0);
|
|
6265
|
+
var outerSize = outerEl.getBoundingClientRect();
|
|
6266
|
+
|
|
6267
|
+
if (this.sizes.totalWidth < outerSize.width) {
|
|
6268
|
+
this.sizes.totalWidth = 0;
|
|
6269
|
+
var equalWidth = outerSize.width / this.options.columns[this.options.columns.length - 1].length;
|
|
6270
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (c, i) {
|
|
6271
|
+
if (!c.width) {
|
|
6272
|
+
if (c.actualWidth < equalWidth) {
|
|
6273
|
+
// adjust the width
|
|
6274
|
+
c.actualWidth = equalWidth;
|
|
6275
|
+
}
|
|
6276
|
+
}
|
|
6277
|
+
|
|
6278
|
+
_this40.sizes.totalWidth += c.width || c.actualWidth;
|
|
6279
|
+
equalWidth = (outerSize.width - _this40.sizes.totalWidth) / (_this40.options.columns[_this40.options.columns.length - 1].length - (i + 1));
|
|
6280
|
+
});
|
|
6281
|
+
} // take the height of the last cell as the official height for data cells
|
|
6282
|
+
// this.sizes.dataCellHeight = this.options.columns[this.options.columns.length - 1].cellHeight
|
|
6283
|
+
|
|
6284
|
+
|
|
6285
|
+
headEl.innerHTML = '';
|
|
6286
|
+
bodyEl.innerHTML = '';
|
|
6287
|
+
footerEl.innerHTML = '';
|
|
6288
|
+
headEl.style.width = 'initial';
|
|
6289
|
+
bodyEl.style.width = 'initial';
|
|
6290
|
+
this.sizes.bodyHeight = this.sizes.table.height - (this.sizes.header.height + this.sizes.total.height);
|
|
6291
|
+
this.sizes.rowsToRender = Math.ceil(this.sizes.bodyHeight / this.sizes.cellHeight);
|
|
6292
|
+
this.sizes.rowsToRenderPrecise = this.sizes.bodyHeight / this.sizes.cellHeight;
|
|
6293
|
+
this.startRow = 0;
|
|
6294
|
+
this.endRow = this.sizes.rowsToRender;
|
|
6295
|
+
this.startCol = 0;
|
|
6296
|
+
this.endCol = this.options.columns[this.options.columns.length - 1].length;
|
|
6297
|
+
|
|
6298
|
+
if (this.sizes.rowsToRender < this.totalRowCount) {
|
|
6299
|
+
this.vScrollRequired = true;
|
|
6300
|
+
}
|
|
6301
|
+
|
|
6302
|
+
if (this.sizes.totalWidth > this.sizes.outer.width) {
|
|
6303
|
+
this.hScrollRequired = true;
|
|
6304
|
+
}
|
|
6305
|
+
|
|
6306
|
+
this.options.allColumns = this.options.columns.map(function (c) {
|
|
6307
|
+
return c;
|
|
6308
|
+
});
|
|
6309
|
+
console.log('sizes', this.sizes);
|
|
6310
|
+
return this.sizes;
|
|
6311
|
+
}
|
|
6312
|
+
}, {
|
|
6313
|
+
key: "createSample",
|
|
6314
|
+
value: function createSample(data) {
|
|
6315
|
+
var output = [];
|
|
6316
|
+
this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
|
|
6317
|
+
if (col.maxLength) {
|
|
6318
|
+
output.push({
|
|
6319
|
+
value: new Array(col.maxLength).fill('W').join('')
|
|
6320
|
+
});
|
|
6321
|
+
} else if (data) {
|
|
6322
|
+
var longest = '';
|
|
6323
|
+
|
|
6324
|
+
for (var i = 0; i < Math.min(data.length, 1000); i++) {
|
|
6325
|
+
if (longest.length < data[i][colIndex].value.length) {
|
|
6326
|
+
longest = data[i][colIndex].value;
|
|
6327
|
+
}
|
|
6328
|
+
}
|
|
6329
|
+
|
|
6330
|
+
output.push({
|
|
6331
|
+
value: longest
|
|
6332
|
+
});
|
|
6333
|
+
} else {
|
|
6334
|
+
output.push({
|
|
6335
|
+
value: ''
|
|
6336
|
+
});
|
|
6337
|
+
}
|
|
6338
|
+
});
|
|
6339
|
+
return output;
|
|
6340
|
+
}
|
|
6341
|
+
}, {
|
|
6342
|
+
key: "handleClick",
|
|
6343
|
+
value: function handleClick(event) {}
|
|
6344
|
+
}, {
|
|
6345
|
+
key: "handleMouseDown",
|
|
6346
|
+
value: function handleMouseDown(event) {
|
|
6347
|
+
if (event.target.classList.contains('websy-scroll-handle-y')) {
|
|
6348
|
+
// set up the scroll start values
|
|
6349
|
+
this.scrollDragging = true;
|
|
6350
|
+
this.scrollDirection = 'y';
|
|
6351
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
6352
|
+
this.handleYStart = scrollHandleEl.offsetTop;
|
|
6353
|
+
this.mouseYStart = event.pageY;
|
|
6354
|
+
console.log('mouse down', this.handleYStart, this.mouseYStart);
|
|
6355
|
+
console.log(scrollHandleEl.offsetTop);
|
|
6356
|
+
} else if (event.target.classList.contains('websy-scroll-handle-x')) {
|
|
6357
|
+
this.scrollDragging = true;
|
|
6358
|
+
this.scrollDirection = 'x';
|
|
6359
|
+
|
|
6360
|
+
var _scrollHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
6361
|
+
|
|
6362
|
+
this.handleXStart = _scrollHandleEl.offsetLeft;
|
|
6363
|
+
this.mouseXStart = event.pageX;
|
|
6364
|
+
}
|
|
6365
|
+
}
|
|
6366
|
+
}, {
|
|
6367
|
+
key: "handleMouseMove",
|
|
6368
|
+
value: function handleMouseMove(event) {
|
|
6369
|
+
// event.preventDefault()
|
|
6370
|
+
if (this.scrollDragging === true) {
|
|
6371
|
+
if (this.scrollDirection === 'y') {
|
|
6372
|
+
var diff = event.pageY - this.mouseYStart;
|
|
6373
|
+
this.scrollY(diff);
|
|
6374
|
+
} else if (this.scrollDirection === 'x') {
|
|
6375
|
+
var _diff = event.pageX - this.mouseXStart;
|
|
6376
|
+
|
|
6377
|
+
this.scrollX(_diff);
|
|
6378
|
+
}
|
|
6379
|
+
}
|
|
6380
|
+
}
|
|
6381
|
+
}, {
|
|
6382
|
+
key: "handleMouseUp",
|
|
6383
|
+
value: function handleMouseUp(event) {
|
|
6384
|
+
this.scrollDragging = false;
|
|
6385
|
+
this.cellDragging = false;
|
|
6386
|
+
this.handleYStart = null;
|
|
6387
|
+
this.mouseYStart = null;
|
|
6388
|
+
this.handleXStart = null;
|
|
6389
|
+
this.mouseXStart = null;
|
|
6390
|
+
}
|
|
6391
|
+
}, {
|
|
6392
|
+
key: "handleScrollWheel",
|
|
6393
|
+
value: function handleScrollWheel(event) {
|
|
6394
|
+
event.preventDefault();
|
|
6395
|
+
console.log('scrollwheel', event);
|
|
6396
|
+
|
|
6397
|
+
if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
|
|
6398
|
+
this.scrollX(Math.max(-5, Math.min(5, event.deltaX)));
|
|
6399
|
+
} else {
|
|
6400
|
+
this.scrollY(Math.max(-5, Math.min(5, event.deltaY)));
|
|
6401
|
+
}
|
|
6402
|
+
}
|
|
6403
|
+
}, {
|
|
6404
|
+
key: "hideError",
|
|
6405
|
+
value: function hideError() {
|
|
6406
|
+
var el = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
6407
|
+
|
|
6408
|
+
if (el) {
|
|
6409
|
+
el.classList.remove('has-error');
|
|
6410
|
+
}
|
|
6411
|
+
|
|
6412
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_tableInner"));
|
|
6413
|
+
tableEl.classList.remove('hidden');
|
|
6414
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
6415
|
+
|
|
6416
|
+
if (containerEl) {
|
|
6417
|
+
containerEl.classList.remove('active');
|
|
6418
|
+
}
|
|
6419
|
+
}
|
|
6420
|
+
}, {
|
|
6421
|
+
key: "hideLoading",
|
|
6422
|
+
value: function hideLoading() {
|
|
6423
|
+
this.loadingDialog.hide();
|
|
6424
|
+
}
|
|
6425
|
+
}, {
|
|
6426
|
+
key: "render",
|
|
6427
|
+
value: function render(data) {
|
|
6428
|
+
var calcSizes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
6429
|
+
|
|
6430
|
+
if (!this.options.columns) {
|
|
6431
|
+
console.log("No columns provided for table with ID ".concat(this.elementId));
|
|
6432
|
+
return;
|
|
6433
|
+
}
|
|
6434
|
+
|
|
6435
|
+
if (this.options.columns.length === 0) {
|
|
6436
|
+
console.log("No columns provided for table with ID ".concat(this.elementId));
|
|
6437
|
+
return;
|
|
6438
|
+
} // this.data = []
|
|
6439
|
+
// Adjust the sizing of the header/body/footer
|
|
6440
|
+
|
|
6441
|
+
|
|
6442
|
+
if (calcSizes === true) {
|
|
6443
|
+
var sample = this.createSample(data);
|
|
6444
|
+
this.calculateSizes(sample, data.length, (data[0] || []).length, 0);
|
|
6445
|
+
}
|
|
6446
|
+
|
|
6447
|
+
console.log(this.options.columns);
|
|
6448
|
+
var tableInnerEl = document.getElementById("".concat(this.elementId, "_tableInner"));
|
|
6449
|
+
|
|
6450
|
+
if (tableInnerEl) {
|
|
6451
|
+
tableInnerEl.style.width = "".concat(this.sizes.totalWidth, "px");
|
|
6452
|
+
}
|
|
6453
|
+
|
|
6454
|
+
this.renderColumnHeaders();
|
|
6455
|
+
this.renderTotals();
|
|
6456
|
+
|
|
6457
|
+
if (data) {
|
|
6458
|
+
this.appendRows(data);
|
|
6459
|
+
}
|
|
6460
|
+
|
|
6461
|
+
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody")); // bodyEl.innerHTML = this.buildBodyHtml(data, true)
|
|
6462
|
+
|
|
6463
|
+
bodyEl.style.height = "calc(100% - ".concat(this.sizes.header.height, "px - ").concat(this.sizes.total.height, "px)");
|
|
6464
|
+
|
|
6465
|
+
if (this.options.virtualScroll === true) {
|
|
6466
|
+
// set the scroll element positions
|
|
6467
|
+
if (this.vScrollRequired === true) {
|
|
6468
|
+
var vScrollEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
|
|
6469
|
+
var vHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
6470
|
+
vScrollEl.style.top = "".concat(this.sizes.header.height + this.sizes.total.height, "px");
|
|
6471
|
+
vScrollEl.style.height = "".concat(this.sizes.bodyHeight, "px");
|
|
6472
|
+
vHandleEl.style.height = Math.max(this.options.minHandleSize, this.sizes.bodyHeight * (this.sizes.rowsToRenderPrecise / this.totalRowCount)) + 'px';
|
|
6473
|
+
}
|
|
6474
|
+
|
|
6475
|
+
if (this.hScrollRequired === true) {
|
|
6476
|
+
var hScrollEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
|
|
6477
|
+
var hHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
6478
|
+
hScrollEl.style.left = "".concat(this.sizes.table.width - this.sizes.scrollableWidth, "px");
|
|
6479
|
+
hScrollEl.style.width = "".concat(this.sizes.scrollableWidth - 20, "px");
|
|
6480
|
+
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalWidth)) + 'px';
|
|
6481
|
+
}
|
|
6482
|
+
}
|
|
6483
|
+
}
|
|
6484
|
+
}, {
|
|
6485
|
+
key: "renderColumnHeaders",
|
|
6486
|
+
value: function renderColumnHeaders() {
|
|
6487
|
+
var headEl = document.getElementById("".concat(this.elementId, "_tableHeader"));
|
|
6488
|
+
|
|
6489
|
+
if (headEl) {
|
|
6490
|
+
headEl.innerHTML = this.buildHeaderHtml(true);
|
|
6491
|
+
}
|
|
6492
|
+
}
|
|
6493
|
+
}, {
|
|
6494
|
+
key: "renderTotals",
|
|
6495
|
+
value: function renderTotals() {
|
|
6496
|
+
var headEl = document.getElementById("".concat(this.elementId, "_tableHeader"));
|
|
6497
|
+
var totalHtml = this.buildTotalHtml(true);
|
|
6498
|
+
|
|
6499
|
+
if (this.options.showTotalsAbove === true) {
|
|
6500
|
+
headEl.innerHTML += totalHtml;
|
|
6501
|
+
} else {
|
|
6502
|
+
var footerEl = document.getElementById("".concat(this.elementId, "_tableFooter"));
|
|
6503
|
+
|
|
6504
|
+
if (footerEl) {
|
|
6505
|
+
footerEl.innerHTML = totalHtml;
|
|
6506
|
+
}
|
|
6507
|
+
}
|
|
6508
|
+
}
|
|
6509
|
+
}, {
|
|
6510
|
+
key: "resize",
|
|
6511
|
+
value: function resize() {}
|
|
6512
|
+
}, {
|
|
6513
|
+
key: "showError",
|
|
6514
|
+
value: function showError(options) {
|
|
6515
|
+
var el = document.getElementById("".concat(this.elementId, "_tableContainer"));
|
|
6516
|
+
|
|
6517
|
+
if (el) {
|
|
6518
|
+
el.classList.add('has-error');
|
|
6519
|
+
}
|
|
6520
|
+
|
|
6521
|
+
var tableEl = document.getElementById("".concat(this.elementId, "_tableInner"));
|
|
6522
|
+
tableEl.classList.add('hidden');
|
|
6523
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
6524
|
+
|
|
6525
|
+
if (containerEl) {
|
|
6526
|
+
containerEl.classList.add('active');
|
|
6527
|
+
}
|
|
6528
|
+
|
|
6529
|
+
if (options.title) {
|
|
6530
|
+
var titleEl = document.getElementById("".concat(this.elementId, "_errorTitle"));
|
|
6531
|
+
|
|
6532
|
+
if (titleEl) {
|
|
6533
|
+
titleEl.innerHTML = options.title;
|
|
6534
|
+
}
|
|
6535
|
+
}
|
|
6536
|
+
|
|
6537
|
+
if (options.message) {
|
|
6538
|
+
var messageEl = document.getElementById("".concat(this.elementId, "_errorMessage"));
|
|
6539
|
+
|
|
6540
|
+
if (messageEl) {
|
|
6541
|
+
messageEl.innerHTML = options.message;
|
|
6542
|
+
}
|
|
6543
|
+
}
|
|
6544
|
+
}
|
|
6545
|
+
}, {
|
|
6546
|
+
key: "scrollX",
|
|
6547
|
+
value: function scrollX(diff) {
|
|
6548
|
+
var scrollContainerEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
|
|
6549
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
6550
|
+
var handlePos;
|
|
6551
|
+
|
|
6552
|
+
if (typeof this.handleXStart !== 'undefined' && this.handleXStart !== null) {
|
|
6553
|
+
handlePos = this.handleXStart + diff;
|
|
6554
|
+
} else {
|
|
6555
|
+
handlePos = scrollHandleEl.offsetLeft + diff;
|
|
6556
|
+
}
|
|
6557
|
+
|
|
6558
|
+
var scrollableSpace = scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width;
|
|
6559
|
+
console.log('dragging x', diff, scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width);
|
|
6560
|
+
scrollHandleEl.style.left = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px';
|
|
6561
|
+
|
|
6562
|
+
if (this.options.onScroll) {
|
|
6563
|
+
var actualLeft = (this.sizes.totalWidth - this.sizes.scrollableWidth) * (Math.min(scrollableSpace, Math.max(0, handlePos)) / scrollableSpace);
|
|
6564
|
+
var cumulativeWidth = 0;
|
|
6565
|
+
this.startCol = 0;
|
|
6566
|
+
this.endCol = 0;
|
|
6567
|
+
|
|
6568
|
+
for (var i = 0; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
6569
|
+
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth;
|
|
6570
|
+
console.log(actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth);
|
|
6571
|
+
|
|
6572
|
+
if (actualLeft < cumulativeWidth) {
|
|
6573
|
+
this.startCol = i;
|
|
6574
|
+
break;
|
|
6575
|
+
}
|
|
6576
|
+
}
|
|
6577
|
+
|
|
6578
|
+
cumulativeWidth = 0;
|
|
6579
|
+
|
|
6580
|
+
for (var _i10 = this.startCol; _i10 < this.options.allColumns[this.options.allColumns.length - 1].length; _i10++) {
|
|
6581
|
+
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][_i10].actualWidth;
|
|
6582
|
+
|
|
6583
|
+
if (cumulativeWidth < this.sizes.scrollableWidth) {
|
|
6584
|
+
this.endCol = _i10;
|
|
6585
|
+
}
|
|
6586
|
+
}
|
|
6587
|
+
|
|
6588
|
+
if (this.endCol < this.options.allColumns[this.options.allColumns.length - 1].length - 1) {
|
|
6589
|
+
this.endCol += 1;
|
|
6590
|
+
}
|
|
6591
|
+
|
|
6592
|
+
if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.totalWidth) {
|
|
6593
|
+
this.startCol += 1;
|
|
6594
|
+
}
|
|
6595
|
+
|
|
6596
|
+
this.endCol = Math.max(this.startCol, this.endCol);
|
|
6597
|
+
this.options.onScroll('y', this.startRow, this.endRow, this.startCol, this.endCol);
|
|
6598
|
+
}
|
|
6599
|
+
}
|
|
6600
|
+
}, {
|
|
6601
|
+
key: "scrollY",
|
|
6602
|
+
value: function scrollY(diff) {
|
|
6603
|
+
var scrollContainerEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
|
|
6604
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
6605
|
+
var handlePos;
|
|
6606
|
+
|
|
6607
|
+
if (typeof this.handleYStart !== 'undefined' && this.handleYStart !== null) {
|
|
6608
|
+
handlePos = this.handleYStart + diff;
|
|
6609
|
+
} else {
|
|
6610
|
+
console.log('appending not resetting');
|
|
6611
|
+
handlePos = scrollHandleEl.offsetTop + diff;
|
|
6612
|
+
}
|
|
6613
|
+
|
|
6614
|
+
var scrollableSpace = scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height;
|
|
6615
|
+
console.log('dragging y', diff, scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height);
|
|
6616
|
+
scrollHandleEl.style.top = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px';
|
|
6617
|
+
|
|
6618
|
+
if (this.options.onScroll) {
|
|
6619
|
+
this.startRow = Math.min(this.totalRowCount - this.sizes.rowsToRender, Math.max(0, Math.round((this.totalRowCount - this.sizes.rowsToRender) * (handlePos / scrollableSpace))));
|
|
6620
|
+
this.endRow = this.startRow + this.sizes.rowsToRender;
|
|
6621
|
+
|
|
6622
|
+
if (this.endRow === this.totalRowCount) {
|
|
6623
|
+
this.startRow += 1;
|
|
6624
|
+
}
|
|
6625
|
+
|
|
6626
|
+
this.options.onScroll('y', this.startRow, this.endRow, this.startCol, this.endCol);
|
|
6627
|
+
}
|
|
6628
|
+
}
|
|
6629
|
+
}, {
|
|
6630
|
+
key: "showLoading",
|
|
6631
|
+
value: function showLoading(options) {
|
|
6632
|
+
this.loadingDialog.show(options);
|
|
6633
|
+
}
|
|
6634
|
+
}, {
|
|
6635
|
+
key: "columns",
|
|
6636
|
+
set: function set(columns) {
|
|
6637
|
+
this.options.columns = columns;
|
|
6638
|
+
this.renderColumnHeaders();
|
|
6639
|
+
}
|
|
6640
|
+
}, {
|
|
6641
|
+
key: "totals",
|
|
6642
|
+
set: function set(totals) {
|
|
6643
|
+
this.options.totals = totals;
|
|
6644
|
+
this.renderTotals();
|
|
6645
|
+
}
|
|
6646
|
+
}]);
|
|
6647
|
+
|
|
6648
|
+
return WebsyTable3;
|
|
6649
|
+
}();
|
|
5676
6650
|
/* global d3 include WebsyDesigns */
|
|
5677
6651
|
|
|
5678
6652
|
|
|
5679
6653
|
var WebsyChart = /*#__PURE__*/function () {
|
|
5680
6654
|
function WebsyChart(elementId, options) {
|
|
5681
|
-
var
|
|
6655
|
+
var _this41 = this;
|
|
5682
6656
|
|
|
5683
6657
|
_classCallCheck(this, WebsyChart);
|
|
5684
6658
|
|
|
@@ -5727,22 +6701,22 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5727
6701
|
this.invertOverride = function (input, input2) {
|
|
5728
6702
|
var xAxis = 'bottomAxis';
|
|
5729
6703
|
|
|
5730
|
-
if (
|
|
6704
|
+
if (_this41.options.orientation === 'horizontal') {
|
|
5731
6705
|
xAxis = 'leftAxis';
|
|
5732
6706
|
}
|
|
5733
6707
|
|
|
5734
|
-
var width =
|
|
6708
|
+
var width = _this41[xAxis].step();
|
|
5735
6709
|
|
|
5736
6710
|
var output;
|
|
5737
6711
|
|
|
5738
|
-
var domain = _toConsumableArray(
|
|
6712
|
+
var domain = _toConsumableArray(_this41[xAxis].domain());
|
|
5739
6713
|
|
|
5740
|
-
if (
|
|
6714
|
+
if (_this41.options.orientation === 'horizontal') {
|
|
5741
6715
|
domain = domain.reverse();
|
|
5742
6716
|
}
|
|
5743
6717
|
|
|
5744
6718
|
for (var j = 0; j < domain.length; j++) {
|
|
5745
|
-
var breakA =
|
|
6719
|
+
var breakA = _this41[xAxis](domain[j]) - width / 2;
|
|
5746
6720
|
var breakB = breakA + width;
|
|
5747
6721
|
|
|
5748
6722
|
if (input > breakA && input <= breakB) {
|
|
@@ -5842,10 +6816,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5842
6816
|
}, {
|
|
5843
6817
|
key: "handleEventMouseMove",
|
|
5844
6818
|
value: function handleEventMouseMove(event, d) {
|
|
5845
|
-
var
|
|
6819
|
+
var _this42 = this;
|
|
5846
6820
|
|
|
5847
6821
|
var bisectDate = d3.bisector(function (d) {
|
|
5848
|
-
return
|
|
6822
|
+
return _this42.parseX(d.x.value);
|
|
5849
6823
|
}).left;
|
|
5850
6824
|
|
|
5851
6825
|
if (this.options.showTrackingLine === true && d3.pointer(event)) {
|
|
@@ -5884,8 +6858,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5884
6858
|
}
|
|
5885
6859
|
|
|
5886
6860
|
this.options.data.series.forEach(function (s) {
|
|
5887
|
-
if (
|
|
5888
|
-
xPoint =
|
|
6861
|
+
if (_this42.options.data[xData].scale !== 'Time') {
|
|
6862
|
+
xPoint = _this42[xAxis](_this42.parseX(xLabel));
|
|
5889
6863
|
s.data.forEach(function (d) {
|
|
5890
6864
|
if (d.x.value === xLabel) {
|
|
5891
6865
|
if (!tooltipTitle) {
|
|
@@ -5904,13 +6878,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5904
6878
|
var pointA = s.data[index - 1];
|
|
5905
6879
|
var pointB = s.data[index];
|
|
5906
6880
|
|
|
5907
|
-
if (
|
|
6881
|
+
if (_this42.options.orientation === 'horizontal') {
|
|
5908
6882
|
pointA = _toConsumableArray(s.data).reverse()[index - 1];
|
|
5909
6883
|
pointB = _toConsumableArray(s.data).reverse()[index];
|
|
5910
6884
|
}
|
|
5911
6885
|
|
|
5912
6886
|
if (pointA && !pointB) {
|
|
5913
|
-
xPoint =
|
|
6887
|
+
xPoint = _this42[xAxis](_this42.parseX(pointA.x.value));
|
|
5914
6888
|
tooltipTitle = pointA.x.value;
|
|
5915
6889
|
|
|
5916
6890
|
if (!pointA.y.color) {
|
|
@@ -5920,12 +6894,12 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5920
6894
|
tooltipData.push(pointA.y);
|
|
5921
6895
|
|
|
5922
6896
|
if (typeof pointA.x.value.getTime !== 'undefined') {
|
|
5923
|
-
tooltipTitle = d3.timeFormat(
|
|
6897
|
+
tooltipTitle = d3.timeFormat(_this42.options.dateFormat || _this42.options.calculatedTimeFormatPattern)(pointA.x.value);
|
|
5924
6898
|
}
|
|
5925
6899
|
}
|
|
5926
6900
|
|
|
5927
6901
|
if (pointB && !pointA) {
|
|
5928
|
-
xPoint =
|
|
6902
|
+
xPoint = _this42[xAxis](_this42.parseX(pointB.x.value));
|
|
5929
6903
|
tooltipTitle = pointB.x.value;
|
|
5930
6904
|
|
|
5931
6905
|
if (!pointB.y.color) {
|
|
@@ -5935,14 +6909,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5935
6909
|
tooltipData.push(pointB.y);
|
|
5936
6910
|
|
|
5937
6911
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
5938
|
-
tooltipTitle = d3.timeFormat(
|
|
6912
|
+
tooltipTitle = d3.timeFormat(_this42.options.dateFormat || _this42.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
5939
6913
|
}
|
|
5940
6914
|
}
|
|
5941
6915
|
|
|
5942
6916
|
if (pointA && pointB) {
|
|
5943
|
-
var d0 =
|
|
6917
|
+
var d0 = _this42[xAxis](_this42.parseX(pointA.x.value));
|
|
5944
6918
|
|
|
5945
|
-
var d1 =
|
|
6919
|
+
var d1 = _this42[xAxis](_this42.parseX(pointB.x.value));
|
|
5946
6920
|
|
|
5947
6921
|
var mid = Math.abs(d0 - d1) / 2;
|
|
5948
6922
|
|
|
@@ -5951,7 +6925,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5951
6925
|
tooltipTitle = pointB.x.value;
|
|
5952
6926
|
|
|
5953
6927
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
5954
|
-
tooltipTitle = d3.timeFormat(
|
|
6928
|
+
tooltipTitle = d3.timeFormat(_this42.options.dateFormat || _this42.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
5955
6929
|
}
|
|
5956
6930
|
|
|
5957
6931
|
if (!pointB.y.color) {
|
|
@@ -5964,7 +6938,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
5964
6938
|
tooltipTitle = pointA.x.value;
|
|
5965
6939
|
|
|
5966
6940
|
if (typeof pointB.x.value.getTime !== 'undefined') {
|
|
5967
|
-
tooltipTitle = d3.timeFormat(
|
|
6941
|
+
tooltipTitle = d3.timeFormat(_this42.options.dateFormat || _this42.options.calculatedTimeFormatPattern)(pointB.x.value);
|
|
5968
6942
|
}
|
|
5969
6943
|
|
|
5970
6944
|
if (!pointA.y.color) {
|
|
@@ -6069,7 +7043,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6069
7043
|
}, {
|
|
6070
7044
|
key: "render",
|
|
6071
7045
|
value: function render(options) {
|
|
6072
|
-
var
|
|
7046
|
+
var _this43 = this;
|
|
6073
7047
|
|
|
6074
7048
|
/* global d3 options WebsyUtils */
|
|
6075
7049
|
if (typeof options !== 'undefined') {
|
|
@@ -6138,7 +7112,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6138
7112
|
var legendData = this.options.data.series.map(function (s, i) {
|
|
6139
7113
|
return {
|
|
6140
7114
|
value: s.label || s.key,
|
|
6141
|
-
color: s.color ||
|
|
7115
|
+
color: s.color || _this43.options.colors[i % _this43.options.colors.length]
|
|
6142
7116
|
};
|
|
6143
7117
|
});
|
|
6144
7118
|
|
|
@@ -6390,7 +7364,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6390
7364
|
|
|
6391
7365
|
if (this.options.data.bottom.formatter) {
|
|
6392
7366
|
bAxisFunc.tickFormat(function (d) {
|
|
6393
|
-
return
|
|
7367
|
+
return _this43.options.data.bottom.formatter(d);
|
|
6394
7368
|
});
|
|
6395
7369
|
}
|
|
6396
7370
|
|
|
@@ -6416,8 +7390,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6416
7390
|
|
|
6417
7391
|
if (this.options.margin.axisLeft > 0) {
|
|
6418
7392
|
this.leftAxisLayer.call(d3.axisLeft(this.leftAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
6419
|
-
if (
|
|
6420
|
-
d =
|
|
7393
|
+
if (_this43.options.data.left.formatter) {
|
|
7394
|
+
d = _this43.options.data.left.formatter(d);
|
|
6421
7395
|
}
|
|
6422
7396
|
|
|
6423
7397
|
return d;
|
|
@@ -6454,8 +7428,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6454
7428
|
|
|
6455
7429
|
if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
|
|
6456
7430
|
this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
|
|
6457
|
-
if (
|
|
6458
|
-
d =
|
|
7431
|
+
if (_this43.options.data.right.formatter) {
|
|
7432
|
+
d = _this43.options.data.right.formatter(d);
|
|
6459
7433
|
}
|
|
6460
7434
|
|
|
6461
7435
|
return d;
|
|
@@ -6481,16 +7455,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6481
7455
|
|
|
6482
7456
|
this.options.data.series.forEach(function (series, index) {
|
|
6483
7457
|
if (!series.key) {
|
|
6484
|
-
series.key =
|
|
7458
|
+
series.key = _this43.createIdentity();
|
|
6485
7459
|
}
|
|
6486
7460
|
|
|
6487
7461
|
if (!series.color) {
|
|
6488
|
-
series.color =
|
|
7462
|
+
series.color = _this43.options.colors[index % _this43.options.colors.length];
|
|
6489
7463
|
}
|
|
6490
7464
|
|
|
6491
|
-
|
|
7465
|
+
_this43["render".concat(series.type || 'bar')](series, index);
|
|
6492
7466
|
|
|
6493
|
-
|
|
7467
|
+
_this43.renderLabels(series, index);
|
|
6494
7468
|
});
|
|
6495
7469
|
}
|
|
6496
7470
|
}
|
|
@@ -6498,17 +7472,17 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6498
7472
|
}, {
|
|
6499
7473
|
key: "renderarea",
|
|
6500
7474
|
value: function renderarea(series, index) {
|
|
6501
|
-
var
|
|
7475
|
+
var _this44 = this;
|
|
6502
7476
|
|
|
6503
7477
|
/* global d3 series index */
|
|
6504
7478
|
var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
|
|
6505
7479
|
return d3.area().x(function (d) {
|
|
6506
|
-
return
|
|
7480
|
+
return _this44[xAxis](_this44.parseX(d.x.value));
|
|
6507
7481
|
}).y0(function (d) {
|
|
6508
|
-
return
|
|
7482
|
+
return _this44[yAxis](0);
|
|
6509
7483
|
}).y1(function (d) {
|
|
6510
|
-
return
|
|
6511
|
-
}).curve(d3[curveStyle ||
|
|
7484
|
+
return _this44[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
7485
|
+
}).curve(d3[curveStyle || _this44.options.curveStyle]);
|
|
6512
7486
|
};
|
|
6513
7487
|
|
|
6514
7488
|
var xAxis = 'bottomAxis';
|
|
@@ -6611,15 +7585,21 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6611
7585
|
}
|
|
6612
7586
|
|
|
6613
7587
|
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',
|
|
7588
|
+
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) {
|
|
7589
|
+
return d.color || series.color;
|
|
7590
|
+
});
|
|
6615
7591
|
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',
|
|
7592
|
+
.attr('fill', function (d) {
|
|
7593
|
+
return d.color || series.color;
|
|
7594
|
+
}).attr('class', function (d) {
|
|
6617
7595
|
return "bar bar_".concat(series.key);
|
|
6618
7596
|
});
|
|
6619
7597
|
}
|
|
6620
7598
|
}, {
|
|
6621
7599
|
key: "renderLabels",
|
|
6622
7600
|
value: function renderLabels(series, index) {
|
|
7601
|
+
var _this45 = this;
|
|
7602
|
+
|
|
6623
7603
|
/* global series index d3 WebsyDesigns */
|
|
6624
7604
|
var xAxis = 'bottomAxis';
|
|
6625
7605
|
var yAxis = 'leftAxis';
|
|
@@ -6636,10 +7616,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6636
7616
|
// We currently only support 'Auto'
|
|
6637
7617
|
var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
|
|
6638
7618
|
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',
|
|
7619
|
+
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) {
|
|
7620
|
+
return _this45.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.color || series.color);
|
|
7621
|
+
}).transition(this.transition).text(function (d) {
|
|
6640
7622
|
return d.y.label || d.y.value;
|
|
6641
7623
|
});
|
|
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',
|
|
7624
|
+
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) {
|
|
7625
|
+
return _this45.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.color || series.color);
|
|
7626
|
+
}).text(function (d) {
|
|
6643
7627
|
return d.y.label || d.y.value;
|
|
6644
7628
|
}).each(function (d, i) {
|
|
6645
7629
|
if (that.options.orientation === 'horizontal') {
|
|
@@ -6683,15 +7667,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6683
7667
|
}, {
|
|
6684
7668
|
key: "renderline",
|
|
6685
7669
|
value: function renderline(series, index) {
|
|
6686
|
-
var
|
|
7670
|
+
var _this46 = this;
|
|
6687
7671
|
|
|
6688
7672
|
/* global series index d3 */
|
|
6689
7673
|
var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
|
|
6690
7674
|
return d3.line().x(function (d) {
|
|
6691
|
-
return
|
|
7675
|
+
return _this46[xAxis](_this46.parseX(d.x.value));
|
|
6692
7676
|
}).y(function (d) {
|
|
6693
|
-
return
|
|
6694
|
-
}).curve(d3[curveStyle ||
|
|
7677
|
+
return _this46[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
7678
|
+
}).curve(d3[curveStyle || _this46.options.curveStyle]);
|
|
6695
7679
|
};
|
|
6696
7680
|
|
|
6697
7681
|
var xAxis = 'bottomAxis';
|
|
@@ -6729,14 +7713,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6729
7713
|
}, {
|
|
6730
7714
|
key: "rendersymbol",
|
|
6731
7715
|
value: function rendersymbol(series, index) {
|
|
6732
|
-
var
|
|
7716
|
+
var _this47 = this;
|
|
6733
7717
|
|
|
6734
7718
|
/* global d3 series index series.key */
|
|
6735
7719
|
var drawSymbol = function drawSymbol(size) {
|
|
6736
7720
|
return d3.symbol() // .type(d => {
|
|
6737
7721
|
// return d3.symbols[0]
|
|
6738
7722
|
// })
|
|
6739
|
-
.size(size ||
|
|
7723
|
+
.size(size || _this47.options.symbolSize);
|
|
6740
7724
|
};
|
|
6741
7725
|
|
|
6742
7726
|
var xAxis = 'bottomAxis';
|
|
@@ -6754,7 +7738,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6754
7738
|
symbols.attr('d', function (d) {
|
|
6755
7739
|
return drawSymbol(d.y.size || series.symbolSize)(d);
|
|
6756
7740
|
}).transition(this.transition).attr('fill', 'white').attr('stroke', series.color).attr('transform', function (d) {
|
|
6757
|
-
return "translate(".concat(
|
|
7741
|
+
return "translate(".concat(_this47[xAxis](_this47.parseX(d.x.value)), ", ").concat(_this47[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
6758
7742
|
}); // Enter
|
|
6759
7743
|
|
|
6760
7744
|
symbols.enter().append('path').attr('d', function (d) {
|
|
@@ -6763,7 +7747,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
6763
7747
|
.attr('fill', 'white').attr('stroke', series.color).attr('class', function (d) {
|
|
6764
7748
|
return "symbol symbol_".concat(series.key);
|
|
6765
7749
|
}).attr('transform', function (d) {
|
|
6766
|
-
return "translate(".concat(
|
|
7750
|
+
return "translate(".concat(_this47[xAxis](_this47.parseX(d.x.value)), ", ").concat(_this47[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
6767
7751
|
});
|
|
6768
7752
|
}
|
|
6769
7753
|
}, {
|
|
@@ -6918,7 +7902,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
6918
7902
|
}, {
|
|
6919
7903
|
key: "resize",
|
|
6920
7904
|
value: function resize() {
|
|
6921
|
-
var
|
|
7905
|
+
var _this48 = this;
|
|
6922
7906
|
|
|
6923
7907
|
var el = document.getElementById(this.elementId);
|
|
6924
7908
|
|
|
@@ -6931,7 +7915,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
6931
7915
|
// }
|
|
6932
7916
|
var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
|
|
6933
7917
|
html += this._data.map(function (d, i) {
|
|
6934
|
-
return
|
|
7918
|
+
return _this48.getLegendItemHTML(d);
|
|
6935
7919
|
}).join('');
|
|
6936
7920
|
html += "\n <div>\n ";
|
|
6937
7921
|
el.innerHTML = html;
|
|
@@ -7103,7 +8087,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
7103
8087
|
}, {
|
|
7104
8088
|
key: "render",
|
|
7105
8089
|
value: function render() {
|
|
7106
|
-
var
|
|
8090
|
+
var _this49 = this;
|
|
7107
8091
|
|
|
7108
8092
|
var mapEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
7109
8093
|
var legendEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
@@ -7112,7 +8096,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
7112
8096
|
var legendData = this.options.data.polygons.map(function (s, i) {
|
|
7113
8097
|
return {
|
|
7114
8098
|
value: s.label || s.key,
|
|
7115
|
-
color: s.color ||
|
|
8099
|
+
color: s.color || _this49.options.colors[i % _this49.options.colors.length]
|
|
7116
8100
|
};
|
|
7117
8101
|
});
|
|
7118
8102
|
var longestValue = legendData.map(function (s) {
|
|
@@ -7176,7 +8160,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
7176
8160
|
|
|
7177
8161
|
if (this.polygons) {
|
|
7178
8162
|
this.polygons.forEach(function (p) {
|
|
7179
|
-
return
|
|
8163
|
+
return _this49.map.removeLayer(p);
|
|
7180
8164
|
});
|
|
7181
8165
|
}
|
|
7182
8166
|
|
|
@@ -7234,18 +8218,18 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
7234
8218
|
}
|
|
7235
8219
|
|
|
7236
8220
|
if (!p.options.color) {
|
|
7237
|
-
p.options.color =
|
|
8221
|
+
p.options.color = _this49.options.colors[i % _this49.options.colors.length];
|
|
7238
8222
|
}
|
|
7239
8223
|
|
|
7240
8224
|
var pol = L.polygon(p.data.map(function (c) {
|
|
7241
8225
|
return c.map(function (d) {
|
|
7242
8226
|
return [d.Latitude, d.Longitude];
|
|
7243
8227
|
});
|
|
7244
|
-
}), p.options).addTo(
|
|
8228
|
+
}), p.options).addTo(_this49.map);
|
|
7245
8229
|
|
|
7246
|
-
|
|
8230
|
+
_this49.polygons.push(pol);
|
|
7247
8231
|
|
|
7248
|
-
|
|
8232
|
+
_this49.map.fitBounds(pol.getBounds());
|
|
7249
8233
|
});
|
|
7250
8234
|
} // if (this.data.markers.length > 0) {
|
|
7251
8235
|
// el.classList.remove('hidden')
|
|
@@ -7378,8 +8362,10 @@ var WebsyDesigns = {
|
|
|
7378
8362
|
Router: WebsyRouter,
|
|
7379
8363
|
WebsyTable: WebsyTable,
|
|
7380
8364
|
WebsyTable2: WebsyTable2,
|
|
8365
|
+
WebsyTable3: WebsyTable3,
|
|
7381
8366
|
Table: WebsyTable,
|
|
7382
8367
|
Table2: WebsyTable2,
|
|
8368
|
+
Table3: WebsyTable3,
|
|
7383
8369
|
WebsyChart: WebsyChart,
|
|
7384
8370
|
Chart: WebsyChart,
|
|
7385
8371
|
WebsyChartTooltip: WebsyChartTooltip,
|
|
@@ -7406,7 +8392,9 @@ var WebsyDesigns = {
|
|
|
7406
8392
|
WebsySignup: WebsySignup,
|
|
7407
8393
|
Signup: WebsySignup,
|
|
7408
8394
|
ResponsiveText: ResponsiveText,
|
|
7409
|
-
WebsyResponsiveText: ResponsiveText
|
|
8395
|
+
WebsyResponsiveText: ResponsiveText,
|
|
8396
|
+
WebsyDragDrop: WebsyDragDrop,
|
|
8397
|
+
DragDrop: WebsyDragDrop
|
|
7410
8398
|
};
|
|
7411
8399
|
WebsyDesigns.service = new WebsyDesigns.APIService('');
|
|
7412
8400
|
var GlobalPubSub = new WebsyPubSub('empty', {});
|