@projectcaluma/ember-form 11.0.0-beta.3 → 11.0.0-beta.31
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +209 -0
- package/addon/components/cf-content.hbs +38 -37
- package/addon/components/cf-content.js +2 -2
- package/addon/components/cf-field/hint.hbs +5 -0
- 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 +8 -4
- 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 +12 -25
- package/addon/components/cf-field/input/date.js +19 -11
- 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/static.hbs +1 -1
- package/addon/components/cf-field/input/table.hbs +20 -19
- 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 +22 -7
- package/addon/components/cf-field-value.js +12 -36
- package/addon/components/cf-field.hbs +42 -9
- package/addon/components/cf-field.js +41 -17
- package/addon/components/cf-form-wrapper.hbs +4 -1
- package/addon/components/cf-form.hbs +6 -1
- package/addon/components/document-validity.js +16 -1
- package/addon/gql/fragments/field.graphql +32 -2
- 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 +1 -1
- 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/field.js +80 -51
- package/addon/lib/navigation.js +3 -1
- package/addon/lib/question.js +12 -4
- 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 +45 -35
- 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/addon/instance-initializers/setup-pikaday-i18n.js +0 -35
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";
|
@@ -71,13 +72,20 @@ export default class Question extends Base {
|
|
71
72
|
);
|
72
73
|
|
73
74
|
return (
|
74
|
-
question.node.dynamicChoiceOptions
|
75
|
+
question.node.dynamicChoiceOptions ??
|
75
76
|
question.node.dynamicMultipleChoiceOptions
|
76
77
|
);
|
77
78
|
}
|
78
79
|
|
79
|
-
|
80
|
-
|
80
|
+
dynamicOptions = trackedTask(this, this.loadDynamicOptions, () => []);
|
81
|
+
|
82
|
+
get dynamicChoiceOptions() {
|
83
|
+
return this.dynamicOptions.value ?? [];
|
84
|
+
}
|
85
|
+
|
86
|
+
get dynamicMultipleChoiceOptions() {
|
87
|
+
return this.dynamicOptions.value ?? [];
|
88
|
+
}
|
81
89
|
|
82
90
|
/**
|
83
91
|
* 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.element).onEnter(this.resize);
|
12
|
+
registerDestructor(this, () => this.inViewport.stopWatching(this.element));
|
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
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@projectcaluma/ember-form",
|
3
|
-
"version": "11.0.0-beta.
|
3
|
+
"version": "11.0.0-beta.31",
|
4
4
|
"description": "Ember addon for rendering Caluma forms.",
|
5
5
|
"keywords": [
|
6
6
|
"ember-addon"
|
@@ -9,70 +9,80 @@
|
|
9
9
|
"homepage": "https://docs.caluma.io/ember-caluma",
|
10
10
|
"repository": "github:projectcaluma/ember-caluma",
|
11
11
|
"scripts": {
|
12
|
-
"test": "npm-run-all test
|
12
|
+
"test": "npm-run-all --print-name \"lint\" \"test:*\"",
|
13
13
|
"test:ember": "ember test",
|
14
14
|
"test:ember-compatibility": "ember try:each"
|
15
15
|
},
|
16
16
|
"dependencies": {
|
17
|
-
"@
|
18
|
-
"@
|
19
|
-
"@
|
20
|
-
"
|
21
|
-
"
|
22
|
-
"ember-
|
17
|
+
"@ember/string": "^3.0.0",
|
18
|
+
"@embroider/macros": "^1.9.0",
|
19
|
+
"@embroider/util": "^1.9.0",
|
20
|
+
"@glimmer/component": "^1.1.2",
|
21
|
+
"@glimmer/tracking": "^1.1.2",
|
22
|
+
"@projectcaluma/ember-core": "^11.0.0-beta.31",
|
23
|
+
"ember-apollo-client": "~4.0.2",
|
24
|
+
"ember-auto-import": "^2.4.3",
|
25
|
+
"ember-autoresize-modifier": "^0.6.0",
|
23
26
|
"ember-cli-babel": "^7.26.11",
|
24
|
-
"ember-cli-htmlbars": "^6.
|
27
|
+
"ember-cli-htmlbars": "^6.1.1",
|
25
28
|
"ember-cli-showdown": "^6.0.1",
|
26
29
|
"ember-composable-helpers": "^5.0.0",
|
27
|
-
"ember-
|
28
|
-
"ember-
|
30
|
+
"ember-concurrency": "^2.3.7",
|
31
|
+
"ember-fetch": "^8.1.2",
|
32
|
+
"ember-flatpickr": "^3.2.3",
|
33
|
+
"ember-in-viewport": "^4.0.2",
|
29
34
|
"ember-intl": "^5.7.2",
|
30
|
-
"ember-math-helpers": "^2.18.
|
31
|
-
"ember-
|
32
|
-
"ember-
|
33
|
-
"ember-
|
34
|
-
"ember-
|
35
|
-
"ember-validators": "^4.0.1",
|
35
|
+
"ember-math-helpers": "^2.18.2",
|
36
|
+
"ember-power-select": "^6.0.1",
|
37
|
+
"ember-resources": "^5.4.0",
|
38
|
+
"ember-uikit": "^6.1.0",
|
39
|
+
"ember-validators": "^4.1.2",
|
36
40
|
"graphql": "^15.8.0",
|
37
41
|
"jexl": "^2.3.0",
|
38
42
|
"lodash.isequal": "^4.5.0",
|
39
|
-
"
|
43
|
+
"luxon": "^3.0.4",
|
40
44
|
"tracked-toolbox": "^1.2.3"
|
41
45
|
},
|
42
46
|
"devDependencies": {
|
43
47
|
"@ember/optional-features": "2.0.0",
|
44
|
-
"@ember/test-helpers": "2.
|
45
|
-
"@embroider/test-setup": "1.
|
46
|
-
"@faker-js/faker": "6.0
|
47
|
-
"@projectcaluma/ember-testing": "
|
48
|
-
"@projectcaluma/ember-workflow": "11.0.0-beta.
|
48
|
+
"@ember/test-helpers": "2.7.0",
|
49
|
+
"@embroider/test-setup": "1.8.3",
|
50
|
+
"@faker-js/faker": "7.6.0",
|
51
|
+
"@projectcaluma/ember-testing": "11.0.0-beta.31",
|
52
|
+
"@projectcaluma/ember-workflow": "^11.0.0-beta.31",
|
49
53
|
"broccoli-asset-rev": "3.0.0",
|
50
|
-
"ember-cli": "
|
54
|
+
"ember-cli": "4.8.0",
|
51
55
|
"ember-cli-code-coverage": "1.0.3",
|
52
|
-
"ember-cli-dependency-checker": "3.
|
56
|
+
"ember-cli-dependency-checker": "3.3.1",
|
53
57
|
"ember-cli-inject-live-reload": "2.1.0",
|
54
|
-
"ember-cli-mirage": "
|
58
|
+
"ember-cli-mirage": "3.0.0-alpha.3",
|
55
59
|
"ember-cli-sri": "2.1.1",
|
56
60
|
"ember-cli-terser": "4.0.2",
|
57
61
|
"ember-disable-prototype-extensions": "1.1.3",
|
58
|
-
"ember-export-application-global": "2.0.1",
|
59
62
|
"ember-load-initializers": "2.1.2",
|
60
|
-
"ember-
|
61
|
-
"ember-qunit": "5.1.5",
|
63
|
+
"ember-qunit": "6.0.0",
|
62
64
|
"ember-resolver": "8.0.3",
|
63
|
-
"ember-source": "
|
65
|
+
"ember-source": "4.8.0",
|
64
66
|
"ember-source-channel-url": "3.0.0",
|
65
67
|
"ember-try": "2.0.0",
|
66
68
|
"loader.js": "4.7.0",
|
67
|
-
"miragejs": "0.1.
|
69
|
+
"miragejs": "0.1.45",
|
68
70
|
"npm-run-all": "4.1.5",
|
69
|
-
"qunit": "2.
|
71
|
+
"qunit": "2.19.2",
|
70
72
|
"qunit-dom": "2.0.0",
|
71
|
-
"uuid": "
|
72
|
-
"webpack": "5.
|
73
|
+
"uuid": "9.0.0",
|
74
|
+
"webpack": "5.74.0"
|
75
|
+
},
|
76
|
+
"peerDependencies": {
|
77
|
+
"@projectcaluma/ember-workflow": "^11.0.0-beta.31"
|
78
|
+
},
|
79
|
+
"peerDependenciesMeta": {
|
80
|
+
"@projectcaluma/ember-workflow": {
|
81
|
+
"optional": true
|
82
|
+
}
|
73
83
|
},
|
74
84
|
"engines": {
|
75
|
-
"node": "
|
85
|
+
"node": "14.* || 16.* || >= 18"
|
76
86
|
},
|
77
87
|
"ember": {
|
78
88
|
"edition": "octane"
|
package/translations/de.yaml
CHANGED
@@ -12,6 +12,10 @@ caluma:
|
|
12
12
|
optionNotAvailable: "Diese Option ist nicht mehr verfügbar"
|
13
13
|
info: "Mehr Informationen"
|
14
14
|
|
15
|
+
error:
|
16
|
+
intro: "Oh nein, auf unserer Seite ist etwas schief gelaufen. Ihre Antwort konnte nicht gespeichert werden."
|
17
|
+
details: "Technische Details:"
|
18
|
+
|
15
19
|
navigation:
|
16
20
|
next: "Weiter"
|
17
21
|
previous: "Zurück"
|
@@ -34,7 +38,6 @@ caluma:
|
|
34
38
|
options-empty: "Keine Optionen vorhanden"
|
35
39
|
search-placeholder: "Hier tippen um zu suchen"
|
36
40
|
search-empty: "Keine Optionen gefunden"
|
37
|
-
null: "Keine Auswahl"
|
38
41
|
|
39
42
|
validation:
|
40
43
|
blank: "Dieses Feld darf nicht leer gelassen werden"
|
@@ -43,11 +46,8 @@ caluma:
|
|
43
46
|
greaterThanOrEqualTo: "Die Eingabe in diesem Feld darf nicht kleiner als {gte} sein"
|
44
47
|
lessThanOrEqualTo: "Die Eingabe in diesem Feld darf nicht grösser als {lte} sein"
|
45
48
|
notAnInteger: "Bitte geben Sie eine ganze Zahl ein"
|
46
|
-
inclusion: "
|
49
|
+
inclusion: '"{label}" ist kein gültiger Wert für dieses Feld'
|
50
|
+
deleteFailed: "Beim Löschen ist ein Fehler aufgetreten."
|
47
51
|
uploadFailed: "Beim Hochladen ist ein Fehler aufgetreten."
|
48
52
|
format: "{errorMsg}"
|
49
53
|
table: "Mindestens eine Zeile der Tabelle wurde nicht korrekt ausgefüllt"
|
50
|
-
|
51
|
-
pikaday:
|
52
|
-
month-previous: "Vorheriger Monat"
|
53
|
-
month-next: "Nächster Monat"
|
package/translations/en.yaml
CHANGED
@@ -12,6 +12,10 @@ caluma:
|
|
12
12
|
optionNotAvailable: "This option is not available anymore"
|
13
13
|
info: "More information"
|
14
14
|
|
15
|
+
error:
|
16
|
+
intro: "Oh no, something went wrong on our side. Your answer could not be saved."
|
17
|
+
details: "Technical details:"
|
18
|
+
|
15
19
|
navigation:
|
16
20
|
next: "Next"
|
17
21
|
previous: "Previous"
|
@@ -34,7 +38,6 @@ caluma:
|
|
34
38
|
options-empty: "No options available"
|
35
39
|
search-placeholder: "Type here to search options"
|
36
40
|
search-empty: "Search didn't match any options"
|
37
|
-
null: "No selection"
|
38
41
|
|
39
42
|
validation:
|
40
43
|
blank: "This field can't be blank"
|
@@ -43,11 +46,8 @@ caluma:
|
|
43
46
|
greaterThanOrEqualTo: "The value of this field must be greater than or equal to {gte}"
|
44
47
|
lessThanOrEqualTo: "The value of this field must be less than or equal to {lte}"
|
45
48
|
notAnInteger: "The value of this field must be an integer"
|
46
|
-
inclusion: "
|
49
|
+
inclusion: '"{label}" is not a valid value for this field'
|
50
|
+
deleteFailed: "An error occured during deletion."
|
47
51
|
uploadFailed: "An error occured during upload."
|
48
52
|
format: "{errorMsg}"
|
49
53
|
table: "At least one row of the table was not filled in correctly"
|
50
|
-
|
51
|
-
pikaday:
|
52
|
-
month-previous: "Previous month"
|
53
|
-
month-next: "Next month"
|
package/translations/fr.yaml
CHANGED
@@ -12,6 +12,10 @@ caluma:
|
|
12
12
|
optionNotAvailable: "Cette option n'est plus disponible"
|
13
13
|
info: "Plus d'informations"
|
14
14
|
|
15
|
+
error:
|
16
|
+
intro: "Oh non, quelque chose a mal tourné de notre côté. Votre réponse n'a pas pu être sauvegardée."
|
17
|
+
details: "Détails techniques :"
|
18
|
+
|
15
19
|
navigation:
|
16
20
|
next: "suivante"
|
17
21
|
previous: "précédente"
|
@@ -34,7 +38,6 @@ caluma:
|
|
34
38
|
options-empty: "Pas d'options disponibles"
|
35
39
|
search-placeholder: "Tapez ici pour rechercher"
|
36
40
|
search-empty: "Pas d'options trouvées"
|
37
|
-
null: "Aucune sélection"
|
38
41
|
|
39
42
|
validation:
|
40
43
|
blank: "Ce champ ne doit pas être laissé vide"
|
@@ -43,11 +46,8 @@ caluma:
|
|
43
46
|
greaterThanOrEqualTo: "La valeur indiquée dans ce champ ne doit pas être inférieure à {gte} "
|
44
47
|
lessThanOrEqualTo: "L'entrée dans ce champ ne doit pas être supérieure à {lte} "
|
45
48
|
notAnInteger: "Veuillez entrer un nombre entier"
|
46
|
-
inclusion: "
|
49
|
+
inclusion: '"{label}" n''est pas une valeur valide pour ce champ'
|
50
|
+
deleteFailed: "Une erreur est survenue lors de la suppression."
|
47
51
|
uploadFailed: "Une erreur s'est produite pendant le téléchargement."
|
48
52
|
format: "{errorMsg}"
|
49
53
|
table: "Au moins une ligne du tableau n'a pas été remplie correctement"
|
50
|
-
|
51
|
-
pikaday:
|
52
|
-
month-previous: "Mois précédent"
|
53
|
-
month-next: "Mois suivant"
|
@@ -1,32 +0,0 @@
|
|
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
|
-
{{on "change" this.save}}
|
10
|
-
/>
|
11
|
-
<UkButton @color="primary" @disabled={{@disabled}}>
|
12
|
-
{{t "caluma.form.selectFile"}}
|
13
|
-
</UkButton>
|
14
|
-
</div>
|
15
|
-
{{#if (and this.downloadUrl this.downloadName)}}
|
16
|
-
<div>
|
17
|
-
<UkButton
|
18
|
-
data-test-download-link
|
19
|
-
@color="link"
|
20
|
-
@onClick={{this.download}}
|
21
|
-
>
|
22
|
-
{{this.downloadName}}
|
23
|
-
</UkButton>
|
24
|
-
<UkIcon
|
25
|
-
class="uk-icon-button uk-margin-small-left"
|
26
|
-
role="button"
|
27
|
-
@icon="trash"
|
28
|
-
{{on "click" this.delete}}
|
29
|
-
/>
|
30
|
-
</div>
|
31
|
-
{{/if}}
|
32
|
-
</div>
|
@@ -1,89 +0,0 @@
|
|
1
|
-
import { action } from "@ember/object";
|
2
|
-
import { inject as service } from "@ember/service";
|
3
|
-
import Component from "@glimmer/component";
|
4
|
-
import { queryManager } from "ember-apollo-client";
|
5
|
-
import fetch from "fetch";
|
6
|
-
|
7
|
-
import removeAnswerMutation from "@projectcaluma/ember-form/gql/mutations/remove-answer.graphql";
|
8
|
-
import getFileAnswerInfoQuery from "@projectcaluma/ember-form/gql/queries/fileanswer-info.graphql";
|
9
|
-
|
10
|
-
export default class CfFieldInputFileComponent extends Component {
|
11
|
-
@service intl;
|
12
|
-
|
13
|
-
@queryManager apollo;
|
14
|
-
|
15
|
-
get downloadUrl() {
|
16
|
-
return this.args.field?.answer?.value?.downloadUrl;
|
17
|
-
}
|
18
|
-
|
19
|
-
get downloadName() {
|
20
|
-
return this.args.field?.answer?.value?.name;
|
21
|
-
}
|
22
|
-
|
23
|
-
@action
|
24
|
-
async download() {
|
25
|
-
const { downloadUrl } = await this.apollo.watchQuery(
|
26
|
-
{
|
27
|
-
query: getFileAnswerInfoQuery,
|
28
|
-
variables: { id: this.args.field.answer.raw.id },
|
29
|
-
fetchPolicy: "cache-and-network",
|
30
|
-
},
|
31
|
-
"node.fileValue"
|
32
|
-
);
|
33
|
-
|
34
|
-
if (downloadUrl) {
|
35
|
-
window.open(downloadUrl, "_blank");
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
@action
|
40
|
-
async save({ target }) {
|
41
|
-
const file = target.files[0];
|
42
|
-
|
43
|
-
if (!file) {
|
44
|
-
return;
|
45
|
-
}
|
46
|
-
|
47
|
-
const { fileValue } = await this.args.onSave(file.name);
|
48
|
-
|
49
|
-
try {
|
50
|
-
const response = await fetch(fileValue.uploadUrl, {
|
51
|
-
method: "PUT",
|
52
|
-
body: file,
|
53
|
-
});
|
54
|
-
|
55
|
-
if (!response.ok) {
|
56
|
-
throw new Error();
|
57
|
-
}
|
58
|
-
|
59
|
-
this.args.field.answer.value = {
|
60
|
-
name: file.name,
|
61
|
-
downloadUrl: fileValue.downloadUrl,
|
62
|
-
};
|
63
|
-
} catch (error) {
|
64
|
-
await this.args.onSave(null);
|
65
|
-
this.args.field._errors = [{ type: "uploadFailed" }];
|
66
|
-
} finally {
|
67
|
-
// eslint-disable-next-line require-atomic-updates
|
68
|
-
target.value = "";
|
69
|
-
}
|
70
|
-
}
|
71
|
-
|
72
|
-
@action
|
73
|
-
async delete() {
|
74
|
-
try {
|
75
|
-
await this.apollo.mutate({
|
76
|
-
mutation: removeAnswerMutation,
|
77
|
-
variables: {
|
78
|
-
input: {
|
79
|
-
answer: this.args.field.answer.uuid,
|
80
|
-
},
|
81
|
-
},
|
82
|
-
});
|
83
|
-
|
84
|
-
await this.args.onSave(null);
|
85
|
-
} catch (error) {
|
86
|
-
this.args.field._errors = [{ type: "deleteFailed" }];
|
87
|
-
}
|
88
|
-
}
|
89
|
-
}
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import EmberObject from "@ember/object";
|
2
|
-
import { inject as service } from "@ember/service";
|
3
|
-
import moment from "moment";
|
4
|
-
|
5
|
-
class Translations extends EmberObject {
|
6
|
-
@service intl;
|
7
|
-
|
8
|
-
get previousMonth() {
|
9
|
-
return this.intl.t("caluma.form.pikaday.month-previous");
|
10
|
-
}
|
11
|
-
|
12
|
-
get nextMonth() {
|
13
|
-
return this.intl.t("caluma.form.pikaday.month-next");
|
14
|
-
}
|
15
|
-
|
16
|
-
months = moment.localeData().months();
|
17
|
-
weekdays = moment.localeData().weekdays();
|
18
|
-
weekdaysShort = moment.localeData().weekdaysShort();
|
19
|
-
}
|
20
|
-
|
21
|
-
export function initialize(applicationInstance) {
|
22
|
-
applicationInstance.register("pikaday-i18n:main", Translations, {
|
23
|
-
singleton: true,
|
24
|
-
});
|
25
|
-
applicationInstance.inject(
|
26
|
-
"component:pikaday-input",
|
27
|
-
"i18n",
|
28
|
-
"pikaday-i18n:main"
|
29
|
-
);
|
30
|
-
}
|
31
|
-
|
32
|
-
export default {
|
33
|
-
name: "setup-pikaday-i18n",
|
34
|
-
initialize,
|
35
|
-
};
|