@projectcaluma/ember-form 10.0.2 → 11.0.0-beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. package/CHANGELOG.md +1112 -0
  2. package/addon/components/cf-content.hbs +36 -39
  3. package/addon/components/cf-content.js +48 -29
  4. package/addon/components/cf-field/info.hbs +1 -1
  5. package/addon/components/cf-field/input/action-button.hbs +1 -1
  6. package/addon/components/cf-field/input/action-button.js +9 -7
  7. package/addon/components/cf-field/input/checkbox.hbs +6 -2
  8. package/addon/components/cf-field/input/checkbox.js +9 -29
  9. package/addon/components/cf-field/input/file.hbs +1 -1
  10. package/addon/components/cf-field/input/file.js +8 -9
  11. package/addon/components/cf-field/input/float.hbs +4 -4
  12. package/addon/components/cf-field/input/integer.hbs +5 -5
  13. package/addon/components/cf-field/input/radio.hbs +4 -1
  14. package/addon/components/cf-field/input/table.hbs +7 -7
  15. package/addon/components/cf-field/input/table.js +12 -10
  16. package/addon/components/cf-field/input/text.hbs +5 -5
  17. package/addon/components/cf-field/input/textarea.hbs +6 -5
  18. package/addon/components/cf-field/input.hbs +10 -1
  19. package/addon/components/cf-field/input.js +1 -1
  20. package/addon/components/cf-field/label.hbs +1 -1
  21. package/addon/components/cf-field-value.hbs +1 -1
  22. package/addon/components/cf-field-value.js +8 -13
  23. package/addon/components/cf-field.hbs +2 -2
  24. package/addon/components/cf-field.js +2 -3
  25. package/addon/components/cf-navigation-item.hbs +2 -2
  26. package/addon/components/cf-navigation.hbs +4 -1
  27. package/addon/components/document-validity.js +1 -1
  28. package/addon/gql/fragments/field.graphql +22 -0
  29. package/addon/gql/mutations/save-document-table-answer.graphql +1 -1
  30. package/addon/gql/mutations/save-document.graphql +1 -0
  31. package/addon/gql/queries/{get-document-answers.graphql → document-answers.graphql} +2 -1
  32. package/addon/gql/queries/{get-document-forms.graphql → document-forms.graphql} +2 -1
  33. package/addon/gql/queries/{get-document-used-dynamic-options.graphql → document-used-dynamic-options.graphql} +2 -1
  34. package/addon/gql/queries/{get-dynamic-options.graphql → dynamic-options.graphql} +2 -1
  35. package/addon/gql/queries/{get-fileanswer-info.graphql → fileanswer-info.graphql} +2 -1
  36. package/addon/helpers/get-widget.js +50 -0
  37. package/addon/lib/answer.js +108 -72
  38. package/addon/lib/base.js +32 -23
  39. package/addon/lib/dependencies.js +36 -71
  40. package/addon/lib/document.js +92 -96
  41. package/addon/lib/field.js +334 -401
  42. package/addon/lib/fieldset.js +46 -47
  43. package/addon/lib/form.js +27 -15
  44. package/addon/lib/navigation.js +211 -192
  45. package/addon/lib/question.js +103 -94
  46. package/addon/services/caluma-store.js +10 -6
  47. package/app/helpers/get-widget.js +4 -0
  48. package/blueprints/@projectcaluma/ember-form/index.js +1 -0
  49. package/package.json +27 -23
  50. package/addon/components/cf-navigation.js +0 -9
@@ -1,44 +1,41 @@
1
1
  {{#if @documentId}}
2
- <div {{did-insert (perform this.fetchData)}} {{will-destroy this.teardown}}>
3
- {{#if this.fetchData.isRunning}}
4
- <div class="uk-text-center"><UkSpinner @ratio={{2}} /></div>
5
- {{else if this.document}}
6
- {{#let
7
- (hash
2
+ {{#if this.loading}}
3
+ <div class="uk-text-center"><UkSpinner @ratio={{2}} /></div>
4
+ {{else if this.document}}
5
+ {{#let
6
+ (hash
7
+ document=this.document
8
+ navigation=(component
9
+ "cf-navigation"
10
+ navigation=this.navigation
11
+ useAsHeading=(or @useAsHeading false)
12
+ headingBaseLevel=(or @headingBaseLevel 1)
13
+ )
14
+ pagination=(component "cf-pagination" navigation=this.navigation)
15
+ form=(component
16
+ "cf-form-wrapper"
8
17
  document=this.document
9
- navigation=(component
10
- "cf-navigation"
11
- navigation=this.navigation
12
- useAsHeading=(or @useAsHeading false)
13
- headingBaseLevel=(or @headingBaseLevel 1)
14
- )
15
- pagination=(component "cf-pagination" navigation=this.navigation)
16
- form=(component
17
- "cf-form-wrapper"
18
- document=this.document
19
- fieldset=this.fieldset
20
- context=@context
21
- disabled=@disabled
22
- )
18
+ fieldset=this.fieldset
19
+ context=@context
20
+ disabled=@disabled
23
21
  )
24
- as |content|
25
- }}
26
- {{#if (has-block)}}
27
- {{yield content}}
28
- {{else if (gt this.document.fieldsets.length 1)}}
29
- <div uk-grid>
30
- <div class="uk-width-1-1 uk-width-1-3@m"><content.navigation
31
- /></div>
32
- <div class="uk-width-1-1 uk-width-2-3@m">
33
- <content.form />
34
- <hr />
35
- <content.pagination />
36
- </div>
22
+ )
23
+ as |content|
24
+ }}
25
+ {{#if (has-block)}}
26
+ {{yield content}}
27
+ {{else if (gt this.document.fieldsets.length 1)}}
28
+ <div uk-grid>
29
+ <div class="uk-width-1-1 uk-width-1-3@m"><content.navigation /></div>
30
+ <div class="uk-width-1-1 uk-width-2-3@m">
31
+ <content.form />
32
+ <hr />
33
+ <content.pagination />
37
34
  </div>
38
- {{else}}
39
- <content.form />
40
- {{/if}}
41
- {{/let}}
42
- {{/if}}
43
- </div>
35
+ </div>
36
+ {{else}}
37
+ <content.form />
38
+ {{/if}}
39
+ {{/let}}
40
+ {{/if}}
44
41
  {{/if}}
@@ -1,12 +1,13 @@
1
1
  import { getOwner } from "@ember/application";
2
- import { action } from "@ember/object";
2
+ import { destroy, registerDestructor } from "@ember/destroyable";
3
3
  import { inject as service } from "@ember/service";
4
4
  import Component from "@glimmer/component";
5
5
  import { queryManager } from "ember-apollo-client";
6
- import { dropTask } from "ember-concurrency-decorators";
6
+ import { dropTask } from "ember-concurrency";
7
+ import { useTask } from "ember-resources";
7
8
 
8
- import getDocumentAnswersQuery from "@projectcaluma/ember-form/gql/queries/get-document-answers.graphql";
9
- import getDocumentFormsQuery from "@projectcaluma/ember-form/gql/queries/get-document-forms.graphql";
9
+ import getDocumentAnswersQuery from "@projectcaluma/ember-form/gql/queries/document-answers.graphql";
10
+ import getDocumentFormsQuery from "@projectcaluma/ember-form/gql/queries/document-forms.graphql";
10
11
  import { parseDocument } from "@projectcaluma/ember-form/lib/parsers";
11
12
 
12
13
  /**
@@ -62,7 +63,7 @@ export default class CfContentComponent extends Component {
62
63
  * Can be used to pass "context" information from the outside through
63
64
  * to custom overrides.
64
65
  *
65
- * @argument {*} context
66
+ * @argument {Object} context
66
67
  */
67
68
 
68
69
  /**
@@ -71,17 +72,40 @@ export default class CfContentComponent extends Component {
71
72
  * @argument {Boolean} disabled
72
73
  */
73
74
 
75
+ /**
76
+ * Whether the form should be displayed as loading, this can be used to
77
+ * indicate a loading state if the application calling this component is
78
+ * loading additional data.
79
+ *
80
+ * @argument {Boolean} loading
81
+ */
82
+
74
83
  /**
75
84
  * The document to display
76
85
  *
77
86
  * @property {Document} document
78
87
  */
79
88
  get document() {
80
- return this.fetchData.lastSuccessful?.value.document;
89
+ return this.data.value?.document;
81
90
  }
82
91
 
92
+ /**
93
+ * The navigation to display
94
+ *
95
+ * @property {Document} document
96
+ */
83
97
  get navigation() {
84
- return this.fetchData.lastSuccessful?.value.navigation;
98
+ return this.data.value?.navigation;
99
+ }
100
+
101
+ /**
102
+ * Whether the component is in a loading state. This can be overwritten by
103
+ * passing `loading` as an argument
104
+ *
105
+ * @property {Boolean} loading
106
+ */
107
+ get loading() {
108
+ return this.args.loading || this.data.isRunning;
85
109
  }
86
110
 
87
111
  /**
@@ -96,22 +120,17 @@ export default class CfContentComponent extends Component {
96
120
  this.router.currentRoute?.queryParams.displayedForm ||
97
121
  this.document?.raw.form.slug;
98
122
 
99
- const fieldset = this.document.fieldsets.find(
123
+ return this.document.fieldsets.find(
100
124
  (fieldset) => fieldset.form.slug === slug
101
125
  );
102
-
103
- if (!fieldset) {
104
- this.router.replaceWith({
105
- queryParams: { displayedForm: "" },
106
- });
107
- }
108
-
109
- return fieldset;
110
126
  }
111
127
 
128
+ data = useTask(this, this.fetchData, () => [this.args.documentId]);
129
+
112
130
  @dropTask
113
131
  *fetchData() {
114
- this.teardown();
132
+ if (this.document) destroy(this.document);
133
+ if (this.navigation) destroy(this.navigation);
115
134
 
116
135
  if (!this.args.documentId) return;
117
136
 
@@ -133,20 +152,20 @@ export default class CfContentComponent extends Component {
133
152
  "allForms.edges"
134
153
  )).map(({ node }) => node);
135
154
 
136
- const document = getOwner(this)
137
- .factoryFor("caluma-model:document")
138
- .create({ raw: parseDocument({ ...answerDocument, form }) });
155
+ const owner = getOwner(this);
156
+ const Document = owner.factoryFor("caluma-model:document").class;
157
+ const Navigation = owner.factoryFor("caluma-model:navigation").class;
139
158
 
140
- const navigation = getOwner(this)
141
- .factoryFor("caluma-model:navigation")
142
- .create({ document });
159
+ const raw = parseDocument({ ...answerDocument, form });
143
160
 
144
- return { document, navigation };
145
- }
161
+ const document = new Document({ raw, owner });
162
+ const navigation = new Navigation({ document, owner });
146
163
 
147
- @action
148
- teardown() {
149
- if (this.document) this.document.destroy();
150
- if (this.navigation) this.navigation.destroy();
164
+ registerDestructor(this, () => {
165
+ destroy(document);
166
+ destroy(navigation);
167
+ });
168
+
169
+ return { document, navigation };
151
170
  }
152
171
  }
@@ -12,7 +12,7 @@
12
12
  <UkModal
13
13
  @visible={{this.modalVisible}}
14
14
  @stack={{true}}
15
- @on-hide={{this.hideModal}}
15
+ @onHide={{this.hideModal}}
16
16
  as |modal|
17
17
  >
18
18
  <modal.body>
@@ -7,7 +7,7 @@
7
7
  <WorkItemButton
8
8
  @workItemId={{this.workItem}}
9
9
  @mutation={{this.action}}
10
- @label={{@field.question.label}}
10
+ @label={{@field.question.raw.label}}
11
11
  @disabled={{and (not-eq isValid null) (not isValid)}}
12
12
  @color={{this.color}}
13
13
  @beforeMutate={{fn this.beforeMutate validate}}
@@ -31,34 +31,36 @@ export default class CfFieldInputActionButtonComponent extends Component {
31
31
  }
32
32
 
33
33
  get action() {
34
- return this.args.field.question.action.toLowerCase();
34
+ return this.args.field.question.raw.action.toLowerCase();
35
35
  }
36
36
 
37
37
  get color() {
38
- return this.args.field.question.color.toLowerCase();
38
+ return this.args.field.question.raw.color.toLowerCase();
39
39
  }
40
40
 
41
41
  get type() {
42
- return this.args.field.question.action === "COMPLETE" ? "submit" : "button";
42
+ return this.args.field.question.raw.action === "COMPLETE"
43
+ ? "submit"
44
+ : "button";
43
45
  }
44
46
 
45
47
  get validateOnEnter() {
46
48
  return (
47
- this.args.field.question.action === "COMPLETE" &&
48
- this.args.field.question.validateOnEnter
49
+ this.args.field.question.raw.action === "COMPLETE" &&
50
+ this.args.field.question.raw.validateOnEnter
49
51
  );
50
52
  }
51
53
 
52
54
  @action
53
55
  async beforeMutate(validateFn) {
54
56
  if (
55
- this.args.field.question.action === "COMPLETE" &&
57
+ this.args.field.question.raw.action === "COMPLETE" &&
56
58
  !(await validateFn())
57
59
  ) {
58
60
  return false;
59
61
  }
60
62
 
61
- const confirmText = this.args.field.question.infoText;
63
+ const confirmText = this.args.field.question.raw.infoText;
62
64
 
63
65
  return !confirmText || confirm(confirmText);
64
66
  }
@@ -1,10 +1,14 @@
1
1
  {{#each @field.options as |option i|}}
2
2
  {{#if (gt i 0)}}<br />{{/if}}
3
- <label class="cf-checkbox_label {{if @field.isInvalid "uk-form-danger"}}">
3
+ <label
4
+ class="cf-checkbox_label
5
+ {{if @field.isInvalid 'uk-form-danger'}}
6
+ {{if @field.raw.question.meta.vertical 'uk-margin-large-right'}}"
7
+ >
4
8
  <input
5
9
  class="uk-checkbox uk-margin-small-right"
6
10
  type="checkbox"
7
- name="{{@field.pk}}:Option:{{option.slug}}"
11
+ name={{@field.pk}}
8
12
  value={{option.slug}}
9
13
  checked={{includes option.slug @field.answer.value}}
10
14
  disabled={{@disabled}}
@@ -1,28 +1,6 @@
1
1
  import { action } from "@ember/object";
2
2
  import Component from "@glimmer/component";
3
3
 
4
- /**
5
- * Function to extract the option slug out of an input element. This is needed
6
- * since IE11 does not properly set the `value` attribute but sets the value to
7
- * `on` if checked and `off` if not. So for all sane browsers we use the
8
- * `value` attribute but for IE11 we use the appended option slug to the field
9
- * id as the input elements `name` property.
10
- *
11
- * E.g: An element with
12
- * `name="Document:xxx-xxx:Question:some-question:Option:some-option"` will
13
- * return `some-option`.
14
- *
15
- * For further information about this bug see
16
- * https://github.com/emberjs/ember.js/issues/15203
17
- *
18
- * @function getSlug
19
- * @param {Element} element The html input element
20
- * @return {String} The option slug
21
- */
22
- const getSlug = ({ value, name }) => {
23
- return ["on", "off"].includes(value) ? name.split(":").pop() : value;
24
- };
25
-
26
4
  /**
27
5
  * Input component for the checkbox question type
28
6
  *
@@ -37,13 +15,15 @@ export default class CfFieldInputCheckboxComponent extends Component {
37
15
  * @method update
38
16
  */
39
17
  @action
40
- update({ target }) {
41
- const checkedBoxes = [
42
- ...target.parentNode.parentNode.querySelectorAll(
43
- "input[type=checkbox]:checked"
44
- ),
45
- ];
18
+ update({ target: { value, checked } }) {
19
+ const valueSet = new Set(this.args.field.value);
20
+
21
+ if (checked) {
22
+ valueSet.add(value);
23
+ } else {
24
+ valueSet.delete(value);
25
+ }
46
26
 
47
- this.args.onSave([...new Set(checkedBoxes.map(getSlug))]);
27
+ this.args.onSave([...valueSet]);
48
28
  }
49
29
  }
@@ -17,7 +17,7 @@
17
17
  <UkButton
18
18
  data-test-download-link
19
19
  @color="link"
20
- @on-click={{this.download}}
20
+ @onClick={{this.download}}
21
21
  >
22
22
  {{this.downloadName}}
23
23
  </UkButton>
@@ -1,10 +1,11 @@
1
- import { action, set } from "@ember/object";
1
+ import { action } from "@ember/object";
2
2
  import { inject as service } from "@ember/service";
3
3
  import Component from "@glimmer/component";
4
4
  import { queryManager } from "ember-apollo-client";
5
+ import fetch from "fetch";
5
6
 
6
7
  import removeAnswerMutation from "@projectcaluma/ember-form/gql/mutations/remove-answer.graphql";
7
- import getFileAnswerInfoQuery from "@projectcaluma/ember-form/gql/queries/get-fileanswer-info.graphql";
8
+ import getFileAnswerInfoQuery from "@projectcaluma/ember-form/gql/queries/fileanswer-info.graphql";
8
9
 
9
10
  export default class CfFieldInputFileComponent extends Component {
10
11
  @service intl;
@@ -24,7 +25,7 @@ export default class CfFieldInputFileComponent extends Component {
24
25
  const { downloadUrl } = await this.apollo.watchQuery(
25
26
  {
26
27
  query: getFileAnswerInfoQuery,
27
- variables: { id: this.args.field.answer.id },
28
+ variables: { id: this.args.field.answer.raw.id },
28
29
  fetchPolicy: "cache-and-network",
29
30
  },
30
31
  "node.fileValue"
@@ -55,15 +56,13 @@ export default class CfFieldInputFileComponent extends Component {
55
56
  throw new Error();
56
57
  }
57
58
 
58
- // eslint-disable-next-line ember/classic-decorator-no-classic-methods
59
- set(this.args.field.answer, "value", {
59
+ this.args.field.answer.value = {
60
60
  name: file.name,
61
61
  downloadUrl: fileValue.downloadUrl,
62
- });
62
+ };
63
63
  } catch (error) {
64
64
  await this.args.onSave(null);
65
- // eslint-disable-next-line ember/classic-decorator-no-classic-methods
66
- set(this.args.field, "_errors", [{ type: "uploadFailed" }]);
65
+ this.args.field._errors = [{ type: "uploadFailed" }];
67
66
  } finally {
68
67
  // eslint-disable-next-line require-atomic-updates
69
68
  target.value = "";
@@ -84,7 +83,7 @@ export default class CfFieldInputFileComponent extends Component {
84
83
 
85
84
  await this.args.onSave(null);
86
85
  } catch (error) {
87
- set(this.args.field, "_errors", [{ type: "deleteFailed" }]);
86
+ this.args.field._errors = [{ type: "deleteFailed" }];
88
87
  }
89
88
  }
90
89
  }
@@ -2,13 +2,13 @@
2
2
  type="number"
3
3
  step="0.001"
4
4
  class="uk-input
5
- {{if @field.isInvalid "uk-form-danger"}}
6
- {{if this.disabled "uk-disabled"}}"
5
+ {{if @field.isInvalid 'uk-form-danger'}}
6
+ {{if this.disabled 'uk-disabled'}}"
7
7
  readonly={{this.disabled}}
8
8
  name={{@field.pk}}
9
9
  id={{@field.pk}}
10
10
  value={{@field.value}}
11
- min={{@field.question.floatMinValue}}
12
- max={{@field.question.floatMaxValue}}
11
+ min={{@field.question.raw.floatMinValue}}
12
+ max={{@field.question.raw.floatMaxValue}}
13
13
  {{on "input" this.input}}
14
14
  />
@@ -2,14 +2,14 @@
2
2
  type="number"
3
3
  step="1"
4
4
  class="uk-input
5
- {{if @field.isInvalid "uk-form-danger"}}
6
- {{if @disabled "uk-disabled"}}"
5
+ {{if @field.isInvalid 'uk-form-danger'}}
6
+ {{if @disabled 'uk-disabled'}}"
7
7
  name={{@field.pk}}
8
8
  id={{@field.pk}}
9
9
  value={{@field.answer.value}}
10
- min={{@field.question.integerMinValue}}
11
- max={{@field.question.integerMaxValue}}
12
- placeholder={{@field.question.placeholder}}
10
+ min={{@field.question.raw.integerMinValue}}
11
+ max={{@field.question.raw.integerMaxValue}}
12
+ placeholder={{@field.question.raw.placeholder}}
13
13
  readonly={{@disabled}}
14
14
  {{on "input" this.input}}
15
15
  />
@@ -1,6 +1,9 @@
1
1
  {{#each @field.options as |option i|}}
2
2
  {{#if (gt i 0)}}<br />{{/if}}
3
- <label class={{if @field.isInvalid "uk-form-danger"}}>
3
+ <label
4
+ class="{{if @field.isInvalid 'uk-form-danger'}}
5
+ {{if @field.raw.question.meta.vertical 'uk-margin-large-right'}}"
6
+ >
4
7
  <input
5
8
  class="uk-radio uk-margin-small-right"
6
9
  type="radio"
@@ -28,7 +28,7 @@
28
28
  <button
29
29
  data-test-edit-row
30
30
  type="button"
31
- class="uk-button-link uk-flex-inline uk-margin-small-left"
31
+ class="uk-button uk-button-link uk-flex-inline uk-margin-small-left"
32
32
  title={{t "caluma.form.edit"}}
33
33
  {{on "click" (fn this.edit document)}}
34
34
  >
@@ -39,7 +39,7 @@
39
39
  <button
40
40
  data-test-delete-row
41
41
  type="button"
42
- class="uk-button-link uk-flex-inline uk-margin-small-left"
42
+ class="uk-button uk-button-link uk-flex-inline uk-margin-small-left"
43
43
  title={{t "caluma.form.delete"}}
44
44
  {{on "click" (fn (perform this.delete) document)}}
45
45
  >
@@ -59,7 +59,7 @@
59
59
  <UkButton
60
60
  @size="small"
61
61
  @color="default"
62
- @on-click={{perform this.add}}
62
+ @onClick={{perform this.add}}
63
63
  data-test-add-row
64
64
  >
65
65
  <UkIcon @icon="plus" />
@@ -74,7 +74,7 @@
74
74
  {{#if this.documentToEdit}}
75
75
  <UkModal
76
76
  @visible={{this.showAddModal}}
77
- @on-hide={{perform this.closeModal}}
77
+ @onHide={{perform this.close}}
78
78
  @bgClose={{false}}
79
79
  as |modal|
80
80
  >
@@ -91,7 +91,7 @@
91
91
  <UkButton
92
92
  @label={{t "caluma.form.close"}}
93
93
  @color="primary"
94
- @on-click={{perform this.close}}
94
+ @onClick={{perform this.close}}
95
95
  @disabled={{this.close.isRunning}}
96
96
  @loading={{this.close.isRunning}}
97
97
  data-test-close
@@ -99,7 +99,7 @@
99
99
  {{else}}
100
100
  <UkButton
101
101
  @label={{t "caluma.form.cancel"}}
102
- @on-click={{perform this.close}}
102
+ @onClick={{perform this.close}}
103
103
  @disabled={{this.close.isRunning}}
104
104
  @loading={{this.close.isRunning}}
105
105
  data-test-cancel
@@ -114,7 +114,7 @@
114
114
  @type="submit"
115
115
  @disabled={{or this.save.isRunning (not isValid)}}
116
116
  @loading={{this.save.isRunning}}
117
- @on-click={{fn (perform this.save) validate}}
117
+ @onClick={{fn (perform this.save) validate}}
118
118
  data-test-save
119
119
  />
120
120
  </DocumentValidity>
@@ -4,7 +4,7 @@ import { inject as service } from "@ember/service";
4
4
  import Component from "@glimmer/component";
5
5
  import { tracked } from "@glimmer/tracking";
6
6
  import { queryManager } from "ember-apollo-client";
7
- import { dropTask } from "ember-concurrency-decorators";
7
+ import { dropTask } from "ember-concurrency";
8
8
  import UIkit from "uikit";
9
9
 
10
10
  import removeDocumentMutation from "@projectcaluma/ember-form/gql/mutations/remove-document.graphql";
@@ -37,13 +37,13 @@ export default class CfFieldInputTableComponent extends Component {
37
37
  }
38
38
 
39
39
  get questions() {
40
- return this.args.field.question.rowForm.questions.edges.map(
40
+ return this.args.field.question.raw.rowForm.questions.edges.map(
41
41
  (edge) => edge.node
42
42
  );
43
43
  }
44
44
 
45
45
  get columns() {
46
- const config = this.args.field.question.meta.columnsToDisplay;
46
+ const config = this.args.field.question.raw.meta.columnsToDisplay;
47
47
 
48
48
  if (config?.length) {
49
49
  return this.questions.filter((question) =>
@@ -59,17 +59,19 @@ export default class CfFieldInputTableComponent extends Component {
59
59
  const raw = yield this.apollo.mutate(
60
60
  {
61
61
  mutation: saveDocumentMutation,
62
- variables: { input: { form: this.args.field.question.rowForm.slug } },
62
+ variables: {
63
+ input: { form: this.args.field.question.raw.rowForm.slug },
64
+ },
63
65
  },
64
66
  "saveDocument.document"
65
67
  );
66
68
 
67
- const newDocument = getOwner(this)
68
- .factoryFor("caluma-model:document")
69
- .create({
70
- raw: this.parseDocument(raw),
71
- parentDocument: this.args.field.document,
72
- });
69
+ const owner = getOwner(this);
70
+ const newDocument = new (owner.factoryFor("caluma-model:document").class)({
71
+ raw: this.parseDocument(raw),
72
+ parentDocument: this.args.field.document,
73
+ owner,
74
+ });
73
75
 
74
76
  this.documentToEditIsNew = true;
75
77
  this.documentToEdit = newDocument;
@@ -1,14 +1,14 @@
1
1
  <input
2
2
  type="text"
3
3
  class="uk-input
4
- {{if @field.isInvalid "uk-form-danger"}}
5
- {{if @disabled "uk-disabled"}}"
4
+ {{if @field.isInvalid 'uk-form-danger'}}
5
+ {{if @disabled 'uk-disabled'}}"
6
6
  name={{@field.pk}}
7
7
  id={{@field.pk}}
8
8
  value={{@field.answer.value}}
9
- placeholder={{@field.question.placeholder}}
9
+ placeholder={{@field.question.raw.placeholder}}
10
10
  readonly={{@disabled}}
11
- minlength={{@field.question.textMinLength}}
12
- maxlength={{@field.question.textMaxLength}}
11
+ minlength={{@field.question.raw.textMinLength}}
12
+ maxlength={{@field.question.raw.textMaxLength}}
13
13
  {{on "input" this.input}}
14
14
  />
@@ -1,12 +1,13 @@
1
1
  <textarea
2
2
  class="uk-textarea
3
- {{if @field.isInvalid "uk-form-danger"}}
4
- {{if @disabled "uk-disabled"}}"
3
+ {{if @field.isInvalid 'uk-form-danger'}}
4
+ {{if @disabled 'uk-disabled'}}"
5
5
  name={{@field.pk}}
6
6
  id={{@field.pk}}
7
- placeholder={{@field.question.placeholder}}
8
- minlength={{@field.question.textareaMinLength}}
9
- maxlength={{@field.question.textareaMaxLength}}
7
+ placeholder={{@field.question.raw.placeholder}}
8
+ minlength={{@field.question.raw.textareaMinLength}}
9
+ maxlength={{@field.question.raw.textareaMaxLength}}
10
10
  readonly={{@disabled}}
11
11
  {{on "input" this.input}}
12
+ {{autoresize mode="height"}}
12
13
  >{{@field.answer.value}}</textarea>
@@ -1,6 +1,15 @@
1
1
  {{#if this.type}}
2
2
  {{#let (component (concat "cf-field/input/" this.type)) as |InputComponent|}}
3
- <div class="uk-form-controls">
3
+ <div
4
+ class="uk-form-controls
5
+ {{if
6
+ (and
7
+ (has-question-type @field.question 'multiple-choice' 'choice')
8
+ @field.question.raw.meta.vertical
9
+ )
10
+ 'uk-flex'
11
+ }}"
12
+ >
4
13
  <InputComponent
5
14
  @field={{@field}}
6
15
  @disabled={{@disabled}}
@@ -22,7 +22,7 @@ export default class CfFieldInputComponent extends Component {
22
22
  * @accessor
23
23
  */
24
24
  get type() {
25
- const typename = this.args.field?.question.__typename;
25
+ const typename = this.args.field?.question.raw.__typename;
26
26
 
27
27
  return (
28
28
  typename &&
@@ -1,6 +1,6 @@
1
1
  <label class="uk-form-label" for={{@field.pk}}>
2
2
  <span class="uk-text-bold">
3
- {{@field.question.label}}
3
+ {{@field.question.raw.label}}
4
4
  </span>
5
5
 
6
6
  {{#if this.optional}}
@@ -2,7 +2,7 @@
2
2
  <UkButton
3
3
  @color="link"
4
4
  @label={{this.value.label}}
5
- @on-click={{fn this.download this.value.fileAnswerId}}
5
+ @onClick={{fn this.download this.value.fileAnswerId}}
6
6
  />
7
7
  {{else}}
8
8
  {{this.value.label}}