diff --git a/packages/form-builder/addon/components/cfb-form-editor/question-usage.hbs b/packages/form-builder/addon/components/cfb-form-editor/question-usage.hbs new file mode 100644 index 0000000000..157a27ccb6 --- /dev/null +++ b/packages/form-builder/addon/components/cfb-form-editor/question-usage.hbs @@ -0,0 +1,56 @@ + + {{t "caluma.form-builder.question.usage.button"}} + + + + + {{t "caluma.form-builder.question.usage.title"}} + + + {{#if this.forms.isLoading}} +
+ +
+ {{else}} + + {{/if}} +
+
\ No newline at end of file diff --git a/packages/form-builder/addon/components/cfb-form-editor/question-usage.js b/packages/form-builder/addon/components/cfb-form-editor/question-usage.js new file mode 100644 index 0000000000..ee2226bbe4 --- /dev/null +++ b/packages/form-builder/addon/components/cfb-form-editor/question-usage.js @@ -0,0 +1,29 @@ +import Component from "@glimmer/component"; +import { tracked } from "@glimmer/tracking"; +import { queryManager } from "ember-apollo-client"; +import { trackedFunction } from "ember-resources/util/function"; + +import allFormsForQuestionQuery from "@projectcaluma/ember-form-builder/gql/queries/all-forms-for-question.graphql"; + +export default class CfbFormEditorQuestionUsage extends Component { + @tracked modalVisible = false; + @queryManager apollo; + + forms = trackedFunction(this, async () => { + if (!this.modalVisible) { + return null; + } + + const forms = await this.apollo.query( + { + query: allFormsForQuestionQuery, + variables: { + slug: this.args.model.slug, + }, + }, + "allForms.edges", + ); + + return forms; + }); +} diff --git a/packages/form-builder/addon/components/cfb-form-editor/question.hbs b/packages/form-builder/addon/components/cfb-form-editor/question.hbs index 5821f4437e..c492665a0d 100644 --- a/packages/form-builder/addon/components/cfb-form-editor/question.hbs +++ b/packages/form-builder/addon/components/cfb-form-editor/question.hbs @@ -435,6 +435,8 @@ {{/if}}
+ +