@websy/websy-designs 1.11.11 → 1.11.13

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.
@@ -294,7 +294,6 @@ class PGHelper {
294
294
  return sql
295
295
  }
296
296
  buildWhere (input, entity) {
297
- console.log('input is', input)
298
297
  if (typeof input === 'undefined' || input.trim() === '') {
299
298
  return '1=1'
300
299
  }
@@ -308,7 +307,7 @@ class PGHelper {
308
307
  // console.log('where input', input)
309
308
  // console.log('splitter is', this.options.fieldValueSeparator)
310
309
  let list = input.split(';').map(d => {
311
- let parts = d.split(this.options.fieldValueSeparator)
310
+ let parts = d.split(this.options.fieldValueSeparator)
312
311
  if (parts.length === 2) {
313
312
  let partValues = parts[1]
314
313
  partValues = partValues.split('|')
@@ -322,12 +321,11 @@ class PGHelper {
322
321
  else if (parts[1].indexOf('%') !== -1) {
323
322
  return `LOWER(${entity ? entity + '.' : ''}${parts[0]}) LIKE '${parts[1]}'`
324
323
  }
325
- else {
324
+ else {
326
325
  return `${entity ? entity + '.' : ''}${parts[0]} = '${parts[1]}'`
327
326
  }
328
327
  }
329
- else {
330
- console.log(`${entity ? entity + '.' : ''}${parts[0]} IN ('${partValues.join('\',\'')}')`)
328
+ else {
331
329
  return `${entity ? entity + '.' : ''}${parts[0]} IN ('${partValues.join('\',\'')}')`
332
330
  }
333
331
  }
@@ -337,9 +335,7 @@ class PGHelper {
337
335
  return `${entity ? entity + '.' : ''}${parts[0]} <> '${parts[1]}'`
338
336
  }
339
337
  }
340
- })
341
- console.log('list is')
342
- console.log(list)
338
+ })
343
339
  return `
344
340
  ${list.length > 0 ? list.join(' AND ') : ''}
345
341
  `
@@ -67,7 +67,9 @@ module.exports = function (options) {
67
67
  app.use('/pdf', require(`./routes/${version}/pdf`))
68
68
  if (options.useDB === true) {
69
69
  const dbHelper = require(`./helpers/${version}/${options.dbEngine}Helper`)
70
- dbHelper.init(options.dbOnError || {}).then(() => {
70
+ let dbOptions = options.dbEngine === 'pg' ? options.dbOptions : options.dbOnError || {}
71
+
72
+ dbHelper.init(dbOptions).then(() => {
71
73
  app.set('trust proxy', 1)
72
74
  app.use(cookieParser(process.env.SESSION_SECRET))
73
75
  let cookieConfig = {
@@ -2087,7 +2087,12 @@ class WebsyDropdown {
2087
2087
  labelEl.innerHTML = item.label
2088
2088
  labelEl.setAttribute('data-info', item.label)
2089
2089
  inputEl.value = item.value
2090
- }
2090
+ }
2091
+ else if (this.selectedItems[0]) {
2092
+ labelEl.innerHTML = dataToUse[this.selectedItems[0]].label
2093
+ labelEl.setAttribute('data-info', dataToUse[this.selectedItems[0]].label)
2094
+ inputEl.value = dataToUse[this.selectedItems[0]].value
2095
+ }
2091
2096
  }
2092
2097
  else if (this.selectedItems.length > 1) {
2093
2098
  if (this.options.showCompleteSelectedList === true) {
@@ -2116,10 +2121,12 @@ class WebsyDropdown {
2116
2121
  if (this.options.onSearch) {
2117
2122
  dataToUse = this.options.items
2118
2123
  }
2124
+ let item
2119
2125
  if (typeof index !== 'undefined' && index !== null) {
2120
2126
  let pos = this.selectedItems.indexOf(index)
2121
2127
  if (this.options.multiSelect === false) {
2122
2128
  this.selectedItems = [index]
2129
+ item = dataToUse[index]
2123
2130
  }
2124
2131
  else {
2125
2132
  if (pos !== -1) {
@@ -2127,11 +2134,10 @@ class WebsyDropdown {
2127
2134
  }
2128
2135
  else {
2129
2136
  this.selectedItems.push(index)
2137
+ item = dataToUse[index]
2130
2138
  }
2131
2139
  }
2132
- }
2133
- // const item = this.options.items[index]
2134
- const item = dataToUse[index]
2140
+ }
2135
2141
  this.updateHeader(item)
2136
2142
  if (item && this.options.onItemSelected) {
2137
2143
  this.options.onItemSelected(item, this.selectedItems, dataToUse, this.options)
@@ -4192,7 +4198,7 @@ class WebsyResultList {
4192
4198
  const el = document.getElementById(this.elementId)
4193
4199
  el.innerHTML += html.replace(/\n/g, '')
4194
4200
  }
4195
- buildHTML (d, startIndex = 0, inputTemplate, locator = []) {
4201
+ buildHTML (d = [], startIndex = 0, inputTemplate, locator = []) {
4196
4202
  let html = ``
4197
4203
  if (this.options.template) {
4198
4204
  if (d.length > 0) {
@@ -2069,6 +2069,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
2069
2069
  labelEl.innerHTML = item.label;
2070
2070
  labelEl.setAttribute('data-info', item.label);
2071
2071
  inputEl.value = item.value;
2072
+ } else if (this.selectedItems[0]) {
2073
+ labelEl.innerHTML = dataToUse[this.selectedItems[0]].label;
2074
+ labelEl.setAttribute('data-info', dataToUse[this.selectedItems[0]].label);
2075
+ inputEl.value = dataToUse[this.selectedItems[0]].value;
2072
2076
  }
2073
2077
  } else if (this.selectedItems.length > 1) {
2074
2078
  if (this.options.showCompleteSelectedList === true) {
@@ -2103,20 +2107,21 @@ var WebsyDropdown = /*#__PURE__*/function () {
2103
2107
  if (this.options.onSearch) {
2104
2108
  dataToUse = this.options.items;
2105
2109
  }
2110
+ var item;
2106
2111
  if (typeof index !== 'undefined' && index !== null) {
2107
2112
  var pos = this.selectedItems.indexOf(index);
2108
2113
  if (this.options.multiSelect === false) {
2109
2114
  this.selectedItems = [index];
2115
+ item = dataToUse[index];
2110
2116
  } else {
2111
2117
  if (pos !== -1) {
2112
2118
  this.selectedItems.splice(pos, 1);
2113
2119
  } else {
2114
2120
  this.selectedItems.push(index);
2121
+ item = dataToUse[index];
2115
2122
  }
2116
2123
  }
2117
2124
  }
2118
- // const item = this.options.items[index]
2119
- var item = dataToUse[index];
2120
2125
  this.updateHeader(item);
2121
2126
  if (item && this.options.onItemSelected) {
2122
2127
  this.options.onItemSelected(item, this.selectedItems, dataToUse, this.options);
@@ -3960,8 +3965,9 @@ var WebsyResultList = /*#__PURE__*/function () {
3960
3965
  }
3961
3966
  }, {
3962
3967
  key: "buildHTML",
3963
- value: function buildHTML(d) {
3968
+ value: function buildHTML() {
3964
3969
  var _this28 = this;
3970
+ var d = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3965
3971
  var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
3966
3972
  var inputTemplate = arguments.length > 2 ? arguments[2] : undefined;
3967
3973
  var locator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];