@unvired/turboforms-embed-sdk 1.0.10 → 1.0.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.
- package/dist/unvired-form-sdk.html +68 -30
- package/dist/unvired-forms-sdk.js +69 -21
- package/package.json +1 -1
|
@@ -59013,19 +59013,31 @@ function FormOnBackNavigation() {
|
|
|
59013
59013
|
|
|
59014
59014
|
// ============================================ FORM-IO ===========================================================
|
|
59015
59015
|
|
|
59016
|
+
// Button state management based on privateExternal and permission
|
|
59016
59017
|
// Button state management based on privateExternal and permission
|
|
59017
59018
|
function initialButtonSetup(privateExternal, permission) {
|
|
59018
59019
|
const saveBtn = document.getElementById("saveBtn");
|
|
59019
59020
|
const submitBtn = document.getElementById("submitBtn");
|
|
59021
|
+
const completeOption = document.getElementById("completeOption");
|
|
59022
|
+
const saveOption = document.getElementById("saveOption");
|
|
59023
|
+
const completeDivider = document.getElementById("completeDivider");
|
|
59024
|
+
const saveDivider = document.getElementById("saveDivider");
|
|
59025
|
+
|
|
59020
59026
|
if (!saveBtn || !submitBtn) return;
|
|
59021
59027
|
|
|
59022
59028
|
const isPrivate = privateExternal === true || privateExternal === "true";
|
|
59023
59029
|
const isPublic = privateExternal === false || privateExternal === "false";
|
|
59024
59030
|
const permissionMode = String(permission || "").toLowerCase();
|
|
59025
59031
|
|
|
59026
|
-
|
|
59027
|
-
|
|
59028
|
-
|
|
59032
|
+
// Helper to toggle dropdown items
|
|
59033
|
+
const toggleDropdown = (option, divider, show) => {
|
|
59034
|
+
if (option) option.style.display = show ? "block" : "none";
|
|
59035
|
+
if (divider) divider.style.display = show ? "block" : "none";
|
|
59036
|
+
};
|
|
59037
|
+
|
|
59038
|
+
// Default: Hide dropdown specific items
|
|
59039
|
+
toggleDropdown(completeOption, completeDivider, false);
|
|
59040
|
+
toggleDropdown(saveOption, saveDivider, false);
|
|
59029
59041
|
|
|
59030
59042
|
// READ ONLY
|
|
59031
59043
|
if (permissionMode === "read") {
|
|
@@ -59042,23 +59054,35 @@ function initialButtonSetup(privateExternal, permission) {
|
|
|
59042
59054
|
console.log("Mode: PUBLIC WRITE → Show submit (disabled)");
|
|
59043
59055
|
saveBtn.style.display = "none";
|
|
59044
59056
|
submitBtn.style.display = "";
|
|
59057
|
+
submitBtn.innerHTML = '<i class="icon save"></i> Submit';
|
|
59045
59058
|
submitBtn.disabled = true;
|
|
59046
59059
|
}
|
|
59047
59060
|
|
|
59048
59061
|
// PRIVATE FORM - writemultiple
|
|
59049
59062
|
else if (isPrivate && permissionMode === "writemultiple") {
|
|
59050
|
-
console.log(
|
|
59051
|
-
|
|
59052
|
-
|
|
59053
|
-
|
|
59063
|
+
console.log(
|
|
59064
|
+
"Mode: PRIVATE WRITEMULTIPLE → Show save (disabled), Complete in Dropdown"
|
|
59065
|
+
);
|
|
59066
|
+
saveBtn.style.display = "";
|
|
59067
|
+
submitBtn.style.display = "none";
|
|
59068
|
+
saveBtn.disabled = true;
|
|
59069
|
+
|
|
59070
|
+
// Show Complete in Dropdown
|
|
59071
|
+
toggleDropdown(completeOption, completeDivider, true);
|
|
59054
59072
|
}
|
|
59055
59073
|
|
|
59056
59074
|
// PRIVATE FORM - writesingle
|
|
59057
59075
|
else if (isPrivate && permissionMode === "writesingle") {
|
|
59058
|
-
console.log(
|
|
59059
|
-
|
|
59060
|
-
|
|
59061
|
-
saveBtn.
|
|
59076
|
+
console.log(
|
|
59077
|
+
"Mode: PRIVATE WRITESINGLE → Show submit (disabled), Save in Dropdown"
|
|
59078
|
+
);
|
|
59079
|
+
saveBtn.style.display = "none";
|
|
59080
|
+
submitBtn.style.display = "";
|
|
59081
|
+
submitBtn.innerHTML = '<i class="icon save"></i> Complete';
|
|
59082
|
+
submitBtn.disabled = true;
|
|
59083
|
+
|
|
59084
|
+
// Show Save in Dropdown
|
|
59085
|
+
toggleDropdown(saveOption, saveDivider, true);
|
|
59062
59086
|
}
|
|
59063
59087
|
|
|
59064
59088
|
// DEFAULT / UNKNOWN
|
|
@@ -59066,6 +59090,7 @@ function initialButtonSetup(privateExternal, permission) {
|
|
|
59066
59090
|
console.log("Mode: DEFAULT / UNKNOWN → Show submit (disabled)");
|
|
59067
59091
|
saveBtn.style.display = "none";
|
|
59068
59092
|
submitBtn.style.display = "";
|
|
59093
|
+
submitBtn.innerHTML = '<i class="icon save"></i> Submit';
|
|
59069
59094
|
submitBtn.disabled = true;
|
|
59070
59095
|
}
|
|
59071
59096
|
}
|
|
@@ -59089,16 +59114,12 @@ function onChangeButtonSetup(
|
|
|
59089
59114
|
v !== undefined &&
|
|
59090
59115
|
v !== null &&
|
|
59091
59116
|
v !== "" &&
|
|
59092
|
-
|
|
59117
|
+
v !== false &&
|
|
59118
|
+
!(Array.isArray(v) && v.length === 0) &&
|
|
59119
|
+
!(typeof v === "object" && !Array.isArray(v) && Object.keys(v).length === 0)
|
|
59093
59120
|
);
|
|
59094
59121
|
const isComplete = completionPercentage >= 100;
|
|
59095
59122
|
|
|
59096
|
-
console.log("=== onChangeButtonSetup ===");
|
|
59097
|
-
console.log("privateExternal:", privateExternal);
|
|
59098
|
-
console.log("permission:", permissionMode);
|
|
59099
|
-
console.log("hasAnyValue:", hasAnyValue);
|
|
59100
|
-
console.log("completionPercentage:", completionPercentage);
|
|
59101
|
-
|
|
59102
59123
|
// READ ONLY
|
|
59103
59124
|
if (permissionMode === "read") {
|
|
59104
59125
|
console.log("Mode: READ → Hide all buttons");
|
|
@@ -59110,26 +59131,24 @@ function onChangeButtonSetup(
|
|
|
59110
59131
|
// PRIVATE FORM - writesingle
|
|
59111
59132
|
if (isPrivate && permissionMode === "writesingle") {
|
|
59112
59133
|
console.log("Mode: PRIVATE WRITESINGLE");
|
|
59134
|
+
// Main: Complete (Submit)
|
|
59113
59135
|
saveBtn.style.display = "none";
|
|
59114
59136
|
submitBtn.style.display = "";
|
|
59115
|
-
|
|
59137
|
+
|
|
59138
|
+
// Logic: Disable Complete until 100%
|
|
59139
|
+
submitBtn.disabled = !isComplete;
|
|
59116
59140
|
return;
|
|
59117
59141
|
}
|
|
59118
59142
|
|
|
59119
59143
|
// PRIVATE FORM - writemultiple
|
|
59120
59144
|
if (isPrivate && permissionMode === "writemultiple") {
|
|
59121
59145
|
console.log("Mode: PRIVATE WRITEMULTIPLE");
|
|
59122
|
-
|
|
59123
|
-
|
|
59124
|
-
|
|
59125
|
-
|
|
59126
|
-
|
|
59127
|
-
|
|
59128
|
-
console.log("→ Incomplete: Show save");
|
|
59129
|
-
saveBtn.style.display = "";
|
|
59130
|
-
submitBtn.style.display = "none";
|
|
59131
|
-
saveBtn.disabled = !hasAnyValue;
|
|
59132
|
-
}
|
|
59146
|
+
// Main: Save
|
|
59147
|
+
saveBtn.style.display = "";
|
|
59148
|
+
submitBtn.style.display = "none";
|
|
59149
|
+
|
|
59150
|
+
// Logic: Enable Save if hasAnyValue
|
|
59151
|
+
saveBtn.disabled = !hasAnyValue;
|
|
59133
59152
|
return;
|
|
59134
59153
|
}
|
|
59135
59154
|
|
|
@@ -59550,6 +59569,9 @@ function setupOnChange(privateExternal, permission) {
|
|
|
59550
59569
|
const completion =
|
|
59551
59570
|
mandatory === 0 ? 100 : Math.round((filledMandatory / mandatory) * 100);
|
|
59552
59571
|
|
|
59572
|
+
calculationPercentage = completion;
|
|
59573
|
+
completeFlag = completion >= 100;
|
|
59574
|
+
|
|
59553
59575
|
console.log("📊 Completion %:", completion);
|
|
59554
59576
|
onChangeButtonSetup(completion, formObj.data, privateExternal, permission);
|
|
59555
59577
|
|
|
@@ -59708,6 +59730,22 @@ function loadComments() {
|
|
|
59708
59730
|
function FormOnSave() {
|
|
59709
59731
|
if (!formObj) return;
|
|
59710
59732
|
|
|
59733
|
+
const formData = formObj.getValue().data;
|
|
59734
|
+
const hasAnyValue = Object.values(formData || {}).some(
|
|
59735
|
+
(v) =>
|
|
59736
|
+
v !== undefined &&
|
|
59737
|
+
v !== null &&
|
|
59738
|
+
v !== "" &&
|
|
59739
|
+
v !== false &&
|
|
59740
|
+
!(Array.isArray(v) && v.length === 0) &&
|
|
59741
|
+
!(typeof v === "object" && !Array.isArray(v) && Object.keys(v).length === 0)
|
|
59742
|
+
);
|
|
59743
|
+
|
|
59744
|
+
if (!hasAnyValue) {
|
|
59745
|
+
showDynamicModal("Attention", [{ label: "OK" }], "Please fill at least one field before saving.");
|
|
59746
|
+
return;
|
|
59747
|
+
}
|
|
59748
|
+
|
|
59711
59749
|
showDynamicModal("Do you want to save the data?", [
|
|
59712
59750
|
{
|
|
59713
59751
|
label: "Yes",
|
|
@@ -27234,6 +27234,10 @@ select.ui.dropdown {
|
|
|
27234
27234
|
<i class="icon options"></i>More
|
|
27235
27235
|
</button>
|
|
27236
27236
|
<div id="moreTooltip" style="display: none;" class="ui vertical menu">
|
|
27237
|
+
<div class="item" id="completeOption" onclick="FormOnSubmit()" style="display: none;">Complete</div>
|
|
27238
|
+
<div class="divider" id="completeDivider" style="display: none;"></div>
|
|
27239
|
+
<div class="item" id="saveOption" onclick="FormOnSave()" style="display: none;">Save</div>
|
|
27240
|
+
<div class="divider" id="saveDivider" style="display: none;"></div>
|
|
27237
27241
|
<div class="item">Documents</div>
|
|
27238
27242
|
<div class="divider" id="comments-divider" style="display: none;"></div>
|
|
27239
27243
|
<div class="item" id="comments-item" style="display: none;" onclick="loadComments()">Comments</div>
|
|
@@ -64975,12 +64979,27 @@ function FormOnBackNavigation() {
|
|
|
64975
64979
|
function initialButtonSetup(privateExternal, permission) {
|
|
64976
64980
|
const saveBtn = document.getElementById("saveBtn");
|
|
64977
64981
|
const submitBtn = document.getElementById("submitBtn");
|
|
64982
|
+
const completeOption = document.getElementById("completeOption");
|
|
64983
|
+
const saveOption = document.getElementById("saveOption");
|
|
64984
|
+
const completeDivider = document.getElementById("completeDivider");
|
|
64985
|
+
const saveDivider = document.getElementById("saveDivider");
|
|
64986
|
+
|
|
64978
64987
|
if (!saveBtn || !submitBtn) return;
|
|
64979
64988
|
|
|
64980
64989
|
const isPrivate = privateExternal === true || privateExternal === "true";
|
|
64981
64990
|
const isPublic = privateExternal === false || privateExternal === "false";
|
|
64982
64991
|
const permissionMode = String(permission || "").toLowerCase();
|
|
64983
64992
|
|
|
64993
|
+
// Helper to toggle dropdown items
|
|
64994
|
+
const toggleDropdown = (option, divider, show) => {
|
|
64995
|
+
if (option) option.style.display = show ? "block" : "none";
|
|
64996
|
+
if (divider) divider.style.display = show ? "block" : "none";
|
|
64997
|
+
};
|
|
64998
|
+
|
|
64999
|
+
// Default: Hide dropdown specific items
|
|
65000
|
+
toggleDropdown(completeOption, completeDivider, false);
|
|
65001
|
+
toggleDropdown(saveOption, saveDivider, false);
|
|
65002
|
+
|
|
64984
65003
|
// READ ONLY
|
|
64985
65004
|
if (permissionMode === "read") {
|
|
64986
65005
|
console.log("Mode: READ \u2192 Hide all buttons");
|
|
@@ -64996,23 +65015,35 @@ function initialButtonSetup(privateExternal, permission) {
|
|
|
64996
65015
|
console.log("Mode: PUBLIC WRITE \u2192 Show submit (disabled)");
|
|
64997
65016
|
saveBtn.style.display = "none";
|
|
64998
65017
|
submitBtn.style.display = "";
|
|
65018
|
+
submitBtn.innerHTML = '<i class="icon save"></i> Submit';
|
|
64999
65019
|
submitBtn.disabled = true;
|
|
65000
65020
|
}
|
|
65001
65021
|
|
|
65002
65022
|
// PRIVATE FORM - writemultiple
|
|
65003
65023
|
else if (isPrivate && permissionMode === "writemultiple") {
|
|
65004
|
-
console.log(
|
|
65005
|
-
|
|
65006
|
-
|
|
65007
|
-
|
|
65024
|
+
console.log(
|
|
65025
|
+
"Mode: PRIVATE WRITEMULTIPLE \u2192 Show save (disabled), Complete in Dropdown"
|
|
65026
|
+
);
|
|
65027
|
+
saveBtn.style.display = "";
|
|
65028
|
+
submitBtn.style.display = "none";
|
|
65029
|
+
saveBtn.disabled = true;
|
|
65030
|
+
|
|
65031
|
+
// Show Complete in Dropdown
|
|
65032
|
+
toggleDropdown(completeOption, completeDivider, true);
|
|
65008
65033
|
}
|
|
65009
65034
|
|
|
65010
65035
|
// PRIVATE FORM - writesingle
|
|
65011
65036
|
else if (isPrivate && permissionMode === "writesingle") {
|
|
65012
|
-
console.log(
|
|
65013
|
-
|
|
65014
|
-
|
|
65015
|
-
saveBtn.
|
|
65037
|
+
console.log(
|
|
65038
|
+
"Mode: PRIVATE WRITESINGLE \u2192 Show submit (disabled), Save in Dropdown"
|
|
65039
|
+
);
|
|
65040
|
+
saveBtn.style.display = "none";
|
|
65041
|
+
submitBtn.style.display = "";
|
|
65042
|
+
submitBtn.innerHTML = '<i class="icon save"></i> Complete';
|
|
65043
|
+
submitBtn.disabled = true;
|
|
65044
|
+
|
|
65045
|
+
// Show Save in Dropdown
|
|
65046
|
+
toggleDropdown(saveOption, saveDivider, true);
|
|
65016
65047
|
}
|
|
65017
65048
|
|
|
65018
65049
|
// DEFAULT / UNKNOWN
|
|
@@ -65020,6 +65051,7 @@ function initialButtonSetup(privateExternal, permission) {
|
|
|
65020
65051
|
console.log("Mode: DEFAULT / UNKNOWN \u2192 Show submit (disabled)");
|
|
65021
65052
|
saveBtn.style.display = "none";
|
|
65022
65053
|
submitBtn.style.display = "";
|
|
65054
|
+
submitBtn.innerHTML = '<i class="icon save"></i> Submit';
|
|
65023
65055
|
submitBtn.disabled = true;
|
|
65024
65056
|
}
|
|
65025
65057
|
}
|
|
@@ -65043,7 +65075,9 @@ function onChangeButtonSetup(
|
|
|
65043
65075
|
v !== undefined &&
|
|
65044
65076
|
v !== null &&
|
|
65045
65077
|
v !== "" &&
|
|
65046
|
-
|
|
65078
|
+
v !== false &&
|
|
65079
|
+
!(Array.isArray(v) && v.length === 0) &&
|
|
65080
|
+
!(typeof v === "object" && !Array.isArray(v) && Object.keys(v).length === 0)
|
|
65047
65081
|
);
|
|
65048
65082
|
const isComplete = completionPercentage >= 100;
|
|
65049
65083
|
|
|
@@ -65058,26 +65092,24 @@ function onChangeButtonSetup(
|
|
|
65058
65092
|
// PRIVATE FORM - writesingle
|
|
65059
65093
|
if (isPrivate && permissionMode === "writesingle") {
|
|
65060
65094
|
console.log("Mode: PRIVATE WRITESINGLE");
|
|
65095
|
+
// Main: Complete (Submit)
|
|
65061
65096
|
saveBtn.style.display = "none";
|
|
65062
65097
|
submitBtn.style.display = "";
|
|
65063
|
-
|
|
65098
|
+
|
|
65099
|
+
// Logic: Disable Complete until 100%
|
|
65100
|
+
submitBtn.disabled = !isComplete;
|
|
65064
65101
|
return;
|
|
65065
65102
|
}
|
|
65066
65103
|
|
|
65067
65104
|
// PRIVATE FORM - writemultiple
|
|
65068
65105
|
if (isPrivate && permissionMode === "writemultiple") {
|
|
65069
65106
|
console.log("Mode: PRIVATE WRITEMULTIPLE");
|
|
65070
|
-
|
|
65071
|
-
|
|
65072
|
-
|
|
65073
|
-
|
|
65074
|
-
|
|
65075
|
-
|
|
65076
|
-
console.log("\u2192 Incomplete: Show save");
|
|
65077
|
-
saveBtn.style.display = "";
|
|
65078
|
-
submitBtn.style.display = "none";
|
|
65079
|
-
saveBtn.disabled = !hasAnyValue;
|
|
65080
|
-
}
|
|
65107
|
+
// Main: Save
|
|
65108
|
+
saveBtn.style.display = "";
|
|
65109
|
+
submitBtn.style.display = "none";
|
|
65110
|
+
|
|
65111
|
+
// Logic: Enable Save if hasAnyValue
|
|
65112
|
+
saveBtn.disabled = !hasAnyValue;
|
|
65081
65113
|
return;
|
|
65082
65114
|
}
|
|
65083
65115
|
|
|
@@ -65666,6 +65698,22 @@ async function loadComments() {
|
|
|
65666
65698
|
function FormOnSave() {
|
|
65667
65699
|
if (!formObj) return;
|
|
65668
65700
|
|
|
65701
|
+
const formData = formObj.getValue().data;
|
|
65702
|
+
const hasAnyValue = Object.values(formData || {}).some(
|
|
65703
|
+
(v) =>
|
|
65704
|
+
v !== undefined &&
|
|
65705
|
+
v !== null &&
|
|
65706
|
+
v !== "" &&
|
|
65707
|
+
v !== false &&
|
|
65708
|
+
!(Array.isArray(v) && v.length === 0) &&
|
|
65709
|
+
!(typeof v === "object" && !Array.isArray(v) && Object.keys(v).length === 0)
|
|
65710
|
+
);
|
|
65711
|
+
|
|
65712
|
+
if (!hasAnyValue) {
|
|
65713
|
+
showDynamicModal("Attention", [{ label: "OK" }], "Please fill at least one field before saving.");
|
|
65714
|
+
return;
|
|
65715
|
+
}
|
|
65716
|
+
|
|
65669
65717
|
showDynamicModal("Do you want to save the data?", [
|
|
65670
65718
|
{
|
|
65671
65719
|
label: "Yes",
|
package/package.json
CHANGED