@websy/websy-designs 1.4.0 → 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.
@@ -37,7 +37,9 @@
37
37
  class APIService {
38
38
  constructor (baseUrl = '', options = {}) {
39
39
  this.baseUrl = baseUrl
40
- this.options = Object.assign({}, options)
40
+ this.options = Object.assign({}, {
41
+ fieldValueSeparator: ':'
42
+ }, options)
41
43
  }
42
44
  add (entity, data, options = {}) {
43
45
  const url = this.buildUrl(entity)
@@ -48,7 +50,7 @@ class APIService {
48
50
  query = []
49
51
  }
50
52
  if (id) {
51
- query.push(`id:${id}`)
53
+ query.push(`id${this.options.fieldValueSeparator}${id}`)
52
54
  }
53
55
  return `${this.baseUrl}/${entity}${query.length > 0 ? `${entity.indexOf('?') === -1 ? '?' : '&'}where=${query.join(';')}` : ''}`
54
56
  }
@@ -243,6 +245,9 @@ class WebsyCarousel {
243
245
  this.render()
244
246
  }
245
247
  }
248
+ close () {
249
+ this.pause()
250
+ }
246
251
  handleClick (event) {
247
252
  if (event.target.classList.contains('websy-next-arrow')) {
248
253
  this.next()
@@ -347,17 +352,17 @@ class WebsyCarousel {
347
352
  }
348
353
  if (this.options.showPrevNext === true && this.options.frames.length > 1) {
349
354
  html += `
350
- <svg xmlns="http://www.w3.org/2000/svg" class="websy-prev-arrow"
351
- viewBox="0 0 512 512">
352
- <title>Caret Back</title>
353
- <path d="M321.94 98L158.82 237.78a24 24 0 000 36.44L321.94 414c15.57 13.34 39.62 2.28 39.62-18.22v-279.6c0-20.5-24.05-31.56-39.62-18.18z"/>
354
- </svg>
355
-
356
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="websy-next-arrow">
357
- <title>Caret Forward</title>
358
- <path d="M190.06 414l163.12-139.78a24 24 0 000-36.44L190.06 98c-15.57-13.34-39.62-2.28-39.62 18.22v279.6c0 20.5 24.05 31.56 39.62 18.18z"/>
359
- </svg>
360
- `
355
+ <svg xmlns="http://www.w3.org/2000/svg" class="websy-prev-arrow"
356
+ viewBox="0 0 512 512">
357
+ <title>Caret Back</title>
358
+ <path d="M321.94 98L158.82 237.78a24 24 0 000 36.44L321.94 414c15.57 13.34 39.62 2.28 39.62-18.22v-279.6c0-20.5-24.05-31.56-39.62-18.18z"/>
359
+ </svg>
360
+
361
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="websy-next-arrow">
362
+ <title>Caret Forward</title>
363
+ <path d="M190.06 414l163.12-139.78a24 24 0 000-36.44L190.06 98c-15.57-13.34-39.62-2.28-39.62 18.22v279.6c0 20.5 24.05 31.56 39.62 18.18z"/>
364
+ </svg>
365
+ `
361
366
  }
362
367
  html += `
363
368
  </div>
@@ -380,22 +385,30 @@ class WebsyCarousel {
380
385
  nextTranslateX = '-101%'
381
386
  }
382
387
  const prevF = document.getElementById(
383
- `${this.elementId}_frame_${prevFrameIndex}`)
384
- setTimeout(() => {
385
- prevF.style.transform = `translateX(${prevTranslateX})`
386
- }, 100)
388
+ `${this.elementId}_frame_${prevFrameIndex}`)
389
+ if (prevF) {
390
+ setTimeout(() => {
391
+ prevF.style.transform = `translateX(${prevTranslateX})`
392
+ }, 100)
393
+ }
387
394
  const btnInactive = document.getElementById(`${this.elementId}_selector_${prevFrameIndex}`)
388
- btnInactive.classList.remove('websy-progress-btn-active')
395
+ if (btnInactive) {
396
+ btnInactive.classList.remove('websy-progress-btn-active')
397
+ }
389
398
  const newF = document.getElementById(`${this.elementId}_frame_${currFrameIndex}`)
390
- newF.classList.remove('animate')
391
- newF.style.transform = `translateX(${nextTranslateX})`
392
- setTimeout(() => {
393
- newF.classList.add('animate')
394
- newF.style.transform = 'translateX(0%)'
395
- }, 100)
399
+ if (newF) {
400
+ newF.classList.remove('animate')
401
+ newF.style.transform = `translateX(${nextTranslateX})`
402
+ setTimeout(() => {
403
+ newF.classList.add('animate')
404
+ newF.style.transform = 'translateX(0%)'
405
+ }, 100)
406
+ }
396
407
 
397
408
  const btnActive = document.getElementById(`${this.elementId}_selector_${currFrameIndex}`)
398
- btnActive.classList.add('websy-progress-btn-active')
409
+ if (btnActive) {
410
+ btnActive.classList.add('websy-progress-btn-active')
411
+ }
399
412
  }
400
413
 
401
414
  // showFrameSelector () {
@@ -724,78 +737,107 @@ class WebsyDatePicker {
724
737
  if (this.selectedRange === 0) {
725
738
  return
726
739
  }
727
- if (this.customRangeSelected === true) {
728
- let diff
729
- if (this.options.mode === 'date') {
730
- diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime() - this.selectedRangeDates[0].getTime()) / this.oneDay)
731
- // if (this.selectedRangeDates[0].getMonth() !== this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth()) {
732
- // diff += 1
733
- // }
734
- }
735
- else if (this.options.mode === 'year') {
736
- diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0]
737
- if (this.selectedRangeDates[this.selectedRangeDates.length - 1] !== this.selectedRangeDates[0]) {
738
- // diff += 1
739
- }
740
- }
741
- else if (this.options.mode === 'monthyear') {
742
- let yearDiff = (this.selectedRangeDates[this.selectedRangeDates.length - 1].getFullYear() - this.selectedRangeDates[0].getFullYear()) * 12
743
- diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth() - this.selectedRangeDates[0].getMonth())) + yearDiff
744
- }
745
- else if (this.options.mode === 'hour') {
746
- diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0]
747
- }
748
- for (let i = 0; i < diff + 1; i++) {
749
- let d
750
- let rangeStart
751
- let rangeEnd
752
- if (this.options.mode === 'date') {
753
- d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + (i * this.oneDay)))
754
- // d.setUTCHours(12, 0, 0, 0)
755
- d = d.getTime()
756
- // console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
757
- rangeStart = this.selectedRangeDates[0].getTime()
758
- rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
759
- }
760
- else if (this.options.mode === 'year') {
761
- d = this.selectedRangeDates[0] + i
762
- rangeStart = this.selectedRangeDates[0]
763
- rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
764
- }
765
- else if (this.options.mode === 'monthyear') {
766
- d = this.floorDate(new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + i))
767
- d = d.getTime()
768
- console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
769
- rangeStart = this.selectedRangeDates[0].getTime()
770
- rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
771
- }
772
- else if (this.options.mode === 'hour') {
773
- d = this.selectedRangeDates[0] + i
774
- rangeStart = this.selectedRangeDates[0]
775
- rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
776
- }
777
- let dateEl
740
+ if (this.customRangeSelected === true) {
741
+ if (this.isContinuousRange || this.mouseDown) {
742
+ let diff
778
743
  if (this.options.mode === 'date') {
779
- dateEl = document.getElementById(`${this.elementId}_${d}_date`)
780
- }
744
+ diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime() - this.selectedRangeDates[0].getTime()) / this.oneDay)
745
+ // if (this.selectedRangeDates[0].getMonth() !== this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth()) {
746
+ // diff += 1
747
+ // }
748
+ }
781
749
  else if (this.options.mode === 'year') {
782
- dateEl = document.getElementById(`${this.elementId}_${d}_year`)
783
- }
784
- else if (this.options.mode === 'monthyear') {
785
- dateEl = document.getElementById(`${this.elementId}_${d}_monthyear`)
750
+ diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0]
751
+ if (this.selectedRangeDates[this.selectedRangeDates.length - 1] !== this.selectedRangeDates[0]) {
752
+ // diff += 1
753
+ }
754
+ }
755
+ else if (this.options.mode === 'monthyear') {
756
+ let yearDiff = (this.selectedRangeDates[this.selectedRangeDates.length - 1].getFullYear() - this.selectedRangeDates[0].getFullYear()) * 12
757
+ diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth() - this.selectedRangeDates[0].getMonth())) + yearDiff
786
758
  }
787
759
  else if (this.options.mode === 'hour') {
788
- dateEl = document.getElementById(`${this.elementId}_${d}_hour`)
789
- }
790
- if (dateEl) {
791
- dateEl.classList.add('selected')
792
- if (d === rangeStart) {
793
- dateEl.classList.add(`${this.options.sortDirection === 'desc' ? 'last' : 'first'}`)
760
+ diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0]
761
+ }
762
+ for (let i = 0; i < diff + 1; i++) {
763
+ let d
764
+ let rangeStart
765
+ let rangeEnd
766
+ if (this.options.mode === 'date') {
767
+ d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + (i * this.oneDay)))
768
+ // d.setUTCHours(12, 0, 0, 0)
769
+ d = d.getTime()
770
+ // console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
771
+ rangeStart = this.selectedRangeDates[0].getTime()
772
+ rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
773
+ }
774
+ else if (this.options.mode === 'year') {
775
+ d = this.selectedRangeDates[0] + i
776
+ rangeStart = this.selectedRangeDates[0]
777
+ rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
778
+ }
779
+ else if (this.options.mode === 'monthyear') {
780
+ d = this.floorDate(new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + i))
781
+ d = d.getTime()
782
+ console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
783
+ rangeStart = this.selectedRangeDates[0].getTime()
784
+ rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
785
+ }
786
+ else if (this.options.mode === 'hour') {
787
+ d = this.selectedRangeDates[0] + i
788
+ rangeStart = this.selectedRangeDates[0]
789
+ rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
790
+ }
791
+ let dateEl
792
+ if (this.options.mode === 'date') {
793
+ dateEl = document.getElementById(`${this.elementId}_${d}_date`)
794
+ }
795
+ else if (this.options.mode === 'year') {
796
+ dateEl = document.getElementById(`${this.elementId}_${d}_year`)
794
797
  }
795
- if (d === rangeEnd) {
796
- dateEl.classList.add(`${this.options.sortDirection === 'desc' ? 'first' : 'last'}`)
798
+ else if (this.options.mode === 'monthyear') {
799
+ dateEl = document.getElementById(`${this.elementId}_${d}_monthyear`)
800
+ }
801
+ else if (this.options.mode === 'hour') {
802
+ dateEl = document.getElementById(`${this.elementId}_${d}_hour`)
803
+ }
804
+ if (dateEl) {
805
+ dateEl.classList.add('selected')
806
+ if (d === rangeStart) {
807
+ dateEl.classList.add(`${this.options.sortDirection === 'desc' ? 'last' : 'first'}`)
808
+ }
809
+ if (d === rangeEnd) {
810
+ dateEl.classList.add(`${this.options.sortDirection === 'desc' ? 'first' : 'last'}`)
811
+ }
797
812
  }
798
813
  }
814
+ }
815
+ else {
816
+ this.selectedRangeDates.forEach(dIn => {
817
+ let d
818
+ let suffix = '_date'
819
+ if (this.options.mode === 'date') {
820
+ d = this.floorDate(new Date(dIn.getTime()))
821
+ d = d.getTime()
822
+ }
823
+ else if (this.options.mode === 'year') {
824
+ d = dIn
825
+ suffix = '_year'
826
+ }
827
+ else if (this.options.mode === 'monthyear') {
828
+ d = this.floorDate(new Date(dIn.getTime()).setMonth(dIn.getMonth()))
829
+ d = d.getTime()
830
+ suffix = '_monthyear'
831
+ }
832
+ else if (this.options.mode === 'hour') {
833
+ d = dIn
834
+ suffix = '_hour'
835
+ }
836
+ const dateEl = document.getElementById(`${this.elementId}_${d}${suffix}`)
837
+ if (dateEl) {
838
+ dateEl.classList.add('selected', 'first', 'last')
839
+ }
840
+ })
799
841
  }
800
842
  }
801
843
  else {
@@ -1063,7 +1105,7 @@ class WebsyDatePicker {
1063
1105
  }
1064
1106
  else if (this.options.mode === 'hour') {
1065
1107
  html += `<div id='${this.elementId}_dateList' class='websy-dp-date-list'><ul>`
1066
- 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('')
1108
+ 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('')
1067
1109
  html += `</ul></div>`
1068
1110
  }
1069
1111
  return html
@@ -1156,7 +1198,7 @@ class WebsyDatePicker {
1156
1198
  }
1157
1199
  selectCustomRange (rangeInput) {
1158
1200
  this.selectedRange = -1
1159
- let isContinuousRange = true
1201
+ this.isContinuousRange = true
1160
1202
  // if (rangeInput.length === 1) {
1161
1203
  // this.selectedRangeDates = [...rangeInput]
1162
1204
  // this.customRangeSelected = true
@@ -1171,21 +1213,21 @@ class WebsyDatePicker {
1171
1213
  if (i > 0) {
1172
1214
  if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
1173
1215
  if ((r.getTime() / this.oneDay) - (rangeInput[i - 1] / this.oneDay) > 1) {
1174
- isContinuousRange = false
1216
+ this.isContinuousRange = false
1175
1217
  }
1176
1218
  }
1177
1219
  else if (this.options.mode === 'hour' || this.options.mode === 'year') {
1178
1220
  if (r - rangeInput[i - 1] > 1) {
1179
- isContinuousRange = false
1221
+ this.isContinuousRange = false
1180
1222
  }
1181
1223
  }
1182
1224
  }
1183
1225
  })
1184
- if (rangeInput.length > 2 && isContinuousRange === true) {
1226
+ if (rangeInput.length > 2 && this.isContinuousRange === true) {
1185
1227
  this.selectedRangeDates = [rangeInput[0], rangeInput[rangeInput.length - 1]]
1186
1228
  this.customRangeSelected = true
1187
1229
  }
1188
- if (isContinuousRange === false) {
1230
+ if (this.isContinuousRange === false) {
1189
1231
  this.currentselection = []
1190
1232
  }
1191
1233
  // check if the custom range matches a configured range
@@ -1270,7 +1312,7 @@ class WebsyDatePicker {
1270
1312
  })
1271
1313
  let start = list[0]
1272
1314
  let end = ''
1273
- if (this.customRangeSelected === true) {
1315
+ if (this.customRangeSelected === true && this.isContinuousRange === true) {
1274
1316
  end = ` - ${list[list.length - 1]}`
1275
1317
  if (this.options.mode === 'hour') {
1276
1318
  start = this.options.hours[start].text
@@ -1347,8 +1389,9 @@ class WebsyDropdown {
1347
1389
  return d
1348
1390
  })
1349
1391
  }
1392
+ this.searchText = ''
1350
1393
  this.tooltipTimeoutFn = null
1351
- this._originalData = []
1394
+ this._originalData = [...this.options.items]
1352
1395
  this.selectedItems = this.options.selectedItems || []
1353
1396
  if (!elementId) {
1354
1397
  console.log('No element Id provided')
@@ -1534,6 +1577,7 @@ class WebsyDropdown {
1534
1577
  }
1535
1578
  handleKeyUp (event) {
1536
1579
  if (event.target.classList.contains('websy-dropdown-search')) {
1580
+ this.searchText = event.target.value
1537
1581
  if (this._originalData.length === 0) {
1538
1582
  this._originalData = [...this.options.items]
1539
1583
  }
@@ -1698,6 +1742,9 @@ class WebsyDropdown {
1698
1742
  const inputEl = document.getElementById(`${this.elementId}_input`)
1699
1743
  const itemEls = el.querySelectorAll(`.websy-dropdown-item`)
1700
1744
  let dataToUse = this._originalData
1745
+ if (this._originalData.length === 0 && this.searchText === '') {
1746
+ dataToUse = this.options.items
1747
+ }
1701
1748
  if (this.options.onSearch) {
1702
1749
  dataToUse = this.options.items
1703
1750
  }
@@ -3515,6 +3562,9 @@ class WebsyResultList {
3515
3562
  const el = document.getElementById(elementId)
3516
3563
  if (el) {
3517
3564
  el.addEventListener('click', this.handleClick.bind(this))
3565
+ el.addEventListener('change', this.handleChange.bind(this))
3566
+ el.addEventListener('keyup', this.handleKeyUp.bind(this))
3567
+ el.addEventListener('keydown', this.handleKeyDown.bind(this))
3518
3568
  }
3519
3569
  if (typeof options.template === 'object' && options.template.url) {
3520
3570
  this.templateService.get(options.template.url).then(templateString => {
@@ -3698,47 +3748,59 @@ class WebsyResultList {
3698
3748
  }
3699
3749
  handleClick (event) {
3700
3750
  if (event.target.classList.contains('clickable')) {
3701
- let l = event.target.getAttribute('data-event')
3702
- if (l) {
3703
- l = l.split('(')
3704
- let params = []
3705
- const id = event.target.getAttribute('data-id')
3706
- const locator = event.target.getAttribute('data-locator')
3707
- if (l[1]) {
3708
- l[1] = l[1].replace(')', '')
3709
- params = l[1].split(',')
3710
- }
3711
- l = l[0]
3712
- let data = this.rows
3713
- if (locator !== '') {
3714
- let locatorItems = locator.split(';')
3715
- locatorItems.forEach(loc => {
3716
- let locatorParts = loc.split(':')
3717
- if (data[locatorParts[0]]) {
3718
- data = data[locatorParts[0]]
3719
- let parts = locatorParts[1].split('.')
3720
- parts.forEach(p => {
3721
- data = data[p]
3722
- })
3723
- }
3724
- })
3725
- }
3726
- params = params.map(p => {
3727
- if (typeof p !== 'string' && typeof p !== 'number') {
3728
- if (data[+id]) {
3729
- p = data[+id][p]
3730
- }
3731
- }
3732
- else if (typeof p === 'string') {
3733
- p = p.replace(/"/g, '').replace(/'/g, '')
3751
+ this.handleEvent(event, 'clickable', 'click')
3752
+ }
3753
+ }
3754
+ handleChange (event) {
3755
+ this.handleEvent(event, 'keyable', 'change')
3756
+ }
3757
+ handleKeyUp (event) {
3758
+ this.handleEvent(event, 'keyable', 'keyup')
3759
+ }
3760
+ handleKeyDown (event) {
3761
+ this.handleEvent(event, 'keyable', 'keydown')
3762
+ }
3763
+ handleEvent (event, eventType, action) {
3764
+ let l = event.target.getAttribute('data-event')
3765
+ if (l) {
3766
+ l = l.split('(')
3767
+ let params = []
3768
+ const id = event.target.getAttribute('data-id')
3769
+ const locator = event.target.getAttribute('data-locator')
3770
+ if (l[1]) {
3771
+ l[1] = l[1].replace(')', '')
3772
+ params = l[1].split(',')
3773
+ }
3774
+ l = l[0]
3775
+ let data = this.rows
3776
+ if (locator !== '') {
3777
+ let locatorItems = locator.split(';')
3778
+ locatorItems.forEach(loc => {
3779
+ let locatorParts = loc.split(':')
3780
+ if (data[locatorParts[0]]) {
3781
+ data = data[locatorParts[0]]
3782
+ let parts = locatorParts[1].split('.')
3783
+ parts.forEach(p => {
3784
+ data = data[p]
3785
+ })
3734
3786
  }
3735
- return p
3736
3787
  })
3737
- if (event.target.classList.contains('clickable') && this.options.listeners.click[l]) {
3738
- event.stopPropagation()
3739
- this.options.listeners.click[l].call(this, event, data[+id], ...params)
3740
- }
3741
3788
  }
3789
+ params = params.map(p => {
3790
+ if (typeof p !== 'string' && typeof p !== 'number') {
3791
+ if (data[+id]) {
3792
+ p = data[+id][p]
3793
+ }
3794
+ }
3795
+ else if (typeof p === 'string') {
3796
+ p = p.replace(/"/g, '').replace(/'/g, '')
3797
+ }
3798
+ return p
3799
+ })
3800
+ if (event.target.classList.contains(eventType) && this.options.listeners[action] && this.options.listeners[action][l]) {
3801
+ event.stopPropagation()
3802
+ this.options.listeners[action][l].call(this, event, data[+id], ...params)
3803
+ }
3742
3804
  }
3743
3805
  }
3744
3806
  render () {
@@ -3773,7 +3835,8 @@ class WebsyRouter {
3773
3835
  defaultView: '',
3774
3836
  defaultGroup: 'main',
3775
3837
  subscribers: { show: [], hide: [] },
3776
- persistentParameters: false
3838
+ persistentParameters: false,
3839
+ fieldValueSeparator: ':'
3777
3840
  }
3778
3841
  this.triggerIdList = []
3779
3842
  this.viewIdList = []
@@ -3829,7 +3892,7 @@ class WebsyRouter {
3829
3892
  }
3830
3893
  }
3831
3894
  }
3832
- addUrlParams (params, reloadView = false) {
3895
+ addUrlParams (params, reloadView = false, noHistory = true) {
3833
3896
  if (typeof params === 'undefined') {
3834
3897
  return
3835
3898
  }
@@ -3852,11 +3915,34 @@ class WebsyRouter {
3852
3915
  if (this.options.urlPrefix) {
3853
3916
  inputPath = `/${this.options.urlPrefix}/${inputPath}`
3854
3917
  }
3855
- history.pushState({
3856
- inputPath
3857
- }, inputPath, `${inputPath}?${path}`)
3918
+ // history.pushState({
3919
+ // inputPath
3920
+ // }, 'unused', `${inputPath}?${path}`)
3858
3921
  if (reloadView === true) {
3859
- this.showView(this.currentView, this.currentParams, 'main')
3922
+ // this.showView(this.currentView, this.currentParams, 'main')
3923
+ this.navigate(`${inputPath}?${path}`, 'main', null, noHistory)
3924
+ }
3925
+ }
3926
+ removeUrlParams (params = [], reloadView = false, noHistory = true) {
3927
+ this.previousParams = Object.assign({}, this.currentParams)
3928
+ const output = {
3929
+ path: '',
3930
+ items: {}
3931
+ }
3932
+ let path = ''
3933
+ if (this.currentParams && this.currentParams.items) {
3934
+ params.forEach(p => {
3935
+ delete this.currentParams.items[p]
3936
+ })
3937
+ path = this.buildUrlPath(this.currentParams.items)
3938
+ }
3939
+ let inputPath = this.currentView
3940
+ if (this.options.urlPrefix) {
3941
+ inputPath = `/${this.options.urlPrefix}/${inputPath}`
3942
+ }
3943
+ if (reloadView === true) {
3944
+ // this.showView(this.currentView, this.currentParams, 'main')
3945
+ this.navigate(`${inputPath}?${path}`, 'main', null, noHistory)
3860
3946
  }
3861
3947
  }
3862
3948
  buildUrlPath (params) {
@@ -3929,6 +4015,25 @@ class WebsyRouter {
3929
4015
  }
3930
4016
  return views
3931
4017
  }
4018
+ getParamValues (param) {
4019
+ let output = []
4020
+ if (this.currentParams && this.currentParams.items && this.currentParams.items[param] && this.currentParams.items[param] !== '') {
4021
+ return this.currentParams.items[param].split('|').map(d => decodeURI(d))
4022
+ }
4023
+ return output
4024
+ }
4025
+ getAPIQuery (ignoredParams = []) {
4026
+ if (this.currentParams && this.currentParams.items) {
4027
+ let query = []
4028
+ for (const key in this.currentParams.items) {
4029
+ if (ignoredParams.indexOf(key) === -1) {
4030
+ query.push(`${key}${this.options.fieldValueSeparator}${this.currentParams.items[key]}`)
4031
+ }
4032
+ }
4033
+ return query
4034
+ }
4035
+ return []
4036
+ }
3932
4037
  handleClick (event) {
3933
4038
  // const id = event.target.id
3934
4039
  if (event.target.classList.contains(this.options.triggerClass)) {
@@ -3952,17 +4057,18 @@ class WebsyRouter {
3952
4057
  if (typeof params !== 'undefined') {
3953
4058
  url += `?${params.path}`
3954
4059
  }
3955
- this.currentView = view
3956
- this.currentViewMain = view
3957
- if (this.currentView === '/' || this.currentView === '') {
3958
- this.currentView = this.options.defaultView
3959
- }
3960
- if (this.currentViewMain === '/' || this.currentViewMain === '') {
3961
- this.currentViewMain = this.options.defaultView
3962
- }
3963
- if (view !== '') {
3964
- this.showView(view, params, 'main')
3965
- }
4060
+ this.navigate(url)
4061
+ // this.currentView = view
4062
+ // this.currentViewMain = view
4063
+ // if (this.currentView === '/' || this.currentView === '') {
4064
+ // this.currentView = this.options.defaultView
4065
+ // }
4066
+ // if (this.currentViewMain === '/' || this.currentViewMain === '') {
4067
+ // this.currentViewMain = this.options.defaultView
4068
+ // }
4069
+ // if (view !== '') {
4070
+ // this.showView(view, params, 'main')
4071
+ // }
3966
4072
  }
3967
4073
  handleFocus (event) {
3968
4074
  this.controlPressed = false
@@ -4227,27 +4333,29 @@ class WebsyRouter {
4227
4333
  if (this.usesHTMLSuffix === true) {
4228
4334
  inputPath = window.location.pathname.split('/').pop() + inputPath
4229
4335
  }
4230
- if ((this.currentPath !== newPath || previousParamsPath !== this.currentParams.path) && group === this.options.defaultGroup) {
4231
- if (popped === false) {
4232
- let historyUrl = inputPath
4233
- if (this.options.urlPrefix) {
4234
- historyUrl = historyUrl === '/' ? '' : `/${historyUrl}`
4235
- inputPath = inputPath === '/' ? '' : `/${inputPath}`
4236
- historyUrl = (`/${this.options.urlPrefix}${historyUrl}`).replace(/\/\//g, '/')
4237
- inputPath = (`/${this.options.urlPrefix}${inputPath}`).replace(/\/\//g, '/')
4238
- }
4239
- if (this.currentParams && this.currentParams.path) {
4240
- historyUrl += `?${this.currentParams.path}`
4241
- }
4242
- else if (this.queryParams && this.options.persistentParameters === true) {
4243
- historyUrl += `?${this.queryParams}`
4244
- }
4336
+ if ((this.currentPath !== inputPath || previousParamsPath !== this.currentParams.path) && group === this.options.defaultGroup) {
4337
+ let historyUrl = inputPath
4338
+ if (this.options.urlPrefix) {
4339
+ historyUrl = historyUrl === '/' ? '' : `/${historyUrl}`
4340
+ inputPath = inputPath === '/' ? '' : `/${inputPath}`
4341
+ historyUrl = (`/${this.options.urlPrefix}${historyUrl}`).replace(/\/\//g, '/')
4342
+ inputPath = (`/${this.options.urlPrefix}${inputPath}`).replace(/\/\//g, '/')
4343
+ }
4344
+ if (this.currentParams && this.currentParams.path) {
4345
+ historyUrl += `?${this.currentParams.path}`
4346
+ }
4347
+ else if (this.queryParams && this.options.persistentParameters === true) {
4348
+ historyUrl += `?${this.queryParams}`
4349
+ }
4350
+ if (popped === false) {
4245
4351
  history.pushState({
4246
- inputPath
4247
- }, inputPath, historyUrl)
4352
+ inputPath: historyUrl
4353
+ }, 'unused', historyUrl)
4248
4354
  }
4249
4355
  else {
4250
- //
4356
+ history.replaceState({
4357
+ inputPath: historyUrl
4358
+ }, 'unused', historyUrl)
4251
4359
  }
4252
4360
  }
4253
4361
  if (toggle === false) {
@@ -4408,6 +4516,12 @@ class WebsySearch {
4408
4516
  }
4409
4517
  }
4410
4518
  }
4519
+ set text (text) {
4520
+ const el = document.getElementById(`${this.elementId}_search`)
4521
+ if (el) {
4522
+ el.value = text
4523
+ }
4524
+ }
4411
4525
  }
4412
4526
 
4413
4527
  /* global WebsyDesigns ENVIRONMENT */
@@ -6567,6 +6681,7 @@ class WebsyChart {
6567
6681
  this.rightAxis = null
6568
6682
  this.topAxis = null
6569
6683
  this.bottomAxis = null
6684
+ this.renderedKeys = {}
6570
6685
  if (!elementId) {
6571
6686
  console.log('No element Id provided for Websy Chart')
6572
6687
  return
@@ -7339,7 +7454,16 @@ else {
7339
7454
  // put the title horizontally on the top
7340
7455
  }
7341
7456
  }
7457
+ // Remove the unnecessary series
7458
+ let newKeys = this.options.data.series.map(s => s.key)
7459
+ for (const key in this.renderedKeys) {
7460
+ if (newKeys.indexOf(key) === -1) {
7461
+ // remove the components
7462
+ this[`remove${this.renderedKeys[key]}`](key)
7463
+ }
7464
+ }
7342
7465
  // Draw the series data
7466
+ this.renderedKeys = {}
7343
7467
  this.options.data.series.forEach((series, index) => {
7344
7468
  if (!series.key) {
7345
7469
  series.key = this.createIdentity()
@@ -7349,6 +7473,7 @@ else {
7349
7473
  }
7350
7474
  this[`render${series.type || 'bar'}`](series, index)
7351
7475
  this.renderLabels(series, index)
7476
+ this.renderedKeys[series.key] = series.type
7352
7477
  })
7353
7478
  }
7354
7479
  }
@@ -7682,6 +7807,14 @@ if (series.showSymbols === true) {
7682
7807
  this.rendersymbol(series, index)
7683
7808
  }
7684
7809
 
7810
+ }
7811
+ removeline (key) {
7812
+ /* global key d3 */
7813
+ let lines = this.lineLayer.selectAll(`.line_${key}`)
7814
+ .transition(this.transition)
7815
+ .style('stroke-opacity', 1e-6)
7816
+ .remove()
7817
+
7685
7818
  }
7686
7819
  rendersymbol (series, index) {
7687
7820
  /* global d3 series index series.key */