@websy/websy-designs 1.2.33 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/helpers/v1/pgHelper.js +13 -5
- package/dist/server/routes/v1/api.js +11 -1
- package/dist/websy-designs-es6.debug.js +124 -57
- package/dist/websy-designs-es6.js +324 -248
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +177 -58
- package/dist/websy-designs.js +271 -139
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -213,12 +213,20 @@ class PGHelper {
|
|
|
213
213
|
let list = input.split(';').map(d => {
|
|
214
214
|
let parts = d.split(':')
|
|
215
215
|
if (parts.length === 2) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
let partValues = parts[1]
|
|
217
|
+
partValues = partValues.split('|')
|
|
218
|
+
if (partValues.length === 1) {
|
|
219
|
+
if (parts[1].indexOf('%') !== -1) {
|
|
220
|
+
return `${entity ? entity + '.' : ''}${parts[0]} LIKE '${parts[1]}'`
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
return `${entity ? entity + '.' : ''}${parts[0]} = '${parts[1]}'`
|
|
224
|
+
}
|
|
225
|
+
}
|
|
219
226
|
else {
|
|
220
|
-
|
|
221
|
-
|
|
227
|
+
console.log(`${entity ? entity + '.' : ''}${parts[0]} IN ('${partValues.join('\',\'')}')`)
|
|
228
|
+
return `${entity ? entity + '.' : ''}${parts[0]} IN ('${partValues.join('\',\'')}')`
|
|
229
|
+
}
|
|
222
230
|
}
|
|
223
231
|
else {
|
|
224
232
|
parts = d.split('!')
|
|
@@ -31,7 +31,17 @@ function APIRoutes (dbHelper) {
|
|
|
31
31
|
// console.log(`lang is ${lang}`)
|
|
32
32
|
const sql = dbHelper.buildSelect(req.params.entity, req.query, req.query.columns, lang)
|
|
33
33
|
dbHelper.execute(sql).then(response => {
|
|
34
|
-
|
|
34
|
+
if (process.env.RETURN_COUNTS === true || process.env.RETURN_COUNTS === 'true') {
|
|
35
|
+
let countWhere = ''
|
|
36
|
+
const countSql = `SELECT COUNT(*) as total FROM ${req.params.entity} WHERE ${dbHelper.buildWhere(req.query.where, req.params.entity)}`
|
|
37
|
+
dbHelper.execute(countSql).then(countResponse => {
|
|
38
|
+
response.totalCount = countResponse.rows[0].total
|
|
39
|
+
res.json(translate(response))
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
res.json(translate(response))
|
|
44
|
+
}
|
|
35
45
|
}, err => res.json(err))
|
|
36
46
|
})
|
|
37
47
|
router.post('/:entity', (req, res) => {
|
|
@@ -425,6 +425,7 @@ class WebsyDatePicker {
|
|
|
425
425
|
if (typeof d === 'number') {
|
|
426
426
|
d = new Date(d)
|
|
427
427
|
}
|
|
428
|
+
// d.setTime(d.getTime() + d.getTimezoneOffset() * 60000)
|
|
428
429
|
return new Date(d.setHours(0, 0, 0, 0))
|
|
429
430
|
}
|
|
430
431
|
handleClick (event) {
|
|
@@ -443,11 +444,7 @@ class WebsyDatePicker {
|
|
|
443
444
|
this.updateRange(index)
|
|
444
445
|
}
|
|
445
446
|
else if (event.target.classList.contains('websy-dp-date')) {
|
|
446
|
-
//
|
|
447
|
-
// return
|
|
448
|
-
// }
|
|
449
|
-
// const timestamp = event.target.id.split('_')[0]
|
|
450
|
-
// this.selectDate(+timestamp)
|
|
447
|
+
//
|
|
451
448
|
}
|
|
452
449
|
else if (event.target.classList.contains('websy-dp-confirm')) {
|
|
453
450
|
this.close(true)
|
|
@@ -476,7 +473,8 @@ class WebsyDatePicker {
|
|
|
476
473
|
handleMouseDown (event) {
|
|
477
474
|
if (this.shiftPressed === true && this.currentselection.length > 0) {
|
|
478
475
|
this.mouseDownId = this.currentselection[this.currentselection.length - 1]
|
|
479
|
-
|
|
476
|
+
let dateId = event.target.getAttribute('data-id')
|
|
477
|
+
this.selectDate(+dateId)
|
|
480
478
|
}
|
|
481
479
|
else {
|
|
482
480
|
this.mouseDown = true
|
|
@@ -489,7 +487,7 @@ class WebsyDatePicker {
|
|
|
489
487
|
this.currentselection = []
|
|
490
488
|
this.customRangeSelected = false
|
|
491
489
|
}
|
|
492
|
-
this.mouseDownId = +event.target.
|
|
490
|
+
this.mouseDownId = +event.target.getAttribute('data-id')
|
|
493
491
|
this.selectDate(this.mouseDownId)
|
|
494
492
|
}
|
|
495
493
|
}
|
|
@@ -500,9 +498,10 @@ class WebsyDatePicker {
|
|
|
500
498
|
if (event.target.classList.contains('websy-disabled-date')) {
|
|
501
499
|
return
|
|
502
500
|
}
|
|
503
|
-
|
|
501
|
+
let dateId = +event.target.getAttribute('data-id')
|
|
502
|
+
if (dateId !== this.mouseDownId) {
|
|
504
503
|
this.dragging = true
|
|
505
|
-
this.selectDate(
|
|
504
|
+
this.selectDate(dateId)
|
|
506
505
|
}
|
|
507
506
|
}
|
|
508
507
|
}
|
|
@@ -550,6 +549,7 @@ class WebsyDatePicker {
|
|
|
550
549
|
let rangeEnd
|
|
551
550
|
if (this.options.mode === 'date') {
|
|
552
551
|
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + (i * this.oneDay)))
|
|
552
|
+
d.setHours(0, 0, 0, 0)
|
|
553
553
|
d = d.getTime()
|
|
554
554
|
rangeStart = this.selectedRangeDates[0].getTime()
|
|
555
555
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
@@ -819,7 +819,7 @@ class WebsyDatePicker {
|
|
|
819
819
|
}
|
|
820
820
|
html += paddedDays.join('')
|
|
821
821
|
}
|
|
822
|
-
html += months[key].map(d => `<li id='${this.elementId}_${d.id}_date' class='websy-dp-date ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.dayOfMonth}</li>`).join('')
|
|
822
|
+
html += months[key].map(d => `<li id='${this.elementId}_${d.id}_date' data-id='${d.id}' class='websy-dp-date ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.dayOfMonth}</li>`).join('')
|
|
823
823
|
html += `
|
|
824
824
|
</ul>
|
|
825
825
|
</div>
|
|
@@ -940,7 +940,7 @@ class WebsyDatePicker {
|
|
|
940
940
|
selectRange (index, confirm = true) {
|
|
941
941
|
if (this.options.ranges[this.options.mode][index]) {
|
|
942
942
|
this.selectedRangeDates = [...this.options.ranges[this.options.mode][index].range]
|
|
943
|
-
this.currentselection =
|
|
943
|
+
this.currentselection = this.options.ranges[this.options.mode][index].range.map(d => d.getTime())
|
|
944
944
|
this.selectedRange = +index
|
|
945
945
|
const el = document.getElementById(`${this.elementId}_header`)
|
|
946
946
|
if (el) {
|
|
@@ -1143,9 +1143,7 @@ class WebsyDragDrop {
|
|
|
1143
1143
|
else {
|
|
1144
1144
|
console.error(`No element found with ID ${this.elementId}`)
|
|
1145
1145
|
}
|
|
1146
|
-
GlobalPubSub.subscribe(this.elementId, 'requestForDDItem', this.handleRequestForItem.bind(this))
|
|
1147
|
-
console.log('constructor dd')
|
|
1148
|
-
console.trace()
|
|
1146
|
+
GlobalPubSub.subscribe(this.elementId, 'requestForDDItem', this.handleRequestForItem.bind(this))
|
|
1149
1147
|
GlobalPubSub.subscribe(this.elementId, 'add', this.addItem.bind(this))
|
|
1150
1148
|
this.render()
|
|
1151
1149
|
}
|
|
@@ -1209,12 +1207,12 @@ class WebsyDragDrop {
|
|
|
1209
1207
|
this.draggedId = event.target.getAttribute('data-id')
|
|
1210
1208
|
event.dataTransfer.effectAllowed = 'move'
|
|
1211
1209
|
event.dataTransfer.setData('application/wd-item', JSON.stringify({el: event.target.id, id: this.elementId, itemId: this.draggedId}))
|
|
1212
|
-
console.log('drag start', event)
|
|
1210
|
+
// console.log('drag start', event)
|
|
1213
1211
|
event.target.style.opacity = 0.5
|
|
1214
1212
|
this.dragging = true
|
|
1215
1213
|
}
|
|
1216
1214
|
handleDragOver (event) {
|
|
1217
|
-
console.log('drag over', event.target.classList)
|
|
1215
|
+
// console.log('drag over', event.target.classList)
|
|
1218
1216
|
if (event.preventDefault) {
|
|
1219
1217
|
event.preventDefault()
|
|
1220
1218
|
}
|
|
@@ -1224,7 +1222,7 @@ class WebsyDragDrop {
|
|
|
1224
1222
|
event.target.classList.add('drag-over')
|
|
1225
1223
|
}
|
|
1226
1224
|
handleDragLeave (event) {
|
|
1227
|
-
console.log('drag leave', event.target.classList)
|
|
1225
|
+
// console.log('drag leave', event.target.classList)
|
|
1228
1226
|
if (!event.target.classList.contains('droppable')) {
|
|
1229
1227
|
return
|
|
1230
1228
|
}
|
|
@@ -1235,8 +1233,8 @@ class WebsyDragDrop {
|
|
|
1235
1233
|
// this.removeExpandedDrop(side, id, droppedItem)
|
|
1236
1234
|
}
|
|
1237
1235
|
handleDrop (event) {
|
|
1238
|
-
console.log('drag drop')
|
|
1239
|
-
console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1236
|
+
// console.log('drag drop')
|
|
1237
|
+
// console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1240
1238
|
const data = JSON.parse(event.dataTransfer.getData('application/wd-item'))
|
|
1241
1239
|
if (event.preventDefault) {
|
|
1242
1240
|
event.preventDefault()
|
|
@@ -1253,7 +1251,7 @@ class WebsyDragDrop {
|
|
|
1253
1251
|
index += 1
|
|
1254
1252
|
}
|
|
1255
1253
|
if (draggedIndex === -1) {
|
|
1256
|
-
console.log('requestForDDItem')
|
|
1254
|
+
// console.log('requestForDDItem')
|
|
1257
1255
|
GlobalPubSub.publish(data.id, 'requestForDDItem', {
|
|
1258
1256
|
group: this.options.group,
|
|
1259
1257
|
source: data.id,
|
|
@@ -1291,7 +1289,7 @@ class WebsyDragDrop {
|
|
|
1291
1289
|
}
|
|
1292
1290
|
}
|
|
1293
1291
|
handleDragEnd (event) {
|
|
1294
|
-
console.log('drag end')
|
|
1292
|
+
// console.log('drag end')
|
|
1295
1293
|
event.target.style.opacity = 1
|
|
1296
1294
|
this.draggedId = null
|
|
1297
1295
|
this.dragging = false
|
|
@@ -1497,6 +1495,7 @@ class WebsyDropdown {
|
|
|
1497
1495
|
if (typeof d.index === 'undefined') {
|
|
1498
1496
|
d.index = i
|
|
1499
1497
|
}
|
|
1498
|
+
d.currentIndex = i
|
|
1500
1499
|
return d
|
|
1501
1500
|
})
|
|
1502
1501
|
const headerEl = document.getElementById(`${this.elementId}_header`)
|
|
@@ -1504,15 +1503,17 @@ class WebsyDropdown {
|
|
|
1504
1503
|
headerEl.classList[`${this.options.allowClear === true ? 'add' : 'remove'}`]('allow-clear')
|
|
1505
1504
|
}
|
|
1506
1505
|
const el = document.getElementById(`${this.elementId}_items`)
|
|
1507
|
-
if (el
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
else {
|
|
1511
|
-
if (this.options.items.length === 0) {
|
|
1512
|
-
this.options.items = [{label: this.options.noItemsText || 'No Items'}]
|
|
1506
|
+
if (el) {
|
|
1507
|
+
if (el.childElementCount === 0) {
|
|
1508
|
+
this.render()
|
|
1513
1509
|
}
|
|
1514
|
-
|
|
1515
|
-
|
|
1510
|
+
else {
|
|
1511
|
+
if (this.options.items.length === 0) {
|
|
1512
|
+
this.options.items = [{label: this.options.noItemsText || 'No Items'}]
|
|
1513
|
+
}
|
|
1514
|
+
this.renderItems()
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1516
1517
|
}
|
|
1517
1518
|
get data () {
|
|
1518
1519
|
return this.options.items
|
|
@@ -1753,6 +1754,10 @@ class WebsyDropdown {
|
|
|
1753
1754
|
const labelEl = document.getElementById(`${this.elementId}_selectedItems`)
|
|
1754
1755
|
const inputEl = document.getElementById(`${this.elementId}_input`)
|
|
1755
1756
|
const itemEls = el.querySelectorAll(`.websy-dropdown-item`)
|
|
1757
|
+
let dataToUse = this._originalData
|
|
1758
|
+
if (this.options.onSearch) {
|
|
1759
|
+
dataToUse = this.options.items
|
|
1760
|
+
}
|
|
1756
1761
|
for (let i = 0; i < itemEls.length; i++) {
|
|
1757
1762
|
itemEls[i].classList.remove('active')
|
|
1758
1763
|
let index = itemEls[i].getAttribute('data-index')
|
|
@@ -1788,14 +1793,14 @@ class WebsyDropdown {
|
|
|
1788
1793
|
}
|
|
1789
1794
|
else if (this.selectedItems.length > 1) {
|
|
1790
1795
|
if (this.options.showCompleteSelectedList === true) {
|
|
1791
|
-
let selectedLabels = this.selectedItems.map(s =>
|
|
1792
|
-
let selectedValues = this.selectedItems.map(s =>
|
|
1796
|
+
let selectedLabels = this.selectedItems.map(s => dataToUse[s].label || dataToUse[s].value).join(this.options.multiValueDelimiter)
|
|
1797
|
+
let selectedValues = this.selectedItems.map(s => dataToUse[s].value || dataToUse[s].label).join(this.options.multiValueDelimiter)
|
|
1793
1798
|
labelEl.innerHTML = selectedLabels
|
|
1794
1799
|
labelEl.setAttribute('data-info', selectedLabels)
|
|
1795
1800
|
inputEl.value = selectedValues
|
|
1796
1801
|
}
|
|
1797
1802
|
else {
|
|
1798
|
-
let selectedValues = this.selectedItems.map(s =>
|
|
1803
|
+
let selectedValues = this.selectedItems.map(s => dataToUse[s].value || dataToUse[s].label).join(this.options.multiValueDelimiter)
|
|
1799
1804
|
labelEl.innerHTML = `${this.selectedItems.length} selected`
|
|
1800
1805
|
labelEl.setAttribute('data-info', '')
|
|
1801
1806
|
inputEl.value = selectedValues
|
|
@@ -1809,6 +1814,10 @@ class WebsyDropdown {
|
|
|
1809
1814
|
}
|
|
1810
1815
|
}
|
|
1811
1816
|
updateSelected (index) {
|
|
1817
|
+
let dataToUse = this._originalData && this._originalData.length > 0 ? this._originalData : this.options.items
|
|
1818
|
+
if (this.options.onSearch) {
|
|
1819
|
+
dataToUse = this.options.items
|
|
1820
|
+
}
|
|
1812
1821
|
if (typeof index !== 'undefined' && index !== null) {
|
|
1813
1822
|
let pos = this.selectedItems.indexOf(index)
|
|
1814
1823
|
if (this.options.multiSelect === false) {
|
|
@@ -1824,10 +1833,10 @@ class WebsyDropdown {
|
|
|
1824
1833
|
}
|
|
1825
1834
|
}
|
|
1826
1835
|
// const item = this.options.items[index]
|
|
1827
|
-
const item =
|
|
1836
|
+
const item = dataToUse[index]
|
|
1828
1837
|
this.updateHeader(item)
|
|
1829
1838
|
if (item && this.options.onItemSelected) {
|
|
1830
|
-
this.options.onItemSelected(item, this.selectedItems,
|
|
1839
|
+
this.options.onItemSelected(item, this.selectedItems, dataToUse, this.options)
|
|
1831
1840
|
}
|
|
1832
1841
|
if (this.options.closeAfterSelection === true) {
|
|
1833
1842
|
this.close()
|
|
@@ -2755,9 +2764,9 @@ class WebsyPubSub {
|
|
|
2755
2764
|
}
|
|
2756
2765
|
}
|
|
2757
2766
|
else {
|
|
2758
|
-
if (this.subscriptions[
|
|
2759
|
-
this.subscriptions[
|
|
2760
|
-
fn(
|
|
2767
|
+
if (this.subscriptions[id]) {
|
|
2768
|
+
this.subscriptions[id].forEach(fn => {
|
|
2769
|
+
fn(method)
|
|
2761
2770
|
})
|
|
2762
2771
|
}
|
|
2763
2772
|
}
|
|
@@ -2772,10 +2781,10 @@ class WebsyPubSub {
|
|
|
2772
2781
|
}
|
|
2773
2782
|
}
|
|
2774
2783
|
else {
|
|
2775
|
-
if (!this.subscriptions[
|
|
2776
|
-
this.subscriptions[
|
|
2784
|
+
if (!this.subscriptions[id]) {
|
|
2785
|
+
this.subscriptions[id] = []
|
|
2777
2786
|
}
|
|
2778
|
-
this.subscriptions[
|
|
2787
|
+
this.subscriptions[id].push(method)
|
|
2779
2788
|
}
|
|
2780
2789
|
}
|
|
2781
2790
|
}
|
|
@@ -3997,6 +4006,7 @@ const WebsyUtils = {
|
|
|
3997
4006
|
let red = 0
|
|
3998
4007
|
let green = 0
|
|
3999
4008
|
let blue = 0
|
|
4009
|
+
let alpha = 1
|
|
4000
4010
|
if (backgroundColor.indexOf('#') !== -1) {
|
|
4001
4011
|
// hex color
|
|
4002
4012
|
backgroundColor = backgroundColor.replace('#', '')
|
|
@@ -4008,13 +4018,15 @@ const WebsyUtils = {
|
|
|
4008
4018
|
}
|
|
4009
4019
|
else if (backgroundColor.toLowerCase().indexOf('rgb') !== -1) {
|
|
4010
4020
|
// rgb color
|
|
4011
|
-
colorParts = backgroundColor.replace(/
|
|
4021
|
+
colorParts = backgroundColor.replace(/rgba\(/gi, '').replace(/\)/gi, '')
|
|
4022
|
+
colorParts = colorParts.replace(/rgb\(/gi, '')
|
|
4012
4023
|
colorParts = colorParts.split(',')
|
|
4013
4024
|
red = colorParts[0]
|
|
4014
4025
|
green = colorParts[1]
|
|
4015
4026
|
blue = colorParts[2]
|
|
4027
|
+
alpha = colorParts[3] || 1
|
|
4016
4028
|
}
|
|
4017
|
-
return (red * 0.299 + green * 0.587 + blue * 0.114) > 186 ? darkColor : lightColor
|
|
4029
|
+
return ((red * 0.299 + green * 0.587 + blue * 0.114) / alpha) > 186 ? darkColor : lightColor
|
|
4018
4030
|
},
|
|
4019
4031
|
measureText (text, rotation = 0, fontSize = '12px') {
|
|
4020
4032
|
if (!isNaN(fontSize)) {
|
|
@@ -4464,8 +4476,15 @@ class WebsyTable {
|
|
|
4464
4476
|
}
|
|
4465
4477
|
let headHTML = '<tr>' + this.options.columns.map((c, i) => {
|
|
4466
4478
|
if (c.show !== false) {
|
|
4479
|
+
let style = ''
|
|
4480
|
+
if (c.style) {
|
|
4481
|
+
style += c.style
|
|
4482
|
+
}
|
|
4483
|
+
if (c.width) {
|
|
4484
|
+
style += `width: ${(c.width || 'auto')};`
|
|
4485
|
+
}
|
|
4467
4486
|
return `
|
|
4468
|
-
<th ${
|
|
4487
|
+
<th style="${style}">
|
|
4469
4488
|
<div class ="tableHeader">
|
|
4470
4489
|
<div class="leftSection">
|
|
4471
4490
|
<div
|
|
@@ -5140,7 +5159,8 @@ class WebsyTable3 {
|
|
|
5140
5159
|
showTotalsAbove: true,
|
|
5141
5160
|
minHandleSize: 20,
|
|
5142
5161
|
maxColWidth: '50%',
|
|
5143
|
-
allowPivoting: false
|
|
5162
|
+
allowPivoting: false,
|
|
5163
|
+
searchIcon: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 512 512"><title>ionicons-v5-f</title><path d="M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/><line x1="338.29" y1="338.29" x2="448" y2="448" style="fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px"/></svg>`
|
|
5144
5164
|
}
|
|
5145
5165
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
5146
5166
|
this.sizes = {}
|
|
@@ -5251,9 +5271,22 @@ class WebsyTable3 {
|
|
|
5251
5271
|
data.forEach(row => {
|
|
5252
5272
|
bodyHtml += `<tr class="websy-table-row">`
|
|
5253
5273
|
row.forEach((cell, cellIndex) => {
|
|
5274
|
+
let style = ''
|
|
5275
|
+
if (cell.style) {
|
|
5276
|
+
style += cell.style
|
|
5277
|
+
}
|
|
5278
|
+
if (cell.backgroundColor) {
|
|
5279
|
+
style += `background-color: ${cell.backgroundColor}; `
|
|
5280
|
+
if (!cell.color) {
|
|
5281
|
+
style += `color: ${WebsyDesigns.Utils.getLightDark(cell.backgroundColor)}; `
|
|
5282
|
+
}
|
|
5283
|
+
}
|
|
5284
|
+
if (cell.color) {
|
|
5285
|
+
style += `color: ${cell.color}; `
|
|
5286
|
+
}
|
|
5254
5287
|
bodyHtml += `<td
|
|
5255
5288
|
class='websy-table-cell'
|
|
5256
|
-
style='${
|
|
5289
|
+
style='${style}'
|
|
5257
5290
|
data-info='${cell.value}'
|
|
5258
5291
|
colspan='${cell.colspan || 1}'
|
|
5259
5292
|
rowspan='${cell.rowspan || 1}'
|
|
@@ -5292,7 +5325,7 @@ class WebsyTable3 {
|
|
|
5292
5325
|
return
|
|
5293
5326
|
}
|
|
5294
5327
|
headerHtml += `<tr class="websy-table-row websy-table-header-row">`
|
|
5295
|
-
row.forEach(col => {
|
|
5328
|
+
row.forEach((col, colIndex) => {
|
|
5296
5329
|
headerHtml += `<td
|
|
5297
5330
|
class='websy-table-cell'
|
|
5298
5331
|
style='${col.style}'
|
|
@@ -5307,13 +5340,35 @@ class WebsyTable3 {
|
|
|
5307
5340
|
// }
|
|
5308
5341
|
headerHtml += `
|
|
5309
5342
|
>
|
|
5310
|
-
|
|
5343
|
+
<div>
|
|
5344
|
+
${col.name}
|
|
5345
|
+
${col.searchable === true ? this.buildSearchIcon(col, colIndex) : ''}
|
|
5346
|
+
</div>
|
|
5311
5347
|
</td>`
|
|
5312
5348
|
})
|
|
5313
5349
|
headerHtml += `</tr>`
|
|
5314
5350
|
})
|
|
5351
|
+
const dropdownEl = document.getElementById(`${this.elementId}_dropdownContainer`)
|
|
5352
|
+
this.options.columns[this.options.columns.length - 1].forEach((c, i) => {
|
|
5353
|
+
if (c.searchable && c.isExternalSearch === true) {
|
|
5354
|
+
const testEl = document.getElementById(`${this.elementId}_columnSearch_${c.dimId || i}`)
|
|
5355
|
+
if (!testEl) {
|
|
5356
|
+
const newE = document.createElement('div')
|
|
5357
|
+
newE.id = `${this.elementId}_columnSearch_${c.dimId || i}`
|
|
5358
|
+
newE.className = 'websy-modal-dropdown'
|
|
5359
|
+
dropdownEl.appendChild(newE)
|
|
5360
|
+
}
|
|
5361
|
+
}
|
|
5362
|
+
})
|
|
5315
5363
|
return headerHtml
|
|
5316
5364
|
}
|
|
5365
|
+
buildSearchIcon (col, index) {
|
|
5366
|
+
return `
|
|
5367
|
+
<div class="websy-table-search-icon" data-col-id="${col.dimId}" data-col-index="${index}">
|
|
5368
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 512 512"><title>ionicons-v5-f</title><path d="M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/><line x1="338.29" y1="338.29" x2="448" y2="448" style="fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px"/></svg>
|
|
5369
|
+
</div>
|
|
5370
|
+
`
|
|
5371
|
+
}
|
|
5317
5372
|
buildTotalHtml (useWidths = false) {
|
|
5318
5373
|
if (!this.options.totals) {
|
|
5319
5374
|
return ''
|
|
@@ -5450,7 +5505,13 @@ class WebsyTable3 {
|
|
|
5450
5505
|
return output
|
|
5451
5506
|
}
|
|
5452
5507
|
handleClick (event) {
|
|
5453
|
-
|
|
5508
|
+
if (event.target.classList.contains('websy-table-search-icon')) {
|
|
5509
|
+
console.log('clicked on search icon')
|
|
5510
|
+
const colIndex = +event.target.getAttribute('data-col-index')
|
|
5511
|
+
if (this.options.columns[this.options.columns.length - 1][colIndex].onSearch) {
|
|
5512
|
+
this.options.columns[this.options.columns.length - 1][colIndex].onSearch(event, this.options.columns[this.options.columns.length - 1][colIndex])
|
|
5513
|
+
}
|
|
5514
|
+
}
|
|
5454
5515
|
}
|
|
5455
5516
|
handleMouseDown (event) {
|
|
5456
5517
|
if (event.target.classList.contains('websy-scroll-handle-y')) {
|
|
@@ -5547,20 +5608,26 @@ class WebsyTable3 {
|
|
|
5547
5608
|
bodyEl.style.height = `calc(100% - ${this.sizes.header.height}px - ${this.sizes.total.height}px)`
|
|
5548
5609
|
if (this.options.virtualScroll === true) {
|
|
5549
5610
|
// set the scroll element positions
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5611
|
+
let vScrollEl = document.getElementById(`${this.elementId}_vScrollContainer`)
|
|
5612
|
+
let vHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
5613
|
+
if (this.vScrollRequired === true) {
|
|
5553
5614
|
vScrollEl.style.top = `${this.sizes.header.height + this.sizes.total.height}px`
|
|
5554
5615
|
vScrollEl.style.height = `${this.sizes.bodyHeight}px`
|
|
5555
5616
|
vHandleEl.style.height = Math.max(this.options.minHandleSize, this.sizes.bodyHeight * (this.sizes.rowsToRenderPrecise / this.totalRowCount)) + 'px'
|
|
5556
|
-
}
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5617
|
+
}
|
|
5618
|
+
else {
|
|
5619
|
+
vHandleEl.style.height = '0px'
|
|
5620
|
+
}
|
|
5621
|
+
let hScrollEl = document.getElementById(`${this.elementId}_hScrollContainer`)
|
|
5622
|
+
let hHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
5623
|
+
if (this.hScrollRequired === true) {
|
|
5560
5624
|
hScrollEl.style.left = `${this.sizes.table.width - this.sizes.scrollableWidth}px`
|
|
5561
5625
|
hScrollEl.style.width = `${this.sizes.scrollableWidth - 20}px`
|
|
5562
5626
|
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalWidth)) + 'px'
|
|
5563
|
-
}
|
|
5627
|
+
}
|
|
5628
|
+
else {
|
|
5629
|
+
hHandleEl.style.height = '0px'
|
|
5630
|
+
}
|
|
5564
5631
|
}
|
|
5565
5632
|
}
|
|
5566
5633
|
renderColumnHeaders () {
|
|
@@ -5629,7 +5696,7 @@ class WebsyTable3 {
|
|
|
5629
5696
|
this.endCol = 0
|
|
5630
5697
|
for (let i = 0; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
5631
5698
|
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
|
|
5632
|
-
console.log(actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth)
|
|
5699
|
+
console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth)
|
|
5633
5700
|
if (actualLeft < cumulativeWidth) {
|
|
5634
5701
|
this.startCol = i
|
|
5635
5702
|
break
|