@websy/websy-designs 1.11.0 → 1.11.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.
@@ -2008,7 +2008,8 @@ class WebsyDropdown {
2008
2008
  }
2009
2009
  get value () {
2010
2010
  if (this.selectedItems && this.selectedItems.length > 0) {
2011
- return this.selectedItems.map((d, i) => this.options.items[+d])
2011
+ // return this.selectedItems.map((d, i) => this.options.items[+d])
2012
+ return this.selectedItems.map((d, i) => this._originalData[+d])
2012
2013
  }
2013
2014
  return []
2014
2015
  }
@@ -3659,7 +3660,7 @@ class WebsyPDFButton {
3659
3660
  else {
3660
3661
  fileName = this.options.fileName || 'Export'
3661
3662
  }
3662
- msg += `download='${fileName}.pdf'`
3663
+ msg += `download="${fileName.replace(/'/g, '')}.pdf"`
3663
3664
  }
3664
3665
  msg += `
3665
3666
  >
@@ -4370,7 +4371,11 @@ class WebsyResultList {
4370
4371
  }
4371
4372
  }
4372
4373
 
4373
- /* global history */
4374
+ /*
4375
+ global
4376
+ history
4377
+ WebsyDesigns
4378
+ */
4374
4379
  class WebsyRouter {
4375
4380
  constructor (options) {
4376
4381
  const defaults = {
@@ -4385,8 +4390,10 @@ class WebsyRouter {
4385
4390
  defaultGroup: 'main',
4386
4391
  subscribers: { show: [], hide: [] },
4387
4392
  persistentParameters: false,
4388
- fieldValueSeparator: ':'
4393
+ fieldValueSeparator: ':',
4394
+ views: {}
4389
4395
  }
4396
+ this.apiService = new WebsyDesigns.APIService('')
4390
4397
  this.triggerIdList = []
4391
4398
  this.viewIdList = []
4392
4399
  this.previousPath = ''
@@ -4419,7 +4426,7 @@ class WebsyRouter {
4419
4426
  }
4420
4427
  addGroup (group) {
4421
4428
  if (!this.groups[group]) {
4422
- const els = document.querySelectorAll(`.websy-view[data-group="${group}"]`)
4429
+ const els = document.querySelectorAll(`.${this.options.viewClass}[data-group="${group}"]`)
4423
4430
  if (els) {
4424
4431
  this.getClosestParent(els[0], parent => {
4425
4432
  this.groups[group] = {
@@ -4538,9 +4545,9 @@ class WebsyRouter {
4538
4545
  if (!this.groups) {
4539
4546
  this.groups = {}
4540
4547
  }
4541
- const parentEl = document.querySelector(`.websy-view[data-view="${parent}"]`)
4548
+ const parentEl = document.querySelector(`.${this.options.viewClass}[data-view="${parent}"]`)
4542
4549
  if (parentEl) {
4543
- const els = parentEl.querySelectorAll(`.websy-view[data-group]`)
4550
+ const els = parentEl.querySelectorAll(`.${this.options.viewClass}[data-group]`)
4544
4551
  for (let i = 0; i < els.length; i++) {
4545
4552
  const g = els[i].getAttribute('data-group')
4546
4553
  const v = els[i].getAttribute('data-view')
@@ -4798,27 +4805,85 @@ class WebsyRouter {
4798
4805
  })
4799
4806
  }
4800
4807
  }
4808
+ preloadView (view, callbackFn) {
4809
+ if (this.options.views[view].load) {
4810
+ this.options.views[view].load(callbackFn)
4811
+ }
4812
+ }
4813
+ initView (view) {
4814
+ return new Promise((resolve, reject) => {
4815
+ if (!this.options.views[view]) {
4816
+ this.options.views[view] = {
4817
+ components: []
4818
+ }
4819
+ }
4820
+ if (this.options.views[view].ready === true) {
4821
+ resolve()
4822
+ }
4823
+ else if (this.options.views[view].template) {
4824
+ this.preloadView(view, (data = {}) => {
4825
+ const viewEl = document.querySelector(`[data-view='${view}'].${this.options.viewClass}`)
4826
+ if (viewEl) {
4827
+ this.options.views[view].templateInstance = new WebsyDesigns.Template(viewEl, {
4828
+ template: this.options.views[view].template,
4829
+ data,
4830
+ readyCallbackFn: () => {
4831
+ this.options.views[view].ready = true
4832
+ resolve()
4833
+ }
4834
+ })
4835
+ }
4836
+ else {
4837
+ console.log(`No view element found for '${view}' to render template`)
4838
+ this.options.views[view].ready = true
4839
+ resolve()
4840
+ }
4841
+ })
4842
+ }
4843
+ else if (this.options.views[view].ready !== true && this.options.views[view].load) {
4844
+ this.preloadView(view, (data = {}) => {
4845
+ this.options.views[view].ready = true
4846
+ resolve()
4847
+ })
4848
+ }
4849
+ else {
4850
+ this.options.views[view].ready = true
4851
+ resolve()
4852
+ }
4853
+ })
4854
+ }
4801
4855
  showView (view, params, group) {
4802
4856
  if (view === '/' || view === '') {
4803
4857
  view = this.options.defaultView || ''
4804
4858
  }
4805
- this.activateItem(view, this.options.triggerClass)
4806
- this.activateItem(view, this.options.viewClass)
4807
- let children = this.getActiveViewsFromParent(view)
4808
- for (let c = 0; c < children.length; c++) {
4809
- this.activateItem(children[c].view, this.options.triggerClass)
4810
- this.activateItem(children[c].view, this.options.viewClass)
4811
- this.showComponents(children[c].view)
4812
- this.publish('show', [children[c].view, null, group])
4813
- }
4814
- if (this.previousView !== this.currentView || group !== 'main') {
4815
- this.showComponents(view)
4816
- this.publish('show', [view, params, group])
4817
- }
4818
- else if (this.previousView === this.currentView && this.previousParams.path !== this.currentParams.path) {
4819
- this.showComponents(view)
4820
- this.publish('show', [view, params, group])
4821
- }
4859
+ this.initView(view).then(() => {
4860
+ this.activateItem(view, this.options.triggerClass)
4861
+ this.activateItem(view, this.options.viewClass)
4862
+ let children = this.getActiveViewsFromParent(view)
4863
+ for (let c = 0; c < children.length; c++) {
4864
+ this.activateItem(children[c].view, this.options.triggerClass)
4865
+ this.activateItem(children[c].view, this.options.viewClass)
4866
+ this.showComponents(children[c].view)
4867
+ if (children[c].show) {
4868
+ children[c].show.call(children[c])
4869
+ }
4870
+ this.publish('show', [children[c].view, null, group])
4871
+ }
4872
+ if (this.previousView !== this.currentView || group !== 'main') {
4873
+ this.showComponents(view)
4874
+ if (this.options.views[view].show) {
4875
+ this.options.views[view].show.call(this.options.views[view])
4876
+ }
4877
+ this.publish('show', [view, params, group])
4878
+ }
4879
+ else if (this.previousView === this.currentView && this.previousParams.path !== this.currentParams.path) {
4880
+ this.showComponents(view)
4881
+ if (this.options.views[view].show) {
4882
+ this.options.views[view].show.call(this.options.views[view])
4883
+ }
4884
+ this.publish('show', [view, params, group])
4885
+ }
4886
+ })
4822
4887
  }
4823
4888
  reloadCurrentView () {
4824
4889
  this.showView(this.currentView, this.currentParams, 'main')
@@ -5109,7 +5174,18 @@ class WebsyTemplate {
5109
5174
  }
5110
5175
  }
5111
5176
  this.options = Object.assign({}, DEFAULTS, options)
5112
- this.elementId = elementId
5177
+ if (typeof elementId === 'object') {
5178
+ if (elementId.id) {
5179
+ this.elementId = elementId.id
5180
+ }
5181
+ else {
5182
+ elementId.id = WebsyDesigns.Utils.createIdentity()
5183
+ this.elementId = elementId.id
5184
+ }
5185
+ }
5186
+ else {
5187
+ this.elementId = elementId
5188
+ }
5113
5189
  this.templateService = new WebsyDesigns.APIService('')
5114
5190
  if (!elementId) {
5115
5191
  console.log('No element Id provided for Websy Template')
@@ -5227,6 +5303,10 @@ class WebsyTemplate {
5227
5303
  }
5228
5304
  return html
5229
5305
  }
5306
+ set data (d) {
5307
+ this.options.data = d
5308
+ this.render()
5309
+ }
5230
5310
  handleClick (event) {
5231
5311
  if (event.target.classList.contains('clickable')) {
5232
5312
  this.handleEvent(event, 'clickable', 'click')
@@ -9966,8 +10046,10 @@ class WebsyKPI {
9966
10046
  }
9967
10047
  html += `
9968
10048
  <div class="websy-kpi-info">
9969
- <div class="websy-kpi-label ${this.options.label.classes.join(' ') || ''}">
9970
- ${(this.options.label || {}).value || ''}
10049
+ <div class="websy-kpi-label-container">
10050
+ <div class="websy-kpi-label ${this.options.label.classes.join(' ') || ''}">
10051
+ ${(this.options.label || {}).value || ''}
10052
+ </div>
9971
10053
  `
9972
10054
  if (this.options.tooltip && this.options.tooltip.value) {
9973
10055
  html += `