@websy/websy-designs 1.8.1 → 1.9.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.
@@ -238,7 +238,7 @@ class ButtonGroup {
238
238
  let activeClass = ''
239
239
  if (this.options.activeItem !== -1) {
240
240
  activeClass = i === this.options.activeItem ? 'active' : 'inactive'
241
- }
241
+ }
242
242
  return `
243
243
  <${this.options.tag} ${(t.attributes || []).join(' ')} data-id="${t.id || t.label}" data-index="${i}" class="websy-button-group-item ${(t.classes || []).join(' ')} ${this.options.style}-style ${activeClass}">${t.label}</${this.options.tag}>
244
244
  `
@@ -1474,24 +1474,47 @@ class WebsyDropdown {
1474
1474
  <div id='${this.elementId}_mask' class='websy-dropdown-mask'></div>
1475
1475
  <div id='${this.elementId}_content' class='websy-dropdown-content'>
1476
1476
  `
1477
- if (this.options.customActions.length > 0) {
1477
+ if (this.options.customActions.length > 0 || this.options.customButtons.length > 0) {
1478
1478
  html += `
1479
1479
  <div class='websy-dropdown-action-container'>
1480
+ `
1481
+ if (this.options.customActions.length > 0) {
1482
+ html += `
1480
1483
  ${this.options.actionsTitle || ''}
1481
1484
  <button class='websy-dropdown-action-button'>
1482
1485
  ${this.options.actionsIcon}
1483
1486
  </button>
1484
- <ul id='${this.elementId}_actionContainer'>
1485
- `
1486
- this.options.customActions.forEach((a, i) => {
1487
+ `
1488
+ }
1489
+ if (this.options.customButtons.length > 0) {
1487
1490
  html += `
1488
- <li class='websy-dropdown-custom-action' data-index='${i}'>${a.label}</li>
1491
+ <div class='websy-dropdown-additional-buttons'>
1489
1492
  `
1490
- })
1491
- html += `
1492
- </ul>
1493
- </div>
1494
- `
1493
+ this.options.customButtons.forEach((b, i) => {
1494
+ html += `
1495
+ <button class='websy-dropdown-custom-button' data-index='${i}'>
1496
+ ${b.label}
1497
+ </button>
1498
+ `
1499
+ })
1500
+ html += `
1501
+ </div>
1502
+ `
1503
+ }
1504
+ if (this.options.customActions.length > 0) {
1505
+ html += `
1506
+ <ul id='${this.elementId}_actionContainer'>
1507
+ `
1508
+ this.options.customActions.forEach((a, i) => {
1509
+ html += `
1510
+ <li class='websy-dropdown-custom-action' data-index='${i}'>${a.label}</li>
1511
+ `
1512
+ })
1513
+ html += `
1514
+ </ul>
1515
+ </div>
1516
+ `
1517
+ }
1495
1518
  }
1496
1519
  if (this.options.disableSearch !== true) {
1497
1520
  html += `
@@ -1511,7 +1534,9 @@ class WebsyDropdown {
1511
1534
  `
1512
1535
  el.innerHTML = html
1513
1536
  const scrollEl = document.getElementById(`${this.elementId}_itemsContainer`)
1514
- scrollEl.addEventListener('scroll', this.handleScroll.bind(this))
1537
+ if (scrollEl) {
1538
+ scrollEl.addEventListener('scroll', this.handleScroll.bind(this))
1539
+ }
1515
1540
  this.render()
1516
1541
  }
1517
1542
  else {
@@ -1559,7 +1584,20 @@ class WebsyDropdown {
1559
1584
  this.options.onClearSelected()
1560
1585
  }
1561
1586
  }
1562
- close () {
1587
+ close () {
1588
+ this.hide()
1589
+ const searchEl = document.getElementById(`${this.elementId}_search`)
1590
+ if (searchEl) {
1591
+ if (searchEl.value.length > 0 && this.options.onCancelSearch) {
1592
+ this.options.onCancelSearch('')
1593
+ searchEl.value = ''
1594
+ }
1595
+ }
1596
+ if (this.options.onClose) {
1597
+ this.options.onClose(this.elementId)
1598
+ }
1599
+ }
1600
+ hide () {
1563
1601
  const maskEl = document.getElementById(`${this.elementId}_mask`)
1564
1602
  const contentEl = document.getElementById(`${this.elementId}_content`)
1565
1603
  const scrollEl = document.getElementById(`${this.elementId}_itemsContainer`)
@@ -1580,17 +1618,7 @@ class WebsyDropdown {
1580
1618
  if (contentEl) {
1581
1619
  contentEl.classList.remove('active')
1582
1620
  contentEl.classList.remove('on-top')
1583
- }
1584
- const searchEl = document.getElementById(`${this.elementId}_search`)
1585
- if (searchEl) {
1586
- if (searchEl.value.length > 0 && this.options.onCancelSearch) {
1587
- this.options.onCancelSearch('')
1588
- searchEl.value = ''
1589
- }
1590
- }
1591
- if (this.options.onClose) {
1592
- this.options.onClose(this.elementId)
1593
- }
1621
+ }
1594
1622
  }
1595
1623
  handleClick (event) {
1596
1624
  if (this.options.disabled === true) {
@@ -1619,6 +1647,12 @@ class WebsyDropdown {
1619
1647
  this.options.customActions[actionIndex].fn()
1620
1648
  }
1621
1649
  }
1650
+ else if (event.target.classList.contains('websy-dropdown-custom-button')) {
1651
+ const actionIndex = +event.target.getAttribute('data-index')
1652
+ if (this.options.customButtons[actionIndex] && this.options.customButtons[actionIndex].fn) {
1653
+ this.options.customButtons[actionIndex].fn()
1654
+ }
1655
+ }
1622
1656
  else if (event.target.classList.contains('websy-dropdown-action-button')) {
1623
1657
  const el = document.getElementById(`${this.elementId}_actionContainer`)
1624
1658
  if (el) {
@@ -2194,7 +2228,7 @@ class WebsyDragDrop {
2194
2228
  class WebsyForm {
2195
2229
  constructor (elementId, options) {
2196
2230
  const defaults = {
2197
- submit: { text: 'Save', classes: '' },
2231
+ submit: { text: 'Save', classes: [] },
2198
2232
  useRecaptcha: false,
2199
2233
  clearAfterSave: false,
2200
2234
  fields: [],
@@ -2265,6 +2299,10 @@ class WebsyForm {
2265
2299
  }
2266
2300
  })
2267
2301
  }
2302
+ clear () {
2303
+ const formEl = document.getElementById(`${this.elementId}Form`)
2304
+ formEl.reset()
2305
+ }
2268
2306
  get data () {
2269
2307
  const formEl = document.getElementById(`${this.elementId}Form`)
2270
2308
  const data = {}
@@ -2946,7 +2984,7 @@ class WebsyLogin {
2946
2984
  useRecaptcha: this.options.useRecaptcha || ENVIRONMENT.useRecaptcha || false,
2947
2985
  submit: {
2948
2986
  text: this.options.buttonText || 'Log in',
2949
- classes: (this.options.buttonClasses || []).join(' ') || ''
2987
+ classes: this.options.buttonClasses || []
2950
2988
  },
2951
2989
  fields: [
2952
2990
  {
@@ -4311,7 +4349,9 @@ class WebsyRouter {
4311
4349
  if (typeof params === 'undefined') {
4312
4350
  return
4313
4351
  }
4314
- this.previousParams = Object.assign({}, this.currentParams)
4352
+ if (reloadView === false) {
4353
+ this.previousParams = Object.assign({}, this.currentParams)
4354
+ }
4315
4355
  const output = {
4316
4356
  path: '',
4317
4357
  items: {}
@@ -4326,7 +4366,9 @@ class WebsyRouter {
4326
4366
  path = this.buildUrlPath(output.items)
4327
4367
  }
4328
4368
  output.path = path
4329
- this.currentParams = output
4369
+ if (reloadView === false) {
4370
+ this.currentParams = output
4371
+ }
4330
4372
  let inputPath = this.currentView
4331
4373
  if (this.options.urlPrefix) {
4332
4374
  inputPath = `/${this.options.urlPrefix}/${inputPath}`
@@ -6443,7 +6485,8 @@ class WebsyTable3 {
6443
6485
  allowPivoting: false,
6444
6486
  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>`,
6445
6487
  plusIcon: WebsyDesigns.Icons.PlusFilled,
6446
- minusIcon: WebsyDesigns.Icons.MinusFilled
6488
+ minusIcon: WebsyDesigns.Icons.MinusFilled,
6489
+ disableInternalLoader: false
6447
6490
  }
6448
6491
  this.options = Object.assign({}, DEFAULTS, options)
6449
6492
  this.isTouchDevice = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)
@@ -6607,7 +6650,7 @@ class WebsyTable3 {
6607
6650
  bodyHtml += `<td
6608
6651
  class='websy-table-cell ${sizeIndex < this.pinnedColumns ? 'pinned' : 'unpinned'} ${(cell.classes || []).join(' ')} ${(sizingColumns[sizeIndex].classes || []).join(' ')}'
6609
6652
  style='${style}'
6610
- data-info='${cell.value}'
6653
+ data-info='${cell.value.replace(/'/g, '`')}'
6611
6654
  colspan='${cell.colspan || 1}'
6612
6655
  rowspan='${cell.rowspan || 1}'
6613
6656
  data-row-index='${rowIndex}'
@@ -6829,6 +6872,9 @@ class WebsyTable3 {
6829
6872
  columnsForSizing[colIndex].actualWidth = 0
6830
6873
  }
6831
6874
  columnsForSizing[colIndex].actualWidth = Math.min(Math.max(columnsForSizing[colIndex].actualWidth, colSize.width), maxWidth)
6875
+ // if (columnsForSizing[colIndex].width) {
6876
+ // columnsForSizing[colIndex].actualWidth = columnsForSizing[colIndex].width
6877
+ // }
6832
6878
  columnsForSizing[colIndex].cellHeight = colSize.height
6833
6879
  if (colIndex >= this.pinnedColumns) {
6834
6880
  firstNonPinnedColumnWidth = columnsForSizing[colIndex].actualWidth
@@ -7470,7 +7516,9 @@ class WebsyTable3 {
7470
7516
  }
7471
7517
  }
7472
7518
  showLoading (options) {
7473
- this.loadingDialog.show(options)
7519
+ if (this.options.disableInternalLoader !== true) {
7520
+ this.loadingDialog.show(options)
7521
+ }
7474
7522
  }
7475
7523
  }
7476
7524