@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
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
WebsySignup
|
|
30
30
|
ResponsiveText
|
|
31
31
|
WebsyDragDrop
|
|
32
|
+
WebsySearch
|
|
32
33
|
Pager
|
|
33
34
|
*/
|
|
34
35
|
|
|
@@ -611,6 +612,7 @@ class WebsyDatePicker {
|
|
|
611
612
|
if (typeof d === 'number') {
|
|
612
613
|
d = new Date(d)
|
|
613
614
|
}
|
|
615
|
+
// d.setTime(d.getTime() + d.getTimezoneOffset() * 60000)
|
|
614
616
|
return new Date(d.setHours(0, 0, 0, 0))
|
|
615
617
|
}
|
|
616
618
|
handleClick (event) {
|
|
@@ -629,11 +631,7 @@ class WebsyDatePicker {
|
|
|
629
631
|
this.updateRange(index)
|
|
630
632
|
}
|
|
631
633
|
else if (event.target.classList.contains('websy-dp-date')) {
|
|
632
|
-
//
|
|
633
|
-
// return
|
|
634
|
-
// }
|
|
635
|
-
// const timestamp = event.target.id.split('_')[0]
|
|
636
|
-
// this.selectDate(+timestamp)
|
|
634
|
+
//
|
|
637
635
|
}
|
|
638
636
|
else if (event.target.classList.contains('websy-dp-confirm')) {
|
|
639
637
|
this.close(true)
|
|
@@ -662,7 +660,8 @@ class WebsyDatePicker {
|
|
|
662
660
|
handleMouseDown (event) {
|
|
663
661
|
if (this.shiftPressed === true && this.currentselection.length > 0) {
|
|
664
662
|
this.mouseDownId = this.currentselection[this.currentselection.length - 1]
|
|
665
|
-
|
|
663
|
+
let dateId = event.target.getAttribute('data-id')
|
|
664
|
+
this.selectDate(+dateId)
|
|
666
665
|
}
|
|
667
666
|
else {
|
|
668
667
|
this.mouseDown = true
|
|
@@ -675,7 +674,7 @@ class WebsyDatePicker {
|
|
|
675
674
|
this.currentselection = []
|
|
676
675
|
this.customRangeSelected = false
|
|
677
676
|
}
|
|
678
|
-
this.mouseDownId = +event.target.
|
|
677
|
+
this.mouseDownId = +event.target.getAttribute('data-id')
|
|
679
678
|
this.selectDate(this.mouseDownId)
|
|
680
679
|
}
|
|
681
680
|
}
|
|
@@ -686,9 +685,10 @@ class WebsyDatePicker {
|
|
|
686
685
|
if (event.target.classList.contains('websy-disabled-date')) {
|
|
687
686
|
return
|
|
688
687
|
}
|
|
689
|
-
|
|
688
|
+
let dateId = +event.target.getAttribute('data-id')
|
|
689
|
+
if (dateId !== this.mouseDownId) {
|
|
690
690
|
this.dragging = true
|
|
691
|
-
this.selectDate(
|
|
691
|
+
this.selectDate(dateId)
|
|
692
692
|
}
|
|
693
693
|
}
|
|
694
694
|
}
|
|
@@ -736,6 +736,7 @@ class WebsyDatePicker {
|
|
|
736
736
|
let rangeEnd
|
|
737
737
|
if (this.options.mode === 'date') {
|
|
738
738
|
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + (i * this.oneDay)))
|
|
739
|
+
d.setHours(0, 0, 0, 0)
|
|
739
740
|
d = d.getTime()
|
|
740
741
|
rangeStart = this.selectedRangeDates[0].getTime()
|
|
741
742
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
@@ -1005,7 +1006,7 @@ class WebsyDatePicker {
|
|
|
1005
1006
|
}
|
|
1006
1007
|
html += paddedDays.join('')
|
|
1007
1008
|
}
|
|
1008
|
-
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('')
|
|
1009
|
+
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('')
|
|
1009
1010
|
html += `
|
|
1010
1011
|
</ul>
|
|
1011
1012
|
</div>
|
|
@@ -1126,7 +1127,7 @@ class WebsyDatePicker {
|
|
|
1126
1127
|
selectRange (index, confirm = true) {
|
|
1127
1128
|
if (this.options.ranges[this.options.mode][index]) {
|
|
1128
1129
|
this.selectedRangeDates = [...this.options.ranges[this.options.mode][index].range]
|
|
1129
|
-
this.currentselection =
|
|
1130
|
+
this.currentselection = this.options.ranges[this.options.mode][index].range.map(d => d.getTime())
|
|
1130
1131
|
this.selectedRange = +index
|
|
1131
1132
|
const el = document.getElementById(`${this.elementId}_header`)
|
|
1132
1133
|
if (el) {
|
|
@@ -1411,6 +1412,7 @@ class WebsyDropdown {
|
|
|
1411
1412
|
if (typeof d.index === 'undefined') {
|
|
1412
1413
|
d.index = i
|
|
1413
1414
|
}
|
|
1415
|
+
d.currentIndex = i
|
|
1414
1416
|
return d
|
|
1415
1417
|
})
|
|
1416
1418
|
const headerEl = document.getElementById(`${this.elementId}_header`)
|
|
@@ -1418,15 +1420,17 @@ class WebsyDropdown {
|
|
|
1418
1420
|
headerEl.classList[`${this.options.allowClear === true ? 'add' : 'remove'}`]('allow-clear')
|
|
1419
1421
|
}
|
|
1420
1422
|
const el = document.getElementById(`${this.elementId}_items`)
|
|
1421
|
-
if (el
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
else {
|
|
1425
|
-
if (this.options.items.length === 0) {
|
|
1426
|
-
this.options.items = [{label: this.options.noItemsText || 'No Items'}]
|
|
1423
|
+
if (el) {
|
|
1424
|
+
if (el.childElementCount === 0) {
|
|
1425
|
+
this.render()
|
|
1427
1426
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1427
|
+
else {
|
|
1428
|
+
if (this.options.items.length === 0) {
|
|
1429
|
+
this.options.items = [{label: this.options.noItemsText || 'No Items'}]
|
|
1430
|
+
}
|
|
1431
|
+
this.renderItems()
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1430
1434
|
}
|
|
1431
1435
|
get data () {
|
|
1432
1436
|
return this.options.items
|
|
@@ -1667,6 +1671,10 @@ class WebsyDropdown {
|
|
|
1667
1671
|
const labelEl = document.getElementById(`${this.elementId}_selectedItems`)
|
|
1668
1672
|
const inputEl = document.getElementById(`${this.elementId}_input`)
|
|
1669
1673
|
const itemEls = el.querySelectorAll(`.websy-dropdown-item`)
|
|
1674
|
+
let dataToUse = this._originalData
|
|
1675
|
+
if (this.options.onSearch) {
|
|
1676
|
+
dataToUse = this.options.items
|
|
1677
|
+
}
|
|
1670
1678
|
for (let i = 0; i < itemEls.length; i++) {
|
|
1671
1679
|
itemEls[i].classList.remove('active')
|
|
1672
1680
|
let index = itemEls[i].getAttribute('data-index')
|
|
@@ -1702,14 +1710,14 @@ class WebsyDropdown {
|
|
|
1702
1710
|
}
|
|
1703
1711
|
else if (this.selectedItems.length > 1) {
|
|
1704
1712
|
if (this.options.showCompleteSelectedList === true) {
|
|
1705
|
-
let selectedLabels = this.selectedItems.map(s =>
|
|
1706
|
-
let selectedValues = this.selectedItems.map(s =>
|
|
1713
|
+
let selectedLabels = this.selectedItems.map(s => dataToUse[s].label || dataToUse[s].value).join(this.options.multiValueDelimiter)
|
|
1714
|
+
let selectedValues = this.selectedItems.map(s => dataToUse[s].value || dataToUse[s].label).join(this.options.multiValueDelimiter)
|
|
1707
1715
|
labelEl.innerHTML = selectedLabels
|
|
1708
1716
|
labelEl.setAttribute('data-info', selectedLabels)
|
|
1709
1717
|
inputEl.value = selectedValues
|
|
1710
1718
|
}
|
|
1711
1719
|
else {
|
|
1712
|
-
let selectedValues = this.selectedItems.map(s =>
|
|
1720
|
+
let selectedValues = this.selectedItems.map(s => dataToUse[s].value || dataToUse[s].label).join(this.options.multiValueDelimiter)
|
|
1713
1721
|
labelEl.innerHTML = `${this.selectedItems.length} selected`
|
|
1714
1722
|
labelEl.setAttribute('data-info', '')
|
|
1715
1723
|
inputEl.value = selectedValues
|
|
@@ -1723,6 +1731,10 @@ class WebsyDropdown {
|
|
|
1723
1731
|
}
|
|
1724
1732
|
}
|
|
1725
1733
|
updateSelected (index) {
|
|
1734
|
+
let dataToUse = this._originalData && this._originalData.length > 0 ? this._originalData : this.options.items
|
|
1735
|
+
if (this.options.onSearch) {
|
|
1736
|
+
dataToUse = this.options.items
|
|
1737
|
+
}
|
|
1726
1738
|
if (typeof index !== 'undefined' && index !== null) {
|
|
1727
1739
|
let pos = this.selectedItems.indexOf(index)
|
|
1728
1740
|
if (this.options.multiSelect === false) {
|
|
@@ -1738,10 +1750,10 @@ class WebsyDropdown {
|
|
|
1738
1750
|
}
|
|
1739
1751
|
}
|
|
1740
1752
|
// const item = this.options.items[index]
|
|
1741
|
-
const item =
|
|
1753
|
+
const item = dataToUse[index]
|
|
1742
1754
|
this.updateHeader(item)
|
|
1743
1755
|
if (item && this.options.onItemSelected) {
|
|
1744
|
-
this.options.onItemSelected(item, this.selectedItems,
|
|
1756
|
+
this.options.onItemSelected(item, this.selectedItems, dataToUse, this.options)
|
|
1745
1757
|
}
|
|
1746
1758
|
if (this.options.closeAfterSelection === true) {
|
|
1747
1759
|
this.close()
|
|
@@ -1781,9 +1793,7 @@ class WebsyDragDrop {
|
|
|
1781
1793
|
else {
|
|
1782
1794
|
console.error(`No element found with ID ${this.elementId}`)
|
|
1783
1795
|
}
|
|
1784
|
-
GlobalPubSub.subscribe(this.elementId, 'requestForDDItem', this.handleRequestForItem.bind(this))
|
|
1785
|
-
console.log('constructor dd')
|
|
1786
|
-
console.trace()
|
|
1796
|
+
GlobalPubSub.subscribe(this.elementId, 'requestForDDItem', this.handleRequestForItem.bind(this))
|
|
1787
1797
|
GlobalPubSub.subscribe(this.elementId, 'add', this.addItem.bind(this))
|
|
1788
1798
|
this.render()
|
|
1789
1799
|
}
|
|
@@ -1847,12 +1857,12 @@ class WebsyDragDrop {
|
|
|
1847
1857
|
this.draggedId = event.target.getAttribute('data-id')
|
|
1848
1858
|
event.dataTransfer.effectAllowed = 'move'
|
|
1849
1859
|
event.dataTransfer.setData('application/wd-item', JSON.stringify({el: event.target.id, id: this.elementId, itemId: this.draggedId}))
|
|
1850
|
-
console.log('drag start', event)
|
|
1860
|
+
// console.log('drag start', event)
|
|
1851
1861
|
event.target.style.opacity = 0.5
|
|
1852
1862
|
this.dragging = true
|
|
1853
1863
|
}
|
|
1854
1864
|
handleDragOver (event) {
|
|
1855
|
-
console.log('drag over', event.target.classList)
|
|
1865
|
+
// console.log('drag over', event.target.classList)
|
|
1856
1866
|
if (event.preventDefault) {
|
|
1857
1867
|
event.preventDefault()
|
|
1858
1868
|
}
|
|
@@ -1862,7 +1872,7 @@ class WebsyDragDrop {
|
|
|
1862
1872
|
event.target.classList.add('drag-over')
|
|
1863
1873
|
}
|
|
1864
1874
|
handleDragLeave (event) {
|
|
1865
|
-
console.log('drag leave', event.target.classList)
|
|
1875
|
+
// console.log('drag leave', event.target.classList)
|
|
1866
1876
|
if (!event.target.classList.contains('droppable')) {
|
|
1867
1877
|
return
|
|
1868
1878
|
}
|
|
@@ -1873,8 +1883,8 @@ class WebsyDragDrop {
|
|
|
1873
1883
|
// this.removeExpandedDrop(side, id, droppedItem)
|
|
1874
1884
|
}
|
|
1875
1885
|
handleDrop (event) {
|
|
1876
|
-
console.log('drag drop')
|
|
1877
|
-
console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1886
|
+
// console.log('drag drop')
|
|
1887
|
+
// console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1878
1888
|
const data = JSON.parse(event.dataTransfer.getData('application/wd-item'))
|
|
1879
1889
|
if (event.preventDefault) {
|
|
1880
1890
|
event.preventDefault()
|
|
@@ -1891,7 +1901,7 @@ class WebsyDragDrop {
|
|
|
1891
1901
|
index += 1
|
|
1892
1902
|
}
|
|
1893
1903
|
if (draggedIndex === -1) {
|
|
1894
|
-
console.log('requestForDDItem')
|
|
1904
|
+
// console.log('requestForDDItem')
|
|
1895
1905
|
GlobalPubSub.publish(data.id, 'requestForDDItem', {
|
|
1896
1906
|
group: this.options.group,
|
|
1897
1907
|
source: data.id,
|
|
@@ -1929,7 +1939,7 @@ class WebsyDragDrop {
|
|
|
1929
1939
|
}
|
|
1930
1940
|
}
|
|
1931
1941
|
handleDragEnd (event) {
|
|
1932
|
-
console.log('drag end')
|
|
1942
|
+
// console.log('drag end')
|
|
1933
1943
|
event.target.style.opacity = 1
|
|
1934
1944
|
this.draggedId = null
|
|
1935
1945
|
this.dragging = false
|
|
@@ -3002,9 +3012,9 @@ class WebsyPubSub {
|
|
|
3002
3012
|
}
|
|
3003
3013
|
}
|
|
3004
3014
|
else {
|
|
3005
|
-
if (this.subscriptions[
|
|
3006
|
-
this.subscriptions[
|
|
3007
|
-
fn(
|
|
3015
|
+
if (this.subscriptions[id]) {
|
|
3016
|
+
this.subscriptions[id].forEach(fn => {
|
|
3017
|
+
fn(method)
|
|
3008
3018
|
})
|
|
3009
3019
|
}
|
|
3010
3020
|
}
|
|
@@ -3019,10 +3029,10 @@ class WebsyPubSub {
|
|
|
3019
3029
|
}
|
|
3020
3030
|
}
|
|
3021
3031
|
else {
|
|
3022
|
-
if (!this.subscriptions[
|
|
3023
|
-
this.subscriptions[
|
|
3032
|
+
if (!this.subscriptions[id]) {
|
|
3033
|
+
this.subscriptions[id] = []
|
|
3024
3034
|
}
|
|
3025
|
-
this.subscriptions[
|
|
3035
|
+
this.subscriptions[id].push(method)
|
|
3026
3036
|
}
|
|
3027
3037
|
}
|
|
3028
3038
|
}
|
|
@@ -4020,6 +4030,55 @@ class WebsyRouter {
|
|
|
4020
4030
|
}
|
|
4021
4031
|
}
|
|
4022
4032
|
|
|
4033
|
+
class WebsySearch {
|
|
4034
|
+
constructor (elementId, options) {
|
|
4035
|
+
this.elementId = elementId
|
|
4036
|
+
const DEFAULTS = {
|
|
4037
|
+
searchIcon: `<svg class='search' width="20" height="20" viewBox="0 0 512 512"><path d="M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/><line x1="338.29" y1="338.29" x2="448" y2="448" style="fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px"/></svg>`,
|
|
4038
|
+
clearIcon: `<svg class='clear' xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 512 512"><title>ionicons-v5-l</title><line x1="368" y1="368" x2="144" y2="144" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/><line x1="368" y1="144" x2="144" y2="368" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/></svg>`,
|
|
4039
|
+
placeholder: 'Search',
|
|
4040
|
+
searchTimeout: 500,
|
|
4041
|
+
minLength: 2
|
|
4042
|
+
}
|
|
4043
|
+
this.options = Object.assign({}, DEFAULTS, options)
|
|
4044
|
+
this.searchTimeoutFn = null
|
|
4045
|
+
const el = document.getElementById(elementId)
|
|
4046
|
+
if (el) {
|
|
4047
|
+
// el.addEventListener('click', this.handleClick.bind(this))
|
|
4048
|
+
el.addEventListener('keyup', this.handleKeyUp.bind(this))
|
|
4049
|
+
el.innerHTML = `
|
|
4050
|
+
<div class='websy-search-input-container'>
|
|
4051
|
+
${this.options.searchIcon}
|
|
4052
|
+
<input id='${this.elementId}_search' class='websy-search-input' placeholder='${this.options.placeholder || 'Search'}'>
|
|
4053
|
+
${this.options.clearIcon}
|
|
4054
|
+
</div>
|
|
4055
|
+
`
|
|
4056
|
+
}
|
|
4057
|
+
else {
|
|
4058
|
+
console.log('No element found with Id', elementId)
|
|
4059
|
+
}
|
|
4060
|
+
}
|
|
4061
|
+
handleKeyUp (event) {
|
|
4062
|
+
if (event.target.classList.contains('websy-search-input')) {
|
|
4063
|
+
if (this.searchTimeoutFn) {
|
|
4064
|
+
clearTimeout(this.searchTimeoutFn)
|
|
4065
|
+
}
|
|
4066
|
+
if (event.target.value.length >= this.options.minLength) {
|
|
4067
|
+
this.searchTimeoutFn = setTimeout(() => {
|
|
4068
|
+
if (this.options.onSearch) {
|
|
4069
|
+
this.options.onSearch(event.target.value)
|
|
4070
|
+
}
|
|
4071
|
+
}, this.options.searchTimeout)
|
|
4072
|
+
}
|
|
4073
|
+
else {
|
|
4074
|
+
if (this.options.onSearch) {
|
|
4075
|
+
this.options.onSearch('')
|
|
4076
|
+
}
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
|
|
4023
4082
|
/* global WebsyDesigns ENVIRONMENT */
|
|
4024
4083
|
class WebsySignup {
|
|
4025
4084
|
constructor (elementId, options) {
|
|
@@ -4295,6 +4354,7 @@ const WebsyUtils = {
|
|
|
4295
4354
|
let red = 0
|
|
4296
4355
|
let green = 0
|
|
4297
4356
|
let blue = 0
|
|
4357
|
+
let alpha = 1
|
|
4298
4358
|
if (backgroundColor.indexOf('#') !== -1) {
|
|
4299
4359
|
// hex color
|
|
4300
4360
|
backgroundColor = backgroundColor.replace('#', '')
|
|
@@ -4306,13 +4366,15 @@ const WebsyUtils = {
|
|
|
4306
4366
|
}
|
|
4307
4367
|
else if (backgroundColor.toLowerCase().indexOf('rgb') !== -1) {
|
|
4308
4368
|
// rgb color
|
|
4309
|
-
colorParts = backgroundColor.replace(/
|
|
4369
|
+
colorParts = backgroundColor.replace(/rgba\(/gi, '').replace(/\)/gi, '')
|
|
4370
|
+
colorParts = colorParts.replace(/rgb\(/gi, '')
|
|
4310
4371
|
colorParts = colorParts.split(',')
|
|
4311
4372
|
red = colorParts[0]
|
|
4312
4373
|
green = colorParts[1]
|
|
4313
4374
|
blue = colorParts[2]
|
|
4375
|
+
alpha = colorParts[3] || 1
|
|
4314
4376
|
}
|
|
4315
|
-
return (red * 0.299 + green * 0.587 + blue * 0.114) > 186 ? darkColor : lightColor
|
|
4377
|
+
return ((red * 0.299 + green * 0.587 + blue * 0.114) / alpha) > 186 ? darkColor : lightColor
|
|
4316
4378
|
},
|
|
4317
4379
|
measureText (text, rotation = 0, fontSize = '12px') {
|
|
4318
4380
|
if (!isNaN(fontSize)) {
|
|
@@ -4762,8 +4824,15 @@ class WebsyTable {
|
|
|
4762
4824
|
}
|
|
4763
4825
|
let headHTML = '<tr>' + this.options.columns.map((c, i) => {
|
|
4764
4826
|
if (c.show !== false) {
|
|
4827
|
+
let style = ''
|
|
4828
|
+
if (c.style) {
|
|
4829
|
+
style += c.style
|
|
4830
|
+
}
|
|
4831
|
+
if (c.width) {
|
|
4832
|
+
style += `width: ${(c.width || 'auto')};`
|
|
4833
|
+
}
|
|
4765
4834
|
return `
|
|
4766
|
-
<th ${
|
|
4835
|
+
<th style="${style}">
|
|
4767
4836
|
<div class ="tableHeader">
|
|
4768
4837
|
<div class="leftSection">
|
|
4769
4838
|
<div
|
|
@@ -5438,7 +5507,8 @@ class WebsyTable3 {
|
|
|
5438
5507
|
showTotalsAbove: true,
|
|
5439
5508
|
minHandleSize: 20,
|
|
5440
5509
|
maxColWidth: '50%',
|
|
5441
|
-
allowPivoting: false
|
|
5510
|
+
allowPivoting: false,
|
|
5511
|
+
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>`
|
|
5442
5512
|
}
|
|
5443
5513
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
5444
5514
|
this.sizes = {}
|
|
@@ -5549,9 +5619,22 @@ class WebsyTable3 {
|
|
|
5549
5619
|
data.forEach(row => {
|
|
5550
5620
|
bodyHtml += `<tr class="websy-table-row">`
|
|
5551
5621
|
row.forEach((cell, cellIndex) => {
|
|
5622
|
+
let style = ''
|
|
5623
|
+
if (cell.style) {
|
|
5624
|
+
style += cell.style
|
|
5625
|
+
}
|
|
5626
|
+
if (cell.backgroundColor) {
|
|
5627
|
+
style += `background-color: ${cell.backgroundColor}; `
|
|
5628
|
+
if (!cell.color) {
|
|
5629
|
+
style += `color: ${WebsyDesigns.Utils.getLightDark(cell.backgroundColor)}; `
|
|
5630
|
+
}
|
|
5631
|
+
}
|
|
5632
|
+
if (cell.color) {
|
|
5633
|
+
style += `color: ${cell.color}; `
|
|
5634
|
+
}
|
|
5552
5635
|
bodyHtml += `<td
|
|
5553
5636
|
class='websy-table-cell'
|
|
5554
|
-
style='${
|
|
5637
|
+
style='${style}'
|
|
5555
5638
|
data-info='${cell.value}'
|
|
5556
5639
|
colspan='${cell.colspan || 1}'
|
|
5557
5640
|
rowspan='${cell.rowspan || 1}'
|
|
@@ -5590,7 +5673,7 @@ class WebsyTable3 {
|
|
|
5590
5673
|
return
|
|
5591
5674
|
}
|
|
5592
5675
|
headerHtml += `<tr class="websy-table-row websy-table-header-row">`
|
|
5593
|
-
row.forEach(col => {
|
|
5676
|
+
row.forEach((col, colIndex) => {
|
|
5594
5677
|
headerHtml += `<td
|
|
5595
5678
|
class='websy-table-cell'
|
|
5596
5679
|
style='${col.style}'
|
|
@@ -5605,13 +5688,35 @@ class WebsyTable3 {
|
|
|
5605
5688
|
// }
|
|
5606
5689
|
headerHtml += `
|
|
5607
5690
|
>
|
|
5608
|
-
|
|
5691
|
+
<div>
|
|
5692
|
+
${col.name}
|
|
5693
|
+
${col.searchable === true ? this.buildSearchIcon(col, colIndex) : ''}
|
|
5694
|
+
</div>
|
|
5609
5695
|
</td>`
|
|
5610
5696
|
})
|
|
5611
5697
|
headerHtml += `</tr>`
|
|
5612
5698
|
})
|
|
5699
|
+
const dropdownEl = document.getElementById(`${this.elementId}_dropdownContainer`)
|
|
5700
|
+
this.options.columns[this.options.columns.length - 1].forEach((c, i) => {
|
|
5701
|
+
if (c.searchable && c.isExternalSearch === true) {
|
|
5702
|
+
const testEl = document.getElementById(`${this.elementId}_columnSearch_${c.dimId || i}`)
|
|
5703
|
+
if (!testEl) {
|
|
5704
|
+
const newE = document.createElement('div')
|
|
5705
|
+
newE.id = `${this.elementId}_columnSearch_${c.dimId || i}`
|
|
5706
|
+
newE.className = 'websy-modal-dropdown'
|
|
5707
|
+
dropdownEl.appendChild(newE)
|
|
5708
|
+
}
|
|
5709
|
+
}
|
|
5710
|
+
})
|
|
5613
5711
|
return headerHtml
|
|
5614
5712
|
}
|
|
5713
|
+
buildSearchIcon (col, index) {
|
|
5714
|
+
return `
|
|
5715
|
+
<div class="websy-table-search-icon" data-col-id="${col.dimId}" data-col-index="${index}">
|
|
5716
|
+
<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>
|
|
5717
|
+
</div>
|
|
5718
|
+
`
|
|
5719
|
+
}
|
|
5615
5720
|
buildTotalHtml (useWidths = false) {
|
|
5616
5721
|
if (!this.options.totals) {
|
|
5617
5722
|
return ''
|
|
@@ -5748,7 +5853,13 @@ class WebsyTable3 {
|
|
|
5748
5853
|
return output
|
|
5749
5854
|
}
|
|
5750
5855
|
handleClick (event) {
|
|
5751
|
-
|
|
5856
|
+
if (event.target.classList.contains('websy-table-search-icon')) {
|
|
5857
|
+
console.log('clicked on search icon')
|
|
5858
|
+
const colIndex = +event.target.getAttribute('data-col-index')
|
|
5859
|
+
if (this.options.columns[this.options.columns.length - 1][colIndex].onSearch) {
|
|
5860
|
+
this.options.columns[this.options.columns.length - 1][colIndex].onSearch(event, this.options.columns[this.options.columns.length - 1][colIndex])
|
|
5861
|
+
}
|
|
5862
|
+
}
|
|
5752
5863
|
}
|
|
5753
5864
|
handleMouseDown (event) {
|
|
5754
5865
|
if (event.target.classList.contains('websy-scroll-handle-y')) {
|
|
@@ -5845,20 +5956,26 @@ class WebsyTable3 {
|
|
|
5845
5956
|
bodyEl.style.height = `calc(100% - ${this.sizes.header.height}px - ${this.sizes.total.height}px)`
|
|
5846
5957
|
if (this.options.virtualScroll === true) {
|
|
5847
5958
|
// set the scroll element positions
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5959
|
+
let vScrollEl = document.getElementById(`${this.elementId}_vScrollContainer`)
|
|
5960
|
+
let vHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
5961
|
+
if (this.vScrollRequired === true) {
|
|
5851
5962
|
vScrollEl.style.top = `${this.sizes.header.height + this.sizes.total.height}px`
|
|
5852
5963
|
vScrollEl.style.height = `${this.sizes.bodyHeight}px`
|
|
5853
5964
|
vHandleEl.style.height = Math.max(this.options.minHandleSize, this.sizes.bodyHeight * (this.sizes.rowsToRenderPrecise / this.totalRowCount)) + 'px'
|
|
5854
|
-
}
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5965
|
+
}
|
|
5966
|
+
else {
|
|
5967
|
+
vHandleEl.style.height = '0px'
|
|
5968
|
+
}
|
|
5969
|
+
let hScrollEl = document.getElementById(`${this.elementId}_hScrollContainer`)
|
|
5970
|
+
let hHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
5971
|
+
if (this.hScrollRequired === true) {
|
|
5858
5972
|
hScrollEl.style.left = `${this.sizes.table.width - this.sizes.scrollableWidth}px`
|
|
5859
5973
|
hScrollEl.style.width = `${this.sizes.scrollableWidth - 20}px`
|
|
5860
5974
|
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalWidth)) + 'px'
|
|
5861
|
-
}
|
|
5975
|
+
}
|
|
5976
|
+
else {
|
|
5977
|
+
hHandleEl.style.height = '0px'
|
|
5978
|
+
}
|
|
5862
5979
|
}
|
|
5863
5980
|
}
|
|
5864
5981
|
renderColumnHeaders () {
|
|
@@ -5927,7 +6044,7 @@ class WebsyTable3 {
|
|
|
5927
6044
|
this.endCol = 0
|
|
5928
6045
|
for (let i = 0; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
5929
6046
|
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
|
|
5930
|
-
console.log(actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth)
|
|
6047
|
+
console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth)
|
|
5931
6048
|
if (actualLeft < cumulativeWidth) {
|
|
5932
6049
|
this.startCol = i
|
|
5933
6050
|
break
|
|
@@ -7693,7 +7810,9 @@ const WebsyDesigns = {
|
|
|
7693
7810
|
ResponsiveText,
|
|
7694
7811
|
WebsyResponsiveText: ResponsiveText,
|
|
7695
7812
|
WebsyDragDrop,
|
|
7696
|
-
DragDrop: WebsyDragDrop
|
|
7813
|
+
DragDrop: WebsyDragDrop,
|
|
7814
|
+
WebsySearch,
|
|
7815
|
+
Search: WebsySearch
|
|
7697
7816
|
}
|
|
7698
7817
|
|
|
7699
7818
|
WebsyDesigns.service = new WebsyDesigns.APIService('')
|