@projectcaluma/ember-form 11.0.0-beta.4 → 11.0.0-beta.40

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/CHANGELOG.md +202 -0
  2. package/addon/components/cf-content.hbs +38 -37
  3. package/addon/components/cf-content.js +7 -3
  4. package/addon/components/cf-field/hint.hbs +5 -0
  5. package/addon/components/cf-field/input/action-button.hbs +8 -4
  6. package/addon/components/cf-field/input/action-button.js +60 -59
  7. package/addon/components/cf-field/input/checkbox.hbs +2 -3
  8. package/addon/components/cf-field/input/date.hbs +12 -25
  9. package/addon/components/cf-field/input/date.js +19 -11
  10. package/addon/components/cf-field/input/files.hbs +38 -0
  11. package/addon/components/cf-field/input/files.js +113 -0
  12. package/addon/components/cf-field/input/powerselect.hbs +27 -29
  13. package/addon/components/cf-field/input/powerselect.js +8 -2
  14. package/addon/components/cf-field/input/radio.hbs +2 -2
  15. package/addon/components/cf-field/input/static.hbs +1 -1
  16. package/addon/components/cf-field/input/table.hbs +20 -18
  17. package/addon/components/cf-field/input/table.js +1 -11
  18. package/addon/components/cf-field/input.hbs +8 -21
  19. package/addon/components/cf-field/input.js +32 -14
  20. package/addon/components/cf-field/label.hbs +4 -2
  21. package/addon/components/cf-field-value.hbs +22 -7
  22. package/addon/components/cf-field-value.js +12 -36
  23. package/addon/components/cf-field.hbs +42 -9
  24. package/addon/components/cf-field.js +41 -17
  25. package/addon/components/cf-form-wrapper.hbs +4 -1
  26. package/addon/components/cf-form.hbs +6 -1
  27. package/addon/components/document-validity.js +16 -1
  28. package/addon/gql/fragments/field.graphql +32 -7
  29. package/addon/gql/mutations/save-document-files-answer.graphql +9 -0
  30. package/addon/gql/queries/document-forms.graphql +1 -1
  31. package/addon/gql/queries/dynamic-options.graphql +4 -4
  32. package/addon/gql/queries/{fileanswer-info.graphql → filesanswer-info.graphql} +4 -4
  33. package/addon/helpers/format-graphql-error.js +21 -0
  34. package/addon/helpers/get-widget.js +16 -2
  35. package/addon/instance-initializers/form-widget-overrides.js +52 -0
  36. package/addon/lib/document.js +9 -1
  37. package/addon/lib/field.js +96 -59
  38. package/addon/lib/navigation.js +3 -1
  39. package/addon/lib/question.js +18 -5
  40. package/addon/modifiers/autoresize.js +14 -0
  41. package/addon/services/caluma-store.js +2 -0
  42. package/app/components/cf-field/{input/file.js → hint.js} +1 -1
  43. package/app/components/cf-field/input/files.js +1 -0
  44. package/app/helpers/format-graphql-error.js +1 -0
  45. package/app/helpers/get-widget.js +1 -4
  46. package/app/instance-initializers/form-widget-overrides.js +4 -0
  47. package/app/modifiers/autoresize.js +1 -0
  48. package/app/styles/@projectcaluma/ember-form.scss +5 -15
  49. package/app/styles/_flatpickr.scss +47 -0
  50. package/blueprints/@projectcaluma/ember-form/index.js +1 -1
  51. package/index.js +12 -0
  52. package/package.json +47 -37
  53. package/translations/de.yaml +6 -6
  54. package/translations/en.yaml +6 -6
  55. package/translations/fr.yaml +6 -6
  56. package/addon/components/cf-field/input/file.hbs +0 -32
  57. package/addon/components/cf-field/input/file.js +0 -89
  58. package/addon/components/cf-field/label.js +0 -11
  59. package/addon/gql/mutations/remove-answer.graphql +0 -7
  60. package/addon/gql/mutations/save-document-file-answer.graphql +0 -9
  61. package/addon/instance-initializers/setup-pikaday-i18n.js +0 -35
  62. package/config/environment.js +0 -5
package/CHANGELOG.md CHANGED
@@ -1,3 +1,205 @@
1
+ # [@projectcaluma/ember-form-v11.0.0-beta.23](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.22...@projectcaluma/ember-form-v11.0.0-beta.23) (2022-08-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **files:** disable delete button when field is disabled ([#2086](https://github.com/projectcaluma/ember-caluma/issues/2086)) ([2055c53](https://github.com/projectcaluma/ember-caluma/commit/2055c53cbcfe07fbdcfa46e6042a763b4b643d65))
7
+ * **form:** allow deselecting disabled multiple choice options ([0dd663e](https://github.com/projectcaluma/ember-caluma/commit/0dd663e467b66f0f8742d667630c28255e03e161))
8
+
9
+ # [@projectcaluma/ember-form-v11.0.0-beta.22](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.21...@projectcaluma/ember-form-v11.0.0-beta.22) (2022-08-05)
10
+
11
+
12
+ * feat!: add multi file upload (#2040) ([c4fd004](https://github.com/projectcaluma/ember-caluma/commit/c4fd0049654b2d2e5ea62e5909a45d89cb888b40)), closes [#2040](https://github.com/projectcaluma/ember-caluma/issues/2040)
13
+
14
+
15
+ ### BREAKING CHANGES
16
+
17
+ * This requires the caluma backend version v8.0.0-beta.12
18
+ or later.
19
+
20
+ # [@projectcaluma/ember-form-v11.0.0-beta.21](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.20...@projectcaluma/ember-form-v11.0.0-beta.21) (2022-06-09)
21
+
22
+
23
+ ### Features
24
+
25
+ * **caluma:** use new filter syntax of caluma ([7a00c03](https://github.com/projectcaluma/ember-caluma/commit/7a00c03a103933d9e48dd88adb7382441a298742))
26
+
27
+
28
+ ### BREAKING CHANGES
29
+
30
+ * **caluma:** `ember-caluma` now requires Caluma version >=
31
+ 8.0.0-beta.6
32
+
33
+ # [@projectcaluma/ember-form-v11.0.0-beta.20](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.19...@projectcaluma/ember-form-v11.0.0-beta.20) (2022-06-09)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * **form:** improve validation of choice and multiple choice fields ([e828fad](https://github.com/projectcaluma/ember-caluma/commit/e828fad9557fd521ca9eec63af74f8cee12e3910))
39
+ * **form:** pass context to table row form ([af1031a](https://github.com/projectcaluma/ember-caluma/commit/af1031ae9e8138a404cd043199709025092da882))
40
+
41
+
42
+ ### Features
43
+
44
+ * **form:** add option to bypass the timeout when saving a field ([a2ba306](https://github.com/projectcaluma/ember-caluma/commit/a2ba306306f90a2d2279b34550507241f0987961))
45
+
46
+ # [@projectcaluma/ember-form-v11.0.0-beta.19](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.18...@projectcaluma/ember-form-v11.0.0-beta.19) (2022-05-09)
47
+
48
+
49
+ ### Bug Fixes
50
+
51
+ * **resources:** fix deprecations of ember-resources ([7a84c5c](https://github.com/projectcaluma/ember-caluma/commit/7a84c5c78d5b28f7b5393c64722907728dd5f42b))
52
+
53
+ # [@projectcaluma/ember-form-v11.0.0-beta.18](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.17...@projectcaluma/ember-form-v11.0.0-beta.18) (2022-04-13)
54
+
55
+
56
+ ### Bug Fixes
57
+
58
+ * **form:** fix error formatting for older browsers ([9e34876](https://github.com/projectcaluma/ember-caluma/commit/9e3487625ccb73918b32fdf787054bab9114162f))
59
+
60
+ # [@projectcaluma/ember-form-v11.0.0-beta.17](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.16...@projectcaluma/ember-form-v11.0.0-beta.17) (2022-04-07)
61
+
62
+
63
+ ### Bug Fixes
64
+
65
+ * **form:** fix error status indicator for backend errors ([03fc27e](https://github.com/projectcaluma/ember-caluma/commit/03fc27e0626edf3a6f774c41d25485158ee6a99d)), closes [#1877](https://github.com/projectcaluma/ember-caluma/issues/1877)
66
+
67
+
68
+ ### Features
69
+
70
+ * **cf-field:** add optional hints for form fields ([d847fbf](https://github.com/projectcaluma/ember-caluma/commit/d847fbffa376ea60971fb9e91aff8bf54ce77d50))
71
+ * **form:** show technical details of backend errors in UI ([c34cda6](https://github.com/projectcaluma/ember-caluma/commit/c34cda691f78623f41da1f9d75a39efce7e0ff0f))
72
+
73
+
74
+ ### BREAKING CHANGES
75
+
76
+ * **cf-field:** Question hints requires Caluma >= v7.15.0
77
+
78
+ Add option to create hints for certain question types. These
79
+ are displayed below the input field and can be used to provide
80
+ short, informative messages. Hints are available for all question
81
+ types except for form, static and action button questions.
82
+
83
+ # [@projectcaluma/ember-form-v11.0.0-beta.16](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.15...@projectcaluma/ember-form-v11.0.0-beta.16) (2022-03-23)
84
+
85
+
86
+ ### Bug Fixes
87
+
88
+ * **embroider:** add missing dependency on @ember/string ([3a6e6bb](https://github.com/projectcaluma/ember-caluma/commit/3a6e6bb39a8c1a40a2ae00b3d4ea00606a755e25))
89
+ * **embroider:** fix dynamic component usage ([1cf0f6e](https://github.com/projectcaluma/ember-caluma/commit/1cf0f6e2914651bbb0ec70d1f7485fd9db90c9b5))
90
+ * **embroider:** remove obsolete export for getWidget helper function ([94fb461](https://github.com/projectcaluma/ember-caluma/commit/94fb461aaa7cac6af9f5612b8f34ad047a2b67bb))
91
+
92
+ # [@projectcaluma/ember-form-v11.0.0-beta.15](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.14...@projectcaluma/ember-form-v11.0.0-beta.15) (2022-03-16)
93
+
94
+
95
+ ### Bug Fixes
96
+
97
+ * **form:** make sure dynamic options are loaded before validating ([2713b37](https://github.com/projectcaluma/ember-caluma/commit/2713b3718b64f9111ca3e7bec2a6c60fafcb183a))
98
+
99
+ # [@projectcaluma/ember-form-v11.0.0-beta.14](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.13...@projectcaluma/ember-form-v11.0.0-beta.14) (2022-03-11)
100
+
101
+
102
+ ### Bug Fixes
103
+
104
+ * **form:** make sure table controls are always visible ([8cd97d2](https://github.com/projectcaluma/ember-caluma/commit/8cd97d204539f2e84b9baf9841591460bddf145a))
105
+
106
+ # [@projectcaluma/ember-form-v11.0.0-beta.13](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.12...@projectcaluma/ember-form-v11.0.0-beta.13) (2022-03-11)
107
+
108
+
109
+ ### Bug Fixes
110
+
111
+ * **form:** don't refetch dynamic options on validation ([27061c6](https://github.com/projectcaluma/ember-caluma/commit/27061c67f0562508f558305247cb51d615fa36b0))
112
+ * **form:** fix input in date fields ([cf54bf5](https://github.com/projectcaluma/ember-caluma/commit/cf54bf5542e35fd7dbe293a9e22288afae6a517a))
113
+ * **navigation:** exclude static questions from visible fields ([6ebd085](https://github.com/projectcaluma/ember-caluma/commit/6ebd085098df71fab693dec5282ea4b81d5b9836))
114
+ * **workflow:** return case status on complete / skip work-item mutation ([524453c](https://github.com/projectcaluma/ember-caluma/commit/524453c1189b4375ca792fca7d35056b916696f8))
115
+
116
+
117
+ ### Features
118
+
119
+ * **form:** support passing component override classes ([9409c7c](https://github.com/projectcaluma/ember-caluma/commit/9409c7cb5901dcdffec1c0294046da64b74b9922))
120
+
121
+ # [@projectcaluma/ember-form-v11.0.0-beta.12](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.11...@projectcaluma/ember-form-v11.0.0-beta.12) (2022-02-23)
122
+
123
+
124
+ ### Bug Fixes
125
+
126
+ * **form:** fix textarea size in tables ([efba737](https://github.com/projectcaluma/ember-caluma/commit/efba737f0a6314225a851ee0c57c2c506403bc06))
127
+
128
+ # [@projectcaluma/ember-form-v11.0.0-beta.11](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.10...@projectcaluma/ember-form-v11.0.0-beta.11) (2022-02-16)
129
+
130
+
131
+ ### Bug Fixes
132
+
133
+ * **form:** always use monday as first day of the week in datepicker ([7008a90](https://github.com/projectcaluma/ember-caluma/commit/7008a90d737d2dca714f4799f846f4c4086ecd4d))
134
+ * **form:** use action button type "button" ([3e9795f](https://github.com/projectcaluma/ember-caluma/commit/3e9795f28b73dcf376ec9ecabcd4c1b6a8085beb))
135
+
136
+
137
+ ### Features
138
+
139
+ * **form:** add notfound named block in cf-content if no document found ([f1861c1](https://github.com/projectcaluma/ember-caluma/commit/f1861c1f3b2da9843771aa1b12956190c98799a6))
140
+
141
+ # [@projectcaluma/ember-form-v11.0.0-beta.10](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.9...@projectcaluma/ember-form-v11.0.0-beta.10) (2022-02-09)
142
+
143
+
144
+ ### Bug Fixes
145
+
146
+ * **form:** always trigger data fetching in cf-content ([3fab675](https://github.com/projectcaluma/ember-caluma/commit/3fab675fca0559cd4164d4d62b44b9d9b74e4a5c))
147
+
148
+ # [@projectcaluma/ember-form-v11.0.0-beta.9](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.8...@projectcaluma/ember-form-v11.0.0-beta.9) (2022-02-07)
149
+
150
+
151
+ ### Bug Fixes
152
+
153
+ * **action-button:** only hide action button visually if disabled ([e292f09](https://github.com/projectcaluma/ember-caluma/commit/e292f093c33efd0b99a73674f8f83de5f496bf40))
154
+ * **deps:** remove moment altogether and update ember-pikday ([b2f7fa2](https://github.com/projectcaluma/ember-caluma/commit/b2f7fa28fa076897addd36e5964c926c671508ff))
155
+ * **form:** change file download actions to query and network-only ([aa4458e](https://github.com/projectcaluma/ember-caluma/commit/aa4458e944263f0f00ba1684a4f7bbfa83d2efea))
156
+
157
+
158
+ ### BREAKING CHANGES
159
+
160
+ * **deps:** The host app now needs to opt-in to use the default
161
+ pikaday styles: https://github.com/adopted-ember-addons/ember-pikaday#styles
162
+
163
+ # [@projectcaluma/ember-form-v11.0.0-beta.8](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.7...@projectcaluma/ember-form-v11.0.0-beta.8) (2022-02-03)
164
+
165
+
166
+ ### Bug Fixes
167
+
168
+ * dye file upload button in default color ([ad9e1b8](https://github.com/projectcaluma/ember-caluma/commit/ad9e1b8ed18c8228c495142af1bbe1f2c219c088))
169
+ * **form:** fix isNew state of answers without backend object ([c10129f](https://github.com/projectcaluma/ember-caluma/commit/c10129ffe76d7751cd0105c71fc4ba010323e2e4))
170
+
171
+ # [@projectcaluma/ember-form-v11.0.0-beta.7](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.6...@projectcaluma/ember-form-v11.0.0-beta.7) (2022-02-03)
172
+
173
+
174
+ ### Bug Fixes
175
+
176
+ * **validation:** sync format validator validation with backend ([ee66968](https://github.com/projectcaluma/ember-caluma/commit/ee66968230b9f0e4c5a4df8bdb3f8e58b44b5b82))
177
+
178
+
179
+ ### BREAKING CHANGES
180
+
181
+ * **validation:** Use the `formatValidators` property of the backend to store and read
182
+ format validators instead of the `meta.formatValidators` so the backend
183
+ validates as well. For more information on how to migrate check the
184
+ migration guide to v11.
185
+
186
+ # [@projectcaluma/ember-form-v11.0.0-beta.6](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.5...@projectcaluma/ember-form-v11.0.0-beta.6) (2022-02-02)
187
+
188
+
189
+ ### Bug Fixes
190
+
191
+ * **action-button:** hide field wrapper if action button is not displayed ([1d4b701](https://github.com/projectcaluma/ember-caluma/commit/1d4b701af35d48d072001f3295b905b1065daffe))
192
+ * render static questions ([28fff94](https://github.com/projectcaluma/ember-caluma/commit/28fff9487e4ad3153fe267db4b66208ad858aaac))
193
+ * **table:** fix styling of table fields ([30c5903](https://github.com/projectcaluma/ember-caluma/commit/30c590389ed82c37ebf666f1484501c66ca8f0bb))
194
+
195
+ # [@projectcaluma/ember-form-v11.0.0-beta.5](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.4...@projectcaluma/ember-form-v11.0.0-beta.5) (2022-02-01)
196
+
197
+
198
+ ### Bug Fixes
199
+
200
+ * **document-validity:** wait to validate until the UI has finished saving values ([9ec5330](https://github.com/projectcaluma/ember-caluma/commit/9ec5330905046604f95ab42985a29a5e0dc369a4))
201
+ * **form:** use component save task instead of field for loading indicator ([6de510d](https://github.com/projectcaluma/ember-caluma/commit/6de510d19a3608b7cd40092908d562a152ef03bd))
202
+
1
203
  # [@projectcaluma/ember-form-v11.0.0-beta.4](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.3...@projectcaluma/ember-form-v11.0.0-beta.4) (2022-02-01)
2
204
 
3
205
 
@@ -1,41 +1,42 @@
1
- {{#if @documentId}}
2
- {{#if this.loading}}
3
- <div class="uk-text-center"><UkSpinner @ratio={{2}} /></div>
4
- {{else if this.document}}
5
- {{#let
6
- (hash
1
+ {{#if this.loading}}
2
+ <div class="uk-text-center"><UkSpinner @ratio={{2}} /></div>
3
+ {{else if this.document}}
4
+ {{#let
5
+ (hash
6
+ document=this.document
7
+ navigation=(component
8
+ "cf-navigation"
9
+ navigation=this.navigation
10
+ useAsHeading=(or @useAsHeading false)
11
+ headingBaseLevel=(or @headingBaseLevel 1)
12
+ )
13
+ pagination=(component "cf-pagination" navigation=this.navigation)
14
+ form=(component
15
+ "cf-form-wrapper"
7
16
  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"
17
- document=this.document
18
- fieldset=this.fieldset
19
- context=@context
20
- disabled=@disabled
21
- )
17
+ fieldset=this.fieldset
18
+ context=@context
19
+ disabled=@disabled
20
+ onSave=@onSave
22
21
  )
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 />
34
- </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 />
35
34
  </div>
36
- {{else}}
37
- <content.form />
38
- {{/if}}
39
- {{/let}}
40
- {{/if}}
35
+ </div>
36
+ {{else}}
37
+ <content.form />
38
+ {{/if}}
39
+ {{/let}}
40
+ {{else}}
41
+ {{yield to="notfound"}}
41
42
  {{/if}}
@@ -4,7 +4,7 @@ import { inject as service } from "@ember/service";
4
4
  import Component from "@glimmer/component";
5
5
  import { queryManager } from "ember-apollo-client";
6
6
  import { dropTask } from "ember-concurrency";
7
- import { useTask } from "ember-resources";
7
+ import { trackedTask } from "ember-resources/util/ember-concurrency";
8
8
 
9
9
  import getDocumentAnswersQuery from "@projectcaluma/ember-form/gql/queries/document-answers.graphql";
10
10
  import getDocumentFormsQuery from "@projectcaluma/ember-form/gql/queries/document-forms.graphql";
@@ -125,7 +125,7 @@ export default class CfContentComponent extends Component {
125
125
  );
126
126
  }
127
127
 
128
- data = useTask(this, this.fetchData, () => [this.args.documentId]);
128
+ data = trackedTask(this, this.fetchData, () => [this.args.documentId]);
129
129
 
130
130
  @dropTask
131
131
  *fetchData() {
@@ -158,7 +158,11 @@ export default class CfContentComponent extends Component {
158
158
 
159
159
  const raw = parseDocument({ ...answerDocument, form });
160
160
 
161
- const document = new Document({ raw, owner });
161
+ const document = new Document({
162
+ raw,
163
+ owner,
164
+ dataSourceContext: this.args.context,
165
+ });
162
166
  const navigation = new Navigation({ document, owner });
163
167
 
164
168
  registerDestructor(this, () => {
@@ -0,0 +1,5 @@
1
+ <div data-test-field-hint={{@field.pk}}>
2
+ <span class="uk-text-small uk-text-muted" ...attributes>
3
+ {{@field.question.raw.hintText}}
4
+ </span>
5
+ </div>
@@ -1,4 +1,8 @@
1
- {{#unless @disabled}}
1
+ {{#if
2
+ (macroCondition
3
+ (macroDependencySatisfies "@projectcaluma/ember-workflow" "*")
4
+ )
5
+ }}
2
6
  <DocumentValidity
3
7
  @document={{@field.document}}
4
8
  @validateOnEnter={{this.validateOnEnter}}
@@ -8,12 +12,12 @@
8
12
  @workItemId={{this.workItem}}
9
13
  @mutation={{this.action}}
10
14
  @label={{@field.question.raw.label}}
11
- @disabled={{and (not-eq isValid null) (not isValid)}}
15
+ @disabled={{or (and (not-eq isValid null) (not isValid)) @disabled}}
12
16
  @color={{this.color}}
13
17
  @beforeMutate={{fn this.beforeMutate validate}}
14
18
  @onSuccess={{this.onSuccess}}
15
19
  @onError={{this.onError}}
16
- @type={{this.type}}
20
+ class={{if @disabled "uk-hidden"}}
17
21
  />
18
22
  </DocumentValidity>
19
- {{/unless}}
23
+ {{/if}}
@@ -1,77 +1,78 @@
1
1
  import { assert } from "@ember/debug";
2
2
  import { action } from "@ember/object";
3
+ import { dependencySatisfies, macroCondition } from "@embroider/macros";
3
4
  import Component from "@glimmer/component";
4
- import UIkit from "uikit";
5
+ import { confirm } from "ember-uikit";
5
6
 
6
- async function confirm(text) {
7
- try {
8
- await UIkit.modal.confirm(text);
7
+ let CfFieldInputActionButtonComponent;
9
8
 
10
- return true;
11
- } catch (error) {
12
- return false;
13
- }
14
- }
9
+ if (macroCondition(dependencySatisfies("@projectcaluma/ember-workflow", ""))) {
10
+ CfFieldInputActionButtonComponent = class extends Component {
11
+ constructor(...args) {
12
+ super(...args);
15
13
 
16
- export default class CfFieldInputActionButtonComponent extends Component {
17
- constructor(...args) {
18
- super(...args);
14
+ assert(
15
+ "The document must have a `workItemUuid` for `<CfField::Input::ActionButton />` to work.",
16
+ this.args.field.document.workItemUuid
17
+ );
18
+ }
19
19
 
20
- assert(
21
- "The document must have a `workItemUuid` for `<CfField::Input::ActionButton />` to work.",
22
- this.args.field.document.workItemUuid
23
- );
24
- }
20
+ get workItem() {
21
+ return (
22
+ this.args.context?.actionButtonWorkItemId ||
23
+ this.args.field.document.workItemUuid
24
+ );
25
+ }
25
26
 
26
- get workItem() {
27
- return (
28
- this.args.context?.actionButtonWorkItemId ||
29
- this.args.field.document.workItemUuid
30
- );
31
- }
27
+ get action() {
28
+ return this.args.field.question.raw.action.toLowerCase();
29
+ }
32
30
 
33
- get action() {
34
- return this.args.field.question.raw.action.toLowerCase();
35
- }
31
+ get color() {
32
+ return this.args.field.question.raw.color.toLowerCase();
33
+ }
36
34
 
37
- get color() {
38
- return this.args.field.question.raw.color.toLowerCase();
39
- }
35
+ get validateOnEnter() {
36
+ return (
37
+ this.args.field.question.raw.action === "COMPLETE" &&
38
+ this.args.field.question.raw.validateOnEnter
39
+ );
40
+ }
40
41
 
41
- get type() {
42
- return this.args.field.question.raw.action === "COMPLETE"
43
- ? "submit"
44
- : "button";
45
- }
42
+ @action
43
+ async beforeMutate(validateFn) {
44
+ if (
45
+ this.args.field.question.raw.action === "COMPLETE" &&
46
+ !(await validateFn())
47
+ ) {
48
+ return false;
49
+ }
46
50
 
47
- get validateOnEnter() {
48
- return (
49
- this.args.field.question.raw.action === "COMPLETE" &&
50
- this.args.field.question.raw.validateOnEnter
51
- );
52
- }
51
+ const confirmText = this.args.field.question.raw.infoText;
53
52
 
54
- @action
55
- async beforeMutate(validateFn) {
56
- if (
57
- this.args.field.question.raw.action === "COMPLETE" &&
58
- !(await validateFn())
59
- ) {
60
- return false;
53
+ return !confirmText || confirm(confirmText);
61
54
  }
62
55
 
63
- const confirmText = this.args.field.question.raw.infoText;
64
-
65
- return !confirmText || confirm(confirmText);
66
- }
56
+ @action
57
+ onSuccess() {
58
+ return this.args.context?.actionButtonOnSuccess?.();
59
+ }
67
60
 
68
- @action
69
- onSuccess() {
70
- return this.args.context?.actionButtonOnSuccess?.();
71
- }
61
+ @action
62
+ onError(error) {
63
+ return this.args.context?.actionButtonOnError?.(error);
64
+ }
65
+ };
66
+ } else {
67
+ CfFieldInputActionButtonComponent = class extends Component {
68
+ constructor(...args) {
69
+ super(...args);
72
70
 
73
- @action
74
- onError(error) {
75
- return this.args.context?.actionButtonOnError?.(error);
76
- }
71
+ assert(
72
+ "@projectcaluma/ember-workflow must be installed to enable the usage of the action button questions"
73
+ );
74
+ }
75
+ };
77
76
  }
77
+
78
+ export default CfFieldInputActionButtonComponent;
@@ -1,8 +1,7 @@
1
1
  {{#each @field.options as |option i|}}
2
- {{#if (gt i 0)}}<br />{{/if}}
2
+ {{#if (and (gt i 0) (not @field.raw.question.meta.vertical))}}<br />{{/if}}
3
3
  <label
4
- class="cf-checkbox_label
5
- {{if @field.isInvalid 'uk-form-danger'}}
4
+ class="{{if @field.isInvalid 'uk-form-danger'}}
6
5
  {{if @field.raw.question.meta.vertical 'uk-margin-large-right'}}"
7
6
  >
8
7
  <input
@@ -1,25 +1,12 @@
1
- {{#if @disabled}}
2
- <input
3
- class="uk-input uk-disabled"
4
- type="text"
5
- name={{@field.pk}}
6
- id={{@field.pk}}
7
- value={{format-date
8
- @field.answer.value
9
- day="2-digit"
10
- month="2-digit"
11
- year="numeric"
12
- }}
13
- readonly
14
- />
15
- {{else}}
16
- <PikadayInput
17
- class="uk-input"
18
- name={{@field.pk}}
19
- id={{@field.pk}}
20
- @format="L"
21
- @onSelection={{this.onChange}}
22
- @useUTC={{true}}
23
- @value={{@field.answer.value}}
24
- />
25
- {{/if}}
1
+ <EmberFlatpickr
2
+ id={{@field.pk}}
3
+ name={{@field.pk}}
4
+ class="uk-input {{if @disabled 'uk-disabled'}}"
5
+ readonly={{@disabled}}
6
+ @disabled={{@disabled}}
7
+ @locale={{this.locale}}
8
+ @date={{or @field.answer.value null}}
9
+ @formatDate={{this.formatDate}}
10
+ @allowInput={{true}}
11
+ @onChange={{this.onChange}}
12
+ />
@@ -1,19 +1,27 @@
1
1
  import { action } from "@ember/object";
2
+ import { inject as service } from "@ember/service";
2
3
  import Component from "@glimmer/component";
3
- import moment from "moment";
4
+ import { DateTime } from "luxon";
4
5
 
5
6
  export default class CfFieldInputDateComponent extends Component {
7
+ @service intl;
8
+
9
+ get locale() {
10
+ return this.intl.primaryLocale.split("-")[0];
11
+ }
12
+
6
13
  @action
7
- onChange(date) {
14
+ onChange([date]) {
8
15
  // Change Javascript date to ISO string if not null.
9
- this.args.onSave(
10
- date
11
- ? moment({
12
- day: date.getUTCDate(),
13
- month: date.getUTCMonth(),
14
- year: date.getUTCFullYear(),
15
- }).format(moment.HTML5_FMT.DATE)
16
- : null
17
- );
16
+ this.args.onSave(date ? DateTime.fromJSDate(date).toISODate() : null);
17
+ }
18
+
19
+ @action
20
+ formatDate(date) {
21
+ return this.intl.formatDate(date, {
22
+ day: "2-digit",
23
+ month: "2-digit",
24
+ year: "numeric",
25
+ });
18
26
  }
19
27
  }
@@ -0,0 +1,38 @@
1
+ <div class="uk-flex-middle uk-grid-divider uk-grid-column-small" uk-grid>
2
+ <div uk-form-custom="target: true">
3
+
4
+ <input
5
+ type="file"
6
+ name={{@field.pk}}
7
+ id={{@field.pk}}
8
+ disabled={{@disabled}}
9
+ multiple
10
+ {{on "change" this.save}}
11
+ />
12
+ <UkButton disabled={{@disabled}}>
13
+ {{t "caluma.form.selectFile"}}
14
+ </UkButton>
15
+ </div>
16
+ <ul class="uk-list uk-list-collapse" data-test-file-list={{@field.pk}}>
17
+ {{#each this.files as |file|}}
18
+ <li class="uk-text-justify uk-text-middle">
19
+ <UkButton
20
+ data-test-download-link={{file.id}}
21
+ @color="link"
22
+ @onClick={{fn this.download file.id}}
23
+ >
24
+ {{file.name}}
25
+ </UkButton>
26
+ {{#unless @disabled}}
27
+ <UkIcon
28
+ data-test-delete={{file.id}}
29
+ class="uk-icon-button uk-margin-small-left"
30
+ role="button"
31
+ @icon="trash"
32
+ {{on "click" (fn this.delete file.id)}}
33
+ />
34
+ {{/unless}}
35
+ </li>
36
+ {{/each}}
37
+ </ul>
38
+ </div>