Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable single- and multiple-choice questions in the inquiry preview #2522

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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