@websy/websy-designs 1.11.0 → 1.11.1

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