@websy/websy-designs 1.9.7 → 1.9.9
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/websy-designs-es6.debug.js +200 -8
- package/dist/websy-designs-es6.js +437 -257
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +200 -8
- package/dist/websy-designs.js +440 -260
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
WebsyNavigationMenu
|
|
6
6
|
WebsyPubSub
|
|
7
7
|
WebsyForm
|
|
8
|
+
MultiForm
|
|
8
9
|
WebsyDatePicker
|
|
9
10
|
WebsyDragDrop
|
|
10
11
|
WebsyDropdown
|
|
@@ -2169,7 +2170,15 @@ class WebsyForm {
|
|
|
2169
2170
|
let index = event.target.getAttribute('data-index')
|
|
2170
2171
|
if (this.options.fields[index] && (this.options.fields[index].required || this.options.fields[index].validate)) {
|
|
2171
2172
|
this.validateField(this.options.fields[index], event.target.value)
|
|
2172
|
-
}
|
|
2173
|
+
}
|
|
2174
|
+
if (this.options.fields[index].onChange) {
|
|
2175
|
+
this.options.fields[index].onChange({
|
|
2176
|
+
value: event.target.value,
|
|
2177
|
+
field: this.options.fields[index],
|
|
2178
|
+
form: this,
|
|
2179
|
+
index
|
|
2180
|
+
})
|
|
2181
|
+
}
|
|
2173
2182
|
}
|
|
2174
2183
|
}
|
|
2175
2184
|
handleClick (event) {
|
|
@@ -2188,6 +2197,14 @@ class WebsyForm {
|
|
|
2188
2197
|
if (this.options.fields[index] && (this.options.fields[index].required || this.options.fields[index].validate)) {
|
|
2189
2198
|
this.validateField(this.options.fields[index], event.target.value)
|
|
2190
2199
|
}
|
|
2200
|
+
if (this.options.fields[index].onLeave) {
|
|
2201
|
+
this.options.fields[index].onLeave({
|
|
2202
|
+
value: event.target.value,
|
|
2203
|
+
field: this.options.fields[index],
|
|
2204
|
+
form: this,
|
|
2205
|
+
index
|
|
2206
|
+
})
|
|
2207
|
+
}
|
|
2191
2208
|
}
|
|
2192
2209
|
}
|
|
2193
2210
|
handleKeyDown (event) {
|
|
@@ -2342,7 +2359,7 @@ class WebsyForm {
|
|
|
2342
2359
|
if (f.component) {
|
|
2343
2360
|
componentsToProcess.push(f)
|
|
2344
2361
|
html += `
|
|
2345
|
-
${i > 0 ? '-->' : ''}<div id='${this.elementId}_${f.field}_inputContainer' class='websy-input-container ${f.classes ? f.classes.join(' ') : ''}'>
|
|
2362
|
+
${i > 0 ? '-->' : ''}<div id='${this.elementId}_${f.field}_inputContainer' style='${f.style || ''}' class='websy-input-container ${f.classes ? f.classes.join(' ') : ''}'>
|
|
2346
2363
|
${f.label ? `<label for="${f.field}">${f.label}</label>` : ''}${f.required === true ? '<span class="websy-form-required-value">*</span>' : ''}
|
|
2347
2364
|
<div id='${this.elementId}_input_${f.field}_component' class='form-component'></div>
|
|
2348
2365
|
<span id='${this.elementId}_${f.field}_error' class='websy-form-validation-error'></span>
|
|
@@ -2351,7 +2368,7 @@ class WebsyForm {
|
|
|
2351
2368
|
}
|
|
2352
2369
|
else if (f.type === 'longtext') {
|
|
2353
2370
|
html += `
|
|
2354
|
-
${i > 0 ? '-->' : ''}<div id='${this.elementId}_${f.field}_inputContainer' class='websy-input-container ${f.classes ? f.classes.join(' ') : ''}'>
|
|
2371
|
+
${i > 0 ? '-->' : ''}<div id='${this.elementId}_${f.field}_inputContainer' style='${f.style || ''}' class='websy-input-container ${f.classes ? f.classes.join(' ') : ''}'>
|
|
2355
2372
|
${f.label ? `<label for="${f.field}">${f.label}</label>` : ''}${f.required === true ? '<span class="websy-form-required-value">*</span>' : ''}
|
|
2356
2373
|
<textarea
|
|
2357
2374
|
id="${this.elementId}_input_${f.field}"
|
|
@@ -2369,7 +2386,7 @@ class WebsyForm {
|
|
|
2369
2386
|
}
|
|
2370
2387
|
else {
|
|
2371
2388
|
html += `
|
|
2372
|
-
${i > 0 ? '-->' : ''}<div id='${this.elementId}_${f.field}_inputContainer' class='websy-input-container ${f.classes ? f.classes.join(' ') : ''}'>
|
|
2389
|
+
${i > 0 ? '-->' : ''}<div id='${this.elementId}_${f.field}_inputContainer' style='${f.style || ''}' class='websy-input-container ${f.classes ? f.classes.join(' ') : ''}'>
|
|
2373
2390
|
${f.label ? `<label for="${f.field}">${f.label}</label>` : ''}${f.required === true ? '<span class="websy-form-required-value">*</span>' : ''}
|
|
2374
2391
|
<input
|
|
2375
2392
|
id="${this.elementId}_input_${f.field}"
|
|
@@ -2558,6 +2575,158 @@ class WebsyForm {
|
|
|
2558
2575
|
}
|
|
2559
2576
|
}
|
|
2560
2577
|
|
|
2578
|
+
/*
|
|
2579
|
+
global
|
|
2580
|
+
WebsyDesigns
|
|
2581
|
+
*/
|
|
2582
|
+
class MultiForm {
|
|
2583
|
+
constructor (elementId, options) {
|
|
2584
|
+
this.elementId = elementId
|
|
2585
|
+
const DEFAULTS = {
|
|
2586
|
+
addButton: `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 512 512"><line x1="256" y1="112" x2="256" y2="400" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/><line x1="400" y1="256" x2="112" y2="256" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/></svg>`,
|
|
2587
|
+
deleteButton: `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 512 512"><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>`
|
|
2588
|
+
}
|
|
2589
|
+
this.options = Object.assign({}, DEFAULTS, options)
|
|
2590
|
+
this.formData = []
|
|
2591
|
+
this.forms = []
|
|
2592
|
+
this.recordsToDelete = []
|
|
2593
|
+
const el = document.getElementById(elementId)
|
|
2594
|
+
if (el) {
|
|
2595
|
+
el.addEventListener('click', this.handleClick.bind(this))
|
|
2596
|
+
el.innerHTML = `<div id='${elementId}_container' class='websy-multi-form-container'></div>`
|
|
2597
|
+
}
|
|
2598
|
+
this.render()
|
|
2599
|
+
}
|
|
2600
|
+
addEntry () {
|
|
2601
|
+
const el = document.getElementById(`${this.elementId}_container`)
|
|
2602
|
+
let newId = WebsyDesigns.Utils.createIdentity()
|
|
2603
|
+
const newFormEl = document.createElement('div')
|
|
2604
|
+
newFormEl.id = `${this.elementId}_${newId}_formContainer`
|
|
2605
|
+
newFormEl.classList.add('websy-multi-form-form-container')
|
|
2606
|
+
newFormEl.innerHTML = `
|
|
2607
|
+
<div id='${this.elementId}_${newId}_form' class='websy-multi-form-form'>
|
|
2608
|
+
</div>
|
|
2609
|
+
<button id='${this.elementId}_${newId}_deleteButton' data-formid='${newId}' class='hidden websy-multi-form-delete'>
|
|
2610
|
+
${this.options.deleteButton}
|
|
2611
|
+
</button>
|
|
2612
|
+
<button id='${this.elementId}_${newId}_addButton' data-formid='${newId}' class='websy-multi-form-add'>
|
|
2613
|
+
${this.options.addButton}
|
|
2614
|
+
</button>
|
|
2615
|
+
`
|
|
2616
|
+
el.appendChild(newFormEl)
|
|
2617
|
+
let formOptions = Object.assign({}, this.options)
|
|
2618
|
+
this.forms.push(new WebsyDesigns.Form(`${this.elementId}_${newId}_form`, formOptions))
|
|
2619
|
+
}
|
|
2620
|
+
clear () {
|
|
2621
|
+
this.formData = []
|
|
2622
|
+
this.forms = []
|
|
2623
|
+
this.recordsToDelete = []
|
|
2624
|
+
const el = document.getElementById(`${this.elementId}_container`)
|
|
2625
|
+
if (el) {
|
|
2626
|
+
el.innerHTML = ''
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
get data () {
|
|
2630
|
+
const d = this.forms.map(f => (f.data))
|
|
2631
|
+
// we don't return the last form
|
|
2632
|
+
d.pop()
|
|
2633
|
+
return d
|
|
2634
|
+
}
|
|
2635
|
+
set data (d) {
|
|
2636
|
+
this.formData = d
|
|
2637
|
+
this.render()
|
|
2638
|
+
}
|
|
2639
|
+
handleClick (event) {
|
|
2640
|
+
if (event.target.classList.contains('websy-multi-form-add')) {
|
|
2641
|
+
let id = event.target.getAttribute('data-formid')
|
|
2642
|
+
// hide add button and show delete button
|
|
2643
|
+
const addButtonEl = document.getElementById(`${this.elementId}_${id}_addButton`)
|
|
2644
|
+
if (addButtonEl) {
|
|
2645
|
+
addButtonEl.classList.add('hidden')
|
|
2646
|
+
}
|
|
2647
|
+
const deleteButtonEl = document.getElementById(`${this.elementId}_${id}_deleteButton`)
|
|
2648
|
+
if (deleteButtonEl) {
|
|
2649
|
+
deleteButtonEl.classList.remove('hidden')
|
|
2650
|
+
}
|
|
2651
|
+
// add new form
|
|
2652
|
+
this.addEntry()
|
|
2653
|
+
}
|
|
2654
|
+
if (event.target.classList.contains('websy-multi-form-delete')) {
|
|
2655
|
+
// delete form based on index
|
|
2656
|
+
let id = event.target.getAttribute('data-formid')
|
|
2657
|
+
let rowId = event.target.getAttribute('data-rowid')
|
|
2658
|
+
this.recordsToDelete.push(rowId)
|
|
2659
|
+
let indexToDelete = -1
|
|
2660
|
+
for (let i = 0; i < this.forms.length; i++) {
|
|
2661
|
+
if (this.forms[i].elementId === `${this.elementId}_${id}_form`) {
|
|
2662
|
+
indexToDelete = i
|
|
2663
|
+
break
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
if (indexToDelete !== -1) {
|
|
2667
|
+
this.forms.splice(indexToDelete, 1)
|
|
2668
|
+
}
|
|
2669
|
+
const el = document.getElementById(`${this.elementId}_${id}_formContainer`)
|
|
2670
|
+
if (el) {
|
|
2671
|
+
el.remove()
|
|
2672
|
+
}
|
|
2673
|
+
// delete form element based on id
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
render () {
|
|
2677
|
+
this.forms = []
|
|
2678
|
+
this.recordsToDelete = []
|
|
2679
|
+
const el = document.getElementById(`${this.elementId}_container`)
|
|
2680
|
+
if (el) {
|
|
2681
|
+
let html = ''
|
|
2682
|
+
this.formData.forEach(d => {
|
|
2683
|
+
d.formId = WebsyDesigns.Utils.createIdentity()
|
|
2684
|
+
html += `
|
|
2685
|
+
<div id='${this.elementId}_${d.formId}_formContainer' class='websy-multi-form-form-container'>
|
|
2686
|
+
<div id='${this.elementId}_${d.formId}_form' class='websy-multi-form-form'>
|
|
2687
|
+
</div>
|
|
2688
|
+
<button id='${this.elementId}_${d.formId}_deleteButton' data-formid='${d.formId}' data-rowid='${d.id}' class='websy-multi-form-delete'>
|
|
2689
|
+
${this.options.deleteButton}
|
|
2690
|
+
</button>
|
|
2691
|
+
</div>
|
|
2692
|
+
`
|
|
2693
|
+
})
|
|
2694
|
+
let id = WebsyDesigns.Utils.createIdentity()
|
|
2695
|
+
html += `
|
|
2696
|
+
<div id='${this.elementId}_${id}_formContainer' class='websy-multi-form-form-container'>
|
|
2697
|
+
<div id='${this.elementId}_${id}_form' class='websy-multi-form-form'>
|
|
2698
|
+
</div>
|
|
2699
|
+
<button id='${this.elementId}_${id}_deleteButton' data-formid='${id}' class='hidden websy-multi-form-delete'>
|
|
2700
|
+
${this.options.deleteButton}
|
|
2701
|
+
</button>
|
|
2702
|
+
<button id='${this.elementId}_${id}_addButton' data-formid='${id}' class='websy-multi-form-add'>
|
|
2703
|
+
${this.options.addButton}
|
|
2704
|
+
</button>
|
|
2705
|
+
</div>
|
|
2706
|
+
`
|
|
2707
|
+
el.innerHTML = html
|
|
2708
|
+
this.formData.forEach(d => {
|
|
2709
|
+
let formOptions = Object.assign({}, this.options)
|
|
2710
|
+
let formObject = new WebsyDesigns.Form(`${this.elementId}_${d.formId}_form`, formOptions)
|
|
2711
|
+
formObject.data = d
|
|
2712
|
+
this.forms.push(formObject)
|
|
2713
|
+
})
|
|
2714
|
+
let formOptions = Object.assign({}, this.options)
|
|
2715
|
+
this.forms.push(new WebsyDesigns.Form(`${this.elementId}_${id}_form`, formOptions))
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
validateForm () {
|
|
2719
|
+
// we don't validate the last form
|
|
2720
|
+
for (let i = 0; i < this.forms.length - 1; i++) {
|
|
2721
|
+
let valid = this.forms[i].validateForm()
|
|
2722
|
+
if (!valid) {
|
|
2723
|
+
return false
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
return true
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2561
2730
|
/* global include */
|
|
2562
2731
|
const WebsyIcons = {
|
|
2563
2732
|
'search-icon': `
|
|
@@ -4013,7 +4182,11 @@ class WebsyResultList {
|
|
|
4013
4182
|
}
|
|
4014
4183
|
render () {
|
|
4015
4184
|
if (this.options.entity) {
|
|
4016
|
-
this.
|
|
4185
|
+
let url = this.options.entity
|
|
4186
|
+
if (this.options.sortField) {
|
|
4187
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + `by=${this.options.sortField}&order=${this.options.sortOrder || 'ASC'}`
|
|
4188
|
+
}
|
|
4189
|
+
this.apiService.get(url).then(results => {
|
|
4017
4190
|
this.rows = results.rows
|
|
4018
4191
|
this.resize()
|
|
4019
4192
|
})
|
|
@@ -6141,7 +6314,7 @@ class WebsyTable3 {
|
|
|
6141
6314
|
<div id="${this.elementId}_errorMessage"></div>
|
|
6142
6315
|
</div>
|
|
6143
6316
|
</div>
|
|
6144
|
-
<div id="${this.elementId}
|
|
6317
|
+
<div id="${this.elementId}_dropdownContainerx" class="table-dropdown-container"></div>
|
|
6145
6318
|
<div id="${this.elementId}_loadingContainer"></div>
|
|
6146
6319
|
</div>
|
|
6147
6320
|
<div id="${this.elementId}_vScrollContainer" class="websy-v-scroll-container" style="width: ${this.options.isTouchDevice ? this.options.touchScrollWidth : this.options.scrollWidth}px;">
|
|
@@ -6160,6 +6333,16 @@ class WebsyTable3 {
|
|
|
6160
6333
|
`
|
|
6161
6334
|
}
|
|
6162
6335
|
el.innerHTML = html
|
|
6336
|
+
const dropdownContainerEl = document.getElementById(`${this.elementId}_dropdownContainer`)
|
|
6337
|
+
if (dropdownContainerEl) {
|
|
6338
|
+
dropdownContainerEl.innerHTML = ''
|
|
6339
|
+
}
|
|
6340
|
+
else {
|
|
6341
|
+
const div = document.createElement('div')
|
|
6342
|
+
div.id = `${this.elementId}_dropdownContainer`
|
|
6343
|
+
div.classList.add('table-dropdown-container')
|
|
6344
|
+
document.body.appendChild(div)
|
|
6345
|
+
}
|
|
6163
6346
|
el.addEventListener('click', this.handleClick.bind(this))
|
|
6164
6347
|
el.addEventListener('mousedown', this.handleMouseDown.bind(this))
|
|
6165
6348
|
el.addEventListener('touchstart', this.handleTouchStart.bind(this))
|
|
@@ -6259,7 +6442,7 @@ class WebsyTable3 {
|
|
|
6259
6442
|
bodyHtml += `<td
|
|
6260
6443
|
class='websy-table-cell ${sizeIndex < this.pinnedColumns ? 'pinned' : 'unpinned'} ${(cell.classes || []).join(' ')} ${(sizingColumns[sizeIndex].classes || []).join(' ')}'
|
|
6261
6444
|
style='${style}'
|
|
6262
|
-
data-info='${cell.value.replace(/'/g, '`')}'
|
|
6445
|
+
data-info='${cell.value.replace ? cell.value.replace(/'/g, '`') : cell.value}'
|
|
6263
6446
|
colspan='${cell.colspan || 1}'
|
|
6264
6447
|
rowspan='${cell.rowspan || 1}'
|
|
6265
6448
|
data-row-index='${rowIndex}'
|
|
@@ -7058,6 +7241,10 @@ class WebsyTable3 {
|
|
|
7058
7241
|
if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.scrollableWidth && actualLeft > 0) {
|
|
7059
7242
|
this.startCol += 1
|
|
7060
7243
|
}
|
|
7244
|
+
if (scrollHandleEl.offsetWidth + scrollHandleEl.offsetLeft >= scrollContainerEl.offsetWidth) {
|
|
7245
|
+
this.startCol += 1
|
|
7246
|
+
this.endCol += 1
|
|
7247
|
+
}
|
|
7061
7248
|
this.endCol = Math.max(this.startCol, this.endCol)
|
|
7062
7249
|
this.options.onScroll('y', this.startRow, this.endRow, this.startCol - this.pinnedColumns, this.endCol - this.pinnedColumns)
|
|
7063
7250
|
}
|
|
@@ -7147,6 +7334,7 @@ class WebsyChart {
|
|
|
7147
7334
|
minBandWidth: 30,
|
|
7148
7335
|
maxBandWidth: 100,
|
|
7149
7336
|
allowUnevenBands: true,
|
|
7337
|
+
allowBrushing: true,
|
|
7150
7338
|
balancedMinMax: false
|
|
7151
7339
|
}
|
|
7152
7340
|
this.elementId = elementId
|
|
@@ -7908,7 +8096,7 @@ else {
|
|
|
7908
8096
|
maxBandWidthFits = true
|
|
7909
8097
|
proposedBandWidth = this.options.maxBandWidth
|
|
7910
8098
|
}
|
|
7911
|
-
if (!maxBandWidthFits) {
|
|
8099
|
+
if (!maxBandWidthFits && this.options.allowBrushing === true) {
|
|
7912
8100
|
// Check to see if all bars at the min allowed width will fit
|
|
7913
8101
|
if (plotable / noOfPoints < this.options.minBandWidth) {
|
|
7914
8102
|
this.brushNeeded = true
|
|
@@ -8111,6 +8299,9 @@ else {
|
|
|
8111
8299
|
else {
|
|
8112
8300
|
leftRange = [(this.widthForCalc + this.totalBandPadding), 0]
|
|
8113
8301
|
}
|
|
8302
|
+
if (this.options.allowBrushing !== true) {
|
|
8303
|
+
bottomRange = bottomBrushRange
|
|
8304
|
+
}
|
|
8114
8305
|
this.bottomAxis = d3[`scale${this.options.data.bottom.scale || 'Ordinal'}`]()
|
|
8115
8306
|
.domain(bottomDomain)
|
|
8116
8307
|
.range(bottomRange)
|
|
@@ -9784,6 +9975,7 @@ const WebsyDesigns = {
|
|
|
9784
9975
|
NavigationMenu: WebsyNavigationMenu,
|
|
9785
9976
|
WebsyForm,
|
|
9786
9977
|
Form: WebsyForm,
|
|
9978
|
+
MultiForm,
|
|
9787
9979
|
WebsyDatePicker,
|
|
9788
9980
|
DatePicker: WebsyDatePicker,
|
|
9789
9981
|
WebsyDragDrop,
|