@clxmedia/clxforms-client 1.0.20 → 1.0.21

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.
@@ -38,23 +38,29 @@ const CLXFormLayoutProcessor = ({ mode, responseData, formRights }) => {
38
38
  return isResponseSaved(responseCopy[ql.form_question_slug]);
39
39
  });
40
40
  };
41
- const questionLayoutProcessor = (questionLayout, response) => {
41
+ const questionLayoutProcessor = (questionLayout, response, responseSection) => {
42
42
  const is_enabled = isQuestionLayoutEnabled(questionLayout);
43
+ if (!is_enabled) {
44
+ responseSection[questionLayout.form_question_slug] = undefined;
45
+ return Object.assign(Object.assign({}, questionLayout), { is_enabled, is_complete: false });
46
+ }
43
47
  return Object.assign(Object.assign({}, questionLayout), { is_enabled, is_complete: is_enabled ? isResponseSaved(response) : false });
44
48
  };
45
- const sectionProcessor = (section) => {
46
- if (section.conditions && !(0, rules_processor_1.CLXRulesetProcessor)({ responseData: responseCopy }).processRuleSet(section.conditions)) {
49
+ const sectionProcessor = (section, responseStep) => {
50
+ const responseSection = JSON.parse(JSON.stringify(responseStep));
51
+ if (section.conditions && !(0, rules_processor_1.CLXRulesetProcessor)({ responseData: responseSection }).processRuleSet(section.conditions)) {
47
52
  return Object.assign(Object.assign({}, section), { is_complete: true, question_layouts: [] });
48
53
  }
49
54
  const is_section_complete = isSectionComplete(section);
50
- return Object.assign(Object.assign({}, section), { is_complete: is_section_complete, question_layouts: section.question_layouts.map(questionLayout => questionLayoutProcessor(questionLayout, responseCopy[questionLayout.form_question_slug])) });
55
+ return Object.assign(Object.assign({}, section), { is_complete: is_section_complete, question_layouts: section.question_layouts.map(questionLayout => questionLayoutProcessor(questionLayout, responseCopy[questionLayout.form_question_slug], responseSection)) });
51
56
  };
52
57
  const stepProcessor = (step) => {
53
- if (step.conditions && !(0, rules_processor_1.CLXRulesetProcessor)({ responseData: responseCopy }).processRuleSet(step.conditions)) {
58
+ const responseStep = JSON.parse(JSON.stringify(responseCopy));
59
+ if (step.conditions && !(0, rules_processor_1.CLXRulesetProcessor)({ responseData: responseStep }).processRuleSet(step.conditions)) {
54
60
  return Object.assign(Object.assign({}, step), { is_complete: true, sections: [] });
55
61
  }
56
62
  const sections = step.sections
57
- .map(section => sectionProcessor(section))
63
+ .map(section => sectionProcessor(section, responseStep))
58
64
  .filter(section => section.question_layouts.some(ql => ql.is_enabled));
59
65
  return Object.assign(Object.assign({}, step), { is_complete: sections.every(section => section.is_complete), sections });
60
66
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clxmedia/clxforms-client",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "CLXperience Forms Client",
5
5
  "author": "Brandon Thompson <brandont@clxmedia.com>",
6
6
  "license": "MIT",