diff --git a/manifest.json b/manifest.json index afc8fd6..f9c71d4 100644 --- a/manifest.json +++ b/manifest.json @@ -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", diff --git a/modules/builder/getFieldText.js b/modules/builder/getFieldText.js new file mode 100644 index 0000000..9429a6a --- /dev/null +++ b/modules/builder/getFieldText.js @@ -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; + } + } +} \ No newline at end of file diff --git a/modules/builder/main.js b/modules/builder/main.js index 4f5e74e..fdcdbbe 100644 --- a/modules/builder/main.js +++ b/modules/builder/main.js @@ -41,6 +41,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"); @@ -73,6 +74,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); @@ -105,6 +107,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); diff --git a/modules/builder/preprocessElements.js b/modules/builder/preprocessElements.js index f7f7a8a..8ee6a62 100644 --- a/modules/builder/preprocessElements.js +++ b/modules/builder/preprocessElements.js @@ -99,17 +99,18 @@ function getActionText(action, questions) { switch (actionType) { case "HideMultiple": case "Hide": - return ` Hide ${questions[action.field].text}`; + return ` Hide ${getFieldText(action.field, questions)}`; case "ShowMultiple": case "Show": - return ` Show ${questions[action.field].text}`; + return ` Show ${getFieldText(action.field, questions)}`; case "Disable": - return ` Disable ${questions[action.field].text}`; + return ` Disable ${getFieldText(action.field, questions)}`; + case "Enable": + return ` Enable ${getFieldText(action.field, questions)}`; case "UnrequireMultiple": case "RequireMultiple": case "Unrequire": case "Require": - case "Enable": return `'${actionType}' not yet added"` } return `'${actionType}' (not yet added)`; diff --git a/modules/list/getFieldLabel.js b/modules/list/getFieldLabel.js index 0c7b712..9709b41 100644 --- a/modules/list/getFieldLabel.js +++ b/modules/list/getFieldLabel.js @@ -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; }