@websy/websy-designs 1.1.12 → 1.2.1
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 +29 -19
- package/dist/server/helpers/v1/pgHelper.js +57 -11
- package/dist/server/helpers/v1/sessionHelper.js +7 -5
- package/dist/server/routes/v1/auth.js +28 -6
- package/dist/server/routes/v1/recaptcha.js +4 -2
- package/dist/server/websy-designs-server.js +36 -9
- package/dist/websy-designs-es6.debug.js +185 -62
- package/dist/websy-designs-es6.js +208 -68
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +356 -85
- package/dist/websy-designs.js +362 -89
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/dist/websy-icons.min.css +1 -0
- package/package.json +2 -4
|
@@ -89,7 +89,7 @@ class APIService {
|
|
|
89
89
|
}
|
|
90
90
|
xhr.withCredentials = true
|
|
91
91
|
xhr.onload = () => {
|
|
92
|
-
if (xhr.status === 401 || xhr.status === 403) {
|
|
92
|
+
if (xhr.status === 401) { // || xhr.status === 403) {
|
|
93
93
|
if (ENV && ENV.AUTH_REDIRECT) {
|
|
94
94
|
window.location = ENV.AUTH_REDIRECT
|
|
95
95
|
}
|
|
@@ -207,6 +207,7 @@ class WebsyDatePicker {
|
|
|
207
207
|
this.shiftPressed = false
|
|
208
208
|
const DEFAULTS = {
|
|
209
209
|
defaultRange: 0,
|
|
210
|
+
allowClear: true,
|
|
210
211
|
minAllowedDate: this.floorDate(new Date(new Date((new Date().setFullYear(new Date().getFullYear() - 1))).setDate(1))),
|
|
211
212
|
maxAllowedDate: this.floorDate(new Date((new Date()))),
|
|
212
213
|
minAllowedYear: 1970,
|
|
@@ -301,9 +302,16 @@ class WebsyDatePicker {
|
|
|
301
302
|
let html = `
|
|
302
303
|
<div class='websy-date-picker-container'>
|
|
303
304
|
<span class='websy-dropdown-header-label'>${this.options.label || 'Date'}</span>
|
|
304
|
-
<div class='websy-date-picker-header'>
|
|
305
|
+
<div id="${this.elementId}_header" class='websy-date-picker-header ${this.options.allowClear === true ? 'allow-clear' : ''}'>
|
|
305
306
|
<span id='${this.elementId}_selectedRange'>${this.options.ranges[this.options.mode][this.selectedRange].label}</span>
|
|
306
307
|
<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>
|
|
308
|
+
`
|
|
309
|
+
if (this.options.allowClear === true) {
|
|
310
|
+
html += `
|
|
311
|
+
<svg class='clear-selection' 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>
|
|
312
|
+
`
|
|
313
|
+
}
|
|
314
|
+
html += `
|
|
307
315
|
</div>
|
|
308
316
|
<div id='${this.elementId}_mask' class='websy-date-picker-mask'></div>
|
|
309
317
|
<div id='${this.elementId}_content' class='websy-date-picker-content'>
|
|
@@ -335,6 +343,10 @@ class WebsyDatePicker {
|
|
|
335
343
|
close (confirm) {
|
|
336
344
|
const maskEl = document.getElementById(`${this.elementId}_mask`)
|
|
337
345
|
const contentEl = document.getElementById(`${this.elementId}_content`)
|
|
346
|
+
const el = document.getElementById(this.elementId)
|
|
347
|
+
if (el) {
|
|
348
|
+
el.style.zIndex = ''
|
|
349
|
+
}
|
|
338
350
|
maskEl.classList.remove('active')
|
|
339
351
|
contentEl.classList.remove('active')
|
|
340
352
|
if (confirm === true) {
|
|
@@ -390,9 +402,12 @@ class WebsyDatePicker {
|
|
|
390
402
|
else if (event.target.classList.contains('websy-dp-cancel')) {
|
|
391
403
|
this.close()
|
|
392
404
|
}
|
|
405
|
+
else if (event.target.classList.contains('clear-selection')) {
|
|
406
|
+
this.selectRange(0)
|
|
407
|
+
this.updateRange(0)
|
|
408
|
+
}
|
|
393
409
|
}
|
|
394
|
-
handleKeyDown (event) {
|
|
395
|
-
console.log('key down', event)
|
|
410
|
+
handleKeyDown (event) {
|
|
396
411
|
if (event.key === 'Shift') {
|
|
397
412
|
this.dragging = true
|
|
398
413
|
this.shiftPressed = true
|
|
@@ -452,13 +467,14 @@ class WebsyDatePicker {
|
|
|
452
467
|
if (this.selectedRange === 0) {
|
|
453
468
|
return
|
|
454
469
|
}
|
|
455
|
-
if (this.customRangeSelected === true) {
|
|
470
|
+
if (this.customRangeSelected === true) {
|
|
471
|
+
console.log('if date selection', this.currentselection)
|
|
456
472
|
let diff
|
|
457
473
|
if (this.options.mode === 'date') {
|
|
458
474
|
diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime() - this.selectedRangeDates[0].getTime()) / this.oneDay)
|
|
459
|
-
if (this.selectedRangeDates[0].getMonth() !== this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth()) {
|
|
460
|
-
|
|
461
|
-
}
|
|
475
|
+
// if (this.selectedRangeDates[0].getMonth() !== this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth()) {
|
|
476
|
+
// diff += 1
|
|
477
|
+
// }
|
|
462
478
|
}
|
|
463
479
|
else if (this.options.mode === 'year') {
|
|
464
480
|
diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0]
|
|
@@ -499,7 +515,7 @@ class WebsyDatePicker {
|
|
|
499
515
|
}
|
|
500
516
|
}
|
|
501
517
|
}
|
|
502
|
-
else {
|
|
518
|
+
else {
|
|
503
519
|
this.currentselection.forEach(d => {
|
|
504
520
|
let dateEl
|
|
505
521
|
if (this.options.mode === 'date') {
|
|
@@ -517,6 +533,10 @@ class WebsyDatePicker {
|
|
|
517
533
|
open (options, override = false) {
|
|
518
534
|
const maskEl = document.getElementById(`${this.elementId}_mask`)
|
|
519
535
|
const contentEl = document.getElementById(`${this.elementId}_content`)
|
|
536
|
+
const el = document.getElementById(this.elementId)
|
|
537
|
+
if (el) {
|
|
538
|
+
el.style.zIndex = 999
|
|
539
|
+
}
|
|
520
540
|
maskEl.classList.add('active')
|
|
521
541
|
contentEl.classList.add('active')
|
|
522
542
|
this.priorSelectedDates = [...this.selectedRangeDates]
|
|
@@ -735,6 +755,15 @@ class WebsyDatePicker {
|
|
|
735
755
|
this.selectedRangeDates = [...this.options.ranges[this.options.mode][index].range]
|
|
736
756
|
this.currentselection = [...this.options.ranges[this.options.mode][index].range]
|
|
737
757
|
this.selectedRange = +index
|
|
758
|
+
const el = document.getElementById(`${this.elementId}_header`)
|
|
759
|
+
if (el) {
|
|
760
|
+
if (this.selectedRange === 0) {
|
|
761
|
+
el.classList.remove('range-selected')
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
el.classList.add('range-selected')
|
|
765
|
+
}
|
|
766
|
+
}
|
|
738
767
|
this.highlightRange()
|
|
739
768
|
this.close(true)
|
|
740
769
|
}
|
|
@@ -926,6 +955,10 @@ class WebsyDropdown {
|
|
|
926
955
|
const maskEl = document.getElementById(`${this.elementId}_mask`)
|
|
927
956
|
const contentEl = document.getElementById(`${this.elementId}_content`)
|
|
928
957
|
const scrollEl = document.getElementById(`${this.elementId}_itemsContainer`)
|
|
958
|
+
const el = document.getElementById(this.elementId)
|
|
959
|
+
if (el) {
|
|
960
|
+
el.style.zIndex = ''
|
|
961
|
+
}
|
|
929
962
|
scrollEl.scrollTop = 0
|
|
930
963
|
maskEl.classList.remove('active')
|
|
931
964
|
contentEl.classList.remove('active')
|
|
@@ -1041,6 +1074,10 @@ class WebsyDropdown {
|
|
|
1041
1074
|
open (options, override = false) {
|
|
1042
1075
|
const maskEl = document.getElementById(`${this.elementId}_mask`)
|
|
1043
1076
|
const contentEl = document.getElementById(`${this.elementId}_content`)
|
|
1077
|
+
const el = document.getElementById(this.elementId)
|
|
1078
|
+
if (el) {
|
|
1079
|
+
el.style.zIndex = 999
|
|
1080
|
+
}
|
|
1044
1081
|
maskEl.classList.add('active')
|
|
1045
1082
|
contentEl.classList.add('active')
|
|
1046
1083
|
if (WebsyUtils.getElementPos(contentEl).bottom > window.innerHeight) {
|
|
@@ -1203,8 +1240,10 @@ class WebsyForm {
|
|
|
1203
1240
|
constructor (elementId, options) {
|
|
1204
1241
|
const defaults = {
|
|
1205
1242
|
submit: { text: 'Save', classes: '' },
|
|
1243
|
+
useRecaptcha: false,
|
|
1206
1244
|
clearAfterSave: false,
|
|
1207
1245
|
fields: [],
|
|
1246
|
+
mode: 'add',
|
|
1208
1247
|
onSuccess: function (data) {},
|
|
1209
1248
|
onError: function (err) { console.log('Error submitting form data:', err) }
|
|
1210
1249
|
}
|
|
@@ -1240,19 +1279,25 @@ class WebsyForm {
|
|
|
1240
1279
|
checkRecaptcha () {
|
|
1241
1280
|
return new Promise((resolve, reject) => {
|
|
1242
1281
|
if (this.options.useRecaptcha === true) {
|
|
1243
|
-
if (this.recaptchaValue) {
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1282
|
+
// if (this.recaptchaValue) {
|
|
1283
|
+
grecaptcha.ready(() => {
|
|
1284
|
+
grecaptcha.execute(ENVIRONMENT.RECAPTCHA_KEY, { action: 'submit' }).then(token => {
|
|
1285
|
+
this.apiService.add('google/checkrecaptcha', {grecaptcharesponse: token}).then(response => {
|
|
1286
|
+
if (response.success && response.success === true) {
|
|
1287
|
+
resolve(true)
|
|
1288
|
+
}
|
|
1289
|
+
else {
|
|
1290
|
+
reject(false)
|
|
1291
|
+
}
|
|
1292
|
+
})
|
|
1293
|
+
}, err => {
|
|
1294
|
+
reject(err)
|
|
1251
1295
|
})
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1296
|
+
})
|
|
1297
|
+
// }
|
|
1298
|
+
// else {
|
|
1299
|
+
// reject(false)
|
|
1300
|
+
// }
|
|
1256
1301
|
}
|
|
1257
1302
|
else {
|
|
1258
1303
|
resolve(true)
|
|
@@ -1333,7 +1378,7 @@ class WebsyForm {
|
|
|
1333
1378
|
let componentsToProcess = []
|
|
1334
1379
|
if (el) {
|
|
1335
1380
|
let html = `
|
|
1336
|
-
<form id="${this.elementId}Form" class="${this.options.classes || ''}">
|
|
1381
|
+
<form id="${this.elementId}Form" class="websy-form ${this.options.classes || ''}">
|
|
1337
1382
|
`
|
|
1338
1383
|
this.options.fields.forEach((f, i) => {
|
|
1339
1384
|
if (f.component) {
|
|
@@ -1354,6 +1399,7 @@ class WebsyForm {
|
|
|
1354
1399
|
${f.required === true ? 'required' : ''}
|
|
1355
1400
|
placeholder="${f.placeholder || ''}"
|
|
1356
1401
|
name="${f.field}"
|
|
1402
|
+
${(f.attributes || []).join(' ')}
|
|
1357
1403
|
class="websy-input websy-textarea"
|
|
1358
1404
|
></textarea>
|
|
1359
1405
|
</div><!--
|
|
@@ -1368,6 +1414,7 @@ class WebsyForm {
|
|
|
1368
1414
|
${f.required === true ? 'required' : ''}
|
|
1369
1415
|
type="${f.type || 'text'}"
|
|
1370
1416
|
class="websy-input"
|
|
1417
|
+
${(f.attributes || []).join(' ')}
|
|
1371
1418
|
name="${f.field}"
|
|
1372
1419
|
placeholder="${f.placeholder || ''}"
|
|
1373
1420
|
value="${f.value || ''}"
|
|
@@ -1398,7 +1445,7 @@ class WebsyForm {
|
|
|
1398
1445
|
el.innerHTML = html
|
|
1399
1446
|
this.processComponents(componentsToProcess, () => {
|
|
1400
1447
|
if (this.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
|
|
1401
|
-
this.recaptchaReady()
|
|
1448
|
+
// this.recaptchaReady()
|
|
1402
1449
|
}
|
|
1403
1450
|
})
|
|
1404
1451
|
}
|
|
@@ -1415,7 +1462,14 @@ class WebsyForm {
|
|
|
1415
1462
|
data[key] = value
|
|
1416
1463
|
})
|
|
1417
1464
|
if (this.options.url) {
|
|
1418
|
-
|
|
1465
|
+
let params = [
|
|
1466
|
+
this.options.url
|
|
1467
|
+
]
|
|
1468
|
+
if (this.options.mode === 'update') {
|
|
1469
|
+
params.push(this.options.id)
|
|
1470
|
+
}
|
|
1471
|
+
params.push(data)
|
|
1472
|
+
this.apiService[this.options.mode](...params).then(result => {
|
|
1419
1473
|
if (this.options.clearAfterSave === true) {
|
|
1420
1474
|
// this.render()
|
|
1421
1475
|
formEl.reset()
|
|
@@ -1624,7 +1678,7 @@ class WebsyNavigationMenu {
|
|
|
1624
1678
|
items[i].classes = items[i].classes.join(' ')
|
|
1625
1679
|
}
|
|
1626
1680
|
html += `
|
|
1627
|
-
<li class='websy-${this.options.orientation}-list-item'>
|
|
1681
|
+
<li class='websy-${this.options.orientation}-list-item ${items[i].alwaysOpen === true ? 'always-open' : ''}'>
|
|
1628
1682
|
<div class='websy-menu-header ${items[i].classes || ''} ${selected} ${active}'
|
|
1629
1683
|
id='${blockId}'
|
|
1630
1684
|
data-id='${currentBlock}'
|
|
@@ -1943,7 +1997,9 @@ class WebsyPDFButton {
|
|
|
1943
1997
|
class WebsyPopupDialog {
|
|
1944
1998
|
constructor (elementId, options) {
|
|
1945
1999
|
this.DEFAULTS = {
|
|
1946
|
-
buttons: []
|
|
2000
|
+
buttons: [],
|
|
2001
|
+
classes: [],
|
|
2002
|
+
style: ''
|
|
1947
2003
|
}
|
|
1948
2004
|
this.options = Object.assign({}, this.DEFAULTS, options)
|
|
1949
2005
|
if (!elementId) {
|
|
@@ -1995,7 +2051,7 @@ class WebsyPopupDialog {
|
|
|
1995
2051
|
}
|
|
1996
2052
|
html += `
|
|
1997
2053
|
<div class='websy-popup-dialog-container'>
|
|
1998
|
-
<div class='websy-popup-dialog'>
|
|
2054
|
+
<div class='websy-popup-dialog ${this.options.classes.join(' ')}' style='${this.options.style}'>
|
|
1999
2055
|
`
|
|
2000
2056
|
if (this.options.title) {
|
|
2001
2057
|
html += `<h1>${this.options.title}</h1>`
|
|
@@ -2310,8 +2366,7 @@ class WebsyRouter {
|
|
|
2310
2366
|
addGroup (group) {
|
|
2311
2367
|
if (!this.groups[group]) {
|
|
2312
2368
|
const els = document.querySelectorAll(`.websy-view[data-group="${group}"]`)
|
|
2313
|
-
if (els) {
|
|
2314
|
-
console.log('els', els)
|
|
2369
|
+
if (els) {
|
|
2315
2370
|
this.getClosestParent(els[0], parent => {
|
|
2316
2371
|
this.groups[group] = {
|
|
2317
2372
|
activeView: '',
|
|
@@ -2716,8 +2771,10 @@ class WebsyRouter {
|
|
|
2716
2771
|
if (popped === false) {
|
|
2717
2772
|
let historyUrl = inputPath
|
|
2718
2773
|
if (this.options.urlPrefix) {
|
|
2719
|
-
historyUrl = `/${
|
|
2720
|
-
inputPath = `/${
|
|
2774
|
+
historyUrl = historyUrl === '/' ? '' : `/${historyUrl}`
|
|
2775
|
+
inputPath = inputPath === '/' ? '' : `/${inputPath}`
|
|
2776
|
+
historyUrl = (`/${this.options.urlPrefix}${historyUrl}`).replace(/\/\//g, '/')
|
|
2777
|
+
inputPath = (`/${this.options.urlPrefix}${inputPath}`).replace(/\/\//g, '/')
|
|
2721
2778
|
}
|
|
2722
2779
|
if (this.currentParams && this.currentParams.path) {
|
|
2723
2780
|
historyUrl += `?${this.currentParams.path}`
|
|
@@ -3055,6 +3112,21 @@ const WebsyUtils = {
|
|
|
3055
3112
|
}
|
|
3056
3113
|
return (red * 0.299 + green * 0.587 + blue * 0.114) > 186 ? darkColor : lightColor
|
|
3057
3114
|
},
|
|
3115
|
+
measureText (text, rotation = 0, fontSize = '12px') {
|
|
3116
|
+
if (!isNaN(fontSize)) {
|
|
3117
|
+
fontSize = `${fontSize}px`
|
|
3118
|
+
}
|
|
3119
|
+
let html = `<div style='display: inline-block; width: auto; font-size: ${fontSize}'>${text}</div>`
|
|
3120
|
+
const el = document.createElement('div')
|
|
3121
|
+
el.style.position = 'absolute'
|
|
3122
|
+
el.style.visibility = 'hidden'
|
|
3123
|
+
el.style.transform = `rotate(${rotation}deg)`
|
|
3124
|
+
el.innerHTML = html
|
|
3125
|
+
document.body.appendChild(el)
|
|
3126
|
+
let w = el.getBoundingClientRect()
|
|
3127
|
+
el.remove()
|
|
3128
|
+
return w
|
|
3129
|
+
},
|
|
3058
3130
|
parseUrlParams: () => {
|
|
3059
3131
|
let queryString = window.location.search.replace('?', '')
|
|
3060
3132
|
const params = {}
|
|
@@ -3295,7 +3367,7 @@ class WebsyTable {
|
|
|
3295
3367
|
data-view='${c.value}'
|
|
3296
3368
|
data-row-index='${this.rowCount + rowIndex}'
|
|
3297
3369
|
data-col-index='${i}'
|
|
3298
|
-
class='trigger-item ${this.options.columns[i].clickable === true ? 'clickable' : ''} ${this.options.columns[i].classes || ''}'
|
|
3370
|
+
class='websy-trigger trigger-item ${this.options.columns[i].clickable === true ? 'clickable' : ''} ${this.options.columns[i].classes || ''}'
|
|
3299
3371
|
style='${style}'
|
|
3300
3372
|
colspan='${c.colspan || 1}'
|
|
3301
3373
|
rowspan='${c.rowspan || 1}'
|
|
@@ -3379,19 +3451,26 @@ class WebsyTable {
|
|
|
3379
3451
|
event.target.classList.remove('active')
|
|
3380
3452
|
})
|
|
3381
3453
|
}
|
|
3382
|
-
else if (event.target.classList.contains('clickable')) {
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
}
|
|
3454
|
+
// else if (event.target.classList.contains('clickable')) {
|
|
3455
|
+
// const colIndex = +event.target.getAttribute('data-col-index')
|
|
3456
|
+
// const rowIndex = +event.target.getAttribute('data-row-index')
|
|
3457
|
+
// if (this.options.onClick) {
|
|
3458
|
+
// this.options.onClick(event, this.data[rowIndex][colIndex], this.data[rowIndex], this.options.columns[colIndex])
|
|
3459
|
+
// }
|
|
3460
|
+
// }
|
|
3389
3461
|
else if (event.target.classList.contains('websy-page-num')) {
|
|
3390
3462
|
const pageNum = +event.target.getAttribute('data-page')
|
|
3391
3463
|
if (this.options.onSetPage) {
|
|
3392
3464
|
this.options.onSetPage(pageNum)
|
|
3393
3465
|
}
|
|
3394
3466
|
}
|
|
3467
|
+
else {
|
|
3468
|
+
const colIndex = +event.target.getAttribute('data-col-index')
|
|
3469
|
+
const rowIndex = +event.target.getAttribute('data-row-index')
|
|
3470
|
+
if (this.options.onClick) {
|
|
3471
|
+
this.options.onClick(event, { cell: this.data[rowIndex][colIndex], row: this.data[rowIndex], column: this.options.columns[colIndex], colIndex, rowIndex })
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3395
3474
|
}
|
|
3396
3475
|
handleMouseMove (event) {
|
|
3397
3476
|
if (this.tooltipTimeoutFn) {
|
|
@@ -3692,7 +3771,7 @@ class WebsyTable2 {
|
|
|
3692
3771
|
data-view='${c.value}'
|
|
3693
3772
|
data-row-index='${this.rowCount + rowIndex}'
|
|
3694
3773
|
data-col-index='${i}'
|
|
3695
|
-
class='trigger-item ${this.options.columns[i].clickable === true ? 'clickable' : ''} ${this.options.columns[i].classes || ''}'
|
|
3774
|
+
class='websy-trigger trigger-item ${this.options.columns[i].clickable === true ? 'clickable' : ''} ${this.options.columns[i].classes || ''}'
|
|
3696
3775
|
style='${style}'
|
|
3697
3776
|
colspan='${c.colspan || 1}'
|
|
3698
3777
|
rowspan='${c.rowspan || 1}'
|
|
@@ -3800,6 +3879,18 @@ class WebsyTable2 {
|
|
|
3800
3879
|
this.options.onSetPage(pageNum)
|
|
3801
3880
|
}
|
|
3802
3881
|
}
|
|
3882
|
+
else if (event.target.classList.contains('websy-h-scroll-container')) {
|
|
3883
|
+
console.log('scroll handle clicked', event)
|
|
3884
|
+
let clickX = event.clientX
|
|
3885
|
+
let elX = event.target.getBoundingClientRect().left
|
|
3886
|
+
const handleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
3887
|
+
let startPoint = clickX - elX - (handleEl.clientWidth / 2)
|
|
3888
|
+
startPoint = Math.max(0, Math.min(startPoint, event.target.clientWidth - handleEl.clientWidth))
|
|
3889
|
+
handleEl.style.left = `${startPoint}px`
|
|
3890
|
+
if (this.options.onScrollX) {
|
|
3891
|
+
this.options.onScrollX(startPoint)
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3803
3894
|
}
|
|
3804
3895
|
handleMouseDown (event) {
|
|
3805
3896
|
if (event.target.classList.contains('websy-scroll-handle')) {
|
|
@@ -3941,8 +4032,15 @@ class WebsyTable2 {
|
|
|
3941
4032
|
// let colGroupHTML = this.options.columns.map(c => `<col style="${c.width ? 'width: ' + c.width : ''}"></col>`)
|
|
3942
4033
|
let headHTML = '<tr>' + this.options.columns.map((c, i) => {
|
|
3943
4034
|
if (c.show !== false) {
|
|
4035
|
+
let style = ''
|
|
4036
|
+
if (c.style) {
|
|
4037
|
+
style += c.style
|
|
4038
|
+
}
|
|
4039
|
+
if (c.width) {
|
|
4040
|
+
style += `width: ${c.width || 'auto'}; `
|
|
4041
|
+
}
|
|
3944
4042
|
return `
|
|
3945
|
-
<th ${
|
|
4043
|
+
<th style="${style}">
|
|
3946
4044
|
<div class ="tableHeader">
|
|
3947
4045
|
<div class="leftSection">
|
|
3948
4046
|
<div
|
|
@@ -4059,7 +4157,7 @@ class WebsyTable2 {
|
|
|
4059
4157
|
const bodyEl = document.getElementById(`${this.elementId}_body`)
|
|
4060
4158
|
bodyEl.innerHTML = '<tr>' + values.map(c => `
|
|
4061
4159
|
<td
|
|
4062
|
-
style='height: ${this.options.cellSize}px; line-height: ${this.options.cellSize}px;'
|
|
4160
|
+
style='height: ${this.options.cellSize}px; line-height: ${this.options.cellSize}px; padding: 10px 5px;'
|
|
4063
4161
|
>${c.value || ' '}</td>
|
|
4064
4162
|
`).join('') + '</tr>'
|
|
4065
4163
|
// get height of the first data cell
|
|
@@ -4067,12 +4165,20 @@ class WebsyTable2 {
|
|
|
4067
4165
|
const tableContainerEl = document.getElementById(`${this.elementId}_tableContainer`)
|
|
4068
4166
|
const cellHeight = cells[0].offsetHeight || cells[0].clientHeight
|
|
4069
4167
|
const cellWidths = []
|
|
4168
|
+
let accWidth = 0
|
|
4070
4169
|
let nonScrollableWidth = 0
|
|
4071
4170
|
for (let i = 0; i < cells.length; i++) {
|
|
4072
4171
|
if (i < this.options.leftColumns) {
|
|
4073
4172
|
nonScrollableWidth += values[i].width || cells[i].offsetWidth || cells[i].clientWidth
|
|
4074
4173
|
}
|
|
4075
4174
|
cellWidths.push(values[i].width || cells[i].offsetWidth || cells[i].clientWidth)
|
|
4175
|
+
accWidth += values[i].width || cells[i].offsetWidth || cells[i].clientWidth
|
|
4176
|
+
}
|
|
4177
|
+
// if the table doesn't fill the available space we adjust the space so that the columns grow
|
|
4178
|
+
if (accWidth < (tableContainerEl.offsetWidth || tableContainerEl.clientWidth) - nonScrollableWidth) {
|
|
4179
|
+
for (let i = this.options.leftColumns; i < cellWidths.length; i++) {
|
|
4180
|
+
cellWidths[i] = ((tableContainerEl.offsetWidth || tableContainerEl.clientWidth) - nonScrollableWidth) / (cellWidths.length - this.options.leftColumns)
|
|
4181
|
+
}
|
|
4076
4182
|
}
|
|
4077
4183
|
// const cellWidth = firstDataCell.offsetWidth || firstDataCell.clientWidth
|
|
4078
4184
|
// tableEl.style.width = ''
|
|
@@ -4109,6 +4215,7 @@ class WebsyChart {
|
|
|
4109
4215
|
legendRight: 0,
|
|
4110
4216
|
legendTop: 0
|
|
4111
4217
|
},
|
|
4218
|
+
axis: {},
|
|
4112
4219
|
orientation: 'vertical',
|
|
4113
4220
|
colors: ['#5e4fa2', '#3288bd', '#66c2a5', '#abdda4', '#e6f598', '#fee08b', '#fdae61', '#f46d43', '#d53e4f', '#9e0142'],
|
|
4114
4221
|
transitionDuration: 650,
|
|
@@ -4433,7 +4540,7 @@ this.render()
|
|
|
4433
4540
|
|
|
4434
4541
|
}
|
|
4435
4542
|
render (options) {
|
|
4436
|
-
/* global d3 options */
|
|
4543
|
+
/* global d3 options WebsyUtils */
|
|
4437
4544
|
if (typeof options !== 'undefined') {
|
|
4438
4545
|
this.options = Object.assign({}, this.options, options)
|
|
4439
4546
|
}
|
|
@@ -4532,9 +4639,9 @@ else {
|
|
|
4532
4639
|
this.options.data.bottom.min = this.options.data.bottom.data[0].value
|
|
4533
4640
|
}
|
|
4534
4641
|
if (this.options.data.bottom && typeof this.options.data.bottom.max !== 'undefined') {
|
|
4535
|
-
this.longestBottom = this.options.data.bottom.max.toString()
|
|
4642
|
+
this.longestBottom = this.options.data.bottom.max.toString()
|
|
4536
4643
|
if (this.options.data.bottom.formatter) {
|
|
4537
|
-
this.longestBottom = this.options.data.bottom.formatter(this.options.data.bottom.max).toString()
|
|
4644
|
+
this.longestBottom = this.options.data.bottom.formatter(this.options.data.bottom.max).toString()
|
|
4538
4645
|
}
|
|
4539
4646
|
}
|
|
4540
4647
|
if (this.options.data.left && this.options.data.left.data && this.options.data.left.max === 'undefined') {
|
|
@@ -4548,9 +4655,9 @@ else {
|
|
|
4548
4655
|
this.options.data.left.min = this.options.data.left.data.reduce((a, b) => a.length < b.value.length ? a : b.value, this.options.data.left.max)
|
|
4549
4656
|
}
|
|
4550
4657
|
if (this.options.data.left && typeof this.options.data.left.max !== 'undefined') {
|
|
4551
|
-
this.longestLeft = this.options.data.left.max.toString()
|
|
4658
|
+
this.longestLeft = this.options.data.left.max.toString()
|
|
4552
4659
|
if (this.options.data.left.formatter) {
|
|
4553
|
-
this.longestLeft = this.options.data.left.formatter(this.options.data.left.max).toString()
|
|
4660
|
+
this.longestLeft = this.options.data.left.formatter(this.options.data.left.max).toString()
|
|
4554
4661
|
}
|
|
4555
4662
|
}
|
|
4556
4663
|
if (this.options.data.right && this.options.data.right.data && this.options.data.right.max === 'undefined') {
|
|
@@ -4558,15 +4665,21 @@ else {
|
|
|
4558
4665
|
this.options.data.right.max = d3.max(this.options.data.right.data)
|
|
4559
4666
|
}
|
|
4560
4667
|
if (this.options.data.right && typeof this.options.data.right.max !== 'undefined') {
|
|
4561
|
-
this.longestRight = this.options.data.right.max.toString()
|
|
4668
|
+
this.longestRight = this.options.data.right.max.toString()
|
|
4562
4669
|
if (this.options.data.right.formatter) {
|
|
4563
|
-
this.longestRight = this.options.data.right.formatter(this.options.data.right.max).toString()
|
|
4670
|
+
this.longestRight = this.options.data.right.formatter(this.options.data.right.max).toString()
|
|
4564
4671
|
}
|
|
4565
4672
|
}
|
|
4566
4673
|
// establish the space needed for the various axes
|
|
4567
|
-
this.options.margin.axisLeft = this.longestLeft * ((this.options.data.left && this.options.data.left.fontSize) || this.options.fontSize) * 0.7
|
|
4568
|
-
this.options.margin.axisRight = this.longestRight * ((this.options.data.right && this.options.data.right.fontSize) || this.options.fontSize) * 0.7
|
|
4569
|
-
this.options.margin.axisBottom = ((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize) + 10
|
|
4674
|
+
// this.options.margin.axisLeft = this.longestLeft * ((this.options.data.left && this.options.data.left.fontSize) || this.options.fontSize) * 0.7
|
|
4675
|
+
// this.options.margin.axisRight = this.longestRight * ((this.options.data.right && this.options.data.right.fontSize) || this.options.fontSize) * 0.7
|
|
4676
|
+
// this.options.margin.axisBottom = ((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize) + 10
|
|
4677
|
+
let longestLeftBounds = WebsyUtils.measureText(this.longestLeft, 0, ((this.options.data.left && this.options.data.left.fontSize) || this.options.fontSize))
|
|
4678
|
+
let longestRightBounds = WebsyUtils.measureText(this.longestRight, 0, ((this.options.data.right && this.options.data.right.fontSize) || this.options.fontSize))
|
|
4679
|
+
let longestBottomBounds = WebsyUtils.measureText(this.longestBottom, ((this.options.data.bottom && this.options.data.bottom.rotate) || 0), ((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize))
|
|
4680
|
+
this.options.margin.axisLeft = longestLeftBounds.width
|
|
4681
|
+
this.options.margin.axisRight = longestRightBounds.width
|
|
4682
|
+
this.options.margin.axisBottom = longestBottomBounds.height + 10
|
|
4570
4683
|
this.options.margin.axisTop = 0
|
|
4571
4684
|
// adjust axis margins based on title options
|
|
4572
4685
|
if (this.options.data.left && this.options.data.left.showTitle === true) {
|
|
@@ -4585,11 +4698,20 @@ else {
|
|
|
4585
4698
|
this.options.margin.axisTop += (this.options.data.right.titleFontSize || 10) + 10
|
|
4586
4699
|
}
|
|
4587
4700
|
}
|
|
4588
|
-
if (this.options.data.bottom.rotate) {
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4701
|
+
if (((this.options.data.bottom && this.options.data.bottom.rotate) || 0) === 0 && this.options.axis.hideBottom !== true) {
|
|
4702
|
+
this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, longestBottomBounds.width / 2)
|
|
4703
|
+
}
|
|
4704
|
+
else if (((this.options.data.bottom && this.options.data.bottom.rotate) || 0) < 0 && this.options.axis.hideBottom !== true) {
|
|
4705
|
+
this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, longestBottomBounds.width)
|
|
4706
|
+
}
|
|
4707
|
+
else if (((this.options.data.bottom && this.options.data.bottom.rotate) || 0) > 0 && this.options.axis.hideBottom !== true) {
|
|
4708
|
+
this.options.margin.axisRight = Math.max(this.options.margin.axisRight, longestBottomBounds.width)
|
|
4709
|
+
}
|
|
4710
|
+
// if (this.options.data.bottom.rotate) {
|
|
4711
|
+
// // this.options.margin.bottom = this.longestBottom * ((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize)
|
|
4712
|
+
// this.options.margin.axisBottom = this.longestBottom * ((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize) * 0.4
|
|
4713
|
+
// // this.options.margin.bottom = this.options.margin.bottom * (1 + this.options.data.bottom.rotate / 100)
|
|
4714
|
+
// }
|
|
4593
4715
|
// hide the margin if necessary
|
|
4594
4716
|
if (this.options.axis) {
|
|
4595
4717
|
if (this.options.axis.hideAll === true) {
|
|
@@ -4724,17 +4846,18 @@ else {
|
|
|
4724
4846
|
let bAxisFunc = d3.axisBottom(this.bottomAxis)
|
|
4725
4847
|
// .ticks(this.options.data.bottom.ticks || Math.min(this.options.data.bottom.data.length, 5))
|
|
4726
4848
|
.ticks(tickDefinition)
|
|
4727
|
-
console.log('tickDefinition', tickDefinition)
|
|
4728
|
-
console.log(bAxisFunc)
|
|
4849
|
+
// console.log('tickDefinition', tickDefinition)
|
|
4850
|
+
// console.log(bAxisFunc)
|
|
4729
4851
|
if (this.options.data.bottom.formatter) {
|
|
4730
4852
|
bAxisFunc.tickFormat(d => this.options.data.bottom.formatter(d))
|
|
4731
4853
|
}
|
|
4732
4854
|
this.bottomAxisLayer.call(bAxisFunc)
|
|
4733
|
-
console.log(this.bottomAxisLayer.ticks)
|
|
4855
|
+
// console.log(this.bottomAxisLayer.ticks)
|
|
4734
4856
|
if (this.options.data.bottom.rotate) {
|
|
4735
4857
|
this.bottomAxisLayer.selectAll('text')
|
|
4736
|
-
.attr('transform', `rotate(${this.options.data.bottom.rotate})`)
|
|
4737
|
-
.style('text-anchor', 'end')
|
|
4858
|
+
.attr('transform', `rotate(${((this.options.data.bottom && this.options.data.bottom.rotate) || 0)})`)
|
|
4859
|
+
.style('text-anchor', `${((this.options.data.bottom && this.options.data.bottom.rotate) || 0) === 0 ? 'middle' : 'end'}`)
|
|
4860
|
+
.style('transform-origin', ((this.options.data.bottom && this.options.data.bottom.rotate) || 0) === 0 ? '0 0' : `0 ${((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize)}px`)
|
|
4738
4861
|
}
|
|
4739
4862
|
}
|
|
4740
4863
|
// Configure the left axis
|