@websy/websy-designs 1.6.2 → 1.7.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.
- package/dist/server/helpers/v1/authHelper.js +3 -2
- package/dist/server/helpers/v1/pgHelper.js +1 -0
- package/dist/websy-designs-es6.debug.js +278 -98
- package/dist/websy-designs-es6.js +600 -369
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +280 -100
- package/dist/websy-designs.js +606 -375
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -1784,7 +1784,13 @@ class WebsyDropdown {
|
|
|
1784
1784
|
}
|
|
1785
1785
|
this.updateHeader(item)
|
|
1786
1786
|
}
|
|
1787
|
-
|
|
1787
|
+
get value () {
|
|
1788
|
+
if (this.selectedItems && this.selectedItems.length > 0) {
|
|
1789
|
+
return this.selectedItems.map((d, i) => this.options.items[+d])
|
|
1790
|
+
}
|
|
1791
|
+
return []
|
|
1792
|
+
}
|
|
1793
|
+
set value (value) {
|
|
1788
1794
|
this.selectedItems = []
|
|
1789
1795
|
if (Array.isArray(value)) {
|
|
1790
1796
|
this.options.items.forEach(d => {
|
|
@@ -1896,6 +1902,9 @@ class WebsyDropdown {
|
|
|
1896
1902
|
if (item && this.options.onItemSelected) {
|
|
1897
1903
|
this.options.onItemSelected(item, this.selectedItems, dataToUse, this.options)
|
|
1898
1904
|
}
|
|
1905
|
+
if (this.options.onChange) {
|
|
1906
|
+
this.options.onChange(this)
|
|
1907
|
+
}
|
|
1899
1908
|
if (this.options.closeAfterSelection === true) {
|
|
1900
1909
|
this.close()
|
|
1901
1910
|
}
|
|
@@ -2209,7 +2218,9 @@ class WebsyForm {
|
|
|
2209
2218
|
// if (this.options.classes) {
|
|
2210
2219
|
// this.options.classes.forEach(c => el.classList.add(c))
|
|
2211
2220
|
// }
|
|
2221
|
+
el.addEventListener('change', this.handleChange.bind(this))
|
|
2212
2222
|
el.addEventListener('click', this.handleClick.bind(this))
|
|
2223
|
+
el.addEventListener('focusout', this.handleFocusOut.bind(this))
|
|
2213
2224
|
el.addEventListener('keyup', this.handleKeyUp.bind(this))
|
|
2214
2225
|
el.addEventListener('keydown', this.handleKeyDown.bind(this))
|
|
2215
2226
|
this.render()
|
|
@@ -2265,15 +2276,18 @@ class WebsyForm {
|
|
|
2265
2276
|
this.options.fields = []
|
|
2266
2277
|
}
|
|
2267
2278
|
for (let key in d) {
|
|
2268
|
-
this.options.fields.forEach(f => {
|
|
2279
|
+
this.options.fields.forEach(f => {
|
|
2269
2280
|
if (f.field === key) {
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2281
|
+
this.setValue(key, d[key])
|
|
2282
|
+
// f.value = d[key]
|
|
2283
|
+
// const el = document.getElementById(`${this.elementId}_input_${f.field}`)
|
|
2284
|
+
// if (el) {
|
|
2285
|
+
// el.value = f.value
|
|
2286
|
+
// }
|
|
2273
2287
|
}
|
|
2274
2288
|
})
|
|
2275
2289
|
}
|
|
2276
|
-
this.render()
|
|
2290
|
+
// this.render()
|
|
2277
2291
|
}
|
|
2278
2292
|
confirmValidation () {
|
|
2279
2293
|
const el = document.getElementById(`${this.elementId}_validationFail`)
|
|
@@ -2287,6 +2301,20 @@ class WebsyForm {
|
|
|
2287
2301
|
el.innerHTML = msg
|
|
2288
2302
|
}
|
|
2289
2303
|
}
|
|
2304
|
+
handleChange (event) {
|
|
2305
|
+
if (event.target.getAttribute('data-user-type') === 'expiry') {
|
|
2306
|
+
if (event.target.value.length === 7) {
|
|
2307
|
+
let value = event.target.value.split('/')
|
|
2308
|
+
event.target.value = `${value[0]}/${value[1].substring(2, 4)}`
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
if (event.target.classList.contains('websy-input')) {
|
|
2312
|
+
let index = event.target.getAttribute('data-index')
|
|
2313
|
+
if (this.options.fields[index] && (this.options.fields[index].required || this.options.fields[index].validate)) {
|
|
2314
|
+
this.validateField(this.options.fields[index], event.target.value)
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2290
2318
|
handleClick (event) {
|
|
2291
2319
|
if (event.target.classList.contains('submit')) {
|
|
2292
2320
|
event.preventDefault()
|
|
@@ -2297,13 +2325,68 @@ class WebsyForm {
|
|
|
2297
2325
|
this.cancelForm()
|
|
2298
2326
|
}
|
|
2299
2327
|
}
|
|
2328
|
+
handleFocusOut (event) {
|
|
2329
|
+
if (event.target.classList.contains('websy-input')) {
|
|
2330
|
+
let index = event.target.getAttribute('data-index')
|
|
2331
|
+
if (this.options.fields[index] && (this.options.fields[index].required || this.options.fields[index].validate)) {
|
|
2332
|
+
this.validateField(this.options.fields[index], event.target.value)
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2300
2336
|
handleKeyDown (event) {
|
|
2301
2337
|
if (event.key === 'enter') {
|
|
2302
2338
|
this.submitForm()
|
|
2303
2339
|
}
|
|
2340
|
+
if (event.target.getAttribute('data-user-type') === 'expiry') {
|
|
2341
|
+
let isNumeric = !isNaN(event.key)
|
|
2342
|
+
let validKey = false
|
|
2343
|
+
if (!validKey) {
|
|
2344
|
+
validKey = ['ArrowLeft', 'ArrowRight', 'Backspace', 'Delete', 'Tab'].indexOf(event.key) !== -1
|
|
2345
|
+
}
|
|
2346
|
+
if ((event.target.value.length === 5 && !validKey) || (!validKey && !isNumeric)) {
|
|
2347
|
+
event.preventDefault()
|
|
2348
|
+
return false
|
|
2349
|
+
}
|
|
2350
|
+
if (event.key === 'Backspace') {
|
|
2351
|
+
if (event.target.value.indexOf('/') === event.target.selectionStart - 1) {
|
|
2352
|
+
let chars = event.target.value.split('')
|
|
2353
|
+
chars.pop()
|
|
2354
|
+
event.target.value = chars.join('')
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
if (event.target.getAttribute('data-user-type') === 'cvv') {
|
|
2359
|
+
let isNumeric = !isNaN(event.key)
|
|
2360
|
+
let validKey = false
|
|
2361
|
+
if (!validKey) {
|
|
2362
|
+
validKey = ['ArrowLeft', 'ArrowRight', 'Backspace', 'Delete', 'Tab'].indexOf(event.key) !== -1
|
|
2363
|
+
}
|
|
2364
|
+
if ((event.target.value.length === 3 && !validKey) || (!validKey && !isNumeric)) {
|
|
2365
|
+
event.preventDefault()
|
|
2366
|
+
return false
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2304
2369
|
}
|
|
2305
2370
|
handleKeyUp (event) {
|
|
2306
|
-
|
|
2371
|
+
if (event.target.getAttribute('data-user-type') === 'expiry') {
|
|
2372
|
+
let chars = event.target.value.split('')
|
|
2373
|
+
let isNumeric = !isNaN(event.key)
|
|
2374
|
+
if (event.key === 'Backspace') {
|
|
2375
|
+
if (chars[chars.length - 1] === '/' && chars.length !== 3) {
|
|
2376
|
+
chars.pop()
|
|
2377
|
+
event.target.value = chars.join('')
|
|
2378
|
+
return
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
if (event.target.selectionStart === 2) {
|
|
2382
|
+
if (chars[2] && ['ArrowLeft', 'ArrowRight', 'Backspace', 'Delete'].indexOf(event.key) === -1) {
|
|
2383
|
+
event.target.setSelectionRange(3, 3)
|
|
2384
|
+
}
|
|
2385
|
+
else if (isNumeric) {
|
|
2386
|
+
event.target.value += '/'
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2307
2390
|
}
|
|
2308
2391
|
processComponents (components, callbackFn) {
|
|
2309
2392
|
if (components.length === 0) {
|
|
@@ -2312,6 +2395,13 @@ class WebsyForm {
|
|
|
2312
2395
|
else {
|
|
2313
2396
|
components.forEach(c => {
|
|
2314
2397
|
if (typeof WebsyDesigns[c.component] !== 'undefined') {
|
|
2398
|
+
if (!c.options.onChange) {
|
|
2399
|
+
c.options.onChange = () => {
|
|
2400
|
+
if (c.required || c.validate) {
|
|
2401
|
+
this.validateField(c, c.instance.value)
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2315
2405
|
c.instance = new WebsyDesigns[c.component](`${this.elementId}_input_${c.field}_component`, c.options)
|
|
2316
2406
|
}
|
|
2317
2407
|
else {
|
|
@@ -2343,35 +2433,41 @@ class WebsyForm {
|
|
|
2343
2433
|
if (f.component) {
|
|
2344
2434
|
componentsToProcess.push(f)
|
|
2345
2435
|
html += `
|
|
2346
|
-
${i > 0 ? '-->' : ''}<div class='${f.classes || ''}'>
|
|
2347
|
-
${f.label ? `<label for="${f.field}">${f.label}</label>` : ''}
|
|
2436
|
+
${i > 0 ? '-->' : ''}<div id='${this.elementId}_${f.field}_inputContainer' class='websy-input-container ${f.classes || ''}'>
|
|
2437
|
+
${f.label ? `<label for="${f.field}">${f.label}</label>` : ''}${f.required === true ? '<span class="websy-form-required-value">*</span>' : ''}
|
|
2348
2438
|
<div id='${this.elementId}_input_${f.field}_component' class='form-component'></div>
|
|
2439
|
+
<span id='${this.elementId}_${f.field}_error' class='websy-form-validation-error'></span>
|
|
2349
2440
|
</div><!--
|
|
2350
2441
|
`
|
|
2351
2442
|
}
|
|
2352
2443
|
else if (f.type === 'longtext') {
|
|
2353
2444
|
html += `
|
|
2354
|
-
${i > 0 ? '-->' : ''}<div class='${f.classes || ''}'>
|
|
2355
|
-
${f.label ? `<label for="${f.field}">${f.label}</label>` : ''}
|
|
2445
|
+
${i > 0 ? '-->' : ''}<div id='${this.elementId}_${f.field}_inputContainer' class='websy-input-container ${f.classes || ''}'>
|
|
2446
|
+
${f.label ? `<label for="${f.field}">${f.label}</label>` : ''}${f.required === true ? '<span class="websy-form-required-value">*</span>' : ''}
|
|
2356
2447
|
<textarea
|
|
2357
2448
|
id="${this.elementId}_input_${f.field}"
|
|
2358
2449
|
${f.required === true ? 'required' : ''}
|
|
2359
2450
|
placeholder="${f.placeholder || ''}"
|
|
2451
|
+
data-user-type="${f.type}"
|
|
2452
|
+
data-index="${i}"
|
|
2360
2453
|
name="${f.field}"
|
|
2361
2454
|
${(f.attributes || []).join(' ')}
|
|
2362
2455
|
class="websy-input websy-textarea"
|
|
2363
2456
|
></textarea>
|
|
2457
|
+
<span id='${this.elementId}_${f.field}_error' class='websy-form-validation-error'></span>
|
|
2364
2458
|
</div><!--
|
|
2365
2459
|
`
|
|
2366
2460
|
}
|
|
2367
2461
|
else {
|
|
2368
2462
|
html += `
|
|
2369
|
-
${i > 0 ? '-->' : ''}<div class='${f.classes || ''}'>
|
|
2370
|
-
${f.label ? `<label for="${f.field}">${f.label}</label>` : ''}
|
|
2463
|
+
${i > 0 ? '-->' : ''}<div id='${this.elementId}_${f.field}_inputContainer' class='websy-input-container ${f.classes || ''}'>
|
|
2464
|
+
${f.label ? `<label for="${f.field}">${f.label}</label>` : ''}${f.required === true ? '<span class="websy-form-required-value">*</span>' : ''}
|
|
2371
2465
|
<input
|
|
2372
2466
|
id="${this.elementId}_input_${f.field}"
|
|
2373
2467
|
${f.required === true ? 'required' : ''}
|
|
2374
|
-
type="${f.type || 'text'}"
|
|
2468
|
+
type="${(f.type === 'expiry' ? 'text' : f.type === 'cvv' ? 'number' : f.type) || 'text'}"
|
|
2469
|
+
data-user-type="${f.type}"
|
|
2470
|
+
data-index="${i}"
|
|
2375
2471
|
class="websy-input"
|
|
2376
2472
|
${(f.attributes || []).join(' ')}
|
|
2377
2473
|
name="${f.field}"
|
|
@@ -2380,6 +2476,7 @@ class WebsyForm {
|
|
|
2380
2476
|
valueAsDate="${f.type === 'date' ? f.value : ''}"
|
|
2381
2477
|
oninvalidx="this.setCustomValidity('${f.invalidMessage || 'Please fill in this field.'}')"
|
|
2382
2478
|
/>
|
|
2479
|
+
<span id='${this.elementId}_${f.field}_error' class='websy-form-validation-error'></span>
|
|
2383
2480
|
</div><!--
|
|
2384
2481
|
`
|
|
2385
2482
|
}
|
|
@@ -2413,7 +2510,7 @@ class WebsyForm {
|
|
|
2413
2510
|
setValue (field, value) {
|
|
2414
2511
|
if (this.fieldMap[field]) {
|
|
2415
2512
|
if (this.fieldMap[field].instance) {
|
|
2416
|
-
this.fieldMap[field].instance.
|
|
2513
|
+
this.fieldMap[field].instance.value = value
|
|
2417
2514
|
}
|
|
2418
2515
|
else {
|
|
2419
2516
|
const el = document.getElementById(`${this.elementId}_input_${field}`)
|
|
@@ -2433,7 +2530,10 @@ class WebsyForm {
|
|
|
2433
2530
|
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
2434
2531
|
const buttonEl = formEl.querySelector('button.websy-btn.submit')
|
|
2435
2532
|
const recaptchErrEl = document.getElementById(`${this.elementId}_recaptchaError`)
|
|
2436
|
-
if (
|
|
2533
|
+
if (this.options.preSubmitFn && this.options.preSubmitFn() === false) {
|
|
2534
|
+
return
|
|
2535
|
+
}
|
|
2536
|
+
if (this.validateForm() === true) {
|
|
2437
2537
|
if (buttonEl) {
|
|
2438
2538
|
buttonEl.setAttribute('disabled', true)
|
|
2439
2539
|
}
|
|
@@ -2491,6 +2591,59 @@ class WebsyForm {
|
|
|
2491
2591
|
})
|
|
2492
2592
|
}
|
|
2493
2593
|
}
|
|
2594
|
+
validateForm () {
|
|
2595
|
+
let valid = true
|
|
2596
|
+
let data = this.data
|
|
2597
|
+
for (let i = 0; i < this.options.fields.length; i++) {
|
|
2598
|
+
if (this.options.fields[i].required || this.options.fields[i].validate) {
|
|
2599
|
+
if (this.validateField(this.options.fields[i], data[this.options.fields[i].field]) === false) {
|
|
2600
|
+
valid = false
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
return valid
|
|
2605
|
+
}
|
|
2606
|
+
validateField (field, value) {
|
|
2607
|
+
const inputContainerEl = document.getElementById(`${this.elementId}_${field.field}_inputContainer`)
|
|
2608
|
+
const errorEl = document.getElementById(`${this.elementId}_${field.field}_error`)
|
|
2609
|
+
if (field.required) {
|
|
2610
|
+
let valid = true
|
|
2611
|
+
if (field.component && field.instance && field.instance.value) {
|
|
2612
|
+
valid = field.instance.value.length > 0
|
|
2613
|
+
}
|
|
2614
|
+
else {
|
|
2615
|
+
valid = !(typeof value === 'undefined' || value === '')
|
|
2616
|
+
}
|
|
2617
|
+
if (!valid) {
|
|
2618
|
+
if (errorEl) {
|
|
2619
|
+
errorEl.innerHTML = field.invalidMessage || 'A value is required'
|
|
2620
|
+
}
|
|
2621
|
+
if (inputContainerEl) {
|
|
2622
|
+
inputContainerEl.classList.add('websy-form-input-has-error')
|
|
2623
|
+
}
|
|
2624
|
+
return false
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
if (field.validate) {
|
|
2628
|
+
let valid = field.validate(field, value)
|
|
2629
|
+
if (!valid) {
|
|
2630
|
+
if (errorEl) {
|
|
2631
|
+
errorEl.innerHTML = field.invalidMessage || 'A value is required'
|
|
2632
|
+
}
|
|
2633
|
+
if (inputContainerEl) {
|
|
2634
|
+
inputContainerEl.classList.add('websy-form-input-has-error')
|
|
2635
|
+
}
|
|
2636
|
+
return false
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
if (errorEl) {
|
|
2640
|
+
errorEl.innerHTML = ''
|
|
2641
|
+
}
|
|
2642
|
+
if (inputContainerEl) {
|
|
2643
|
+
inputContainerEl.classList.remove('websy-form-input-has-error')
|
|
2644
|
+
}
|
|
2645
|
+
return true
|
|
2646
|
+
}
|
|
2494
2647
|
validateRecaptcha (token) {
|
|
2495
2648
|
this.recaptchaValue = token
|
|
2496
2649
|
}
|
|
@@ -2683,24 +2836,26 @@ class WebsyLoadingDialog {
|
|
|
2683
2836
|
return
|
|
2684
2837
|
}
|
|
2685
2838
|
const el = document.getElementById(this.elementId)
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2839
|
+
if (el) {
|
|
2840
|
+
let html = `
|
|
2841
|
+
<div class='websy-loading-container ${(this.options.classes || []).join(' ')}'>
|
|
2842
|
+
<div class='websy-ripple'>
|
|
2843
|
+
<div></div>
|
|
2844
|
+
<div></div>
|
|
2845
|
+
</div>
|
|
2846
|
+
<h4>${this.options.title || 'Loading...'}</h4>
|
|
2847
|
+
`
|
|
2848
|
+
if (this.options.messages) {
|
|
2849
|
+
for (let i = 0; i < this.options.messages.length; i++) {
|
|
2850
|
+
html += `<p>${this.options.messages[i]}</p>`
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
html += `
|
|
2854
|
+
</div>
|
|
2855
|
+
`
|
|
2856
|
+
el.classList.add('loading')
|
|
2857
|
+
el.innerHTML = html
|
|
2858
|
+
}
|
|
2704
2859
|
}
|
|
2705
2860
|
show (options, override = false) {
|
|
2706
2861
|
if (options) {
|
|
@@ -4115,6 +4270,7 @@ class WebsyRouter {
|
|
|
4115
4270
|
output.items = Object.assign({}, params)
|
|
4116
4271
|
path = this.buildUrlPath(output.items)
|
|
4117
4272
|
}
|
|
4273
|
+
output.path = path
|
|
4118
4274
|
this.currentParams = output
|
|
4119
4275
|
let inputPath = this.currentView
|
|
4120
4276
|
if (this.options.urlPrefix) {
|
|
@@ -4127,13 +4283,13 @@ class WebsyRouter {
|
|
|
4127
4283
|
// this.showView(this.currentView, this.currentParams, 'main')
|
|
4128
4284
|
this.navigate(`${inputPath}?${path}`, 'main', null, noHistory)
|
|
4129
4285
|
}
|
|
4286
|
+
else {
|
|
4287
|
+
this.updateHistory(inputPath, !noHistory, true)
|
|
4288
|
+
}
|
|
4130
4289
|
}
|
|
4131
4290
|
removeUrlParams (params = [], reloadView = false, noHistory = true) {
|
|
4132
4291
|
this.previousParams = Object.assign({}, this.currentParams)
|
|
4133
|
-
|
|
4134
|
-
path: '',
|
|
4135
|
-
items: {}
|
|
4136
|
-
}
|
|
4292
|
+
|
|
4137
4293
|
let path = ''
|
|
4138
4294
|
if (this.currentParams && this.currentParams.items) {
|
|
4139
4295
|
params.forEach(p => {
|
|
@@ -4149,6 +4305,13 @@ class WebsyRouter {
|
|
|
4149
4305
|
// this.showView(this.currentView, this.currentParams, 'main')
|
|
4150
4306
|
this.navigate(`${inputPath}?${path}`, 'main', null, noHistory)
|
|
4151
4307
|
}
|
|
4308
|
+
else if (noHistory === false) {
|
|
4309
|
+
this.currentParams = {
|
|
4310
|
+
items: this.currentParams.items,
|
|
4311
|
+
path
|
|
4312
|
+
}
|
|
4313
|
+
this.updateHistory(inputPath, !noHistory, true)
|
|
4314
|
+
}
|
|
4152
4315
|
}
|
|
4153
4316
|
removeAllUrlParams (reloadView = false, noHistory = true) {
|
|
4154
4317
|
// const output = {
|
|
@@ -4163,14 +4326,12 @@ class WebsyRouter {
|
|
|
4163
4326
|
this.currentParams = {
|
|
4164
4327
|
path: '',
|
|
4165
4328
|
items: {}
|
|
4166
|
-
}
|
|
4329
|
+
}
|
|
4167
4330
|
if (reloadView === true) {
|
|
4168
4331
|
this.navigate(`${inputPath}`, 'main', null, noHistory)
|
|
4169
4332
|
}
|
|
4170
4333
|
else {
|
|
4171
|
-
|
|
4172
|
-
inputPath
|
|
4173
|
-
}, 'unused', inputPath)
|
|
4334
|
+
this.updateHistory(inputPath, !noHistory, true)
|
|
4174
4335
|
}
|
|
4175
4336
|
}
|
|
4176
4337
|
buildUrlPath (params) {
|
|
@@ -4445,6 +4606,9 @@ class WebsyRouter {
|
|
|
4445
4606
|
}
|
|
4446
4607
|
}
|
|
4447
4608
|
showView (view, params, group) {
|
|
4609
|
+
if (view === '/' || view === '') {
|
|
4610
|
+
view = this.options.defaultView || ''
|
|
4611
|
+
}
|
|
4448
4612
|
this.activateItem(view, this.options.triggerClass)
|
|
4449
4613
|
this.activateItem(view, this.options.viewClass)
|
|
4450
4614
|
let children = this.getActiveViewsFromParent(view)
|
|
@@ -4569,28 +4733,7 @@ class WebsyRouter {
|
|
|
4569
4733
|
}
|
|
4570
4734
|
if ((this.currentPath !== inputPath || previousParamsPath !== this.currentParams.path) && group === this.options.defaultGroup) {
|
|
4571
4735
|
let historyUrl = inputPath
|
|
4572
|
-
|
|
4573
|
-
historyUrl = historyUrl === '/' ? '' : `/${historyUrl}`
|
|
4574
|
-
inputPath = inputPath === '/' ? '' : `/${inputPath}`
|
|
4575
|
-
historyUrl = (`/${this.options.urlPrefix}${historyUrl}`).replace(/\/\//g, '/')
|
|
4576
|
-
inputPath = (`/${this.options.urlPrefix}${inputPath}`).replace(/\/\//g, '/')
|
|
4577
|
-
}
|
|
4578
|
-
if (this.currentParams && this.currentParams.path) {
|
|
4579
|
-
historyUrl += `?${this.currentParams.path}`
|
|
4580
|
-
}
|
|
4581
|
-
else if (this.queryParams && this.options.persistentParameters === true) {
|
|
4582
|
-
historyUrl += `?${this.queryParams}`
|
|
4583
|
-
}
|
|
4584
|
-
if (popped === false) {
|
|
4585
|
-
history.pushState({
|
|
4586
|
-
inputPath: historyUrl
|
|
4587
|
-
}, 'unused', historyUrl)
|
|
4588
|
-
}
|
|
4589
|
-
else {
|
|
4590
|
-
history.replaceState({
|
|
4591
|
-
inputPath: historyUrl
|
|
4592
|
-
}, 'unused', historyUrl)
|
|
4593
|
-
}
|
|
4736
|
+
this.updateHistory(historyUrl, popped)
|
|
4594
4737
|
}
|
|
4595
4738
|
if (toggle === false) {
|
|
4596
4739
|
this.showView(newPath.split('?')[0], this.currentParams, group)
|
|
@@ -4625,6 +4768,28 @@ class WebsyRouter {
|
|
|
4625
4768
|
item.apply(null, params)
|
|
4626
4769
|
})
|
|
4627
4770
|
}
|
|
4771
|
+
updateHistory (historyUrl, replaceState = false, overridePersistent = false) {
|
|
4772
|
+
if (this.options.urlPrefix) {
|
|
4773
|
+
historyUrl = historyUrl === '/' ? '' : `/${historyUrl}`
|
|
4774
|
+
historyUrl = (`/${this.options.urlPrefix}${historyUrl}`).replace(/\/\//g, '/')
|
|
4775
|
+
}
|
|
4776
|
+
if ((this.currentParams && this.currentParams.path) || overridePersistent === true) {
|
|
4777
|
+
historyUrl += `?${this.currentParams.path}`
|
|
4778
|
+
}
|
|
4779
|
+
else if (this.queryParams && this.options.persistentParameters === true) {
|
|
4780
|
+
historyUrl += `?${this.queryParams}`
|
|
4781
|
+
}
|
|
4782
|
+
if (replaceState === false) {
|
|
4783
|
+
history.pushState({
|
|
4784
|
+
inputPath: historyUrl
|
|
4785
|
+
}, 'unused', historyUrl)
|
|
4786
|
+
}
|
|
4787
|
+
else {
|
|
4788
|
+
history.replaceState({
|
|
4789
|
+
inputPath: historyUrl
|
|
4790
|
+
}, 'unused', historyUrl)
|
|
4791
|
+
}
|
|
4792
|
+
}
|
|
4628
4793
|
subscribe (event, fn) {
|
|
4629
4794
|
this.options.subscribers[event].push(fn)
|
|
4630
4795
|
}
|
|
@@ -4751,14 +4916,14 @@ class WebsySearch {
|
|
|
4751
4916
|
if (event.target.value.length >= this.options.minLength) {
|
|
4752
4917
|
this.searchTimeoutFn = setTimeout(() => {
|
|
4753
4918
|
if (this.options.onSearch) {
|
|
4754
|
-
this.options.onSearch(event.target.value)
|
|
4919
|
+
this.options.onSearch(event.target.value, event)
|
|
4755
4920
|
}
|
|
4756
4921
|
}, this.options.searchTimeout)
|
|
4757
4922
|
}
|
|
4758
4923
|
else {
|
|
4759
4924
|
if (this.options.onSearch && (event.key === 'Delete' || event.key === 'Backspace')) {
|
|
4760
4925
|
if (this.options.onSearch) {
|
|
4761
|
-
this.options.onSearch('')
|
|
4926
|
+
this.options.onSearch('', event)
|
|
4762
4927
|
}
|
|
4763
4928
|
}
|
|
4764
4929
|
}
|
|
@@ -6317,7 +6482,7 @@ class WebsyTable3 {
|
|
|
6317
6482
|
return ''
|
|
6318
6483
|
}
|
|
6319
6484
|
let bodyHtml = ``
|
|
6320
|
-
let sizingColumns = this.options.columns[this.options.columns.length - 1]
|
|
6485
|
+
let sizingColumns = this.options.columns[this.options.columns.length - 1].filter(c => c.show !== false)
|
|
6321
6486
|
if (useWidths === true) {
|
|
6322
6487
|
bodyHtml += '<colgroup>'
|
|
6323
6488
|
bodyHtml += sizingColumns.map(c => `
|
|
@@ -6329,9 +6494,9 @@ class WebsyTable3 {
|
|
|
6329
6494
|
}
|
|
6330
6495
|
data.forEach((row, rowIndex) => {
|
|
6331
6496
|
bodyHtml += `<tr class="websy-table-row">`
|
|
6332
|
-
row.forEach((cell, cellIndex) => {
|
|
6497
|
+
row.forEach((cell, cellIndex) => {
|
|
6333
6498
|
let sizeIndex = cell.level || cellIndex
|
|
6334
|
-
if (typeof sizingColumns[sizeIndex] === 'undefined') {
|
|
6499
|
+
if (typeof sizingColumns[sizeIndex] === 'undefined' || sizingColumns[sizeIndex].show === false) {
|
|
6335
6500
|
return // need to revisit this logic
|
|
6336
6501
|
}
|
|
6337
6502
|
let style = ''
|
|
@@ -6428,7 +6593,7 @@ class WebsyTable3 {
|
|
|
6428
6593
|
return ''
|
|
6429
6594
|
}
|
|
6430
6595
|
let headerHtml = ''
|
|
6431
|
-
let sizingColumns = this.options.columns[this.options.columns.length - 1]
|
|
6596
|
+
let sizingColumns = this.options.columns[this.options.columns.length - 1].filter(c => c.show !== false)
|
|
6432
6597
|
if (useWidths === true) {
|
|
6433
6598
|
headerHtml += '<colgroup>'
|
|
6434
6599
|
headerHtml += sizingColumns.map(c => `
|
|
@@ -6444,7 +6609,10 @@ class WebsyTable3 {
|
|
|
6444
6609
|
return
|
|
6445
6610
|
}
|
|
6446
6611
|
headerHtml += `<tr class="websy-table-row websy-table-header-row">`
|
|
6447
|
-
row.forEach((col, colIndex) => {
|
|
6612
|
+
row.filter(c => c.show !== false).forEach((col, colIndex) => {
|
|
6613
|
+
if (typeof sizingColumns[colIndex] === 'undefined' || sizingColumns[colIndex].show === false) {
|
|
6614
|
+
return // need to revisit this logic
|
|
6615
|
+
}
|
|
6448
6616
|
let style = `width: ${sizingColumns[colIndex].width || sizingColumns[colIndex].actualWidth}px!important; `
|
|
6449
6617
|
let divStyle = style
|
|
6450
6618
|
if (useWidths === true) {
|
|
@@ -6508,8 +6676,12 @@ class WebsyTable3 {
|
|
|
6508
6676
|
if (!this.options.totals) {
|
|
6509
6677
|
return ''
|
|
6510
6678
|
}
|
|
6679
|
+
let sizingColumns = this.options.columns[this.options.columns.length - 1].filter(c => c.show !== false)
|
|
6511
6680
|
let totalHtml = `<tr class="websy-table-row websy-table-total-row">`
|
|
6512
6681
|
this.options.totals.forEach((col, colIndex) => {
|
|
6682
|
+
if (typeof sizingColumns[colIndex] === 'undefined' || sizingColumns[colIndex].show === false) {
|
|
6683
|
+
return // need to revisit this logic
|
|
6684
|
+
}
|
|
6513
6685
|
totalHtml += `<td
|
|
6514
6686
|
class='websy-table-cell ${(col.classes || []).join(' ')}'
|
|
6515
6687
|
colspan='${col.colspan || 1}'
|
|
@@ -6565,36 +6737,37 @@ class WebsyTable3 {
|
|
|
6565
6737
|
let totalWidth = 0
|
|
6566
6738
|
this.sizes.scrollableWidth = this.sizes.outer.width
|
|
6567
6739
|
let firstNonPinnedColumnWidth = 0
|
|
6740
|
+
let columnsForSizing = this.options.columns[this.options.columns.length - 1].filter(c => c.show !== false)
|
|
6568
6741
|
rows.forEach((row, rowIndex) => {
|
|
6569
6742
|
Array.from(row.children).forEach((col, colIndex) => {
|
|
6570
6743
|
let colSize = col.getBoundingClientRect()
|
|
6571
6744
|
this.sizes.cellHeight = colSize.height
|
|
6572
|
-
if (
|
|
6573
|
-
if (!
|
|
6574
|
-
|
|
6745
|
+
if (columnsForSizing[colIndex]) {
|
|
6746
|
+
if (!columnsForSizing[colIndex].actualWidth) {
|
|
6747
|
+
columnsForSizing[colIndex].actualWidth = 0
|
|
6575
6748
|
}
|
|
6576
|
-
|
|
6577
|
-
|
|
6749
|
+
columnsForSizing[colIndex].actualWidth = Math.min(Math.max(columnsForSizing[colIndex].actualWidth, colSize.width), maxWidth)
|
|
6750
|
+
columnsForSizing[colIndex].cellHeight = colSize.height
|
|
6578
6751
|
if (colIndex >= this.pinnedColumns) {
|
|
6579
|
-
firstNonPinnedColumnWidth =
|
|
6752
|
+
firstNonPinnedColumnWidth = columnsForSizing[colIndex].actualWidth
|
|
6580
6753
|
}
|
|
6581
6754
|
}
|
|
6582
6755
|
})
|
|
6583
6756
|
})
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
})
|
|
6589
|
-
this.sizes.totalWidth =
|
|
6590
|
-
this.sizes.totalNonPinnedWidth =
|
|
6757
|
+
// columnsForSizing.forEach((col, colIndex) => {
|
|
6758
|
+
// if (colIndex < this.pinnedColumns) {
|
|
6759
|
+
// this.sizes.scrollableWidth -= col.actualWidth
|
|
6760
|
+
// }
|
|
6761
|
+
// })
|
|
6762
|
+
this.sizes.totalWidth = columnsForSizing.reduce((a, b) => a + (b.width || b.actualWidth), 0)
|
|
6763
|
+
this.sizes.totalNonPinnedWidth = columnsForSizing.filter((c, i) => i >= this.pinnedColumns).reduce((a, b) => a + (b.width || b.actualWidth), 0)
|
|
6591
6764
|
this.sizes.pinnedWidth = this.sizes.totalWidth - this.sizes.totalNonPinnedWidth
|
|
6592
6765
|
// const outerSize = outerEl.getBoundingClientRect()
|
|
6593
6766
|
if (this.sizes.totalWidth < this.sizes.outer.width) {
|
|
6594
|
-
let equalWidth = (this.sizes.outer.width - this.sizes.totalWidth) /
|
|
6767
|
+
let equalWidth = (this.sizes.outer.width - this.sizes.totalWidth) / columnsForSizing.length
|
|
6595
6768
|
this.sizes.totalWidth = 0
|
|
6596
6769
|
this.sizes.totalNonPinnedWidth = 0
|
|
6597
|
-
|
|
6770
|
+
columnsForSizing.forEach((c, i) => {
|
|
6598
6771
|
// if (!c.width) {
|
|
6599
6772
|
// if (c.actualWidth < equalWidth) {
|
|
6600
6773
|
// adjust the width
|
|
@@ -6605,7 +6778,7 @@ class WebsyTable3 {
|
|
|
6605
6778
|
// }
|
|
6606
6779
|
// }
|
|
6607
6780
|
this.sizes.totalWidth += c.width || c.actualWidth
|
|
6608
|
-
if (i
|
|
6781
|
+
if (i > this.pinnedColumns) {
|
|
6609
6782
|
this.sizes.totalNonPinnedWidth += c.width || c.actualWidth
|
|
6610
6783
|
}
|
|
6611
6784
|
// equalWidth = (outerSize.width - this.sizes.totalWidth) / (this.options.columns[this.options.columns.length - 1].length - (i + 1))
|
|
@@ -6615,17 +6788,21 @@ class WebsyTable3 {
|
|
|
6615
6788
|
if (this.sizes.pinnedWidth > (this.sizes.outer.width - firstNonPinnedColumnWidth)) {
|
|
6616
6789
|
this.sizes.totalWidth = 0
|
|
6617
6790
|
let diff = this.sizes.pinnedWidth - (this.sizes.outer.width - firstNonPinnedColumnWidth)
|
|
6791
|
+
let oldPinnedWidth = this.sizes.pinnedWidth
|
|
6792
|
+
this.sizes.pinnedWidth = 0
|
|
6618
6793
|
// let colDiff = diff / this.pinnedColumns
|
|
6619
|
-
for (let i = 0; i <
|
|
6794
|
+
for (let i = 0; i < columnsForSizing.length; i++) {
|
|
6620
6795
|
if (i < this.pinnedColumns) {
|
|
6621
|
-
let colDiff = (
|
|
6622
|
-
|
|
6796
|
+
let colDiff = (columnsForSizing[i].actualWidth / oldPinnedWidth) * diff
|
|
6797
|
+
columnsForSizing[i].actualWidth -= colDiff
|
|
6798
|
+
this.sizes.pinnedWidth += columnsForSizing[i].actualWidth
|
|
6623
6799
|
}
|
|
6624
|
-
this.sizes.totalWidth +=
|
|
6800
|
+
this.sizes.totalWidth += columnsForSizing[i].width || columnsForSizing[i].actualWidth
|
|
6625
6801
|
}
|
|
6626
6802
|
}
|
|
6627
6803
|
// take the height of the last cell as the official height for data cells
|
|
6628
6804
|
// this.sizes.dataCellHeight = this.options.columns[this.options.columns.length - 1].cellHeight
|
|
6805
|
+
this.sizes.scrollableWidth = this.sizes.table.width - this.sizes.pinnedWidth
|
|
6629
6806
|
headEl.innerHTML = ''
|
|
6630
6807
|
bodyEl.innerHTML = ''
|
|
6631
6808
|
footerEl.innerHTML = ''
|
|
@@ -6935,18 +7112,21 @@ class WebsyTable3 {
|
|
|
6935
7112
|
this.startCol = 0
|
|
6936
7113
|
this.endCol = 0
|
|
6937
7114
|
for (let i = this.pinnedColumns; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
7115
|
+
if (this.options.allColumns[this.options.allColumns.length - 1][i].show !== false) {
|
|
7116
|
+
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
|
|
7117
|
+
if (actualLeft < cumulativeWidth) {
|
|
7118
|
+
this.startCol = i
|
|
7119
|
+
break
|
|
7120
|
+
}
|
|
7121
|
+
}
|
|
6944
7122
|
}
|
|
6945
7123
|
cumulativeWidth = 0
|
|
6946
7124
|
for (let i = this.startCol; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
this.
|
|
7125
|
+
if (this.options.allColumns[this.options.allColumns.length - 1][i].show !== false) {
|
|
7126
|
+
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
|
|
7127
|
+
if (cumulativeWidth < this.sizes.scrollableWidth) {
|
|
7128
|
+
this.endCol = i
|
|
7129
|
+
}
|
|
6950
7130
|
}
|
|
6951
7131
|
}
|
|
6952
7132
|
if (this.endCol < this.options.allColumns[this.options.allColumns.length - 1].length - 1) {
|