@websy/websy-designs 1.4.1 → 1.4.2
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 +6 -6
- package/dist/websy-designs-es6.debug.js +245 -148
- package/dist/websy-designs-es6.js +397 -270
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +285 -171
- package/dist/websy-designs.js +441 -285
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -79,16 +79,14 @@ class PGHelper {
|
|
|
79
79
|
this.pool = pool
|
|
80
80
|
this.onReadyAuthCallbackFn = null
|
|
81
81
|
this.onReadyShopCallbackFn = null
|
|
82
|
-
this.options = { entityConfig: {} }
|
|
82
|
+
this.options = { entityConfig: {}, fieldValueSeparator: ':' }
|
|
83
83
|
this.updateIgnores = [
|
|
84
84
|
'id',
|
|
85
85
|
'create_date'
|
|
86
86
|
]
|
|
87
87
|
}
|
|
88
|
-
init (options) {
|
|
89
|
-
|
|
90
|
-
this.options = Object.assign({}, options)
|
|
91
|
-
}
|
|
88
|
+
init (options) {
|
|
89
|
+
this.options = Object.assign({}, this.options, options)
|
|
92
90
|
return new Promise((resolve, reject) => {
|
|
93
91
|
this.pool.connect().then(client => {
|
|
94
92
|
this.client = client
|
|
@@ -210,8 +208,10 @@ class PGHelper {
|
|
|
210
208
|
catch (error) {
|
|
211
209
|
// console.log(error)
|
|
212
210
|
}
|
|
211
|
+
console.log('where input', input)
|
|
212
|
+
console.log('splitter is', this.options.fieldValueSeparator)
|
|
213
213
|
let list = input.split(';').map(d => {
|
|
214
|
-
let parts = d.split(
|
|
214
|
+
let parts = d.split(this.options.fieldValueSeparator)
|
|
215
215
|
if (parts.length === 2) {
|
|
216
216
|
let partValues = parts[1]
|
|
217
217
|
partValues = partValues.split('|')
|
|
@@ -33,7 +33,9 @@ import WebsyDesignsQlikPlugins from '@websy/websy-designs-qlik-plugin/dist/websy
|
|
|
33
33
|
class APIService {
|
|
34
34
|
constructor (baseUrl = '', options = {}) {
|
|
35
35
|
this.baseUrl = baseUrl
|
|
36
|
-
this.options = Object.assign({},
|
|
36
|
+
this.options = Object.assign({}, {
|
|
37
|
+
fieldValueSeparator: ':'
|
|
38
|
+
}, options)
|
|
37
39
|
}
|
|
38
40
|
add (entity, data, options = {}) {
|
|
39
41
|
const url = this.buildUrl(entity)
|
|
@@ -44,7 +46,7 @@ class APIService {
|
|
|
44
46
|
query = []
|
|
45
47
|
}
|
|
46
48
|
if (id) {
|
|
47
|
-
query.push(`id
|
|
49
|
+
query.push(`id${this.options.fieldValueSeparator}${id}`)
|
|
48
50
|
}
|
|
49
51
|
return `${this.baseUrl}/${entity}${query.length > 0 ? `${entity.indexOf('?') === -1 ? '?' : '&'}where=${query.join(';')}` : ''}`
|
|
50
52
|
}
|
|
@@ -537,78 +539,107 @@ class WebsyDatePicker {
|
|
|
537
539
|
if (this.selectedRange === 0) {
|
|
538
540
|
return
|
|
539
541
|
}
|
|
540
|
-
if (this.customRangeSelected === true) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime() - this.selectedRangeDates[0].getTime()) / this.oneDay)
|
|
544
|
-
// if (this.selectedRangeDates[0].getMonth() !== this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth()) {
|
|
545
|
-
// diff += 1
|
|
546
|
-
// }
|
|
547
|
-
}
|
|
548
|
-
else if (this.options.mode === 'year') {
|
|
549
|
-
diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0]
|
|
550
|
-
if (this.selectedRangeDates[this.selectedRangeDates.length - 1] !== this.selectedRangeDates[0]) {
|
|
551
|
-
// diff += 1
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
else if (this.options.mode === 'monthyear') {
|
|
555
|
-
let yearDiff = (this.selectedRangeDates[this.selectedRangeDates.length - 1].getFullYear() - this.selectedRangeDates[0].getFullYear()) * 12
|
|
556
|
-
diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth() - this.selectedRangeDates[0].getMonth())) + yearDiff
|
|
557
|
-
}
|
|
558
|
-
else if (this.options.mode === 'hour') {
|
|
559
|
-
diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0]
|
|
560
|
-
}
|
|
561
|
-
for (let i = 0; i < diff + 1; i++) {
|
|
562
|
-
let d
|
|
563
|
-
let rangeStart
|
|
564
|
-
let rangeEnd
|
|
565
|
-
if (this.options.mode === 'date') {
|
|
566
|
-
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + (i * this.oneDay)))
|
|
567
|
-
// d.setUTCHours(12, 0, 0, 0)
|
|
568
|
-
d = d.getTime()
|
|
569
|
-
// console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
|
|
570
|
-
rangeStart = this.selectedRangeDates[0].getTime()
|
|
571
|
-
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
572
|
-
}
|
|
573
|
-
else if (this.options.mode === 'year') {
|
|
574
|
-
d = this.selectedRangeDates[0] + i
|
|
575
|
-
rangeStart = this.selectedRangeDates[0]
|
|
576
|
-
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
|
|
577
|
-
}
|
|
578
|
-
else if (this.options.mode === 'monthyear') {
|
|
579
|
-
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + i))
|
|
580
|
-
d = d.getTime()
|
|
581
|
-
console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
|
|
582
|
-
rangeStart = this.selectedRangeDates[0].getTime()
|
|
583
|
-
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
584
|
-
}
|
|
585
|
-
else if (this.options.mode === 'hour') {
|
|
586
|
-
d = this.selectedRangeDates[0] + i
|
|
587
|
-
rangeStart = this.selectedRangeDates[0]
|
|
588
|
-
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
|
|
589
|
-
}
|
|
590
|
-
let dateEl
|
|
542
|
+
if (this.customRangeSelected === true) {
|
|
543
|
+
if (this.isContinuousRange || this.mouseDown) {
|
|
544
|
+
let diff
|
|
591
545
|
if (this.options.mode === 'date') {
|
|
592
|
-
|
|
593
|
-
|
|
546
|
+
diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime() - this.selectedRangeDates[0].getTime()) / this.oneDay)
|
|
547
|
+
// if (this.selectedRangeDates[0].getMonth() !== this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth()) {
|
|
548
|
+
// diff += 1
|
|
549
|
+
// }
|
|
550
|
+
}
|
|
594
551
|
else if (this.options.mode === 'year') {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
552
|
+
diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0]
|
|
553
|
+
if (this.selectedRangeDates[this.selectedRangeDates.length - 1] !== this.selectedRangeDates[0]) {
|
|
554
|
+
// diff += 1
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
else if (this.options.mode === 'monthyear') {
|
|
558
|
+
let yearDiff = (this.selectedRangeDates[this.selectedRangeDates.length - 1].getFullYear() - this.selectedRangeDates[0].getFullYear()) * 12
|
|
559
|
+
diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth() - this.selectedRangeDates[0].getMonth())) + yearDiff
|
|
599
560
|
}
|
|
600
561
|
else if (this.options.mode === 'hour') {
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
562
|
+
diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0]
|
|
563
|
+
}
|
|
564
|
+
for (let i = 0; i < diff + 1; i++) {
|
|
565
|
+
let d
|
|
566
|
+
let rangeStart
|
|
567
|
+
let rangeEnd
|
|
568
|
+
if (this.options.mode === 'date') {
|
|
569
|
+
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + (i * this.oneDay)))
|
|
570
|
+
// d.setUTCHours(12, 0, 0, 0)
|
|
571
|
+
d = d.getTime()
|
|
572
|
+
// console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
|
|
573
|
+
rangeStart = this.selectedRangeDates[0].getTime()
|
|
574
|
+
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
575
|
+
}
|
|
576
|
+
else if (this.options.mode === 'year') {
|
|
577
|
+
d = this.selectedRangeDates[0] + i
|
|
578
|
+
rangeStart = this.selectedRangeDates[0]
|
|
579
|
+
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
|
|
580
|
+
}
|
|
581
|
+
else if (this.options.mode === 'monthyear') {
|
|
582
|
+
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + i))
|
|
583
|
+
d = d.getTime()
|
|
584
|
+
console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
|
|
585
|
+
rangeStart = this.selectedRangeDates[0].getTime()
|
|
586
|
+
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
587
|
+
}
|
|
588
|
+
else if (this.options.mode === 'hour') {
|
|
589
|
+
d = this.selectedRangeDates[0] + i
|
|
590
|
+
rangeStart = this.selectedRangeDates[0]
|
|
591
|
+
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
|
|
592
|
+
}
|
|
593
|
+
let dateEl
|
|
594
|
+
if (this.options.mode === 'date') {
|
|
595
|
+
dateEl = document.getElementById(`${this.elementId}_${d}_date`)
|
|
607
596
|
}
|
|
608
|
-
if (
|
|
609
|
-
dateEl.
|
|
597
|
+
else if (this.options.mode === 'year') {
|
|
598
|
+
dateEl = document.getElementById(`${this.elementId}_${d}_year`)
|
|
599
|
+
}
|
|
600
|
+
else if (this.options.mode === 'monthyear') {
|
|
601
|
+
dateEl = document.getElementById(`${this.elementId}_${d}_monthyear`)
|
|
602
|
+
}
|
|
603
|
+
else if (this.options.mode === 'hour') {
|
|
604
|
+
dateEl = document.getElementById(`${this.elementId}_${d}_hour`)
|
|
605
|
+
}
|
|
606
|
+
if (dateEl) {
|
|
607
|
+
dateEl.classList.add('selected')
|
|
608
|
+
if (d === rangeStart) {
|
|
609
|
+
dateEl.classList.add(`${this.options.sortDirection === 'desc' ? 'last' : 'first'}`)
|
|
610
|
+
}
|
|
611
|
+
if (d === rangeEnd) {
|
|
612
|
+
dateEl.classList.add(`${this.options.sortDirection === 'desc' ? 'first' : 'last'}`)
|
|
613
|
+
}
|
|
610
614
|
}
|
|
611
615
|
}
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
this.selectedRangeDates.forEach(dIn => {
|
|
619
|
+
let d
|
|
620
|
+
let suffix = '_date'
|
|
621
|
+
if (this.options.mode === 'date') {
|
|
622
|
+
d = this.floorDate(new Date(dIn.getTime()))
|
|
623
|
+
d = d.getTime()
|
|
624
|
+
}
|
|
625
|
+
else if (this.options.mode === 'year') {
|
|
626
|
+
d = dIn
|
|
627
|
+
suffix = '_year'
|
|
628
|
+
}
|
|
629
|
+
else if (this.options.mode === 'monthyear') {
|
|
630
|
+
d = this.floorDate(new Date(dIn.getTime()).setMonth(dIn.getMonth()))
|
|
631
|
+
d = d.getTime()
|
|
632
|
+
suffix = '_monthyear'
|
|
633
|
+
}
|
|
634
|
+
else if (this.options.mode === 'hour') {
|
|
635
|
+
d = dIn
|
|
636
|
+
suffix = '_hour'
|
|
637
|
+
}
|
|
638
|
+
const dateEl = document.getElementById(`${this.elementId}_${d}${suffix}`)
|
|
639
|
+
if (dateEl) {
|
|
640
|
+
dateEl.classList.add('selected', 'first', 'last')
|
|
641
|
+
}
|
|
642
|
+
})
|
|
612
643
|
}
|
|
613
644
|
}
|
|
614
645
|
else {
|
|
@@ -876,7 +907,7 @@ class WebsyDatePicker {
|
|
|
876
907
|
}
|
|
877
908
|
else if (this.options.mode === 'hour') {
|
|
878
909
|
html += `<div id='${this.elementId}_dateList' class='websy-dp-date-list'><ul>`
|
|
879
|
-
html += this.options.hours.map(h => `<li id='${this.elementId}_${+h.text.split(':')[0]}_hour' data-hour='${h.text}' class='websy-dp-date websy-dp-hour'>${h.text}</li>`).join('')
|
|
910
|
+
html += this.options.hours.map(h => `<li id='${this.elementId}_${+h.text.split(':')[0]}_hour' data-id='${+h.text.split(':')[0]}' data-hour='${h.text}' class='websy-dp-date websy-dp-hour'>${h.text}</li>`).join('')
|
|
880
911
|
html += `</ul></div>`
|
|
881
912
|
}
|
|
882
913
|
return html
|
|
@@ -969,7 +1000,7 @@ class WebsyDatePicker {
|
|
|
969
1000
|
}
|
|
970
1001
|
selectCustomRange (rangeInput) {
|
|
971
1002
|
this.selectedRange = -1
|
|
972
|
-
|
|
1003
|
+
this.isContinuousRange = true
|
|
973
1004
|
// if (rangeInput.length === 1) {
|
|
974
1005
|
// this.selectedRangeDates = [...rangeInput]
|
|
975
1006
|
// this.customRangeSelected = true
|
|
@@ -984,21 +1015,21 @@ class WebsyDatePicker {
|
|
|
984
1015
|
if (i > 0) {
|
|
985
1016
|
if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
|
|
986
1017
|
if ((r.getTime() / this.oneDay) - (rangeInput[i - 1] / this.oneDay) > 1) {
|
|
987
|
-
isContinuousRange = false
|
|
1018
|
+
this.isContinuousRange = false
|
|
988
1019
|
}
|
|
989
1020
|
}
|
|
990
1021
|
else if (this.options.mode === 'hour' || this.options.mode === 'year') {
|
|
991
1022
|
if (r - rangeInput[i - 1] > 1) {
|
|
992
|
-
isContinuousRange = false
|
|
1023
|
+
this.isContinuousRange = false
|
|
993
1024
|
}
|
|
994
1025
|
}
|
|
995
1026
|
}
|
|
996
1027
|
})
|
|
997
|
-
if (rangeInput.length > 2 && isContinuousRange === true) {
|
|
1028
|
+
if (rangeInput.length > 2 && this.isContinuousRange === true) {
|
|
998
1029
|
this.selectedRangeDates = [rangeInput[0], rangeInput[rangeInput.length - 1]]
|
|
999
1030
|
this.customRangeSelected = true
|
|
1000
1031
|
}
|
|
1001
|
-
if (isContinuousRange === false) {
|
|
1032
|
+
if (this.isContinuousRange === false) {
|
|
1002
1033
|
this.currentselection = []
|
|
1003
1034
|
}
|
|
1004
1035
|
// check if the custom range matches a configured range
|
|
@@ -1083,7 +1114,7 @@ class WebsyDatePicker {
|
|
|
1083
1114
|
})
|
|
1084
1115
|
let start = list[0]
|
|
1085
1116
|
let end = ''
|
|
1086
|
-
if (this.customRangeSelected === true) {
|
|
1117
|
+
if (this.customRangeSelected === true && this.isContinuousRange === true) {
|
|
1087
1118
|
end = ` - ${list[list.length - 1]}`
|
|
1088
1119
|
if (this.options.mode === 'hour') {
|
|
1089
1120
|
start = this.options.hours[start].text
|
|
@@ -1438,8 +1469,9 @@ class WebsyDropdown {
|
|
|
1438
1469
|
return d
|
|
1439
1470
|
})
|
|
1440
1471
|
}
|
|
1472
|
+
this.searchText = ''
|
|
1441
1473
|
this.tooltipTimeoutFn = null
|
|
1442
|
-
this._originalData = []
|
|
1474
|
+
this._originalData = [...this.options.items]
|
|
1443
1475
|
this.selectedItems = this.options.selectedItems || []
|
|
1444
1476
|
if (!elementId) {
|
|
1445
1477
|
console.log('No element Id provided')
|
|
@@ -1625,6 +1657,7 @@ class WebsyDropdown {
|
|
|
1625
1657
|
}
|
|
1626
1658
|
handleKeyUp (event) {
|
|
1627
1659
|
if (event.target.classList.contains('websy-dropdown-search')) {
|
|
1660
|
+
this.searchText = event.target.value
|
|
1628
1661
|
if (this._originalData.length === 0) {
|
|
1629
1662
|
this._originalData = [...this.options.items]
|
|
1630
1663
|
}
|
|
@@ -1789,6 +1822,9 @@ class WebsyDropdown {
|
|
|
1789
1822
|
const inputEl = document.getElementById(`${this.elementId}_input`)
|
|
1790
1823
|
const itemEls = el.querySelectorAll(`.websy-dropdown-item`)
|
|
1791
1824
|
let dataToUse = this._originalData
|
|
1825
|
+
if (this._originalData.length === 0 && this.searchText === '') {
|
|
1826
|
+
dataToUse = this.options.items
|
|
1827
|
+
}
|
|
1792
1828
|
if (this.options.onSearch) {
|
|
1793
1829
|
dataToUse = this.options.items
|
|
1794
1830
|
}
|
|
@@ -3267,6 +3303,9 @@ class WebsyResultList {
|
|
|
3267
3303
|
const el = document.getElementById(elementId)
|
|
3268
3304
|
if (el) {
|
|
3269
3305
|
el.addEventListener('click', this.handleClick.bind(this))
|
|
3306
|
+
el.addEventListener('change', this.handleChange.bind(this))
|
|
3307
|
+
el.addEventListener('keyup', this.handleKeyUp.bind(this))
|
|
3308
|
+
el.addEventListener('keydown', this.handleKeyDown.bind(this))
|
|
3270
3309
|
}
|
|
3271
3310
|
if (typeof options.template === 'object' && options.template.url) {
|
|
3272
3311
|
this.templateService.get(options.template.url).then(templateString => {
|
|
@@ -3450,47 +3489,59 @@ class WebsyResultList {
|
|
|
3450
3489
|
}
|
|
3451
3490
|
handleClick (event) {
|
|
3452
3491
|
if (event.target.classList.contains('clickable')) {
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3492
|
+
this.handleEvent(event, 'clickable', 'click')
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
handleChange (event) {
|
|
3496
|
+
this.handleEvent(event, 'keyable', 'change')
|
|
3497
|
+
}
|
|
3498
|
+
handleKeyUp (event) {
|
|
3499
|
+
this.handleEvent(event, 'keyable', 'keyup')
|
|
3500
|
+
}
|
|
3501
|
+
handleKeyDown (event) {
|
|
3502
|
+
this.handleEvent(event, 'keyable', 'keydown')
|
|
3503
|
+
}
|
|
3504
|
+
handleEvent (event, eventType, action) {
|
|
3505
|
+
let l = event.target.getAttribute('data-event')
|
|
3506
|
+
if (l) {
|
|
3507
|
+
l = l.split('(')
|
|
3508
|
+
let params = []
|
|
3509
|
+
const id = event.target.getAttribute('data-id')
|
|
3510
|
+
const locator = event.target.getAttribute('data-locator')
|
|
3511
|
+
if (l[1]) {
|
|
3512
|
+
l[1] = l[1].replace(')', '')
|
|
3513
|
+
params = l[1].split(',')
|
|
3514
|
+
}
|
|
3515
|
+
l = l[0]
|
|
3516
|
+
let data = this.rows
|
|
3517
|
+
if (locator !== '') {
|
|
3518
|
+
let locatorItems = locator.split(';')
|
|
3519
|
+
locatorItems.forEach(loc => {
|
|
3520
|
+
let locatorParts = loc.split(':')
|
|
3521
|
+
if (data[locatorParts[0]]) {
|
|
3522
|
+
data = data[locatorParts[0]]
|
|
3523
|
+
let parts = locatorParts[1].split('.')
|
|
3524
|
+
parts.forEach(p => {
|
|
3525
|
+
data = data[p]
|
|
3526
|
+
})
|
|
3486
3527
|
}
|
|
3487
|
-
return p
|
|
3488
3528
|
})
|
|
3489
|
-
if (event.target.classList.contains('clickable') && this.options.listeners.click[l]) {
|
|
3490
|
-
event.stopPropagation()
|
|
3491
|
-
this.options.listeners.click[l].call(this, event, data[+id], ...params)
|
|
3492
|
-
}
|
|
3493
3529
|
}
|
|
3530
|
+
params = params.map(p => {
|
|
3531
|
+
if (typeof p !== 'string' && typeof p !== 'number') {
|
|
3532
|
+
if (data[+id]) {
|
|
3533
|
+
p = data[+id][p]
|
|
3534
|
+
}
|
|
3535
|
+
}
|
|
3536
|
+
else if (typeof p === 'string') {
|
|
3537
|
+
p = p.replace(/"/g, '').replace(/'/g, '')
|
|
3538
|
+
}
|
|
3539
|
+
return p
|
|
3540
|
+
})
|
|
3541
|
+
if (event.target.classList.contains(eventType) && this.options.listeners[action] && this.options.listeners[action][l]) {
|
|
3542
|
+
event.stopPropagation()
|
|
3543
|
+
this.options.listeners[action][l].call(this, event, data[+id], ...params)
|
|
3544
|
+
}
|
|
3494
3545
|
}
|
|
3495
3546
|
}
|
|
3496
3547
|
render () {
|
|
@@ -3525,7 +3576,8 @@ class WebsyRouter {
|
|
|
3525
3576
|
defaultView: '',
|
|
3526
3577
|
defaultGroup: 'main',
|
|
3527
3578
|
subscribers: { show: [], hide: [] },
|
|
3528
|
-
persistentParameters: false
|
|
3579
|
+
persistentParameters: false,
|
|
3580
|
+
fieldValueSeparator: ':'
|
|
3529
3581
|
}
|
|
3530
3582
|
this.triggerIdList = []
|
|
3531
3583
|
this.viewIdList = []
|
|
@@ -3581,7 +3633,7 @@ class WebsyRouter {
|
|
|
3581
3633
|
}
|
|
3582
3634
|
}
|
|
3583
3635
|
}
|
|
3584
|
-
addUrlParams (params, reloadView = false) {
|
|
3636
|
+
addUrlParams (params, reloadView = false, noHistory = true) {
|
|
3585
3637
|
if (typeof params === 'undefined') {
|
|
3586
3638
|
return
|
|
3587
3639
|
}
|
|
@@ -3604,11 +3656,34 @@ class WebsyRouter {
|
|
|
3604
3656
|
if (this.options.urlPrefix) {
|
|
3605
3657
|
inputPath = `/${this.options.urlPrefix}/${inputPath}`
|
|
3606
3658
|
}
|
|
3607
|
-
history.pushState({
|
|
3608
|
-
|
|
3609
|
-
},
|
|
3659
|
+
// history.pushState({
|
|
3660
|
+
// inputPath
|
|
3661
|
+
// }, 'unused', `${inputPath}?${path}`)
|
|
3610
3662
|
if (reloadView === true) {
|
|
3611
|
-
this.showView(this.currentView, this.currentParams, 'main')
|
|
3663
|
+
// this.showView(this.currentView, this.currentParams, 'main')
|
|
3664
|
+
this.navigate(`${inputPath}?${path}`, 'main', null, noHistory)
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3667
|
+
removeUrlParams (params = [], reloadView = false, noHistory = true) {
|
|
3668
|
+
this.previousParams = Object.assign({}, this.currentParams)
|
|
3669
|
+
const output = {
|
|
3670
|
+
path: '',
|
|
3671
|
+
items: {}
|
|
3672
|
+
}
|
|
3673
|
+
let path = ''
|
|
3674
|
+
if (this.currentParams && this.currentParams.items) {
|
|
3675
|
+
params.forEach(p => {
|
|
3676
|
+
delete this.currentParams.items[p]
|
|
3677
|
+
})
|
|
3678
|
+
path = this.buildUrlPath(this.currentParams.items)
|
|
3679
|
+
}
|
|
3680
|
+
let inputPath = this.currentView
|
|
3681
|
+
if (this.options.urlPrefix) {
|
|
3682
|
+
inputPath = `/${this.options.urlPrefix}/${inputPath}`
|
|
3683
|
+
}
|
|
3684
|
+
if (reloadView === true) {
|
|
3685
|
+
// this.showView(this.currentView, this.currentParams, 'main')
|
|
3686
|
+
this.navigate(`${inputPath}?${path}`, 'main', null, noHistory)
|
|
3612
3687
|
}
|
|
3613
3688
|
}
|
|
3614
3689
|
buildUrlPath (params) {
|
|
@@ -3681,6 +3756,25 @@ class WebsyRouter {
|
|
|
3681
3756
|
}
|
|
3682
3757
|
return views
|
|
3683
3758
|
}
|
|
3759
|
+
getParamValues (param) {
|
|
3760
|
+
let output = []
|
|
3761
|
+
if (this.currentParams && this.currentParams.items && this.currentParams.items[param] && this.currentParams.items[param] !== '') {
|
|
3762
|
+
return this.currentParams.items[param].split('|').map(d => decodeURI(d))
|
|
3763
|
+
}
|
|
3764
|
+
return output
|
|
3765
|
+
}
|
|
3766
|
+
getAPIQuery (ignoredParams = []) {
|
|
3767
|
+
if (this.currentParams && this.currentParams.items) {
|
|
3768
|
+
let query = []
|
|
3769
|
+
for (const key in this.currentParams.items) {
|
|
3770
|
+
if (ignoredParams.indexOf(key) === -1) {
|
|
3771
|
+
query.push(`${key}${this.options.fieldValueSeparator}${this.currentParams.items[key]}`)
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
return query
|
|
3775
|
+
}
|
|
3776
|
+
return []
|
|
3777
|
+
}
|
|
3684
3778
|
handleClick (event) {
|
|
3685
3779
|
// const id = event.target.id
|
|
3686
3780
|
if (event.target.classList.contains(this.options.triggerClass)) {
|
|
@@ -3704,17 +3798,18 @@ class WebsyRouter {
|
|
|
3704
3798
|
if (typeof params !== 'undefined') {
|
|
3705
3799
|
url += `?${params.path}`
|
|
3706
3800
|
}
|
|
3707
|
-
this.
|
|
3708
|
-
this.
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3801
|
+
this.navigate(url)
|
|
3802
|
+
// this.currentView = view
|
|
3803
|
+
// this.currentViewMain = view
|
|
3804
|
+
// if (this.currentView === '/' || this.currentView === '') {
|
|
3805
|
+
// this.currentView = this.options.defaultView
|
|
3806
|
+
// }
|
|
3807
|
+
// if (this.currentViewMain === '/' || this.currentViewMain === '') {
|
|
3808
|
+
// this.currentViewMain = this.options.defaultView
|
|
3809
|
+
// }
|
|
3810
|
+
// if (view !== '') {
|
|
3811
|
+
// this.showView(view, params, 'main')
|
|
3812
|
+
// }
|
|
3718
3813
|
}
|
|
3719
3814
|
handleFocus (event) {
|
|
3720
3815
|
this.controlPressed = false
|
|
@@ -3979,27 +4074,29 @@ class WebsyRouter {
|
|
|
3979
4074
|
if (this.usesHTMLSuffix === true) {
|
|
3980
4075
|
inputPath = window.location.pathname.split('/').pop() + inputPath
|
|
3981
4076
|
}
|
|
3982
|
-
if ((this.currentPath !==
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
4077
|
+
if ((this.currentPath !== inputPath || previousParamsPath !== this.currentParams.path) && group === this.options.defaultGroup) {
|
|
4078
|
+
let historyUrl = inputPath
|
|
4079
|
+
if (this.options.urlPrefix) {
|
|
4080
|
+
historyUrl = historyUrl === '/' ? '' : `/${historyUrl}`
|
|
4081
|
+
inputPath = inputPath === '/' ? '' : `/${inputPath}`
|
|
4082
|
+
historyUrl = (`/${this.options.urlPrefix}${historyUrl}`).replace(/\/\//g, '/')
|
|
4083
|
+
inputPath = (`/${this.options.urlPrefix}${inputPath}`).replace(/\/\//g, '/')
|
|
4084
|
+
}
|
|
4085
|
+
if (this.currentParams && this.currentParams.path) {
|
|
4086
|
+
historyUrl += `?${this.currentParams.path}`
|
|
4087
|
+
}
|
|
4088
|
+
else if (this.queryParams && this.options.persistentParameters === true) {
|
|
4089
|
+
historyUrl += `?${this.queryParams}`
|
|
4090
|
+
}
|
|
4091
|
+
if (popped === false) {
|
|
3997
4092
|
history.pushState({
|
|
3998
|
-
inputPath
|
|
3999
|
-
},
|
|
4093
|
+
inputPath: historyUrl
|
|
4094
|
+
}, 'unused', historyUrl)
|
|
4000
4095
|
}
|
|
4001
4096
|
else {
|
|
4002
|
-
|
|
4097
|
+
history.replaceState({
|
|
4098
|
+
inputPath: historyUrl
|
|
4099
|
+
}, 'unused', historyUrl)
|
|
4003
4100
|
}
|
|
4004
4101
|
}
|
|
4005
4102
|
if (toggle === false) {
|