@projectcaluma/ember-form 11.0.0-beta.2 → 11.0.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +190 -0
  2. package/addon/components/cf-content.hbs +37 -37
  3. package/addon/components/cf-content.js +2 -2
  4. package/addon/components/cf-field/hint.hbs +5 -0
  5. package/addon/components/cf-field/info.hbs +2 -2
  6. package/addon/components/cf-field/info.js +0 -15
  7. package/addon/components/cf-field/input/action-button.hbs +8 -4
  8. package/addon/components/cf-field/input/action-button.js +60 -59
  9. package/addon/components/cf-field/input/checkbox.hbs +3 -4
  10. package/addon/components/cf-field/input/date.hbs +10 -5
  11. package/addon/components/cf-field/input/date.js +40 -10
  12. package/addon/components/cf-field/input/file.hbs +2 -2
  13. package/addon/components/cf-field/input/file.js +2 -2
  14. package/addon/components/cf-field/input/powerselect.hbs +27 -29
  15. package/addon/components/cf-field/input/powerselect.js +8 -2
  16. package/addon/components/cf-field/input/radio.hbs +2 -2
  17. package/addon/components/cf-field/input/static.hbs +1 -1
  18. package/addon/components/cf-field/input/table.hbs +25 -24
  19. package/addon/components/cf-field/input/table.js +1 -11
  20. package/addon/components/cf-field/input.hbs +8 -21
  21. package/addon/components/cf-field/input.js +32 -14
  22. package/addon/components/cf-field/label.hbs +4 -2
  23. package/addon/components/cf-field-value.hbs +22 -7
  24. package/addon/components/cf-field-value.js +8 -33
  25. package/addon/components/cf-field.hbs +39 -6
  26. package/addon/components/cf-field.js +37 -17
  27. package/addon/components/cf-form-wrapper.hbs +3 -1
  28. package/addon/components/document-validity.js +16 -1
  29. package/addon/gql/fragments/field.graphql +30 -0
  30. package/addon/helpers/format-graphql-error.js +21 -0
  31. package/addon/helpers/get-widget.js +16 -2
  32. package/addon/instance-initializers/form-widget-overrides.js +52 -0
  33. package/addon/lib/field.js +73 -46
  34. package/addon/lib/navigation.js +3 -1
  35. package/addon/lib/question.js +12 -4
  36. package/addon/modifiers/autoresize.js +16 -0
  37. package/app/components/cf-field/hint.js +1 -0
  38. package/app/helpers/format-graphql-error.js +1 -0
  39. package/app/helpers/get-widget.js +1 -4
  40. package/app/instance-initializers/form-widget-overrides.js +4 -0
  41. package/app/modifiers/autoresize.js +1 -0
  42. package/app/styles/@projectcaluma/ember-form.scss +3 -15
  43. package/package.json +37 -25
  44. package/translations/de.yaml +6 -2
  45. package/translations/en.yaml +6 -2
  46. package/translations/fr.yaml +6 -2
  47. package/addon/components/cf-field/label.js +0 -11
  48. package/addon/instance-initializers/setup-pikaday-i18n.js +0 -35
package/CHANGELOG.md CHANGED
@@ -1,3 +1,193 @@
1
+ # [@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)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **form:** improve validation of choice and multiple choice fields ([e828fad](https://github.com/projectcaluma/ember-caluma/commit/e828fad9557fd521ca9eec63af74f8cee12e3910))
7
+ * **form:** pass context to table row form ([af1031a](https://github.com/projectcaluma/ember-caluma/commit/af1031ae9e8138a404cd043199709025092da882))
8
+
9
+
10
+ ### Features
11
+
12
+ * **form:** add option to bypass the timeout when saving a field ([a2ba306](https://github.com/projectcaluma/ember-caluma/commit/a2ba306306f90a2d2279b34550507241f0987961))
13
+
14
+ # [@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)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **resources:** fix deprecations of ember-resources ([7a84c5c](https://github.com/projectcaluma/ember-caluma/commit/7a84c5c78d5b28f7b5393c64722907728dd5f42b))
20
+
21
+ # [@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)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * **form:** fix error formatting for older browsers ([9e34876](https://github.com/projectcaluma/ember-caluma/commit/9e3487625ccb73918b32fdf787054bab9114162f))
27
+
28
+ # [@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)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **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)
34
+
35
+
36
+ ### Features
37
+
38
+ * **cf-field:** add optional hints for form fields ([d847fbf](https://github.com/projectcaluma/ember-caluma/commit/d847fbffa376ea60971fb9e91aff8bf54ce77d50))
39
+ * **form:** show technical details of backend errors in UI ([c34cda6](https://github.com/projectcaluma/ember-caluma/commit/c34cda691f78623f41da1f9d75a39efce7e0ff0f))
40
+
41
+
42
+ ### BREAKING CHANGES
43
+
44
+ * **cf-field:** Question hints requires Caluma >= v7.15.0
45
+
46
+ Add option to create hints for certain question types. These
47
+ are displayed below the input field and can be used to provide
48
+ short, informative messages. Hints are available for all question
49
+ types except for form, static and action button questions.
50
+
51
+ # [@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)
52
+
53
+
54
+ ### Bug Fixes
55
+
56
+ * **embroider:** add missing dependency on @ember/string ([3a6e6bb](https://github.com/projectcaluma/ember-caluma/commit/3a6e6bb39a8c1a40a2ae00b3d4ea00606a755e25))
57
+ * **embroider:** fix dynamic component usage ([1cf0f6e](https://github.com/projectcaluma/ember-caluma/commit/1cf0f6e2914651bbb0ec70d1f7485fd9db90c9b5))
58
+ * **embroider:** remove obsolete export for getWidget helper function ([94fb461](https://github.com/projectcaluma/ember-caluma/commit/94fb461aaa7cac6af9f5612b8f34ad047a2b67bb))
59
+
60
+ # [@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)
61
+
62
+
63
+ ### Bug Fixes
64
+
65
+ * **form:** make sure dynamic options are loaded before validating ([2713b37](https://github.com/projectcaluma/ember-caluma/commit/2713b3718b64f9111ca3e7bec2a6c60fafcb183a))
66
+
67
+ # [@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)
68
+
69
+
70
+ ### Bug Fixes
71
+
72
+ * **form:** make sure table controls are always visible ([8cd97d2](https://github.com/projectcaluma/ember-caluma/commit/8cd97d204539f2e84b9baf9841591460bddf145a))
73
+
74
+ # [@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)
75
+
76
+
77
+ ### Bug Fixes
78
+
79
+ * **form:** don't refetch dynamic options on validation ([27061c6](https://github.com/projectcaluma/ember-caluma/commit/27061c67f0562508f558305247cb51d615fa36b0))
80
+ * **form:** fix input in date fields ([cf54bf5](https://github.com/projectcaluma/ember-caluma/commit/cf54bf5542e35fd7dbe293a9e22288afae6a517a))
81
+ * **navigation:** exclude static questions from visible fields ([6ebd085](https://github.com/projectcaluma/ember-caluma/commit/6ebd085098df71fab693dec5282ea4b81d5b9836))
82
+ * **workflow:** return case status on complete / skip work-item mutation ([524453c](https://github.com/projectcaluma/ember-caluma/commit/524453c1189b4375ca792fca7d35056b916696f8))
83
+
84
+
85
+ ### Features
86
+
87
+ * **form:** support passing component override classes ([9409c7c](https://github.com/projectcaluma/ember-caluma/commit/9409c7cb5901dcdffec1c0294046da64b74b9922))
88
+
89
+ # [@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)
90
+
91
+
92
+ ### Bug Fixes
93
+
94
+ * **form:** fix textarea size in tables ([efba737](https://github.com/projectcaluma/ember-caluma/commit/efba737f0a6314225a851ee0c57c2c506403bc06))
95
+
96
+ # [@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)
97
+
98
+
99
+ ### Bug Fixes
100
+
101
+ * **form:** always use monday as first day of the week in datepicker ([7008a90](https://github.com/projectcaluma/ember-caluma/commit/7008a90d737d2dca714f4799f846f4c4086ecd4d))
102
+ * **form:** use action button type "button" ([3e9795f](https://github.com/projectcaluma/ember-caluma/commit/3e9795f28b73dcf376ec9ecabcd4c1b6a8085beb))
103
+
104
+
105
+ ### Features
106
+
107
+ * **form:** add notfound named block in cf-content if no document found ([f1861c1](https://github.com/projectcaluma/ember-caluma/commit/f1861c1f3b2da9843771aa1b12956190c98799a6))
108
+
109
+ # [@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)
110
+
111
+
112
+ ### Bug Fixes
113
+
114
+ * **form:** always trigger data fetching in cf-content ([3fab675](https://github.com/projectcaluma/ember-caluma/commit/3fab675fca0559cd4164d4d62b44b9d9b74e4a5c))
115
+
116
+ # [@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)
117
+
118
+
119
+ ### Bug Fixes
120
+
121
+ * **action-button:** only hide action button visually if disabled ([e292f09](https://github.com/projectcaluma/ember-caluma/commit/e292f093c33efd0b99a73674f8f83de5f496bf40))
122
+ * **deps:** remove moment altogether and update ember-pikday ([b2f7fa2](https://github.com/projectcaluma/ember-caluma/commit/b2f7fa28fa076897addd36e5964c926c671508ff))
123
+ * **form:** change file download actions to query and network-only ([aa4458e](https://github.com/projectcaluma/ember-caluma/commit/aa4458e944263f0f00ba1684a4f7bbfa83d2efea))
124
+
125
+
126
+ ### BREAKING CHANGES
127
+
128
+ * **deps:** The host app now needs to opt-in to use the default
129
+ pikaday styles: https://github.com/adopted-ember-addons/ember-pikaday#styles
130
+
131
+ # [@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)
132
+
133
+
134
+ ### Bug Fixes
135
+
136
+ * dye file upload button in default color ([ad9e1b8](https://github.com/projectcaluma/ember-caluma/commit/ad9e1b8ed18c8228c495142af1bbe1f2c219c088))
137
+ * **form:** fix isNew state of answers without backend object ([c10129f](https://github.com/projectcaluma/ember-caluma/commit/c10129ffe76d7751cd0105c71fc4ba010323e2e4))
138
+
139
+ # [@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)
140
+
141
+
142
+ ### Bug Fixes
143
+
144
+ * **validation:** sync format validator validation with backend ([ee66968](https://github.com/projectcaluma/ember-caluma/commit/ee66968230b9f0e4c5a4df8bdb3f8e58b44b5b82))
145
+
146
+
147
+ ### BREAKING CHANGES
148
+
149
+ * **validation:** Use the `formatValidators` property of the backend to store and read
150
+ format validators instead of the `meta.formatValidators` so the backend
151
+ validates as well. For more information on how to migrate check the
152
+ migration guide to v11.
153
+
154
+ # [@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)
155
+
156
+
157
+ ### Bug Fixes
158
+
159
+ * **action-button:** hide field wrapper if action button is not displayed ([1d4b701](https://github.com/projectcaluma/ember-caluma/commit/1d4b701af35d48d072001f3295b905b1065daffe))
160
+ * render static questions ([28fff94](https://github.com/projectcaluma/ember-caluma/commit/28fff9487e4ad3153fe267db4b66208ad858aaac))
161
+ * **table:** fix styling of table fields ([30c5903](https://github.com/projectcaluma/ember-caluma/commit/30c590389ed82c37ebf666f1484501c66ca8f0bb))
162
+
163
+ # [@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)
164
+
165
+
166
+ ### Bug Fixes
167
+
168
+ * **document-validity:** wait to validate until the UI has finished saving values ([9ec5330](https://github.com/projectcaluma/ember-caluma/commit/9ec5330905046604f95ab42985a29a5e0dc369a4))
169
+ * **form:** use component save task instead of field for loading indicator ([6de510d](https://github.com/projectcaluma/ember-caluma/commit/6de510d19a3608b7cd40092908d562a152ef03bd))
170
+
171
+ # [@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)
172
+
173
+
174
+ ### Bug Fixes
175
+
176
+ * **form:** fix closing of info modal ([b46095a](https://github.com/projectcaluma/ember-caluma/commit/b46095aa3b31bc1b2035a0818778edaa8fd9c745))
177
+
178
+ # [@projectcaluma/ember-form-v11.0.0-beta.3](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.2...@projectcaluma/ember-form-v11.0.0-beta.3) (2022-01-24)
179
+
180
+
181
+ ### chore
182
+
183
+ * **deps:** update ember-uikit to v5 beta ([6568d39](https://github.com/projectcaluma/ember-caluma/commit/6568d398216d33b44da5b659830ca3c200dd7012))
184
+
185
+
186
+ ### BREAKING CHANGES
187
+
188
+ * **deps:** All `@projectcaluma/ember-*` packages now require
189
+ `ember-uikit` v5+.
190
+
1
191
  # [@projectcaluma/ember-form-v11.0.0-beta.2](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.1...@projectcaluma/ember-form-v11.0.0-beta.2) (2022-01-18)
2
192
 
3
193
 
@@ -1,41 +1,41 @@
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
22
20
  )
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>
21
+ )
22
+ as |content|
23
+ }}
24
+ {{#if (has-block)}}
25
+ {{yield content}}
26
+ {{else if (gt this.document.fieldsets.length 1)}}
27
+ <div uk-grid>
28
+ <div class="uk-width-1-1 uk-width-1-3@m"><content.navigation /></div>
29
+ <div class="uk-width-1-1 uk-width-2-3@m">
30
+ <content.form />
31
+ <hr />
32
+ <content.pagination />
35
33
  </div>
36
- {{else}}
37
- <content.form />
38
- {{/if}}
39
- {{/let}}
40
- {{/if}}
34
+ </div>
35
+ {{else}}
36
+ <content.form />
37
+ {{/if}}
38
+ {{/let}}
39
+ {{else}}
40
+ {{yield to="notfound"}}
41
41
  {{/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() {
@@ -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>
@@ -4,7 +4,7 @@
4
4
  class="uk-icon-button"
5
5
  uk-icon="info"
6
6
  title={{t "caluma.form.info"}}
7
- {{on "click" this.showModal}}
7
+ {{on "click" (fn (mut this.modalVisible) true)}}
8
8
  >
9
9
  <span class="uk-hidden">{{t "caluma.form.info"}}</span>
10
10
  </button>
@@ -12,7 +12,7 @@
12
12
  <UkModal
13
13
  @visible={{this.modalVisible}}
14
14
  @stack={{true}}
15
- @on-hide={{this.hideModal}}
15
+ @onHide={{fn (mut this.modalVisible) false}}
16
16
  as |modal|
17
17
  >
18
18
  <modal.body>
@@ -1,21 +1,6 @@
1
- import { action } from "@ember/object";
2
1
  import Component from "@glimmer/component";
3
2
  import { tracked } from "@glimmer/tracking";
4
3
 
5
4
  export default class CfFieldInfoComponent extends Component {
6
5
  @tracked modalVisible = false;
7
-
8
- @action
9
- showModal(e) {
10
- e.preventDefault();
11
-
12
- this.modalVisible = true;
13
- }
14
-
15
- @action
16
- hideModal(e) {
17
- e.preventDefault();
18
-
19
- this.modalVisible = false;
20
- }
21
6
  }
@@ -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
@@ -11,7 +10,7 @@
11
10
  name={{@field.pk}}
12
11
  value={{option.slug}}
13
12
  checked={{includes option.slug @field.answer.value}}
14
- disabled={{@disabled}}
13
+ disabled={{or option.disabled @disabled}}
15
14
  {{on "change" this.update}}
16
15
  />
17
16
  {{#if (and option.disabled (not @disabled))}}
@@ -13,13 +13,18 @@
13
13
  readonly
14
14
  />
15
15
  {{else}}
16
- <PikadayInput
16
+ <input
17
17
  class="uk-input"
18
+ type="text"
18
19
  name={{@field.pk}}
19
20
  id={{@field.pk}}
20
- @format="L"
21
- @onSelection={{this.onChange}}
22
- @useUTC={{true}}
23
- @value={{@field.answer.value}}
21
+ {{pikaday
22
+ firstDay=1
23
+ toString=this.formatDate
24
+ i18n=this.pikadayTranslations
25
+ value=@field.answer.value
26
+ onSelect=this.onChange
27
+ parse=this.parseDate
28
+ }}
24
29
  />
25
30
  {{/if}}
@@ -1,19 +1,49 @@
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, Info } from "luxon";
5
+ import { cached } from "tracked-toolbox";
6
+
7
+ // put the last element to the front of the array
8
+ const shift = (array) => [...array.slice(-1), ...array.slice(0, -1)];
4
9
 
5
10
  export default class CfFieldInputDateComponent extends Component {
11
+ @service intl;
12
+
6
13
  @action
7
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
+ parseDate(value) {
21
+ const date = DateTime.fromFormat(value, "D", {
22
+ locale: this.intl.primaryLocale,
23
+ });
24
+
25
+ return date.isValid ? date.toJSDate() : null;
26
+ }
27
+
28
+ @action
29
+ formatDate(date) {
30
+ return this.intl.formatDate(date, {
31
+ day: "2-digit",
32
+ month: "2-digit",
33
+ year: "numeric",
34
+ });
35
+ }
36
+
37
+ @cached
38
+ get pikadayTranslations() {
39
+ const locale = this.intl.primaryLocale;
40
+
41
+ return {
42
+ previousMonth: this.intl.t("caluma.form.pikaday.month-previous"),
43
+ nextMonth: this.intl.t("caluma.form.pikaday.month-next"),
44
+ months: Info.months("long", { locale }),
45
+ weekdays: shift(Info.weekdays("long", { locale })),
46
+ weekdaysShort: shift(Info.weekdays("short", { locale })),
47
+ };
18
48
  }
19
49
  }
@@ -8,7 +8,7 @@
8
8
  disabled={{@disabled}}
9
9
  {{on "change" this.save}}
10
10
  />
11
- <UkButton @color="primary" @disabled={{@disabled}}>
11
+ <UkButton disabled={{@disabled}}>
12
12
  {{t "caluma.form.selectFile"}}
13
13
  </UkButton>
14
14
  </div>
@@ -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>
@@ -22,11 +22,11 @@ export default class CfFieldInputFileComponent extends Component {
22
22
 
23
23
  @action
24
24
  async download() {
25
- const { downloadUrl } = await this.apollo.watchQuery(
25
+ const { downloadUrl } = await this.apollo.query(
26
26
  {
27
27
  query: getFileAnswerInfoQuery,
28
28
  variables: { id: this.args.field.answer.raw.id },
29
- fetchPolicy: "cache-and-network",
29
+ fetchPolicy: "network-only",
30
30
  },
31
31
  "node.fileValue"
32
32
  );