@projectcaluma/ember-form 11.0.0-beta.8 → 11.0.0-beta.9
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 +15 -0
- package/addon/components/cf-field/input/action-button.hbs +18 -19
- 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.js +2 -2
- package/addon/components/cf-field-value.hbs +22 -7
- package/addon/components/cf-field-value.js +8 -33
- package/addon/components/cf-field.hbs +5 -1
- package/addon/components/cf-field.js +1 -5
- package/package.json +7 -7
- package/addon/instance-initializers/setup-pikaday-i18n.js +0 -35
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
# [@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
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* **action-button:** only hide action button visually if disabled ([e292f09](https://github.com/projectcaluma/ember-caluma/commit/e292f093c33efd0b99a73674f8f83de5f496bf40))
|
7
|
+
* **deps:** remove moment altogether and update ember-pikday ([b2f7fa2](https://github.com/projectcaluma/ember-caluma/commit/b2f7fa28fa076897addd36e5964c926c671508ff))
|
8
|
+
* **form:** change file download actions to query and network-only ([aa4458e](https://github.com/projectcaluma/ember-caluma/commit/aa4458e944263f0f00ba1684a4f7bbfa83d2efea))
|
9
|
+
|
10
|
+
|
11
|
+
### BREAKING CHANGES
|
12
|
+
|
13
|
+
* **deps:** The host app now needs to opt-in to use the default
|
14
|
+
pikaday styles: https://github.com/adopted-ember-addons/ember-pikaday#styles
|
15
|
+
|
1
16
|
# [@projectcaluma/ember-form-v11.0.0-beta.8](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.7...@projectcaluma/ember-form-v11.0.0-beta.8) (2022-02-03)
|
2
17
|
|
3
18
|
|
@@ -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>
|
@@ -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
|
}
|
@@ -22,11 +22,11 @@ export default class CfFieldInputFileComponent extends Component {
|
|
22
22
|
|
23
23
|
@action
|
24
24
|
async download() {
|
25
|
-
const { downloadUrl } = await this.apollo.
|
25
|
+
const { downloadUrl } = await this.apollo.query(
|
26
26
|
{
|
27
27
|
query: getFileAnswerInfoQuery,
|
28
28
|
variables: { id: this.args.field.answer.raw.id },
|
29
|
-
fetchPolicy: "
|
29
|
+
fetchPolicy: "network-only",
|
30
30
|
},
|
31
31
|
"node.fileValue"
|
32
32
|
);
|
@@ -1,9 +1,24 @@
|
|
1
|
-
{{#if
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
{{#if (has-question-type @field.question "choice" "dynamic-choice")}}
|
2
|
+
{{@field.selected.label}}
|
3
|
+
{{else if (has-question-type
|
4
|
+
@field.question "multiple-choice" "multiple-dynamic-choice"
|
5
|
+
)}}
|
6
|
+
{{#each @field.selected as |opt i|}}{{if (gt i 0) ", "}}{{opt.label}}{{/each}}
|
7
|
+
{{else if (has-question-type @field.question "date")}}
|
8
|
+
{{format-date
|
9
|
+
@field.answer.value
|
10
|
+
day="2-digit"
|
11
|
+
month="2-digit"
|
12
|
+
year="numeric"
|
13
|
+
}}
|
14
|
+
{{else if (has-question-type @field.question "file")}}
|
15
|
+
{{#if @field.answer.value}}
|
16
|
+
<UkButton
|
17
|
+
@color="link"
|
18
|
+
@label={{@field.answer.value.name}}
|
19
|
+
@onClick={{fn this.download @field.answer.raw.id}}
|
20
|
+
/>
|
21
|
+
{{/if}}
|
7
22
|
{{else}}
|
8
|
-
{{
|
23
|
+
{{@field.answer.value}}
|
9
24
|
{{/if}}
|
@@ -1,50 +1,25 @@
|
|
1
1
|
import { action } from "@ember/object";
|
2
2
|
import Component from "@glimmer/component";
|
3
3
|
import { queryManager } from "ember-apollo-client";
|
4
|
-
import moment from "moment";
|
5
4
|
|
6
5
|
import getFileAnswerInfoQuery from "@projectcaluma/ember-form/gql/queries/fileanswer-info.graphql";
|
7
6
|
|
8
7
|
export default class CfFieldValueComponent extends Component {
|
9
8
|
@queryManager apollo;
|
10
9
|
|
11
|
-
get value() {
|
12
|
-
const field = this.args.field;
|
13
|
-
|
14
|
-
switch (field.questionType) {
|
15
|
-
case "ChoiceQuestion":
|
16
|
-
case "DynamicChoiceQuestion": {
|
17
|
-
return field.selected;
|
18
|
-
}
|
19
|
-
case "MultipleChoiceQuestion":
|
20
|
-
case "DynamicMultipleChoiceQuestion": {
|
21
|
-
return { label: field.selected.map(({ label }) => label).join(", ") };
|
22
|
-
}
|
23
|
-
case "FileQuestion": {
|
24
|
-
const answerValue = field.answer.value;
|
25
|
-
return {
|
26
|
-
fileAnswerId: answerValue && field.answer.raw.id,
|
27
|
-
label: answerValue?.name,
|
28
|
-
};
|
29
|
-
}
|
30
|
-
case "DateQuestion": {
|
31
|
-
return {
|
32
|
-
label: field.answer.value && moment(field.answer.value).format("L"),
|
33
|
-
};
|
34
|
-
}
|
35
|
-
|
36
|
-
default:
|
37
|
-
return { label: field.answer.value };
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
10
|
@action
|
42
11
|
async download(id) {
|
43
12
|
const { downloadUrl } = await this.apollo.query(
|
44
|
-
{
|
13
|
+
{
|
14
|
+
query: getFileAnswerInfoQuery,
|
15
|
+
variables: { id },
|
16
|
+
fetchPolicy: "network-only",
|
17
|
+
},
|
45
18
|
"node.fileValue"
|
46
19
|
);
|
47
20
|
|
48
|
-
|
21
|
+
if (downloadUrl) {
|
22
|
+
window.open(downloadUrl, "_blank");
|
23
|
+
}
|
49
24
|
}
|
50
25
|
}
|
@@ -31,11 +31,7 @@ export default class CfFieldComponent extends Component {
|
|
31
31
|
get visible() {
|
32
32
|
return (
|
33
33
|
!this.args.field?.hidden &&
|
34
|
-
!hasQuestionType(this.args.field?.question, "form")
|
35
|
-
!(
|
36
|
-
hasQuestionType(this.args.field?.question, "action-button") &&
|
37
|
-
this.args.disabled
|
38
|
-
)
|
34
|
+
!hasQuestionType(this.args.field?.question, "form")
|
39
35
|
);
|
40
36
|
}
|
41
37
|
|
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.9",
|
4
4
|
"description": "Ember addon for rendering Caluma forms.",
|
5
5
|
"keywords": [
|
6
6
|
"ember-addon"
|
@@ -16,7 +16,7 @@
|
|
16
16
|
"dependencies": {
|
17
17
|
"@glimmer/component": "^1.0.4",
|
18
18
|
"@glimmer/tracking": "^1.0.4",
|
19
|
-
"@projectcaluma/ember-core": "^11.0.0-beta.
|
19
|
+
"@projectcaluma/ember-core": "^11.0.0-beta.4",
|
20
20
|
"ember-apollo-client": "^3.2.0",
|
21
21
|
"ember-auto-import": "^2.4.0",
|
22
22
|
"ember-autoresize-modifier": "^0.5.0",
|
@@ -29,15 +29,15 @@
|
|
29
29
|
"ember-in-viewport": "^4.0.0",
|
30
30
|
"ember-intl": "^5.7.2",
|
31
31
|
"ember-math-helpers": "^2.18.1",
|
32
|
-
"ember-pikaday": "^
|
32
|
+
"ember-pikaday": "^4.0.0",
|
33
33
|
"ember-power-select": "^5.0.3",
|
34
|
-
"ember-resources": "^4.
|
35
|
-
"ember-uikit": "^5.0.0
|
34
|
+
"ember-resources": "^4.3.1",
|
35
|
+
"ember-uikit": "^5.0.0",
|
36
36
|
"ember-validators": "^4.1.0",
|
37
37
|
"graphql": "^15.8.0",
|
38
38
|
"jexl": "^2.3.0",
|
39
39
|
"lodash.isequal": "^4.5.0",
|
40
|
-
"
|
40
|
+
"luxon": "^2.3.0",
|
41
41
|
"tracked-toolbox": "^1.2.3"
|
42
42
|
},
|
43
43
|
"devDependencies": {
|
@@ -45,7 +45,7 @@
|
|
45
45
|
"@ember/test-helpers": "2.6.0",
|
46
46
|
"@embroider/test-setup": "1.0.0",
|
47
47
|
"@faker-js/faker": "6.0.0-alpha.5",
|
48
|
-
"@projectcaluma/ember-testing": "11.0.0-beta.
|
48
|
+
"@projectcaluma/ember-testing": "11.0.0-beta.2",
|
49
49
|
"@projectcaluma/ember-workflow": "11.0.0-beta.3",
|
50
50
|
"broccoli-asset-rev": "3.0.0",
|
51
51
|
"ember-cli": "3.28.5",
|
@@ -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
|
-
};
|