@projectcaluma/ember-form 10.0.1 → 11.0.0-beta.10
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1181 -0
- package/addon/components/cf-content.hbs +36 -41
- package/addon/components/cf-content.js +48 -29
- package/addon/components/cf-field/info.hbs +2 -2
- package/addon/components/cf-field/info.js +0 -15
- package/addon/components/cf-field/input/action-button.hbs +18 -19
- package/addon/components/cf-field/input/action-button.js +9 -7
- package/addon/components/cf-field/input/checkbox.hbs +6 -2
- package/addon/components/cf-field/input/checkbox.js +9 -29
- package/addon/components/cf-field/input/date.hbs +8 -5
- package/addon/components/cf-field/input/date.js +28 -10
- package/addon/components/cf-field/input/file.hbs +2 -2
- package/addon/components/cf-field/input/file.js +10 -11
- package/addon/components/cf-field/input/float.hbs +4 -4
- package/addon/components/cf-field/input/integer.hbs +5 -5
- package/addon/components/cf-field/input/radio.hbs +4 -1
- package/addon/components/cf-field/input/static.hbs +1 -1
- package/addon/components/cf-field/input/table.hbs +24 -24
- package/addon/components/cf-field/input/table.js +12 -10
- package/addon/components/cf-field/input/text.hbs +5 -5
- package/addon/components/cf-field/input/textarea.hbs +6 -5
- package/addon/components/cf-field/input.hbs +10 -1
- package/addon/components/cf-field/input.js +1 -1
- package/addon/components/cf-field/label.hbs +1 -1
- package/addon/components/cf-field-value.hbs +22 -7
- package/addon/components/cf-field-value.js +8 -38
- package/addon/components/cf-field.hbs +14 -6
- package/addon/components/cf-field.js +22 -8
- package/addon/components/cf-navigation-item.hbs +2 -2
- package/addon/components/cf-navigation.hbs +4 -1
- package/addon/components/document-validity.js +17 -2
- package/addon/gql/fragments/field.graphql +45 -0
- package/addon/gql/mutations/save-document-table-answer.graphql +1 -1
- package/addon/gql/mutations/save-document.graphql +1 -0
- package/addon/gql/queries/{get-document-answers.graphql → document-answers.graphql} +2 -1
- package/addon/gql/queries/{get-document-forms.graphql → document-forms.graphql} +2 -1
- package/addon/gql/queries/{get-document-used-dynamic-options.graphql → document-used-dynamic-options.graphql} +2 -1
- package/addon/gql/queries/{get-dynamic-options.graphql → dynamic-options.graphql} +2 -1
- package/addon/gql/queries/{get-fileanswer-info.graphql → fileanswer-info.graphql} +2 -1
- package/addon/helpers/get-widget.js +50 -0
- package/addon/lib/answer.js +108 -72
- package/addon/lib/base.js +32 -23
- package/addon/lib/dependencies.js +36 -71
- package/addon/lib/document.js +92 -96
- package/addon/lib/field.js +374 -407
- package/addon/lib/fieldset.js +46 -47
- package/addon/lib/form.js +27 -15
- package/addon/lib/navigation.js +211 -192
- package/addon/lib/question.js +103 -94
- package/addon/services/caluma-store.js +10 -6
- package/app/helpers/get-widget.js +4 -0
- package/blueprints/@projectcaluma/ember-form/index.js +1 -0
- package/package.json +30 -25
- package/addon/components/cf-navigation.js +0 -9
- package/addon/instance-initializers/setup-pikaday-i18n.js +0 -35
@@ -1,44 +1,39 @@
|
|
1
|
-
{{#if
|
2
|
-
<div
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}}
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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>
|
37
|
-
</div>
|
38
|
-
{{else}}
|
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"
|
16
|
+
document=this.document
|
17
|
+
fieldset=this.fieldset
|
18
|
+
context=@context
|
19
|
+
disabled=@disabled
|
20
|
+
)
|
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">
|
39
30
|
<content.form />
|
40
|
-
|
41
|
-
|
31
|
+
<hr />
|
32
|
+
<content.pagination />
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
{{else}}
|
36
|
+
<content.form />
|
42
37
|
{{/if}}
|
43
|
-
|
38
|
+
{{/let}}
|
44
39
|
{{/if}}
|
@@ -1,12 +1,13 @@
|
|
1
1
|
import { getOwner } from "@ember/application";
|
2
|
-
import {
|
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
|
6
|
+
import { dropTask } from "ember-concurrency";
|
7
|
+
import { useTask } from "ember-resources";
|
7
8
|
|
8
|
-
import getDocumentAnswersQuery from "@projectcaluma/ember-form/gql/queries/
|
9
|
-
import getDocumentFormsQuery from "@projectcaluma/ember-form/gql/queries/
|
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 {
|
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.
|
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.
|
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
|
-
|
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.
|
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
|
137
|
-
|
138
|
-
|
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
|
141
|
-
.factoryFor("caluma-model:navigation")
|
142
|
-
.create({ document });
|
159
|
+
const raw = parseDocument({ ...answerDocument, form });
|
143
160
|
|
144
|
-
|
145
|
-
|
161
|
+
const document = new Document({ raw, owner });
|
162
|
+
const navigation = new Navigation({ document, owner });
|
146
163
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
164
|
+
registerDestructor(this, () => {
|
165
|
+
destroy(document);
|
166
|
+
destroy(navigation);
|
167
|
+
});
|
168
|
+
|
169
|
+
return { document, navigation };
|
151
170
|
}
|
152
171
|
}
|
@@ -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.
|
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
|
-
@
|
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,19 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
{{/unless}}
|
1
|
+
<DocumentValidity
|
2
|
+
@document={{@field.document}}
|
3
|
+
@validateOnEnter={{this.validateOnEnter}}
|
4
|
+
as |isValid validate|
|
5
|
+
>
|
6
|
+
<WorkItemButton
|
7
|
+
@workItemId={{this.workItem}}
|
8
|
+
@mutation={{this.action}}
|
9
|
+
@label={{@field.question.raw.label}}
|
10
|
+
@disabled={{or (and (not-eq isValid null) (not isValid)) @disabled}}
|
11
|
+
@color={{this.color}}
|
12
|
+
@beforeMutate={{fn this.beforeMutate validate}}
|
13
|
+
@onSuccess={{this.onSuccess}}
|
14
|
+
@onError={{this.onError}}
|
15
|
+
@type={{this.type}}
|
16
|
+
class={{if @disabled "uk-hidden"}}
|
17
|
+
/>
|
18
|
+
</DocumentValidity>
|
@@ -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"
|
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
|
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=
|
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
|
42
|
-
|
43
|
-
|
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([...
|
27
|
+
this.args.onSave([...valueSet]);
|
48
28
|
}
|
49
29
|
}
|
@@ -13,13 +13,16 @@
|
|
13
13
|
readonly
|
14
14
|
/>
|
15
15
|
{{else}}
|
16
|
-
<
|
16
|
+
<input
|
17
17
|
class="uk-input"
|
18
|
+
type="text"
|
18
19
|
name={{@field.pk}}
|
19
20
|
id={{@field.pk}}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
{{pikaday
|
22
|
+
toString=this.formatDate
|
23
|
+
i18n=this.pikadayTranslations
|
24
|
+
value=@field.answer.value
|
25
|
+
onSelect=this.onChange
|
26
|
+
}}
|
24
27
|
/>
|
25
28
|
{{/if}}
|
@@ -1,19 +1,37 @@
|
|
1
1
|
import { action } from "@ember/object";
|
2
|
+
import { inject as service } from "@ember/service";
|
2
3
|
import Component from "@glimmer/component";
|
3
|
-
import
|
4
|
+
import { DateTime, Info } from "luxon";
|
5
|
+
import { cached } from "tracked-toolbox";
|
4
6
|
|
5
7
|
export default class CfFieldInputDateComponent extends Component {
|
8
|
+
@service intl;
|
9
|
+
|
6
10
|
@action
|
7
11
|
onChange(date) {
|
8
12
|
// Change Javascript date to ISO string if not null.
|
9
|
-
this.args.onSave(
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
this.args.onSave(date ? DateTime.fromJSDate(date).toISODate() : null);
|
14
|
+
}
|
15
|
+
|
16
|
+
@action
|
17
|
+
formatDate(date) {
|
18
|
+
return this.intl.formatDate(date, {
|
19
|
+
day: "2-digit",
|
20
|
+
month: "2-digit",
|
21
|
+
year: "numeric",
|
22
|
+
});
|
23
|
+
}
|
24
|
+
|
25
|
+
@cached
|
26
|
+
get pikadayTranslations() {
|
27
|
+
const locale = this.intl.primaryLocale;
|
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
|
+
};
|
18
36
|
}
|
19
37
|
}
|
@@ -8,7 +8,7 @@
|
|
8
8
|
disabled={{@disabled}}
|
9
9
|
{{on "change" this.save}}
|
10
10
|
/>
|
11
|
-
<UkButton
|
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
|
-
@
|
20
|
+
@onClick={{this.download}}
|
21
21
|
>
|
22
22
|
{{this.downloadName}}
|
23
23
|
</UkButton>
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import { action
|
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/
|
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;
|
@@ -21,11 +22,11 @@ export default class CfFieldInputFileComponent extends Component {
|
|
21
22
|
|
22
23
|
@action
|
23
24
|
async download() {
|
24
|
-
const { downloadUrl } = await this.apollo.
|
25
|
+
const { downloadUrl } = await this.apollo.query(
|
25
26
|
{
|
26
27
|
query: getFileAnswerInfoQuery,
|
27
|
-
variables: { id: this.args.field.answer.id },
|
28
|
-
fetchPolicy: "
|
28
|
+
variables: { id: this.args.field.answer.raw.id },
|
29
|
+
fetchPolicy: "network-only",
|
29
30
|
},
|
30
31
|
"node.fileValue"
|
31
32
|
);
|
@@ -55,15 +56,13 @@ export default class CfFieldInputFileComponent extends Component {
|
|
55
56
|
throw new Error();
|
56
57
|
}
|
57
58
|
|
58
|
-
|
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
|
-
|
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
|
-
|
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
|
6
|
-
{{if this.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
|
6
|
-
{{if @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
|
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"
|