@websy/websy-designs 1.3.4 → 1.3.6

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.
@@ -48,9 +48,9 @@ const sql = {
48
48
  )
49
49
  WITH (OIDS=FALSE);
50
50
 
51
- ALTER TABLE "session" ADD CONSTRAINT "session_pkey" PRIMARY KEY ("sid") NOT DEFERRABLE INITIALLY IMMEDIATE;
51
+ ALTER TABLE "sessions" ADD CONSTRAINT "session_pkey" PRIMARY KEY ("sid") NOT DEFERRABLE INITIALLY IMMEDIATE;
52
52
 
53
- CREATE INDEX "IDX_session_expire" ON "session" ("expire");
53
+ CREATE INDEX "IDX_session_expire" ON "sessions" ("expire");
54
54
  `,
55
55
  users: `
56
56
  CREATE TABLE users (
@@ -216,7 +216,13 @@ class PGHelper {
216
216
  let partValues = parts[1]
217
217
  partValues = partValues.split('|')
218
218
  if (partValues.length === 1) {
219
- if (parts[1].indexOf('%') !== -1) {
219
+ if (parts[1].indexOf('>') !== -1) {
220
+ return `${entity ? entity + '.' : ''}${parts[0]} > '${parts[1].replace('>', '')}'`
221
+ }
222
+ else if (parts[1].indexOf('<') !== -1) {
223
+ return `${entity ? entity + '.' : ''}${parts[0]} < '${parts[1].replace('<', '')}'`
224
+ }
225
+ else if (parts[1].indexOf('%') !== -1) {
220
226
  return `${entity ? entity + '.' : ''}${parts[0]} LIKE '${parts[1]}'`
221
227
  }
222
228
  else {
@@ -1412,9 +1412,9 @@ class WebsyDropdown {
1412
1412
  showCompleteSelectedList: false,
1413
1413
  closeAfterSelection: true,
1414
1414
  customActions: [],
1415
- searchIcon: `<svg class='search' 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>`,
1416
- clearIcon: `<svg class='clear' 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>`,
1417
- arrowIcon: `<svg class='arrow' 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>`,
1415
+ 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>`,
1416
+ 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>`,
1417
+ 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>`,
1418
1418
  actionsIcon: `<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 512 512">><circle cx="256" cy="256" r="32" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/><circle cx="416" cy="256" r="32" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/><circle cx="96" cy="256" r="32" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/></svg>`
1419
1419
  }
1420
1420
  this.options = Object.assign({}, DEFAULTS, options)
@@ -1443,16 +1443,20 @@ class WebsyDropdown {
1443
1443
  let html = `
1444
1444
  <div id='${this.elementId}_container' class='websy-dropdown-container ${this.options.disabled ? 'disabled' : ''} ${this.options.disableSearch !== true ? 'with-search' : ''} ${this.options.style} ${this.options.customActions.length > 0 ? 'with-actions' : ''}'>
1445
1445
  <div id='${this.elementId}_header' class='websy-dropdown-header ${this.selectedItems.length === 1 ? 'one-selected' : ''} ${this.options.allowClear === true ? 'allow-clear' : ''}'>
1446
- ${this.options.searchIcon}
1447
- <span>
1446
+ `
1447
+ if (this.options.disableSearch !== true) {
1448
+ html += `<div class='search'>${this.options.searchIcon}</div>`
1449
+ }
1450
+ html += `
1451
+ <div class='header-label'>
1448
1452
  <span class='websy-dropdown-header-value' data-info='${headerLabel}' id='${this.elementId}_selectedItems'>${headerLabel}</span>
1449
1453
  <span class='websy-dropdown-header-label' id='${this.elementId}_headerLabel'>${this.options.label}</span>
1450
- </span>
1454
+ </div>
1451
1455
  <input class='dropdown-input' id='${this.elementId}_input' name='${this.options.field || this.options.label}' value='${headerValue}'>
1452
- ${this.options.arrowIcon}
1456
+ <div class='arrow'>${this.options.arrowIcon}</div>
1453
1457
  `
1454
1458
  if (this.options.allowClear === true) {
1455
- html += this.options.clearIcon
1459
+ html += `<div class='clear'>${this.options.clearIcon}</div>`
1456
1460
  }
1457
1461
  html += `
1458
1462
  </div>
@@ -2139,7 +2143,7 @@ const WebsyIcons = {
2139
2143
  `,
2140
2144
  'bag-icon': `
2141
2145
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
2142
- viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
2146
+ viewBox="0 0 500 500">
2143
2147
  <path d="M456.6,472.3H43.4c-5.3,0-10.2-2.1-13.7-6c-3.6-3.9-5.2-9.2-4.5-14.4l37-285.4c1.2-9,9-15.9,18.2-15.9h339.2
2144
2148
  c9.2,0,17,6.8,18.2,15.8l37,285.4c0.7,5.2-1,10.5-4.5,14.4l0,0C466.8,470.1,461.9,472.3,456.6,472.3z M46.5,451.2h407l-36.3-279.6
2145
2149
  H82.8L46.5,451.2z"/>
@@ -2162,6 +2166,104 @@ const WebsyIcons = {
2162
2166
  c0-62.9-23.4-122-65.9-166.5c-42.5-44.5-99-69-159.1-69s-116.6,24.5-159.1,69C48.4,353,25,412.1,25,475c0,0,0,0,0,0H45z"/>
2163
2167
  </svg>
2164
2168
 
2169
+ `,
2170
+ 'Search': `
2171
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
2172
+ viewBox="0 0 500 500" xml:space="preserve">
2173
+ <path d="M481.4,468.6c-17.2-17.2-34.4-34.4-51.6-51.6c-27.4-27.4-54.8-54.8-82.2-82.2c-4.8-4.8-9.5-9.5-14.3-14.3
2174
+ c29.4-32.5,47.4-75.5,47.4-122.7C380.7,97,298.7,15,197.9,15S15,97,15,197.9s82,182.9,182.9,182.9c47.2,0,90.3-18,122.7-47.4
2175
+ c15.7,15.7,31.4,31.4,47.1,47.1c27.4,27.4,54.8,54.8,82.2,82.2c6.3,6.3,12.5,12.5,18.8,18.8C476.8,489.6,489.6,476.8,481.4,468.6z
2176
+ M35,197.9C35,108.1,108.1,35,197.9,35s162.9,73.1,162.9,162.9s-73.1,162.9-162.9,162.9S35,287.7,35,197.9z"/>
2177
+ </svg>
2178
+
2179
+ `,
2180
+ 'Bag': `
2181
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
2182
+ viewBox="0 0 500 500">
2183
+ <path d="M456.6,472.3H43.4c-5.3,0-10.2-2.1-13.7-6c-3.6-3.9-5.2-9.2-4.5-14.4l37-285.4c1.2-9,9-15.9,18.2-15.9h339.2
2184
+ c9.2,0,17,6.8,18.2,15.8l37,285.4c0.7,5.2-1,10.5-4.5,14.4l0,0C466.8,470.1,461.9,472.3,456.6,472.3z M46.5,451.2h407l-36.3-279.6
2185
+ H82.8L46.5,451.2z"/>
2186
+ <g>
2187
+ <path d="M361.3,157.1C357.3,94.8,308.4,46,249.9,46c-28,0-54.8,11.1-75.4,31.4c-20.7,20.3-33.5,47.9-35.9,77.8l-21.5-1.6
2188
+ c2.8-34.8,17.7-67.1,42.1-91C183.9,38.3,216.1,25,249.9,25c34.2,0,66.6,13.6,91.5,38.3c24.5,24.3,39.2,57.2,41.5,92.5L361.3,157.1z
2189
+ "/>
2190
+ </g>
2191
+ </svg>
2192
+
2193
+ `,
2194
+ 'User': `
2195
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
2196
+ viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
2197
+ <g>
2198
+ <path d="M248,260.5c-62,0-112.5-52.8-112.5-117.7S186,25,248,25s112.5,52.8,112.5,117.7S310,260.5,248,260.5z M248,45.9
2199
+ c-51,0-92.5,43.4-92.5,96.8s41.5,96.8,92.5,96.8c51,0,92.5-43.4,92.5-96.8S299,45.9,248,45.9z"/>
2200
+ </g>
2201
+ <path d="M45,475C45,475,45,475,45,475c0-118.3,92-214.5,205-214.5c113,0,205,96.2,205,214.5c0,0,0,0,0,0h20c0,0,0,0,0,0
2202
+ c0-62.9-23.4-122-65.9-166.5c-42.5-44.5-99-69-159.1-69s-116.6,24.5-159.1,69C48.4,353,25,412.1,25,475c0,0,0,0,0,0H45z"/>
2203
+ </svg>
2204
+
2205
+ `,
2206
+ 'DockLeft': `
2207
+ <svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
2208
+ viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
2209
+ <g>
2210
+ <path d="M419.7,425H80.3C49.8,425,25,400.2,25,369.7V130.3C25,99.8,49.8,75,80.3,75h339.4c30.5,0,55.3,24.8,55.3,55.3v239.4
2211
+ C475,400.2,450.2,425,419.7,425z M80.3,95C60.8,95,45,110.8,45,130.3v239.4c0,19.5,15.8,35.3,35.3,35.3h339.4
2212
+ c19.5,0,35.3-15.8,35.3-35.3V130.3c0-19.5-15.8-35.3-35.3-35.3H80.3z"/>
2213
+ </g>
2214
+ <path d="M92.8,90.1H92h-4.2c-24.8,0-45,20.2-45,45v229.8c0,24.8,20.2,45,45,45H92h0.8h105.4V90.1H92.8z"/>
2215
+ </svg>
2216
+
2217
+ `,
2218
+ 'DockRight': `
2219
+ <svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
2220
+ viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
2221
+ <g>
2222
+ <path d="M25,369.7V130.3C25,99.8,49.8,75,80.3,75h339.4c30.5,0,55.3,24.8,55.3,55.3v239.4c0,30.5-24.8,55.3-55.3,55.3H80.3
2223
+ C49.8,425,25,400.2,25,369.7z M80.3,95C60.8,95,45,110.8,45,130.3v239.4c0,19.5,15.8,35.3,35.3,35.3h339.4
2224
+ c19.5,0,35.3-15.8,35.3-35.3V130.3c0-19.5-15.8-35.3-35.3-35.3H80.3z"/>
2225
+ </g>
2226
+ <path d="M407.2,90.1h0.8h4.2c24.8,0,45,20.2,45,45v229.8c0,24.8-20.2,45-45,45H408h-0.8H301.8V90.1H407.2z"/>
2227
+ </svg>
2228
+
2229
+ `,
2230
+ 'Pin': `
2231
+ <svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
2232
+ viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
2233
+ <g>
2234
+ <path d="M368,312.1H132l-0.6-9.4c-0.1-2.4-0.2-4.8-0.2-7.1c0-40.3,20.7-78.1,54.4-99.9V73.2h-9c-13,0-23.6-10.6-23.6-23.6
2235
+ S163.5,26,176.6,26h146.9c13,0,23.6,10.6,23.6,23.6s-10.6,23.6-23.6,23.6h-9v122.5c33.7,21.8,54.4,59.5,54.4,99.9
2236
+ c0,2.3-0.1,4.7-0.2,7.1L368,312.1z M151.2,292.1h197.5c-1.2-33.8-19.9-65.1-49.4-82.1l-5-2.9V53.2h29c2,0,3.6-1.6,3.6-3.6
2237
+ c0-2-1.6-3.6-3.6-3.6H176.6c-2,0-3.6,1.6-3.6,3.6c0,2,1.6,3.6,3.6,3.6h29v153.9l-5,2.9C171.1,227,152.4,258.3,151.2,292.1z"/>
2238
+ </g>
2239
+ <path d="M260.9,403.8V299.9h-21.8v108.8h0c0.1,36.1,4.9,65.3,10.9,65.3c6,0,10.9-29.7,10.9-66.4
2240
+ C260.9,406.4,260.9,405.1,260.9,403.8z"/>
2241
+ </svg>
2242
+
2243
+ `,
2244
+ 'WindowPopout': `
2245
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
2246
+ viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
2247
+ <style type="text/css">
2248
+ .st0{fill:none;stroke:#000000;stroke-width:20;stroke-miterlimit:10;}
2249
+ </style>
2250
+ <path class="st0" d="M420.1,359.6h-285c-24.7,0-45-20.2-45-45V124.9c0-24.7,20.2-45,45-45h285c24.7,0,45,20.2,45,45v189.7
2251
+ C465.1,339.3,444.9,359.6,420.1,359.6z"/>
2252
+ <path class="st0" d="M407.3,389.8c-6.3,17.3-22.9,29.7-42.3,29.7H80c-24.7,0-45-20.2-45-45V184.9c0-18.2,10.9-33.9,26.5-41"/>
2253
+ </svg>
2254
+
2255
+ `,
2256
+ 'Plus': `
2257
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 500 500">
2258
+ <path d="M254.7,486h-10.3c-5.5,0-10-4.5-10-10V26c0-5.5,4.5-10,10-10h10.3c5.5,0,10,4.5,10,10v450C264.6,481.5,260.2,486,254.7,486z"/>
2259
+ <path d="M15,255.1v-10.3c0-5.5,4.5-10,10-10h450c5.5,0,10,4.5,10,10v10.3c0,5.5-4.5,10-10,10H25C19.5,265.1,15,260.7,15,255.1z"/>
2260
+ </svg>
2261
+
2262
+ `,
2263
+ 'Minus': `
2264
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 500 500">
2265
+ <path d="M15,255.1v-10.3c0-5.5,4.5-10,10-10h450c5.5,0,10,4.5,10,10v10.3c0,5.5-4.5,10-10,10H25C19.5,265.1,15,260.7,15,255.1z"/>
2266
+ </svg>
2165
2267
  `
2166
2268
  }
2167
2269
 
@@ -2217,7 +2319,7 @@ class WebsyLoadingDialog {
2217
2319
  }
2218
2320
  }
2219
2321
 
2220
- /* global */
2322
+ /* global WebsyDesigns */
2221
2323
  class WebsyNavigationMenu {
2222
2324
  constructor (elementId, options) {
2223
2325
  this.options = Object.assign({}, {
@@ -2225,20 +2327,28 @@ class WebsyNavigationMenu {
2225
2327
  orientation: 'horizontal',
2226
2328
  parentMap: {},
2227
2329
  childIndentation: 10,
2228
- activeSymbol: 'none'
2330
+ activeSymbol: 'none',
2331
+ enableSearch: false,
2332
+ searchProp: 'text',
2333
+ menuIcon: `<svg viewbox="0 0 40 40" width="30" height="40">
2334
+ <rect x="0" y="0" width="30" height="4" rx="2"></rect>
2335
+ <rect x="0" y="12" width="30" height="4" rx="2"></rect>
2336
+ <rect x="0" y="24" width="30" height="4" rx="2"></rect>
2337
+ </svg>`,
2338
+ searchOptions: {}
2229
2339
  }, options)
2230
2340
  if (!elementId) {
2231
2341
  console.log('No element Id provided for Websy Menu')
2232
2342
  return
2233
2343
  }
2344
+ this.maxLevel = 0
2234
2345
  const el = document.getElementById(elementId)
2235
2346
  if (el) {
2236
2347
  this.elementId = elementId
2237
2348
  this.lowestLevel = 0
2238
2349
  this.flatItems = []
2239
2350
  this.itemMap = {}
2240
- this.flattenItems(0, this.options.items)
2241
- console.log(this.flatItems)
2351
+ this.flattenItems(0, this.options.items)
2242
2352
  el.classList.add(`websy-${this.options.orientation}-list-container`)
2243
2353
  el.classList.add('websy-menu')
2244
2354
  if (this.options.align) {
@@ -2250,27 +2360,27 @@ class WebsyNavigationMenu {
2250
2360
  if (this.options.classes) {
2251
2361
  this.options.classes.split(' ').forEach(c => el.classList.add(c))
2252
2362
  }
2253
- el.addEventListener('click', this.handleClick.bind(this))
2363
+ el.addEventListener('click', this.handleClick.bind(this))
2254
2364
  this.render()
2255
2365
  }
2256
2366
  }
2257
- flattenItems (index, items, level = 0) {
2367
+ flattenItems (index, items, level = 0, path = '') {
2258
2368
  if (items[index]) {
2259
2369
  this.lowestLevel = Math.max(level, this.lowestLevel)
2260
2370
  items[index].id = items[index].id || `${this.elementId}_${this.normaliseString(items[index].text)}`
2261
- this.itemMap[items[index].id] = items[index]
2262
2371
  items[index].level = level
2372
+ items[index].hasChildren = items[index].items && items[index].items.length > 0
2373
+ items[index].path = path !== '' ? `${path}::${items[index].id}` : items[index].id
2374
+ this.itemMap[items[index].id] = Object.assign({}, items[index])
2263
2375
  this.flatItems.push(items[index])
2264
2376
  if (items[index].items) {
2265
- this.flattenItems(0, items[index].items, level + 1)
2377
+ this.flattenItems(0, items[index].items, level + 1, items[index].path)
2266
2378
  }
2267
- this.flattenItems(++index, items, level)
2379
+ this.flattenItems(++index, items, level, path)
2268
2380
  }
2269
2381
  }
2270
2382
  handleClick (event) {
2271
- if (event.target.classList.contains('websy-menu-icon') ||
2272
- event.target.nodeName === 'svg' ||
2273
- event.target.nodeName === 'rect') {
2383
+ if (event.target.classList.contains('websy-menu-icon')) {
2274
2384
  this.toggleMobileMenu()
2275
2385
  }
2276
2386
  if (event.target.classList.contains('websy-menu-header')) {
@@ -2278,7 +2388,7 @@ class WebsyNavigationMenu {
2278
2388
  if (event.target.classList.contains('trigger-item') && item.level === this.lowestLevel) {
2279
2389
  this.toggleMobileMenu('remove')
2280
2390
  }
2281
- if (item.items) {
2391
+ if (item.hasChildren === true) {
2282
2392
  event.target.classList.toggle('menu-open')
2283
2393
  this.toggleMenu(item.id)
2284
2394
  }
@@ -2287,6 +2397,42 @@ class WebsyNavigationMenu {
2287
2397
  this.toggleMobileMenu()
2288
2398
  }
2289
2399
  }
2400
+ handleSearch (searchText) {
2401
+ const el = document.getElementById(this.elementId)
2402
+ let lowestItems = this.flatItems.filter(d => d.level === this.maxLevel)
2403
+ let visibleItems = lowestItems
2404
+ let defaultMethod = 'remove'
2405
+ if (searchText.length > 1) {
2406
+ defaultMethod = 'add'
2407
+ visibleItems = lowestItems.filter(d => d[this.options.searchProp].toLowerCase().indexOf(searchText.toLowerCase()) !== -1)
2408
+ }
2409
+ // hide everything
2410
+ const textEls = el.querySelectorAll(`div.websy-menu-header`)
2411
+ for (let t = 0; t < textEls.length; t++) {
2412
+ textEls[t].classList[defaultMethod]('websy-hidden')
2413
+ }
2414
+ const listEls = el.querySelectorAll(`ul.websy-child-list`)
2415
+ for (let l = 0; l < listEls.length; l++) {
2416
+ listEls[l].classList.add('websy-menu-collapsed')
2417
+ }
2418
+ if (searchText.length > 1) {
2419
+ visibleItems.forEach(d => {
2420
+ // show the item and open the list
2421
+ let pathParts = d.path.split('::')
2422
+ pathParts.forEach(p => {
2423
+ const textEl = document.getElementById(p)
2424
+ if (textEl) {
2425
+ textEl.classList.remove('websy-hidden')
2426
+ }
2427
+ const listEl = document.getElementById(`${p}_list`)
2428
+ if (listEl) {
2429
+ listEl.classList.remove('websy-menu-collapsed')
2430
+ }
2431
+ })
2432
+ })
2433
+ }
2434
+ console.log('visibleItems', visibleItems)
2435
+ }
2290
2436
  normaliseString (text) {
2291
2437
  return text.replace(/-/g, '').replace(/\s/g, '_')
2292
2438
  }
@@ -2297,14 +2443,10 @@ class WebsyNavigationMenu {
2297
2443
  if (this.options.collapsible === true) {
2298
2444
  html += `
2299
2445
  <div id='${this.elementId}_menuIcon' class='websy-menu-icon'>
2300
- <svg viewbox="0 0 40 40" width="30" height="40">
2301
- <rect x="0" y="0" width="30" height="4" rx="2"></rect>
2302
- <rect x="0" y="12" width="30" height="4" rx="2"></rect>
2303
- <rect x="0" y="24" width="30" height="4" rx="2"></rect>
2304
- </svg>
2446
+ ${this.options.menuIcon}
2305
2447
  </div>
2306
2448
  `
2307
- }
2449
+ }
2308
2450
  if (this.options.logo) {
2309
2451
  if (Array.isArray(this.options.logo.classes)) {
2310
2452
  this.options.logo.classes = this.options.logo.classes.join(' ')
@@ -2320,14 +2462,25 @@ class WebsyNavigationMenu {
2320
2462
  <div id="${this.elementId}_menuContainer" class="websy-menu-block-container">
2321
2463
  `
2322
2464
  }
2323
- html += this.renderBlock(this.options.items, 'main', 0)
2465
+ if (this.options.enableSearch === true) {
2466
+ html += `
2467
+ <div id='${this.elementId}_search' class='websy-menu-search'></div>
2468
+ `
2469
+ }
2470
+ html += this.renderBlock(this.elementId, this.elementId, this.options.items, 'main', 0)
2324
2471
  html += `</div>`
2325
2472
  el.innerHTML = html
2473
+ if (this.options.enableSearch === true) {
2474
+ this.search = new WebsyDesigns.Search(`${this.elementId}_search`, Object.assign({}, {
2475
+ onSearch: this.handleSearch.bind(this)
2476
+ }, this.options.searchOptions))
2477
+ }
2326
2478
  }
2327
2479
  }
2328
- renderBlock (items, block, level = 0) {
2480
+ renderBlock (id, path, items, block, level = 0) {
2481
+ this.maxLevel = Math.max(this.maxLevel, level)
2329
2482
  let html = `
2330
- <ul class='websy-${this.options.orientation}-list ${level > 0 ? 'websy-child-list' : ''} ${(block !== 'main' ? 'websy-menu-collapsed' : '')}' id='${this.elementId}_${block}_list'
2483
+ <ul class='websy-${this.options.orientation}-list ${level > 0 ? 'websy-child-list' : ''} ${(block !== 'main' ? 'websy-menu-collapsed' : '')}' id='${id}_list' data-path='${path}'
2331
2484
  `
2332
2485
  if (block !== 'main') {
2333
2486
  html += ` data-collapsed='${(block !== 'main' ? 'true' : 'false')}'`
@@ -2345,13 +2498,14 @@ class WebsyNavigationMenu {
2345
2498
  html += `
2346
2499
  <li class='websy-${this.options.orientation}-list-item ${items[i].alwaysOpen === true ? 'always-open' : ''}'>
2347
2500
  <div class='websy-menu-header ${items[i].classes || ''} ${selected} ${active}'
2348
- id='${blockId}'
2349
- data-id='${currentBlock}'
2350
- data-menu-id='${this.elementId}_${currentBlock}_list'
2351
- data-popout-id='${level > 1 ? block : currentBlock}'
2352
- data-text='${items[i].isLink !== true ? items[i].text : ''}'
2353
- style='padding-left: ${level * this.options.childIndentation}px'
2354
- ${(items[i].attributes && items[i].attributes.join(' ')) || ''}
2501
+ id='${blockId}'
2502
+ data-id='${currentBlock}'
2503
+ data-path='${items[i].path}'
2504
+ data-menu-id='${this.elementId}_${currentBlock}_list'
2505
+ data-popout-id='${level > 1 ? block : currentBlock}'
2506
+ data-text='${items[i].isLink !== true ? items[i].text : ''}'
2507
+ style='padding-left: ${level * this.options.childIndentation}px'
2508
+ ${(items[i].attributes && items[i].attributes.join(' ')) || ''}
2355
2509
  >
2356
2510
  `
2357
2511
  if (this.options.orientation === 'horizontal') {
@@ -2371,9 +2525,9 @@ class WebsyNavigationMenu {
2371
2525
  <span class='${items[i].items && items[i].items.length > 0 ? 'menu-carat' : ''}'></span>
2372
2526
  `
2373
2527
  if (this.options.orientation === 'vertical') {
2374
- html += `
2375
- &nbsp;
2376
- `
2528
+ // html += `
2529
+ // &nbsp;
2530
+ // `
2377
2531
  }
2378
2532
  if (items[i].isLink === true && items[i].href) {
2379
2533
  html += `<a href='${items[i].href}'>${items[i].text}</a>`
@@ -2382,7 +2536,7 @@ class WebsyNavigationMenu {
2382
2536
  </div>
2383
2537
  `
2384
2538
  if (items[i].items) {
2385
- html += this.renderBlock(items[i].items, currentBlock, items[i].level + 1)
2539
+ html += this.renderBlock(blockId, items[i].path, items[i].items, currentBlock, items[i].level + 1)
2386
2540
  }
2387
2541
  // map the item to it's parent
2388
2542
  if (block && block !== 'main') {
@@ -2399,6 +2553,8 @@ class WebsyNavigationMenu {
2399
2553
  }
2400
2554
  toggleMenu (id) {
2401
2555
  const el = document.getElementById(`${id}_list`)
2556
+ // const menuId = el.getAttribute('data-menu-id')
2557
+ // const menuEl = document.getElementById(menuId)
2402
2558
  if (el) {
2403
2559
  el.classList.toggle('websy-menu-collapsed')
2404
2560
  }
@@ -3336,7 +3492,14 @@ class WebsyRouter {
3336
3492
  this.previousView = ''
3337
3493
  this.currentView = ''
3338
3494
  this.currentViewMain = ''
3339
- this.currentParams = {}
3495
+ this.currentParams = {
3496
+ path: '',
3497
+ items: {}
3498
+ }
3499
+ this.previousParams = {
3500
+ path: '',
3501
+ items: {}
3502
+ }
3340
3503
  this.controlPressed = false
3341
3504
  this.usesHTMLSuffix = window.location.pathname.indexOf('.htm') !== -1
3342
3505
  window.addEventListener('popstate', this.onPopState.bind(this))
@@ -3377,10 +3540,11 @@ class WebsyRouter {
3377
3540
  }
3378
3541
  }
3379
3542
  }
3380
- addUrlParams (params) {
3543
+ addUrlParams (params, reloadView = false) {
3381
3544
  if (typeof params === 'undefined') {
3382
3545
  return
3383
3546
  }
3547
+ this.previousParams = Object.assign({}, this.currentParams)
3384
3548
  const output = {
3385
3549
  path: '',
3386
3550
  items: {}
@@ -3402,6 +3566,9 @@ class WebsyRouter {
3402
3566
  history.pushState({
3403
3567
  inputPath
3404
3568
  }, inputPath, `${inputPath}?${path}`)
3569
+ if (reloadView === true) {
3570
+ this.showView(this.currentView, this.currentParams, 'main')
3571
+ }
3405
3572
  }
3406
3573
  buildUrlPath (params) {
3407
3574
  let path = []
@@ -3430,6 +3597,7 @@ class WebsyRouter {
3430
3597
  }
3431
3598
  }
3432
3599
  formatParams (params) {
3600
+ this.previousParams = Object.assign({}, this.currentParams)
3433
3601
  const output = {
3434
3602
  path: params,
3435
3603
  items: {}
@@ -3649,6 +3817,10 @@ class WebsyRouter {
3649
3817
  if (this.previousView !== this.currentView || group !== 'main') {
3650
3818
  this.showComponents(view)
3651
3819
  this.publish('show', [view, params, group])
3820
+ }
3821
+ else if (this.previousView === this.currentView && this.previousParams.path !== this.currentParams.path) {
3822
+ this.showComponents(view)
3823
+ this.publish('show', [view, params, group])
3652
3824
  }
3653
3825
  }
3654
3826
  reloadCurrentView () {
@@ -3664,17 +3836,14 @@ class WebsyRouter {
3664
3836
  let groupActiveView
3665
3837
  let params = {}
3666
3838
  let newPath = inputPath
3667
- if (inputPath === this.options.defaultView && this.usesHTMLSuffix === false) {
3839
+ if (inputPath.split('?')[0] === this.options.defaultView && this.usesHTMLSuffix === false) {
3668
3840
  inputPath = inputPath.replace(this.options.defaultView, '/')
3669
3841
  }
3670
3842
  if (this.options.persistentParameters === true) {
3671
3843
  if (inputPath.indexOf('?') === -1 && this.queryParams) {
3672
3844
  inputPath += `?${this.queryParams}`
3673
3845
  }
3674
- }
3675
- else {
3676
- this.currentParams = {}
3677
- }
3846
+ }
3678
3847
  if (this.usesHTMLSuffix === true) {
3679
3848
  if (inputPath.indexOf('?') === -1) {
3680
3849
  inputPath = `?view=${inputPath}`
@@ -3695,7 +3864,11 @@ class WebsyRouter {
3695
3864
  inputPath = parts[0]
3696
3865
  }
3697
3866
  else if (group === this.options.defaultGroup) {
3698
- this.currentParams = {}
3867
+ this.previousParams = Object.assign({}, this.currentParams)
3868
+ this.currentParams = {
3869
+ path: '',
3870
+ items: {}
3871
+ }
3699
3872
  }
3700
3873
  if (event) {
3701
3874
  if (event.target && event.target.classList.contains(this.options.triggerToggleClass)) {
@@ -3747,13 +3920,7 @@ class WebsyRouter {
3747
3920
  }
3748
3921
  if (toggle === true && newPath === groupActiveView) {
3749
3922
  return
3750
- }
3751
- if (toggle === false) {
3752
- this.showView(this.currentView, this.currentParams, group)
3753
- }
3754
- else if (newPath && newPath !== '') {
3755
- this.showView(newPath, null, group)
3756
- }
3923
+ }
3757
3924
  if (this.usesHTMLSuffix === true) {
3758
3925
  inputPath = window.location.pathname.split('/').pop() + inputPath
3759
3926
  }
@@ -3780,6 +3947,12 @@ class WebsyRouter {
3780
3947
  //
3781
3948
  }
3782
3949
  }
3950
+ if (toggle === false) {
3951
+ this.showView(this.currentView, this.currentParams, group)
3952
+ }
3953
+ else if (newPath && newPath !== '') {
3954
+ this.showView(newPath, null, group)
3955
+ }
3783
3956
  }
3784
3957
  on (event, fn) {
3785
3958
  this.options.subscribers[event].push(fn)
@@ -5345,7 +5518,7 @@ class WebsyTable3 {
5345
5518
  `).join('')
5346
5519
  bodyHtml += '</colgroup>'
5347
5520
  }
5348
- data.forEach(row => {
5521
+ data.forEach((row, rowIndex) => {
5349
5522
  bodyHtml += `<tr class="websy-table-row">`
5350
5523
  row.forEach((cell, cellIndex) => {
5351
5524
  if (typeof sizingColumns[cellIndex] === 'undefined') {
@@ -5374,6 +5547,8 @@ class WebsyTable3 {
5374
5547
  data-info='${cell.value}'
5375
5548
  colspan='${cell.colspan || 1}'
5376
5549
  rowspan='${cell.rowspan || 1}'
5550
+ data-row-index='${rowIndex}'
5551
+ data-col-index='${cellIndex}'
5377
5552
  `
5378
5553
  // if (useWidths === true) {
5379
5554
  // bodyHtml += `
@@ -5382,7 +5557,22 @@ class WebsyTable3 {
5382
5557
  // `
5383
5558
  // }
5384
5559
  bodyHtml += `
5385
- >
5560
+ >`
5561
+ if (cell.expandable === true) {
5562
+ bodyHtml += `<i
5563
+ data-row-index='${rowIndex}'
5564
+ data-col-index='${cellIndex}'
5565
+ class='websy-table-cell-expand'
5566
+ >${WebsyDesigns.Icons.Plus}</i>`
5567
+ }
5568
+ if (cell.collapsable === true) {
5569
+ bodyHtml += `<i
5570
+ data-row-index='${rowIndex}'
5571
+ data-col-index='${cellIndex}'
5572
+ class='websy-table-cell-collapse'
5573
+ >${WebsyDesigns.Icons.Minus}</i>`
5574
+ }
5575
+ bodyHtml += `
5386
5576
  ${cell.value}
5387
5577
  </td>`
5388
5578
  })
@@ -5600,13 +5790,30 @@ class WebsyTable3 {
5600
5790
  return output
5601
5791
  }
5602
5792
  handleClick (event) {
5793
+ const colIndex = +event.target.getAttribute('data-col-index')
5794
+ const rowIndex = +event.target.getAttribute('data-row-index')
5603
5795
  if (event.target.classList.contains('websy-table-search-icon')) {
5604
- console.log('clicked on search icon')
5605
- const colIndex = +event.target.getAttribute('data-col-index')
5796
+ console.log('clicked on search icon')
5606
5797
  if (this.options.columns[this.options.columns.length - 1][colIndex].onSearch) {
5607
5798
  this.options.columns[this.options.columns.length - 1][colIndex].onSearch(event, this.options.columns[this.options.columns.length - 1][colIndex])
5608
5799
  }
5609
5800
  }
5801
+ if (event.target.classList.contains('websy-table-cell-collapse')) {
5802
+ if (this.options.onCollapseCell) {
5803
+ this.options.onCollapseCell(event, +rowIndex, +colIndex)
5804
+ }
5805
+ else {
5806
+ // out of box function
5807
+ }
5808
+ }
5809
+ if (event.target.classList.contains('websy-table-cell-expand')) {
5810
+ if (this.options.onExpandCell) {
5811
+ this.options.onExpandCell(event, +rowIndex, +colIndex)
5812
+ }
5813
+ else {
5814
+ // out of box function
5815
+ }
5816
+ }
5610
5817
  }
5611
5818
  handleMouseDown (event) {
5612
5819
  if (event.target.classList.contains('websy-scroll-handle-y')) {
@@ -6311,6 +6518,9 @@ else {
6311
6518
  this.longestBottom = this.options.data.bottom.max.toString()
6312
6519
  if (this.options.data.bottom.formatter) {
6313
6520
  this.longestBottom = this.options.data.bottom.formatter(this.options.data.bottom.max).toString()
6521
+ }
6522
+ else {
6523
+ this.longestBottom = '01/01/2000'
6314
6524
  }
6315
6525
  }
6316
6526
  if (this.options.data.left && this.options.data.left.data && this.options.data.left.max === 'undefined') {
@@ -6826,8 +7036,8 @@ if (this.options.showLabels === true || series.showLabels === true) {
6826
7036
  .style('stroke-opacity', 1e-6)
6827
7037
  .remove()
6828
7038
  labels
6829
- .attr('x', getLabelX.bind(this))
6830
- .attr('y', getLabelY.bind(this))
7039
+ .attr('x', d => getLabelX.call(this, d, series.labelPosition))
7040
+ .attr('y', d => getLabelY.call(this, d, series.labelPosition))
6831
7041
  .attr('class', `label_${series.key}`)
6832
7042
  .attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
6833
7043
  .style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
@@ -6863,8 +7073,8 @@ if (this.options.showLabels === true || series.showLabels === true) {
6863
7073
  .enter()
6864
7074
  .append('text')
6865
7075
  .attr('class', `label_${series.key}`)
6866
- .attr('x', getLabelX.bind(this))
6867
- .attr('y', getLabelY.bind(this))
7076
+ .attr('x', d => getLabelX.call(this, d, series.labelPosition))
7077
+ .attr('y', d => getLabelY.call(this, d, series.labelPosition))
6868
7078
  .attr('alignment-baseline', 'central')
6869
7079
  .attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle')
6870
7080
  .attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))