@projectcaluma/ember-form 11.0.0-beta.9 → 11.0.1
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.
- package/CHANGELOG.md +147 -0
- package/addon/components/cf-content.hbs +38 -37
- package/addon/components/cf-content.js +7 -3
- package/addon/components/cf-field/hint.hbs +5 -0
- package/addon/components/cf-field/input/action-button.hbs +23 -18
- package/addon/components/cf-field/input/action-button.js +60 -59
- package/addon/components/cf-field/input/checkbox.hbs +2 -3
- package/addon/components/cf-field/input/date.hbs +22 -25
- package/addon/components/cf-field/input/date.js +37 -22
- package/addon/components/cf-field/input/files.hbs +38 -0
- package/addon/components/cf-field/input/files.js +113 -0
- package/addon/components/cf-field/input/powerselect.hbs +27 -29
- package/addon/components/cf-field/input/powerselect.js +8 -2
- package/addon/components/cf-field/input/radio.hbs +2 -2
- package/addon/components/cf-field/input/table.hbs +3 -2
- package/addon/components/cf-field/input/table.js +1 -11
- package/addon/components/cf-field/input.hbs +8 -21
- package/addon/components/cf-field/input.js +32 -14
- package/addon/components/cf-field/label.hbs +4 -2
- package/addon/components/cf-field-value.hbs +10 -8
- package/addon/components/cf-field-value.js +6 -5
- package/addon/components/cf-field.hbs +30 -5
- package/addon/components/cf-field.js +24 -15
- package/addon/components/cf-form-wrapper.hbs +4 -1
- package/addon/components/cf-form.hbs +6 -1
- package/addon/gql/fragments/field.graphql +14 -7
- package/addon/gql/mutations/save-document-files-answer.graphql +9 -0
- package/addon/gql/queries/document-forms.graphql +1 -1
- package/addon/gql/queries/dynamic-options.graphql +4 -4
- package/addon/gql/queries/{fileanswer-info.graphql → filesanswer-info.graphql} +4 -4
- package/addon/helpers/format-graphql-error.js +21 -0
- package/addon/helpers/get-widget.js +16 -2
- package/addon/instance-initializers/form-widget-overrides.js +52 -0
- package/addon/lib/document.js +9 -1
- package/addon/lib/field.js +49 -46
- package/addon/lib/navigation.js +3 -1
- package/addon/lib/question.js +18 -5
- package/addon/modifiers/autoresize.js +14 -0
- package/addon/services/caluma-store.js +2 -0
- package/app/components/cf-field/{input/file.js → hint.js} +1 -1
- package/app/components/cf-field/input/files.js +1 -0
- package/app/helpers/format-graphql-error.js +1 -0
- package/app/helpers/get-widget.js +1 -4
- package/app/instance-initializers/form-widget-overrides.js +4 -0
- package/app/modifiers/autoresize.js +1 -0
- package/app/styles/@projectcaluma/ember-form.scss +5 -15
- package/app/styles/_flatpickr.scss +47 -0
- package/blueprints/@projectcaluma/ember-form/index.js +1 -1
- package/index.js +12 -0
- package/package.json +49 -40
- package/translations/de.yaml +6 -6
- package/translations/en.yaml +6 -6
- package/translations/fr.yaml +6 -6
- package/addon/components/cf-field/input/file.hbs +0 -32
- package/addon/components/cf-field/input/file.js +0 -89
- package/addon/components/cf-field/label.js +0 -11
- package/addon/gql/mutations/remove-answer.graphql +0 -7
- package/addon/gql/mutations/save-document-file-answer.graphql +0 -9
- package/config/environment.js +0 -5
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,150 @@
|
|
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
|
+
|
1
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)
|
2
149
|
|
3
150
|
|
@@ -1,41 +1,42 @@
|
|
1
|
-
{{#if
|
2
|
-
{{
|
3
|
-
|
4
|
-
{{
|
5
|
-
|
6
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
{{
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
{{/
|
40
|
-
{{/
|
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 {
|
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 =
|
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({
|
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, () => {
|
@@ -1,18 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
<
|
7
|
-
@
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
{{#if
|
2
|
+
(macroCondition
|
3
|
+
(macroDependencySatisfies "@projectcaluma/ember-workflow" "*")
|
4
|
+
)
|
5
|
+
}}
|
6
|
+
<DocumentValidity
|
7
|
+
@document={{@field.document}}
|
8
|
+
@validateOnEnter={{this.validateOnEnter}}
|
9
|
+
as |isValid validate|
|
10
|
+
>
|
11
|
+
<WorkItemButton
|
12
|
+
@workItemId={{this.workItem}}
|
13
|
+
@mutation={{this.action}}
|
14
|
+
@label={{@field.question.raw.label}}
|
15
|
+
@disabled={{or (and (not-eq isValid null) (not isValid)) @disabled}}
|
16
|
+
@color={{this.color}}
|
17
|
+
@beforeMutate={{fn this.beforeMutate validate}}
|
18
|
+
@onSuccess={{this.onSuccess}}
|
19
|
+
@onError={{this.onError}}
|
20
|
+
class={{if @disabled "uk-hidden"}}
|
21
|
+
/>
|
22
|
+
</DocumentValidity>
|
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
|
5
|
+
import { confirm } from "ember-uikit";
|
5
6
|
|
6
|
-
|
7
|
-
try {
|
8
|
-
await UIkit.modal.confirm(text);
|
7
|
+
let CfFieldInputActionButtonComponent;
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
9
|
+
if (macroCondition(dependencySatisfies("@projectcaluma/ember-workflow", ""))) {
|
10
|
+
CfFieldInputActionButtonComponent = class extends Component {
|
11
|
+
constructor(...args) {
|
12
|
+
super(...args);
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
get workItem() {
|
21
|
+
return (
|
22
|
+
this.args.context?.actionButtonWorkItemId ||
|
23
|
+
this.args.field.document.workItemUuid
|
24
|
+
);
|
25
|
+
}
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
this.args.field.document.workItemUuid
|
30
|
-
);
|
31
|
-
}
|
27
|
+
get action() {
|
28
|
+
return this.args.field.question.raw.action.toLowerCase();
|
29
|
+
}
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
get color() {
|
32
|
+
return this.args.field.question.raw.color.toLowerCase();
|
33
|
+
}
|
36
34
|
|
37
|
-
|
38
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
56
|
+
@action
|
57
|
+
onSuccess() {
|
58
|
+
return this.args.context?.actionButtonOnSuccess?.();
|
59
|
+
}
|
67
60
|
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
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="
|
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,28 +1,25 @@
|
|
1
|
-
|
2
|
-
<
|
3
|
-
class="uk-
|
4
|
-
|
5
|
-
|
1
|
+
<div class="uk-inline uk-width-1-1">
|
2
|
+
<a
|
3
|
+
class="uk-form-icon uk-form-icon-flip"
|
4
|
+
uk-tooltip={{t "caluma.form.delete"}}
|
5
|
+
href="#"
|
6
|
+
{{on "click" this.clearCalendar}}
|
7
|
+
>
|
8
|
+
<UkIcon @icon="close" />
|
9
|
+
</a>
|
10
|
+
<EmberFlatpickr
|
6
11
|
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
|
-
<input
|
17
|
-
class="uk-input"
|
18
|
-
type="text"
|
19
12
|
name={{@field.pk}}
|
20
|
-
|
21
|
-
{{
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}}
|
13
|
+
class="uk-input {{if @disabled 'uk-disabled'}}"
|
14
|
+
readonly={{@disabled}}
|
15
|
+
@disabled={{@disabled}}
|
16
|
+
@locale={{this.locale}}
|
17
|
+
@date={{or @field.answer.value null}}
|
18
|
+
@altFormat={{this.dateFormat}}
|
19
|
+
@altInput={{true}}
|
20
|
+
@allowInput={{true}}
|
21
|
+
@onChange={{this.onChange}}
|
22
|
+
@onReady={{this.onReady}}
|
23
|
+
@onClose={{this.onClose}}
|
27
24
|
/>
|
28
|
-
|
25
|
+
</div>
|
@@ -1,37 +1,52 @@
|
|
1
|
+
import { getOwner } from "@ember/application";
|
1
2
|
import { action } from "@ember/object";
|
2
3
|
import { inject as service } from "@ember/service";
|
3
4
|
import Component from "@glimmer/component";
|
4
|
-
import {
|
5
|
-
import {
|
5
|
+
import { tracked } from "@glimmer/tracking";
|
6
|
+
import { DateTime } from "luxon";
|
6
7
|
|
7
8
|
export default class CfFieldInputDateComponent extends Component {
|
8
9
|
@service intl;
|
9
10
|
|
11
|
+
@tracked flatpickrRef = null;
|
12
|
+
|
13
|
+
get locale() {
|
14
|
+
return this.intl.primaryLocale.split("-")[0];
|
15
|
+
}
|
16
|
+
|
17
|
+
get config() {
|
18
|
+
return getOwner(this).resolveRegistration("config:environment");
|
19
|
+
}
|
20
|
+
|
21
|
+
get dateFormat() {
|
22
|
+
const {
|
23
|
+
FLATPICKR_DATE_FORMAT = {},
|
24
|
+
FLATPICKR_DATE_FORMAT_DEFAULT = "m/d/Y",
|
25
|
+
} = this.config["ember-caluma"] || {};
|
26
|
+
|
27
|
+
return FLATPICKR_DATE_FORMAT[this.locale] ?? FLATPICKR_DATE_FORMAT_DEFAULT;
|
28
|
+
}
|
29
|
+
|
10
30
|
@action
|
11
|
-
|
12
|
-
|
13
|
-
|
31
|
+
onReady(_selectedDates, _dateStr, flatpickrRef) {
|
32
|
+
this.flatpickrRef = flatpickrRef;
|
33
|
+
}
|
34
|
+
|
35
|
+
@action
|
36
|
+
clearCalendar(e) {
|
37
|
+
e.stopPropagation();
|
38
|
+
this.flatpickrRef.clear();
|
14
39
|
}
|
15
40
|
|
16
41
|
@action
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
month: "2-digit",
|
21
|
-
year: "numeric",
|
22
|
-
});
|
42
|
+
onChange([date]) {
|
43
|
+
// Change Javascript date to ISO string if not null.
|
44
|
+
this.args.onSave(date ? DateTime.fromJSDate(date).toISODate() : null);
|
23
45
|
}
|
24
46
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
return {
|
30
|
-
previousMonth: this.intl.t("caluma.form.pikaday.month-previous"),
|
31
|
-
nextMonth: this.intl.t("caluma.form.pikaday.month-next"),
|
32
|
-
months: Info.months("long", { locale }),
|
33
|
-
weekdays: Info.weekdays("long", { locale }),
|
34
|
-
weekdaysShort: Info.weekdays("short", { locale }),
|
35
|
-
};
|
47
|
+
// flatpickr doesnt call onChange after manual input and clicking outside.
|
48
|
+
@action
|
49
|
+
onClose(dates) {
|
50
|
+
this.onChange(dates);
|
36
51
|
}
|
37
52
|
}
|
@@ -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>
|