Skip to content
Permalink
Browse files

fix(form): fix loading of subforms and improve error handling

  • Loading branch information...
anehx committed Jun 24, 2019
1 parent f38ccce commit b47cd4dffb2035ace379ed8893edf7019f41d8d0
Showing with 20 additions and 4 deletions.
  1. +10 −4 addon/components/cf-content.js
  2. +10 −0 addon/gql/fragments/field-answer.graphql
@@ -9,6 +9,7 @@ import { later, once } from "@ember/runloop";

import getNavigationDocumentsQuery from "ember-caluma/gql/queries/get-navigation-documents";
import getNavigationFormsQuery from "ember-caluma/gql/queries/get-navigation-forms";
import { assert } from "@ember/debug";

const isDisplayableDocument = doc =>
doc &&
@@ -38,11 +39,16 @@ const buildTree = (rootDocument, documents, forms) => {

rootDocument.answers.edges.forEach(answer => {
if (answer.node.__typename === "FormAnswer") {
answer.node.formValue = buildTree(
documents.find(doc => doc.form.slug === answer.node.question.slug),
documents,
forms
const childDocument = documents.find(
doc => doc.form.slug === answer.node.question.subForm.slug
);

assert(
`Document for form "${answer.node.question.subForm.slug}" not found`,
childDocument
);

answer.node.formValue = buildTree(childDocument, documents, forms);
}
});

@@ -28,6 +28,16 @@ fragment SimpleAnswer on Answer {
... on DateAnswer {
dateValue: value
}
... on FormAnswer {
question {
slug
... on FormQuestion {
subForm {
slug
}
}
}
}
}

fragment FieldAnswer on Answer {

0 comments on commit b47cd4d

Please sign in to comment.
You can’t perform that action at this time.