Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
larsyngvelundin committed Jul 8, 2024
2 parents f632ee7 + b4a8559 commit 84498c7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"modules/builder/fetchFormProps.js",
"modules/builder/fetchHtmlContent.js",
"modules/builder/fetchQuestionsProps.js",
"modules/builder/getFieldText.js",
"modules/builder/main.js",
"modules/builder/preprocessConditions.js",
"modules/builder/preprocessElements.js",
Expand Down
23 changes: 23 additions & 0 deletions modules/builder/getFieldText.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function getFieldText(id, questions) {
try {
fieldName = questions[id].text
fieldName = removeSpanTags(fieldName);
fieldName = fieldName.trim();
if (fieldName == "") {
return "Empty Label"
}
return fieldName.trim();
}
catch (error) {
try{
let baseId = id.split("|")[0];
let baseField = questions[baseId]
let subId = `field_${id.split("|")[1]}`
return `${baseField.text} / ${baseField.sublabels[subId]}`
}
catch (error){
fieldName = `Unkown Label ${id}`
return fieldName;
}
}
}
3 changes: 3 additions & 0 deletions modules/builder/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async function startInBuilder() {
&& getActionType(conditions[iCon].action[iAct]) ==
getActionType(conditions[iCon2].action[iAct2])) {
let className = `conflict-${conditions[iCon].action[iAct].field}-${getActionType(conditions[iCon].action[iAct])}`;
className = className.replace("|", "slash"); //fix for multiline

conditionElements[iCon].classList.add(className);
conditionElements[iCon].classList.add("possibleConflict");
Expand Down Expand Up @@ -72,6 +73,7 @@ async function startInBuilder() {
if (conditions[iCon].action[iAct].resultField ==
conditions[iCon2].action[iAct2].resultField) {
let className = `conflict-${conditions[iCon].action[iAct].resultField}-${getActionType(conditions[iCon].action[iAct])}`;
className = className.replace("|", "slash"); //fix for multiline

conditionElements[iCon].classList.add(className);
conditionElements[iCon2].classList.add(className);
Expand Down Expand Up @@ -104,6 +106,7 @@ async function startInBuilder() {
conditions[iCon].action[0].skipTo ==
conditions[iCon2].action[0].skipTo) {
let className = `conflict-${conditions[iCon].action[0].skipHide}-${conditions[iCon].action[0].skipTo}`;
className = className.replace("|", "slash"); //fix for multiline

conditionElements[iCon].classList.add(className);
conditionElements[iCon2].classList.add(className);
Expand Down
9 changes: 5 additions & 4 deletions modules/builder/preprocessElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,18 @@ function getActionText(action, questions) {
switch (actionType) {
case "HideMultiple":
case "Hide":
return `<b> Hide </b><span class=""></span> <span>${questions[action.field].text}</span>`;
return `<b> Hide </b><span class=""></span> <span>${getFieldText(action.field, questions)}</span>`;
case "ShowMultiple":
case "Show":
return `<b> Show </b><span class=""></span> <span>${questions[action.field].text}</span>`;
return `<b> Show </b><span class=""></span> <span>${getFieldText(action.field, questions)}</span>`;
case "Disable":
return `<b> Disable </b><span class=""></span><span class="">${questions[action.field].text}</span>`;
return `<b> Disable </b><span class=""></span><span class="">${getFieldText(action.field, questions)}</span>`;
case "Enable":
return `<b> Enable </b><span class=""></span><span class="">${getFieldText(action.field, questions)}</span>`;
case "UnrequireMultiple":
case "RequireMultiple":
case "Unrequire":
case "Require":
case "Enable":
return `'${actionType}' not yet added"`
}
return `'${actionType}' (not yet added)`;
Expand Down
3 changes: 3 additions & 0 deletions modules/list/getFieldLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ function getFieldLabel(id) {
return fieldName.trim();
}
catch (error) {
let baseId = id.split("|")[0];
let baseField = JotForm.getFieldFromID(baseId)
// console.log("Here's basefield", baseField);
fieldName = `Unkown Label ${id}`
return fieldName;
}
Expand Down

0 comments on commit 84498c7

Please sign in to comment.