Skip to content

Commit

Permalink
feat: enable single- and multiple-choice questions in the inquiry pre…
Browse files Browse the repository at this point in the history
…view
  • Loading branch information
StephanH90 authored Oct 18, 2023
1 parent 251c20d commit 8c97c44
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,24 @@ export default class CdInquiryDialogInquiryPartComponent extends Component {

return this.args.type === "answer"
? this.args.inquiry.childCase.document.info.edges
.filter((edge) => !isEmpty(edge.node.value))
.filter(
(edge) =>
!isEmpty(edge.node.value) ||
!isEmpty(edge.node.selectedOption) ||
!isEmpty(edge.node.selectedOptions),
)
.sort(
(a, b) =>
questions.indexOf(a.node.question.slug) -
questions.indexOf(b.node.question.slug),
)
.map((edge) => ({
question: edge.node.question.label,
value: edge.node.value,
value: edge.node.selectedOption // single choice answer
? edge.node.selectedOption.label
: edge.node.selectedOptions // multiple choice answer
? edge.node.selectedOptions.edges.map((edge) => edge.node.label)
: edge.node.value, // regular answer
}))
: null;
}
Expand Down
24 changes: 16 additions & 8 deletions packages/distribution/addon/components/cd-truncated.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<p class="cd-truncated" ...attributes>
{{~this.displayedText~}}
{{#if this.truncate}}
<a href="" {{on "click" this.toggleExpand}}>
{{~t (concat "caluma.distribution." (if this.expand "less" "more"))~}}
</a>
{{/if}}
</p>
{{#if (is-array @text)}}
<UkList @bullet={{true}} class="uk-margin-remove" ...attributes as |list|>
{{#each @text as |item|}}
<list.item>{{item}}</list.item>
{{/each}}
</UkList>
{{else}}
<p class="cd-truncated" ...attributes>
{{~this.displayedText~}}
{{#if this.truncate}}
<a href="" {{on "click" this.toggleExpand}}>
{{~t (concat "caluma.distribution." (if this.expand "less" "more"))~}}
</a>
{{/if}}
</p>
{{/if}}
12 changes: 12 additions & 0 deletions packages/distribution/addon/gql/fragments/inquiry-answer.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ fragment InquiryAnswer on Document {
}
... on StringAnswer {
value
selectedOption {
label
}
}
... on ListAnswer {
selectedOptions {
edges {
node {
label
}
}
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/testing/addon/mirage-graphql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export default function createGraphqlHandler(server) {
SelectedOption: ({ value }) => {
const option = server.schema.options.findBy({ slug: value });

if (!option) {
return null;
}

return {
slug: value,
label: option.label,
Expand Down

0 comments on commit 8c97c44

Please sign in to comment.