@websy/websy-designs 1.10.1 → 1.10.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.
@@ -3,7 +3,7 @@ const router = express.Router()
3
3
  // const PG = require('../helpers/dbHelper')
4
4
  // const dbHelper = new PG()
5
5
 
6
- function APIRoutes (dbHelper, authHelper) {
6
+ function APIRoutes (dbHelper, authHelper) {
7
7
  router.delete('/:entity/:id', (req, res) => {
8
8
  const sql = `DELETE FROM ${req.params.entity} WHERE ${dbHelper.buildWhereWithId(req.params.entity, req.params.id)}`
9
9
  dbHelper.execute(sql).then(response => res.json(response), err => res.json(err))
@@ -12,6 +12,18 @@ function APIRoutes (dbHelper, authHelper) {
12
12
  const sql = dbHelper.buildDelete(req.params.entity, req.query.where)
13
13
  dbHelper.execute(sql).then(response => res.json(response), err => res.json(err))
14
14
  })
15
+ router.get('/currentuser', (req, res) => {
16
+ let user = {}
17
+ if (req.session && req.session.user) {
18
+ user = req.session.user
19
+ }
20
+ if (process.env.SENSITIVE_USERPROPS) {
21
+ process.env.SENSITIVE_USERPROPS.split(',').forEach(d => {
22
+ delete user[d.trim()]
23
+ })
24
+ }
25
+ res.json(user)
26
+ })
15
27
  router.get('/:entity/:id', (req, res) => {
16
28
  let lang = process.env.DEFAULT_LANGUAGE
17
29
  if (req.session && req.session.language && req.query.notranslate !== 'true') {
@@ -49,7 +61,6 @@ function APIRoutes (dbHelper, authHelper) {
49
61
  user = req.session.user
50
62
  }
51
63
  const sql = dbHelper.buildUpsert(req.params.entity, req.body, user)
52
- console.log('upsert sql', sql)
53
64
  dbHelper.execute(sql).then(response => res.json(response), err => res.json(err))
54
65
  })
55
66
  router.post('/:entity', authHelper.checkPermissions, (req, res) => {
@@ -1559,6 +1559,7 @@ class WebsyDropdown {
1559
1559
  closeAfterSelection: true,
1560
1560
  customActions: [],
1561
1561
  customButtons: [],
1562
+ minWidth: 220,
1562
1563
  searchIcon: `<svg width="20" height="20" viewBox="0 0 512 512"><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>`,
1563
1564
  clearIcon: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 512 512"><title>ionicons-v5-l</title><line x1="368" y1="368" x2="144" y2="144" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/><line x1="368" y1="144" x2="144" y2="368" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/></svg>`,
1564
1565
  arrowIcon: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z"/></svg>`,
@@ -1585,7 +1586,7 @@ class WebsyDropdown {
1585
1586
  el.addEventListener('click', this.handleClick.bind(this))
1586
1587
  el.addEventListener('keyup', this.handleKeyUp.bind(this))
1587
1588
  el.addEventListener('mouseout', this.handleMouseOut.bind(this))
1588
- el.addEventListener('mousemove', this.handleMouseMove.bind(this))
1589
+ el.addEventListener('mousemove', this.handleMouseMove.bind(this))
1589
1590
  const headerLabel = this.selectedItems.map(s => this.options.items[s].label || this.options.items[s].value).join(this.options.multiValueDelimiter)
1590
1591
  const headerValue = this.selectedItems.map(s => this.options.items[s].value || this.options.items[s].label).join(this.options.multiValueDelimiter)
1591
1592
  let html = `
@@ -1670,6 +1671,15 @@ class WebsyDropdown {
1670
1671
  </div>
1671
1672
  `
1672
1673
  el.innerHTML = html
1674
+ const maskEl = document.getElementById(`${this.elementId}_mask`)
1675
+ if (maskEl) {
1676
+ maskEl.addEventListener('mousewheel', event => {
1677
+ if (event.target.classList.contains('websy-dropdown-mask')) {
1678
+ event.preventDefault()
1679
+ event.stopPropagation()
1680
+ }
1681
+ })
1682
+ }
1673
1683
  const scrollEl = document.getElementById(`${this.elementId}_itemsContainer`)
1674
1684
  if (scrollEl) {
1675
1685
  scrollEl.addEventListener('scroll', this.handleScroll.bind(this))
@@ -1900,7 +1910,7 @@ class WebsyDropdown {
1900
1910
  const contentPos = WebsyUtils.getElementPos(contentEl)
1901
1911
  if (this.options.style === 'plain' && headerPos.width > 0 && headerPos.height > 0) {
1902
1912
  contentEl.style.right = `calc(100vw - ${headerPos.right}px)`
1903
- contentEl.style.width = `${headerEl.clientWidth}px`
1913
+ contentEl.style.width = `${Math.max(this.options.minWidth, headerEl.clientWidth)}px`
1904
1914
  if (headerPos.bottom + contentPos.height > window.innerHeight) {
1905
1915
  // contentEl.classList.add('on-top')
1906
1916
  contentEl.style.bottom = `calc(100vh - ${headerPos.top}px)`
@@ -1912,7 +1922,7 @@ class WebsyDropdown {
1912
1922
  else if (this.options.style === 'plain' && headerPos.width === 0 && headerPos.height === 0) {
1913
1923
  const targetPos = WebsyUtils.getElementPos(event.target)
1914
1924
  contentEl.style.right = `calc(100vw - ${targetPos.right}px)`
1915
- contentEl.style.width = `${targetPos.width}px`
1925
+ contentEl.style.width = `${Math.max(this.options.minWidth, targetPos.width)}px`
1916
1926
  }
1917
1927
  if (this.options.disableSearch !== true) {
1918
1928
  const searchEl = document.getElementById(`${this.elementId}_search`)
@@ -5277,10 +5287,12 @@ const WebsyUtils = {
5277
5287
  const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft
5278
5288
  const scrollTop = window.pageYOffset || document.documentElement.scrollTop
5279
5289
  return {
5280
- top: rect.top + scrollTop,
5281
- left: rect.left + scrollLeft,
5282
- bottom: rect.top + scrollTop + el.clientHeight,
5283
- right: rect.left + scrollLeft + el.clientWidth,
5290
+ top: rect.top, // + scrollTop,
5291
+ left: rect.left, // + scrollLeft,
5292
+ // bottom: rect.top + scrollTop + el.clientHeight,
5293
+ bottom: rect.top + el.clientHeight,
5294
+ // right: rect.left + scrollLeft + el.clientWidth,
5295
+ right: rect.left + el.clientWidth,
5284
5296
  width: rect.width,
5285
5297
  height: rect.height
5286
5298
  }
@@ -5468,6 +5480,7 @@ class WebsyTable {
5468
5480
  this.busy = false
5469
5481
  this.tooltipTimeoutFn = null
5470
5482
  this.data = []
5483
+ this._isRendered = false
5471
5484
  const el = document.getElementById(this.elementId)
5472
5485
  if (el) {
5473
5486
  let html = `
@@ -5527,7 +5540,11 @@ class WebsyTable {
5527
5540
  console.error(`No element found with ID ${this.elementId}`)
5528
5541
  }
5529
5542
  }
5543
+ get isRendered () {
5544
+ return this._isRendered
5545
+ }
5530
5546
  appendRows (data) {
5547
+ this._isRendered = false
5531
5548
  this.hideError()
5532
5549
  let bodyHTML = ''
5533
5550
  if (data) {
@@ -5604,6 +5621,7 @@ class WebsyTable {
5604
5621
  }
5605
5622
  const bodyEl = document.getElementById(`${this.elementId}_body`)
5606
5623
  bodyEl.innerHTML += bodyHTML
5624
+ this._isRendered = true
5607
5625
  }
5608
5626
  buildSearchIcon (field) {
5609
5627
  return `
@@ -5743,6 +5761,7 @@ class WebsyTable {
5743
5761
  this.render(this.data)
5744
5762
  }
5745
5763
  render (data) {
5764
+ this._isRendered = false
5746
5765
  if (!this.options.columns) {
5747
5766
  return
5748
5767
  }
@@ -1565,6 +1565,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1565
1565
  closeAfterSelection: true,
1566
1566
  customActions: [],
1567
1567
  customButtons: [],
1568
+ minWidth: 220,
1568
1569
  searchIcon: "<svg width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><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>",
1569
1570
  clearIcon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 512 512\"><title>ionicons-v5-l</title><line x1=\"368\" y1=\"368\" x2=\"144\" y2=\"144\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"368\" y1=\"144\" x2=\"144\" y2=\"368\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>",
1570
1571
  arrowIcon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z\"/></svg>",
@@ -1632,6 +1633,15 @@ var WebsyDropdown = /*#__PURE__*/function () {
1632
1633
  }
1633
1634
  html += "\n <div id='".concat(this.elementId, "_itemsContainer' class='websy-dropdown-items'>\n <ul id='").concat(this.elementId, "_items'> \n </ul>\n </div><!--\n --><div class='websy-dropdown-custom'></div>\n </div>\n </div>\n ");
1634
1635
  el.innerHTML = html;
1636
+ var maskEl = document.getElementById("".concat(this.elementId, "_mask"));
1637
+ if (maskEl) {
1638
+ maskEl.addEventListener('mousewheel', function (event) {
1639
+ if (event.target.classList.contains('websy-dropdown-mask')) {
1640
+ event.preventDefault();
1641
+ event.stopPropagation();
1642
+ }
1643
+ });
1644
+ }
1635
1645
  var scrollEl = document.getElementById("".concat(this.elementId, "_itemsContainer"));
1636
1646
  if (scrollEl) {
1637
1647
  scrollEl.addEventListener('scroll', this.handleScroll.bind(this));
@@ -1873,7 +1883,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1873
1883
  var contentPos = WebsyUtils.getElementPos(contentEl);
1874
1884
  if (this.options.style === 'plain' && headerPos.width > 0 && headerPos.height > 0) {
1875
1885
  contentEl.style.right = "calc(100vw - ".concat(headerPos.right, "px)");
1876
- contentEl.style.width = "".concat(headerEl.clientWidth, "px");
1886
+ contentEl.style.width = "".concat(Math.max(this.options.minWidth, headerEl.clientWidth), "px");
1877
1887
  if (headerPos.bottom + contentPos.height > window.innerHeight) {
1878
1888
  // contentEl.classList.add('on-top')
1879
1889
  contentEl.style.bottom = "calc(100vh - ".concat(headerPos.top, "px)");
@@ -1883,7 +1893,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1883
1893
  } else if (this.options.style === 'plain' && headerPos.width === 0 && headerPos.height === 0) {
1884
1894
  var targetPos = WebsyUtils.getElementPos(event.target);
1885
1895
  contentEl.style.right = "calc(100vw - ".concat(targetPos.right, "px)");
1886
- contentEl.style.width = "".concat(targetPos.width, "px");
1896
+ contentEl.style.width = "".concat(Math.max(this.options.minWidth, targetPos.width), "px");
1887
1897
  }
1888
1898
  if (this.options.disableSearch !== true) {
1889
1899
  var searchEl = document.getElementById("".concat(this.elementId, "_search"));
@@ -5138,10 +5148,14 @@ var WebsyUtils = {
5138
5148
  var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
5139
5149
  var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
5140
5150
  return {
5141
- top: rect.top + scrollTop,
5142
- left: rect.left + scrollLeft,
5143
- bottom: rect.top + scrollTop + el.clientHeight,
5144
- right: rect.left + scrollLeft + el.clientWidth,
5151
+ top: rect.top,
5152
+ // + scrollTop,
5153
+ left: rect.left,
5154
+ // + scrollLeft,
5155
+ // bottom: rect.top + scrollTop + el.clientHeight,
5156
+ bottom: rect.top + el.clientHeight,
5157
+ // right: rect.left + scrollLeft + el.clientWidth,
5158
+ right: rect.left + el.clientWidth,
5145
5159
  width: rect.width,
5146
5160
  height: rect.height
5147
5161
  };
@@ -5339,6 +5353,7 @@ var WebsyTable = /*#__PURE__*/function () {
5339
5353
  this.busy = false;
5340
5354
  this.tooltipTimeoutFn = null;
5341
5355
  this.data = [];
5356
+ this._isRendered = false;
5342
5357
  var el = document.getElementById(this.elementId);
5343
5358
  if (el) {
5344
5359
  var html = "\n <div id='".concat(this.elementId, "_tableContainer' class='websy-vis-table ").concat(this.options.paging === 'pages' ? 'with-paging' : '', "'>\n <!--<div class=\"download-button\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M16 11h5l-9 10-9-10h5v-11h8v11zm1 11h-10v2h10v-2z\"/></svg>\n </div>-->\n <table>\n <thead id=\"").concat(this.elementId, "_head\">\n </thead>\n <tbody id=\"").concat(this.elementId, "_body\">\n </tbody>\n <tfoot id=\"").concat(this.elementId, "_foot\">\n </tfoot>\n </table> \n <div id=\"").concat(this.elementId, "_errorContainer\" class='websy-vis-error-container'>\n <div>\n <div id=\"").concat(this.elementId, "_errorTitle\"></div>\n <div id=\"").concat(this.elementId, "_errorMessage\"></div>\n </div> \n </div>\n <div id=\"").concat(this.elementId, "_loadingContainer\"></div>\n </div>\n ");
@@ -5377,9 +5392,15 @@ var WebsyTable = /*#__PURE__*/function () {
5377
5392
  }
5378
5393
  }
5379
5394
  _createClass(WebsyTable, [{
5395
+ key: "isRendered",
5396
+ get: function get() {
5397
+ return this._isRendered;
5398
+ }
5399
+ }, {
5380
5400
  key: "appendRows",
5381
5401
  value: function appendRows(data) {
5382
5402
  var _this36 = this;
5403
+ this._isRendered = false;
5383
5404
  this.hideError();
5384
5405
  var bodyHTML = '';
5385
5406
  if (data) {
@@ -5421,6 +5442,7 @@ var WebsyTable = /*#__PURE__*/function () {
5421
5442
  }
5422
5443
  var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
5423
5444
  bodyEl.innerHTML += bodyHTML;
5445
+ this._isRendered = true;
5424
5446
  }
5425
5447
  }, {
5426
5448
  key: "buildSearchIcon",
@@ -5571,6 +5593,7 @@ var WebsyTable = /*#__PURE__*/function () {
5571
5593
  key: "render",
5572
5594
  value: function render(data) {
5573
5595
  var _this37 = this;
5596
+ this._isRendered = false;
5574
5597
  if (!this.options.columns) {
5575
5598
  return;
5576
5599
  }