@projectcaluma/ember-form 11.0.0-beta.9 → 11.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,8 +1,3 @@
|
|
1
|
-
# We can not symlink this file so an exact copy exists in another package:
|
2
|
-
# packages/form-builder/addon/gql/fragments/field.graphql
|
3
|
-
#
|
4
|
-
# When changing this file the other must also receive the same changes.
|
5
|
-
|
6
1
|
fragment SimpleQuestion on Question {
|
7
2
|
id
|
8
3
|
slug
|
@@ -28,6 +23,7 @@ fragment SimpleQuestion on Question {
|
|
28
23
|
}
|
29
24
|
}
|
30
25
|
}
|
26
|
+
hintText
|
31
27
|
}
|
32
28
|
... on TextareaQuestion {
|
33
29
|
textareaMinLength: minLength
|
@@ -46,6 +42,7 @@ fragment SimpleQuestion on Question {
|
|
46
42
|
}
|
47
43
|
}
|
48
44
|
}
|
45
|
+
hintText
|
49
46
|
}
|
50
47
|
... on IntegerQuestion {
|
51
48
|
integerMinValue: minValue
|
@@ -55,6 +52,7 @@ fragment SimpleQuestion on Question {
|
|
55
52
|
value
|
56
53
|
}
|
57
54
|
placeholder
|
55
|
+
hintText
|
58
56
|
}
|
59
57
|
... on FloatQuestion {
|
60
58
|
floatMinValue: minValue
|
@@ -64,6 +62,7 @@ fragment SimpleQuestion on Question {
|
|
64
62
|
value
|
65
63
|
}
|
66
64
|
placeholder
|
65
|
+
hintText
|
67
66
|
}
|
68
67
|
... on ChoiceQuestion {
|
69
68
|
choiceOptions: options {
|
@@ -80,6 +79,7 @@ fragment SimpleQuestion on Question {
|
|
80
79
|
id
|
81
80
|
value
|
82
81
|
}
|
82
|
+
hintText
|
83
83
|
}
|
84
84
|
... on MultipleChoiceQuestion {
|
85
85
|
multipleChoiceOptions: options {
|
@@ -96,18 +96,24 @@ fragment SimpleQuestion on Question {
|
|
96
96
|
id
|
97
97
|
value
|
98
98
|
}
|
99
|
+
hintText
|
99
100
|
}
|
100
101
|
... on DateQuestion {
|
101
102
|
dateDefaultAnswer: defaultAnswer {
|
102
103
|
id
|
103
104
|
value
|
104
105
|
}
|
106
|
+
hintText
|
105
107
|
}
|
106
108
|
... on StaticQuestion {
|
107
109
|
staticContent
|
108
110
|
}
|
109
111
|
... on CalculatedFloatQuestion {
|
110
112
|
calcExpression
|
113
|
+
hintText
|
114
|
+
}
|
115
|
+
... on FilesQuestion {
|
116
|
+
hintText
|
111
117
|
}
|
112
118
|
... on ActionButtonQuestion {
|
113
119
|
action
|
@@ -130,6 +136,7 @@ fragment FieldTableQuestion on Question {
|
|
130
136
|
}
|
131
137
|
}
|
132
138
|
}
|
139
|
+
hintText
|
133
140
|
tableDefaultAnswer: defaultAnswer {
|
134
141
|
id
|
135
142
|
value {
|
@@ -222,8 +229,8 @@ fragment SimpleAnswer on Answer {
|
|
222
229
|
... on ListAnswer {
|
223
230
|
listValue: value
|
224
231
|
}
|
225
|
-
... on
|
226
|
-
|
232
|
+
... on FilesAnswer {
|
233
|
+
filesValue: value {
|
227
234
|
id
|
228
235
|
uploadUrl
|
229
236
|
downloadUrl
|
@@ -1,11 +1,11 @@
|
|
1
|
-
query DynamicOptions($question: String
|
2
|
-
allQuestions(filter: [{
|
1
|
+
query DynamicOptions($question: String!, $context: JSONString) {
|
2
|
+
allQuestions(filter: [{ slugs: [$question] }], first: 1) {
|
3
3
|
edges {
|
4
4
|
node {
|
5
5
|
id
|
6
6
|
slug
|
7
7
|
... on DynamicChoiceQuestion {
|
8
|
-
dynamicChoiceOptions: options {
|
8
|
+
dynamicChoiceOptions: options(context: $context) {
|
9
9
|
edges {
|
10
10
|
node {
|
11
11
|
slug
|
@@ -15,7 +15,7 @@ query DynamicOptions($question: String!) {
|
|
15
15
|
}
|
16
16
|
}
|
17
17
|
... on DynamicMultipleChoiceQuestion {
|
18
|
-
dynamicMultipleChoiceOptions: options {
|
18
|
+
dynamicMultipleChoiceOptions: options(context: $context) {
|
19
19
|
edges {
|
20
20
|
node {
|
21
21
|
slug
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { helper } from "@ember/component/helper";
|
2
|
+
|
3
|
+
export function formatGraphqlErrorObject(error) {
|
4
|
+
try {
|
5
|
+
const path = error.path.join(".");
|
6
|
+
const { line, column } = error.locations[error.locations.length - 1];
|
7
|
+
|
8
|
+
return `${path}:${line}:${column}: ${error.message}`;
|
9
|
+
} catch (e) {
|
10
|
+
return null;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
export function formatGraphqlError(error) {
|
15
|
+
return (
|
16
|
+
error?.errors?.map(formatGraphqlErrorObject).filter(Boolean).join("\n") ??
|
17
|
+
""
|
18
|
+
);
|
19
|
+
}
|
20
|
+
|
21
|
+
export default helper(([error]) => formatGraphqlError(error));
|
@@ -1,6 +1,15 @@
|
|
1
1
|
import Helper from "@ember/component/helper";
|
2
2
|
import { warn } from "@ember/debug";
|
3
3
|
import { inject as service } from "@ember/service";
|
4
|
+
import { ensureSafeComponent } from "@embroider/util";
|
5
|
+
|
6
|
+
import InputComponent from "@projectcaluma/ember-form/components/cf-field/input";
|
7
|
+
import FormComponent from "@projectcaluma/ember-form/components/cf-form";
|
8
|
+
|
9
|
+
const DEFAULT_WIDGETS = {
|
10
|
+
"cf-field/input": InputComponent,
|
11
|
+
"cf-form": FormComponent,
|
12
|
+
};
|
4
13
|
|
5
14
|
/**
|
6
15
|
* Helper for getting the right widget.
|
@@ -42,9 +51,14 @@ export default class GetWidgetHelper extends Helper {
|
|
42
51
|
{ id: "ember-caluma.unregistered-override" }
|
43
52
|
);
|
44
53
|
|
45
|
-
if (override)
|
54
|
+
if (override) {
|
55
|
+
return ensureSafeComponent(
|
56
|
+
override.componentClass ?? override.component,
|
57
|
+
this
|
58
|
+
);
|
59
|
+
}
|
46
60
|
}
|
47
61
|
|
48
|
-
return defaultWidget;
|
62
|
+
return ensureSafeComponent(DEFAULT_WIDGETS[defaultWidget], this);
|
49
63
|
}
|
50
64
|
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { setOwner } from "@ember/application";
|
2
|
+
import { inject as service } from "@ember/service";
|
3
|
+
|
4
|
+
import HiddenComponent from "@projectcaluma/ember-form/components/cf-field/input/hidden";
|
5
|
+
import PowerSelectComponent from "@projectcaluma/ember-form/components/cf-field/input/powerselect";
|
6
|
+
|
7
|
+
class HiddenOverride {
|
8
|
+
@service intl;
|
9
|
+
|
10
|
+
get label() {
|
11
|
+
return this.intl.t("caluma.form-builder.question.widgetOverrides.hidden");
|
12
|
+
}
|
13
|
+
|
14
|
+
component = "cf-field/input/hidden";
|
15
|
+
componentClass = HiddenComponent;
|
16
|
+
}
|
17
|
+
|
18
|
+
class PowerSelectOverride {
|
19
|
+
@service intl;
|
20
|
+
|
21
|
+
get label() {
|
22
|
+
return this.intl.t(
|
23
|
+
"caluma.form-builder.question.widgetOverrides.powerselect"
|
24
|
+
);
|
25
|
+
}
|
26
|
+
|
27
|
+
component = "cf-field/input/powerselect";
|
28
|
+
componentClass = PowerSelectComponent;
|
29
|
+
types = [
|
30
|
+
"ChoiceQuestion",
|
31
|
+
"MultipleChoiceQuestion",
|
32
|
+
"DynamicChoiceQuestion",
|
33
|
+
"DynamicMultipleChoiceQuestion",
|
34
|
+
];
|
35
|
+
}
|
36
|
+
|
37
|
+
export function initialize(appInstance) {
|
38
|
+
const options = appInstance.lookup("service:caluma-options");
|
39
|
+
|
40
|
+
const hiddenOverride = new HiddenOverride();
|
41
|
+
const powerSelectOverride = new PowerSelectOverride();
|
42
|
+
|
43
|
+
setOwner(hiddenOverride, appInstance);
|
44
|
+
setOwner(powerSelectOverride, appInstance);
|
45
|
+
|
46
|
+
options.registerComponentOverride(hiddenOverride);
|
47
|
+
options.registerComponentOverride(powerSelectOverride);
|
48
|
+
}
|
49
|
+
|
50
|
+
export default {
|
51
|
+
initialize,
|
52
|
+
};
|
package/addon/lib/document.js
CHANGED
@@ -18,7 +18,7 @@ const sum = (nums) => nums.reduce((num, base) => base + num, 0);
|
|
18
18
|
* @class Document
|
19
19
|
*/
|
20
20
|
export default class Document extends Base {
|
21
|
-
constructor({ raw, parentDocument, ...args }) {
|
21
|
+
constructor({ raw, parentDocument, dataSourceContext, ...args }) {
|
22
22
|
assert(
|
23
23
|
"A graphql document `raw` must be passed",
|
24
24
|
raw?.__typename === "Document"
|
@@ -27,6 +27,7 @@ export default class Document extends Base {
|
|
27
27
|
super({ raw, ...args });
|
28
28
|
|
29
29
|
this.parentDocument = parentDocument;
|
30
|
+
this.dataSourceContext = dataSourceContext;
|
30
31
|
|
31
32
|
this.pushIntoStore();
|
32
33
|
|
@@ -83,6 +84,13 @@ export default class Document extends Base {
|
|
83
84
|
*/
|
84
85
|
fieldsets = [];
|
85
86
|
|
87
|
+
/**
|
88
|
+
* Context object for data sources
|
89
|
+
*
|
90
|
+
* @property {Object} dataSourceContext
|
91
|
+
*/
|
92
|
+
dataSourceContext = null;
|
93
|
+
|
86
94
|
/**
|
87
95
|
* The primary key of the document.
|
88
96
|
*
|
package/addon/lib/field.js
CHANGED
@@ -13,7 +13,7 @@ import { cached } from "tracked-toolbox";
|
|
13
13
|
|
14
14
|
import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
|
15
15
|
import saveDocumentDateAnswerMutation from "@projectcaluma/ember-form/gql/mutations/save-document-date-answer.graphql";
|
16
|
-
import
|
16
|
+
import saveDocumentFilesAnswerMutation from "@projectcaluma/ember-form/gql/mutations/save-document-files-answer.graphql";
|
17
17
|
import saveDocumentFloatAnswerMutation from "@projectcaluma/ember-form/gql/mutations/save-document-float-answer.graphql";
|
18
18
|
import saveDocumentIntegerAnswerMutation from "@projectcaluma/ember-form/gql/mutations/save-document-integer-answer.graphql";
|
19
19
|
import saveDocumentListAnswerMutation from "@projectcaluma/ember-form/gql/mutations/save-document-list-answer.graphql";
|
@@ -34,7 +34,7 @@ export const TYPE_MAP = {
|
|
34
34
|
DynamicChoiceQuestion: "StringAnswer",
|
35
35
|
TableQuestion: "TableAnswer",
|
36
36
|
FormQuestion: null,
|
37
|
-
|
37
|
+
FilesQuestion: "FilesAnswer",
|
38
38
|
StaticQuestion: null,
|
39
39
|
DateQuestion: "DateAnswer",
|
40
40
|
};
|
@@ -44,7 +44,7 @@ const MUTATION_MAP = {
|
|
44
44
|
IntegerAnswer: saveDocumentIntegerAnswerMutation,
|
45
45
|
StringAnswer: saveDocumentStringAnswerMutation,
|
46
46
|
ListAnswer: saveDocumentListAnswerMutation,
|
47
|
-
|
47
|
+
FilesAnswer: saveDocumentFilesAnswerMutation,
|
48
48
|
DateAnswer: saveDocumentDateAnswerMutation,
|
49
49
|
TableAnswer: saveDocumentTableAnswerMutation,
|
50
50
|
};
|
@@ -83,18 +83,14 @@ export default class Field extends Base {
|
|
83
83
|
_createQuestion() {
|
84
84
|
const owner = getOwner(this);
|
85
85
|
|
86
|
-
|
86
|
+
this.question =
|
87
87
|
this.calumaStore.find(`Question:${this.raw.question.slug}`) ||
|
88
88
|
new (owner.factoryFor("caluma-model:question").class)({
|
89
89
|
raw: this.raw.question,
|
90
90
|
owner,
|
91
91
|
});
|
92
92
|
|
93
|
-
|
94
|
-
question.loadDynamicOptions.perform();
|
95
|
-
}
|
96
|
-
|
97
|
-
this.question = question;
|
93
|
+
this.question.dataSourceContext = this.document.dataSourceContext;
|
98
94
|
}
|
99
95
|
|
100
96
|
_createAnswer() {
|
@@ -551,18 +547,24 @@ export default class Field extends Base {
|
|
551
547
|
|
552
548
|
const type = this.answer.raw.__typename;
|
553
549
|
|
550
|
+
const value = this.answer.serializedValue;
|
551
|
+
const input = {
|
552
|
+
question: this.question.slug,
|
553
|
+
document: this.document.uuid,
|
554
|
+
};
|
555
|
+
|
556
|
+
if (value !== null) {
|
557
|
+
input.value = value;
|
558
|
+
}
|
559
|
+
|
560
|
+
if (this.document.dataSourceContext) {
|
561
|
+
input.dataSourceContext = JSON.stringify(this.document.dataSourceContext);
|
562
|
+
}
|
563
|
+
|
554
564
|
const response = yield this.apollo.mutate(
|
555
565
|
{
|
556
566
|
mutation: MUTATION_MAP[type],
|
557
|
-
variables: {
|
558
|
-
input: {
|
559
|
-
question: this.question.slug,
|
560
|
-
document: this.document.uuid,
|
561
|
-
...(this.answer.serializedValue !== null
|
562
|
-
? { value: this.answer.serializedValue }
|
563
|
-
: {}),
|
564
|
-
},
|
565
|
-
},
|
567
|
+
variables: { input },
|
566
568
|
},
|
567
569
|
`saveDocument${type}.answer`
|
568
570
|
);
|
@@ -588,10 +590,10 @@ export default class Field extends Base {
|
|
588
590
|
@cached
|
589
591
|
get errors() {
|
590
592
|
return this._errors.map(({ type, context, value }) => {
|
591
|
-
return this.intl.t(
|
592
|
-
|
593
|
-
|
594
|
-
);
|
593
|
+
return this.intl.t(`caluma.form.validation.${type}`, {
|
594
|
+
...context,
|
595
|
+
value,
|
596
|
+
});
|
595
597
|
});
|
596
598
|
}
|
597
599
|
|
@@ -748,10 +750,7 @@ export default class Field extends Base {
|
|
748
750
|
* @private
|
749
751
|
*/
|
750
752
|
_validateChoiceQuestion() {
|
751
|
-
return
|
752
|
-
allowBlank: true,
|
753
|
-
in: (this.options || []).map(({ slug }) => slug),
|
754
|
-
});
|
753
|
+
return this._validateOption(this.answer.value, true);
|
755
754
|
}
|
756
755
|
|
757
756
|
/**
|
@@ -763,15 +762,9 @@ export default class Field extends Base {
|
|
763
762
|
* @private
|
764
763
|
*/
|
765
764
|
_validateMultipleChoiceQuestion() {
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
}
|
770
|
-
return value.map((value) =>
|
771
|
-
validate("inclusion", value, {
|
772
|
-
in: (this.options || []).map(({ slug }) => slug),
|
773
|
-
})
|
774
|
-
);
|
765
|
+
return this.answer.value
|
766
|
+
? this.answer.value.map((value) => this._validateOption(value))
|
767
|
+
: true;
|
775
768
|
}
|
776
769
|
|
777
770
|
/**
|
@@ -783,11 +776,9 @@ export default class Field extends Base {
|
|
783
776
|
* @private
|
784
777
|
*/
|
785
778
|
async _validateDynamicChoiceQuestion() {
|
786
|
-
await this.question.
|
779
|
+
await this.question.dynamicOptions;
|
787
780
|
|
788
|
-
return
|
789
|
-
in: (this.options || []).map(({ slug }) => slug),
|
790
|
-
});
|
781
|
+
return this._validateOption(this.answer.value, true);
|
791
782
|
}
|
792
783
|
|
793
784
|
/**
|
@@ -805,23 +796,35 @@ export default class Field extends Base {
|
|
805
796
|
return true;
|
806
797
|
}
|
807
798
|
|
808
|
-
await this.question.
|
799
|
+
await this.question.dynamicOptions;
|
809
800
|
|
810
|
-
return
|
811
|
-
|
812
|
-
|
813
|
-
|
801
|
+
return this.answer.value
|
802
|
+
? value.map((value) => this._validateOption(value))
|
803
|
+
: true;
|
804
|
+
}
|
805
|
+
|
806
|
+
_validateOption(value, allowBlank = false) {
|
807
|
+
const label = Array.isArray(this.selected)
|
808
|
+
? this.selected.find((selected) => selected.slug === value)?.label
|
809
|
+
: this.selected?.label;
|
810
|
+
|
811
|
+
return validate("inclusion", value, {
|
812
|
+
in: (this.options || [])
|
813
|
+
.filter((option) => !option.disabled)
|
814
|
+
.map(({ slug }) => slug),
|
815
|
+
allowBlank,
|
816
|
+
label: label ?? value,
|
814
817
|
});
|
815
818
|
}
|
816
819
|
|
817
820
|
/**
|
818
821
|
* Dummy method for the validation of file uploads.
|
819
822
|
*
|
820
|
-
* @method
|
823
|
+
* @method _validateFilesQuestion
|
821
824
|
* @return {Boolean} Always returns true
|
822
825
|
* @private
|
823
826
|
*/
|
824
|
-
|
827
|
+
_validateFilesQuestion() {
|
825
828
|
return true;
|
826
829
|
}
|
827
830
|
|
package/addon/lib/navigation.js
CHANGED
@@ -232,7 +232,9 @@ export class NavigationItem extends Base {
|
|
232
232
|
@cached
|
233
233
|
get visibleFields() {
|
234
234
|
return this.fieldset.fields.filter(
|
235
|
-
(f) =>
|
235
|
+
(f) =>
|
236
|
+
!["FormQuestion", "StaticQuestion"].includes(f.questionType) &&
|
237
|
+
!f.hidden
|
236
238
|
);
|
237
239
|
}
|
238
240
|
|
package/addon/lib/question.js
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
import { assert } from "@ember/debug";
|
2
2
|
import { camelize } from "@ember/string";
|
3
3
|
import { queryManager } from "ember-apollo-client";
|
4
|
-
import { dropTask
|
4
|
+
import { dropTask } from "ember-concurrency";
|
5
|
+
import { trackedTask } from "ember-resources/util/ember-concurrency";
|
5
6
|
import { cached } from "tracked-toolbox";
|
6
7
|
|
7
8
|
import getDynamicOptions from "@projectcaluma/ember-form/gql/queries/dynamic-options.graphql";
|
@@ -65,19 +66,31 @@ export default class Question extends Base {
|
|
65
66
|
{
|
66
67
|
query: getDynamicOptions,
|
67
68
|
fetchPolicy: "network-only",
|
68
|
-
variables: {
|
69
|
+
variables: {
|
70
|
+
question: this.slug,
|
71
|
+
context: this.dataSourceContext
|
72
|
+
? JSON.stringify(this.dataSourceContext)
|
73
|
+
: null,
|
74
|
+
},
|
69
75
|
},
|
70
76
|
"allQuestions.edges"
|
71
77
|
);
|
72
78
|
|
73
79
|
return (
|
74
|
-
question.node.dynamicChoiceOptions
|
80
|
+
question.node.dynamicChoiceOptions ??
|
75
81
|
question.node.dynamicMultipleChoiceOptions
|
76
82
|
);
|
77
83
|
}
|
78
84
|
|
79
|
-
|
80
|
-
|
85
|
+
dynamicOptions = trackedTask(this, this.loadDynamicOptions, () => []);
|
86
|
+
|
87
|
+
get dynamicChoiceOptions() {
|
88
|
+
return this.dynamicOptions.value ?? [];
|
89
|
+
}
|
90
|
+
|
91
|
+
get dynamicMultipleChoiceOptions() {
|
92
|
+
return this.dynamicOptions.value ?? [];
|
93
|
+
}
|
81
94
|
|
82
95
|
/**
|
83
96
|
* Whether the question is a single choice question
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { registerDestructor } from "@ember/destroyable";
|
2
|
+
import { inject as service } from "@ember/service";
|
3
|
+
import AutoresizeModifier from "ember-autoresize-modifier/modifiers/autoresize";
|
4
|
+
|
5
|
+
export default class CustomAutoresizeModifier extends AutoresizeModifier {
|
6
|
+
@service inViewport;
|
7
|
+
|
8
|
+
modify(...args) {
|
9
|
+
super.modify(...args);
|
10
|
+
|
11
|
+
this.inViewport.watchElement(this.el).onEnter(this.resize);
|
12
|
+
registerDestructor(this, () => this.inViewport.stopWatching(this.el));
|
13
|
+
}
|
14
|
+
}
|
@@ -43,6 +43,8 @@ export default class CalumaStoreService extends Service {
|
|
43
43
|
clear() {
|
44
44
|
this._store.forEach((obj) => obj.destroy());
|
45
45
|
|
46
|
+
// `this._store` is not an ember array but a native map
|
47
|
+
// eslint-disable-next-line ember/no-array-prototype-extensions
|
46
48
|
this._store.clear();
|
47
49
|
}
|
48
50
|
}
|
@@ -1 +1 @@
|
|
1
|
-
export { default } from "@projectcaluma/ember-form/components/cf-field/
|
1
|
+
export { default } from "@projectcaluma/ember-form/components/cf-field/hint";
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from "@projectcaluma/ember-form/components/cf-field/input/files";
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from "@projectcaluma/ember-form/helpers/format-graphql-error";
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from "@projectcaluma/ember-form/modifiers/autoresize";
|
@@ -3,21 +3,11 @@
|
|
3
3
|
@import "../cf-field";
|
4
4
|
@import "../cf-navigation";
|
5
5
|
|
6
|
-
@import "../
|
7
|
-
|
8
|
-
.cf-checkbox_label {
|
9
|
-
display: block;
|
10
|
-
position: relative;
|
11
|
-
padding-left: 26px;
|
6
|
+
@import "../flatpickr";
|
12
7
|
|
13
|
-
|
14
|
-
position: absolute;
|
15
|
-
top: 0.25em;
|
16
|
-
left: 0;
|
17
|
-
margin: 0;
|
18
|
-
}
|
8
|
+
@import "../uikit-overwrites";
|
19
9
|
|
20
|
-
|
21
|
-
|
22
|
-
|
10
|
+
.table-controls > .uk-icon {
|
11
|
+
min-height: 20px;
|
12
|
+
min-width: 20px;
|
23
13
|
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
$flatpickr-today-color: $global-warning-background;
|
2
|
+
$flatpickr-selected-color: $global-primary-background;
|
3
|
+
|
4
|
+
span.flatpickr-day {
|
5
|
+
font-weight: $base-body-font-weight;
|
6
|
+
|
7
|
+
&.today:not(.selected) {
|
8
|
+
border-bottom-color: $flatpickr-today-color;
|
9
|
+
|
10
|
+
&:hover {
|
11
|
+
background: $flatpickr-today-color;
|
12
|
+
border-color: $flatpickr-today-color;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
&.selected {
|
17
|
+
background: $flatpickr-selected-color;
|
18
|
+
border-color: $flatpickr-selected-color;
|
19
|
+
font-weight: 700;
|
20
|
+
|
21
|
+
&:hover {
|
22
|
+
background: darken($flatpickr-selected-color, 10%);
|
23
|
+
border-color: darken($flatpickr-selected-color, 10%);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
.flatpickr-months {
|
29
|
+
.flatpickr-prev-month:hover,
|
30
|
+
.flatpickr-next-month:hover {
|
31
|
+
color: $flatpickr-today-color;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
span.flatpickr-weekday {
|
36
|
+
font-size: $global-small-font-size;
|
37
|
+
font-weight: $base-body-font-weight;
|
38
|
+
}
|
39
|
+
|
40
|
+
.flatpickr-current-month {
|
41
|
+
font-size: $global-font-size;
|
42
|
+
font-weight: $base-body-font-weight;
|
43
|
+
|
44
|
+
.flatpickr-monthDropdown-months {
|
45
|
+
font-weight: $base-body-font-weight;
|
46
|
+
}
|
47
|
+
}
|
@@ -10,7 +10,7 @@ module.exports = {
|
|
10
10
|
{ name: "ember-cli-showdown" },
|
11
11
|
{ name: "ember-composable-helpers" },
|
12
12
|
{ name: "ember-math-helpers" },
|
13
|
-
{ name: "ember-
|
13
|
+
{ name: "ember-flatpickr" },
|
14
14
|
{ name: "ember-power-select" },
|
15
15
|
{ name: "ember-autoresize-modifier" },
|
16
16
|
],
|
package/index.js
CHANGED
@@ -2,4 +2,16 @@
|
|
2
2
|
|
3
3
|
module.exports = {
|
4
4
|
name: require("./package").name,
|
5
|
+
|
6
|
+
included(...args) {
|
7
|
+
const app = this._findHost(this);
|
8
|
+
|
9
|
+
app.options.flatpickr = {
|
10
|
+
locales: ["de", "fr"],
|
11
|
+
theme: "airbnb",
|
12
|
+
...(app.options.flatpickr ?? {}),
|
13
|
+
};
|
14
|
+
|
15
|
+
this._super.included.apply(this, args);
|
16
|
+
},
|
5
17
|
};
|