@websy/websy-designs 1.11.10 → 1.11.11
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.
|
@@ -2155,6 +2155,7 @@ class WebsyForm {
|
|
|
2155
2155
|
clearAfterSave: false,
|
|
2156
2156
|
fields: [],
|
|
2157
2157
|
mode: 'add',
|
|
2158
|
+
useLoader: false,
|
|
2158
2159
|
onSuccess: function (data) {},
|
|
2159
2160
|
onError: function (err) { console.log('Error submitting form data:', err) }
|
|
2160
2161
|
}
|
|
@@ -2189,6 +2190,7 @@ class WebsyForm {
|
|
|
2189
2190
|
if (this.options.cancelFn) {
|
|
2190
2191
|
this.options.cancelFn(this.elementId)
|
|
2191
2192
|
}
|
|
2193
|
+
this.loader.hide()
|
|
2192
2194
|
}
|
|
2193
2195
|
checkRecaptcha () {
|
|
2194
2196
|
return new Promise((resolve, reject) => {
|
|
@@ -2239,6 +2241,7 @@ class WebsyForm {
|
|
|
2239
2241
|
clear () {
|
|
2240
2242
|
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
2241
2243
|
formEl.reset()
|
|
2244
|
+
this.loader.hide()
|
|
2242
2245
|
}
|
|
2243
2246
|
get data () {
|
|
2244
2247
|
const formEl = document.getElementById(`${this.elementId}Form`)
|
|
@@ -2261,6 +2264,9 @@ class WebsyForm {
|
|
|
2261
2264
|
if (this.fieldMap[key] && this.fieldMap[key].type === 'checkbox') {
|
|
2262
2265
|
data[key] = false
|
|
2263
2266
|
}
|
|
2267
|
+
else if (this.fieldMap[key] && (this.fieldMap[key].component === 'Switch' || this.fieldMap[key].component === 'WebsySwitch')) {
|
|
2268
|
+
data[key] = this.fieldMap[key].instance.options.enabled
|
|
2269
|
+
}
|
|
2264
2270
|
else if (this.fieldMap[key] && this.fieldMap[key].instance && this.fieldMap[key].instance.value) {
|
|
2265
2271
|
data[key] = this.fieldMap[key].instance.value
|
|
2266
2272
|
}
|
|
@@ -2497,6 +2503,7 @@ class WebsyForm {
|
|
|
2497
2503
|
this.options.fields.forEach((f, i) => {
|
|
2498
2504
|
this.fieldMap[f.field] = f
|
|
2499
2505
|
f.owningElement = this.elementId
|
|
2506
|
+
let inputValue = typeof f.value === 'function' ? f.value() : f.value
|
|
2500
2507
|
if (f.disabled || f.readOnly || this.options.readOnly) {
|
|
2501
2508
|
if (!f.options) {
|
|
2502
2509
|
f.options = {}
|
|
@@ -2540,7 +2547,7 @@ class WebsyForm {
|
|
|
2540
2547
|
${f.disabled || f.readOnly || this.options.readOnly ? 'disabled' : ''}
|
|
2541
2548
|
${(f.attributes || []).join(' ')}
|
|
2542
2549
|
class="websy-input websy-textarea ${f.readOnly || this.options.readOnly ? 'websy-input-readonly' : ''}"
|
|
2543
|
-
>${
|
|
2550
|
+
>${inputValue || ''}</textarea>
|
|
2544
2551
|
<span id='${this.elementId}_${f.field}_error' class='websy-form-validation-error'></span>
|
|
2545
2552
|
</div><!--
|
|
2546
2553
|
`
|
|
@@ -2559,8 +2566,8 @@ class WebsyForm {
|
|
|
2559
2566
|
${(f.attributes || []).join(' ')}
|
|
2560
2567
|
name="${f.field}"
|
|
2561
2568
|
placeholder="${f.placeholder || ''}"
|
|
2562
|
-
value="${f.type === 'date' ? '' :
|
|
2563
|
-
valueAsDate="${f.type === 'date' ?
|
|
2569
|
+
value="${f.type === 'date' ? '' : inputValue || ''}"
|
|
2570
|
+
valueAsDate="${f.type === 'date' ? inputValue : ''}"
|
|
2564
2571
|
${f.disabled || f.readOnly || this.options.readOnly ? 'disabled' : ''}
|
|
2565
2572
|
oninvalidx="this.setCustomValidity('${f.invalidMessage || 'Please fill in this field.'}')"
|
|
2566
2573
|
/>
|
|
@@ -2591,8 +2598,12 @@ class WebsyForm {
|
|
|
2591
2598
|
html += `
|
|
2592
2599
|
</form>
|
|
2593
2600
|
<div id="${this.elementId}_validationFail" class="websy-validation-failure"></div>
|
|
2601
|
+
<div id="${this.elementId}_loader" class=""></div>
|
|
2594
2602
|
`
|
|
2595
2603
|
el.innerHTML = html
|
|
2604
|
+
if (!this.loader) {
|
|
2605
|
+
this.loader = new WebsyDesigns.LoadingDialog(`${this.elementId}_loader`, { title: ' ' })
|
|
2606
|
+
}
|
|
2596
2607
|
this.processComponents(componentsToProcess, () => {
|
|
2597
2608
|
if ((this.options.useRecaptcha === true || this.options.useRecaptchaV3 === true) && typeof grecaptcha !== 'undefined') {
|
|
2598
2609
|
this.recaptchaReady()
|
|
@@ -2645,6 +2656,9 @@ class WebsyForm {
|
|
|
2645
2656
|
if (recaptchErrEl) {
|
|
2646
2657
|
recaptchErrEl.classList.add('websy-hidden')
|
|
2647
2658
|
}
|
|
2659
|
+
if (this.options.useLoader) {
|
|
2660
|
+
this.loader.show()
|
|
2661
|
+
}
|
|
2648
2662
|
const formData = new FormData(formEl)
|
|
2649
2663
|
const data = {}
|
|
2650
2664
|
const temp = new FormData(formEl)
|
|
@@ -2673,10 +2687,13 @@ class WebsyForm {
|
|
|
2673
2687
|
}
|
|
2674
2688
|
else if (this.options.submitFn) {
|
|
2675
2689
|
this.options.submitFn(data, () => {
|
|
2690
|
+
this.loader.hide()
|
|
2676
2691
|
if (this.options.clearAfterSave === true) {
|
|
2677
2692
|
// this.render()
|
|
2678
2693
|
formEl.reset()
|
|
2679
2694
|
}
|
|
2695
|
+
}, () => {
|
|
2696
|
+
this.loader.hide()
|
|
2680
2697
|
})
|
|
2681
2698
|
}
|
|
2682
2699
|
}
|
|
@@ -4937,6 +4954,10 @@ class WebsyRouter {
|
|
|
4937
4954
|
this.showView(this.currentView, this.currentParams, 'main')
|
|
4938
4955
|
}
|
|
4939
4956
|
navigate (inputPath, group = 'main', event, popped) {
|
|
4957
|
+
if (inputPath.indexOf('http') === 0) {
|
|
4958
|
+
window.open(inputPath, '_blank')
|
|
4959
|
+
return
|
|
4960
|
+
}
|
|
4940
4961
|
if (typeof popped === 'undefined') {
|
|
4941
4962
|
popped = false
|
|
4942
4963
|
}
|
|
@@ -5162,6 +5183,12 @@ class Switch {
|
|
|
5162
5183
|
this.render()
|
|
5163
5184
|
}
|
|
5164
5185
|
}
|
|
5186
|
+
get data () {
|
|
5187
|
+
return this.options.enabled
|
|
5188
|
+
}
|
|
5189
|
+
set data (d) {
|
|
5190
|
+
this.options.enabled = d
|
|
5191
|
+
}
|
|
5165
5192
|
disable () {
|
|
5166
5193
|
this.options.enabled = false
|
|
5167
5194
|
let method = this.options.enabled === true ? 'add' : 'remove'
|
|
@@ -2145,6 +2145,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2145
2145
|
clearAfterSave: false,
|
|
2146
2146
|
fields: [],
|
|
2147
2147
|
mode: 'add',
|
|
2148
|
+
useLoader: false,
|
|
2148
2149
|
onSuccess: function onSuccess(data) {},
|
|
2149
2150
|
onError: function onError(err) {
|
|
2150
2151
|
console.log('Error submitting form data:', err);
|
|
@@ -2183,6 +2184,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2183
2184
|
if (this.options.cancelFn) {
|
|
2184
2185
|
this.options.cancelFn(this.elementId);
|
|
2185
2186
|
}
|
|
2187
|
+
this.loader.hide();
|
|
2186
2188
|
}
|
|
2187
2189
|
}, {
|
|
2188
2190
|
key: "checkRecaptcha",
|
|
@@ -2243,6 +2245,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2243
2245
|
value: function clear() {
|
|
2244
2246
|
var formEl = document.getElementById("".concat(this.elementId, "Form"));
|
|
2245
2247
|
formEl.reset();
|
|
2248
|
+
this.loader.hide();
|
|
2246
2249
|
}
|
|
2247
2250
|
}, {
|
|
2248
2251
|
key: "data",
|
|
@@ -2266,6 +2269,8 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2266
2269
|
if (keys.indexOf(key) === -1) {
|
|
2267
2270
|
if (this.fieldMap[key] && this.fieldMap[key].type === 'checkbox') {
|
|
2268
2271
|
data[key] = false;
|
|
2272
|
+
} else if (this.fieldMap[key] && (this.fieldMap[key].component === 'Switch' || this.fieldMap[key].component === 'WebsySwitch')) {
|
|
2273
|
+
data[key] = this.fieldMap[key].instance.options.enabled;
|
|
2269
2274
|
} else if (this.fieldMap[key] && this.fieldMap[key].instance && this.fieldMap[key].instance.value) {
|
|
2270
2275
|
data[key] = this.fieldMap[key].instance.value;
|
|
2271
2276
|
}
|
|
@@ -2527,6 +2532,7 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2527
2532
|
this.options.fields.forEach(function (f, i) {
|
|
2528
2533
|
_this18.fieldMap[f.field] = f;
|
|
2529
2534
|
f.owningElement = _this18.elementId;
|
|
2535
|
+
var inputValue = typeof f.value === 'function' ? f.value() : f.value;
|
|
2530
2536
|
if (f.disabled || f.readOnly || _this18.options.readOnly) {
|
|
2531
2537
|
if (!f.options) {
|
|
2532
2538
|
f.options = {};
|
|
@@ -2550,9 +2556,9 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2550
2556
|
componentsToProcess.push(f);
|
|
2551
2557
|
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', " ").concat(f.component === 'MediaUpload' ? 'media-upload' : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <div id='").concat(_this18.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n <span id='").concat(_this18.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
|
|
2552
2558
|
} else if (f.type === 'longtext') {
|
|
2553
|
-
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <textarea\n id=\"").concat(_this18.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n data-user-type=\"").concat(f.type, "\"\n data-index=\"").concat(i, "\"\n name=\"").concat(f.field, "\" \n ").concat(f.disabled || f.readOnly || _this18.options.readOnly ? 'disabled' : '', "\n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea ").concat(f.readOnly || _this18.options.readOnly ? 'websy-input-readonly' : '', "\"\n >").concat(
|
|
2559
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <textarea\n id=\"").concat(_this18.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n data-user-type=\"").concat(f.type, "\"\n data-index=\"").concat(i, "\"\n name=\"").concat(f.field, "\" \n ").concat(f.disabled || f.readOnly || _this18.options.readOnly ? 'disabled' : '', "\n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea ").concat(f.readOnly || _this18.options.readOnly ? 'websy-input-readonly' : '', "\"\n >").concat(inputValue || '', "</textarea>\n <span id='").concat(_this18.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
|
|
2554
2560
|
} else {
|
|
2555
|
-
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <input \n id=\"").concat(_this18.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat((f.type === 'expiry' ? 'text' : f.type === 'cvv' ? 'number' : f.type) || 'text', "\" \n data-user-type=\"").concat(f.type, "\"\n data-index=\"").concat(i, "\"\n class=\"websy-input ").concat(f.readOnly || _this18.options.readOnly ? 'websy-input-readonly' : '', "\" \n ").concat((f.attributes || []).join(' '), "\n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.type === 'date' ? '' :
|
|
2561
|
+
html += "\n ".concat(i > 0 ? '-->' : '', "<div id='").concat(_this18.elementId, "_").concat(f.field, "_inputContainer' style='").concat(f.style || '', "' class='websy-input-container ").concat(f.classes ? f.classes.join(' ') : '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '').concat(f.required === true ? '<span class="websy-form-required-value">*</span>' : '', "\n <input \n id=\"").concat(_this18.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat((f.type === 'expiry' ? 'text' : f.type === 'cvv' ? 'number' : f.type) || 'text', "\" \n data-user-type=\"").concat(f.type, "\"\n data-index=\"").concat(i, "\"\n class=\"websy-input ").concat(f.readOnly || _this18.options.readOnly ? 'websy-input-readonly' : '', "\" \n ").concat((f.attributes || []).join(' '), "\n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.type === 'date' ? '' : inputValue || '', "\"\n valueAsDate=\"").concat(f.type === 'date' ? inputValue : '', "\"\n ").concat(f.disabled || f.readOnly || _this18.options.readOnly ? 'disabled' : '', "\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n <span id='").concat(_this18.elementId, "_").concat(f.field, "_error' class='websy-form-validation-error'></span>\n </div><!--\n ");
|
|
2556
2562
|
}
|
|
2557
2563
|
});
|
|
2558
2564
|
if (this.options.useRecaptcha === true) {
|
|
@@ -2566,8 +2572,13 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2566
2572
|
if (this.options.cancel) {
|
|
2567
2573
|
html += "\n --><button class=\"websy-btn cancel ".concat(this.options.cancel.classes ? this.options.cancel.classes.join(' ') : '', "\">").concat(this.options.cancel.text || 'Cancel', "</button>\n ");
|
|
2568
2574
|
}
|
|
2569
|
-
html += " \n </form>\n <div id=\"".concat(this.elementId, "_validationFail\" class=\"websy-validation-failure\"></div>\n ");
|
|
2575
|
+
html += " \n </form>\n <div id=\"".concat(this.elementId, "_validationFail\" class=\"websy-validation-failure\"></div>\n <div id=\"").concat(this.elementId, "_loader\" class=\"\"></div>\n ");
|
|
2570
2576
|
el.innerHTML = html;
|
|
2577
|
+
if (!this.loader) {
|
|
2578
|
+
this.loader = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loader"), {
|
|
2579
|
+
title: ' '
|
|
2580
|
+
});
|
|
2581
|
+
}
|
|
2571
2582
|
this.processComponents(componentsToProcess, function () {
|
|
2572
2583
|
if ((_this18.options.useRecaptcha === true || _this18.options.useRecaptchaV3 === true) && typeof grecaptcha !== 'undefined') {
|
|
2573
2584
|
_this18.recaptchaReady();
|
|
@@ -2622,6 +2633,9 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2622
2633
|
if (recaptchErrEl) {
|
|
2623
2634
|
recaptchErrEl.classList.add('websy-hidden');
|
|
2624
2635
|
}
|
|
2636
|
+
if (_this19.options.useLoader) {
|
|
2637
|
+
_this19.loader.show();
|
|
2638
|
+
}
|
|
2625
2639
|
var formData = new FormData(formEl);
|
|
2626
2640
|
var data = {};
|
|
2627
2641
|
var temp = new FormData(formEl);
|
|
@@ -2648,10 +2662,13 @@ var WebsyForm = /*#__PURE__*/function () {
|
|
|
2648
2662
|
});
|
|
2649
2663
|
} else if (_this19.options.submitFn) {
|
|
2650
2664
|
_this19.options.submitFn(data, function () {
|
|
2665
|
+
_this19.loader.hide();
|
|
2651
2666
|
if (_this19.options.clearAfterSave === true) {
|
|
2652
2667
|
// this.render()
|
|
2653
2668
|
formEl.reset();
|
|
2654
2669
|
}
|
|
2670
|
+
}, function () {
|
|
2671
|
+
_this19.loader.hide();
|
|
2655
2672
|
});
|
|
2656
2673
|
}
|
|
2657
2674
|
} else {
|
|
@@ -4776,6 +4793,10 @@ var WebsyRouter = /*#__PURE__*/function () {
|
|
|
4776
4793
|
var group = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'main';
|
|
4777
4794
|
var event = arguments.length > 2 ? arguments[2] : undefined;
|
|
4778
4795
|
var popped = arguments.length > 3 ? arguments[3] : undefined;
|
|
4796
|
+
if (inputPath.indexOf('http') === 0) {
|
|
4797
|
+
window.open(inputPath, '_blank');
|
|
4798
|
+
return;
|
|
4799
|
+
}
|
|
4779
4800
|
if (typeof popped === 'undefined') {
|
|
4780
4801
|
popped = false;
|
|
4781
4802
|
}
|
|
@@ -5017,6 +5038,14 @@ var Switch = /*#__PURE__*/function () {
|
|
|
5017
5038
|
}
|
|
5018
5039
|
}
|
|
5019
5040
|
_createClass(Switch, [{
|
|
5041
|
+
key: "data",
|
|
5042
|
+
get: function get() {
|
|
5043
|
+
return this.options.enabled;
|
|
5044
|
+
},
|
|
5045
|
+
set: function set(d) {
|
|
5046
|
+
this.options.enabled = d;
|
|
5047
|
+
}
|
|
5048
|
+
}, {
|
|
5020
5049
|
key: "disable",
|
|
5021
5050
|
value: function disable() {
|
|
5022
5051
|
this.options.enabled = false;
|