ember-validated-form 3.0.3 → 5.0.0
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/.github/ISSUE_TEMPLATE/bug_report.md +0 -1
- package/.github/dependabot.yml +11 -0
- package/.github/workflows/deploy.yml +5 -3
- package/.github/workflows/release.yml +7 -5
- package/.github/workflows/test.yml +10 -11
- package/CHANGELOG.md +66 -0
- package/README.md +3 -3
- package/addon/-private/themed-component.js +31 -38
- package/addon/components/validated-button/-themes/bootstrap/button.js +7 -9
- package/addon/components/validated-button/-themes/uikit/button.js +7 -9
- package/addon/components/validated-button/button.hbs +9 -0
- package/addon/components/validated-button/button.js +3 -8
- package/addon/components/validated-button.hbs +17 -0
- package/addon/components/validated-button.js +4 -8
- package/addon/components/validated-form.hbs +21 -0
- package/addon/components/validated-form.js +32 -46
- package/addon/components/validated-input/-themes/bootstrap/error.js +3 -3
- package/addon/components/validated-input/-themes/bootstrap/hint.js +3 -3
- package/addon/components/validated-input/-themes/bootstrap/label.js +1 -1
- package/addon/components/validated-input/-themes/bootstrap/render.js +3 -3
- package/addon/components/validated-input/-themes/uikit/error.hbs +4 -0
- package/addon/components/validated-input/-themes/uikit/error.js +1 -4
- package/addon/components/validated-input/-themes/uikit/hint.js +3 -3
- package/addon/components/validated-input/-themes/uikit/label.js +3 -3
- package/addon/components/validated-input/-themes/uikit/render.hbs +110 -0
- package/addon/components/validated-input/-themes/uikit/render.js +3 -5
- package/addon/components/validated-input/error.hbs +1 -0
- package/addon/components/validated-input/error.js +6 -7
- package/addon/components/validated-input/hint.hbs +1 -0
- package/addon/components/validated-input/hint.js +3 -7
- package/addon/components/validated-input/label.hbs +3 -0
- package/addon/components/validated-input/label.js +3 -8
- package/addon/components/validated-input/render.hbs +108 -0
- package/addon/components/validated-input/render.js +10 -10
- package/addon/components/validated-input/types/-themes/bootstrap/checkbox-group.hbs +19 -0
- package/addon/components/validated-input/types/-themes/bootstrap/checkbox-group.js +3 -0
- package/addon/components/validated-input/types/-themes/bootstrap/checkbox.hbs +14 -0
- package/addon/components/validated-input/types/-themes/bootstrap/checkbox.js +1 -6
- package/addon/components/validated-input/types/-themes/bootstrap/input.js +11 -4
- package/addon/components/validated-input/types/-themes/bootstrap/radio-group.hbs +20 -0
- package/addon/components/validated-input/types/-themes/bootstrap/radio-group.js +1 -4
- package/addon/components/validated-input/types/-themes/bootstrap/select.js +11 -4
- package/addon/components/validated-input/types/-themes/bootstrap/textarea.js +11 -4
- package/addon/components/validated-input/types/-themes/uikit/checkbox-group.hbs +19 -0
- package/addon/components/validated-input/types/-themes/uikit/checkbox-group.js +3 -0
- package/addon/components/validated-input/types/-themes/uikit/checkbox.hbs +15 -0
- package/addon/components/validated-input/types/-themes/uikit/checkbox.js +1 -4
- package/addon/components/validated-input/types/-themes/uikit/input.js +11 -4
- package/addon/components/validated-input/types/-themes/uikit/radio-group.hbs +20 -0
- package/addon/components/validated-input/types/-themes/uikit/radio-group.js +1 -4
- package/addon/components/validated-input/types/-themes/uikit/select.js +11 -4
- package/addon/components/validated-input/types/-themes/uikit/textarea.js +11 -4
- package/addon/components/validated-input/types/checkbox-group.hbs +14 -0
- package/addon/components/validated-input/types/checkbox-group.js +21 -0
- package/addon/components/validated-input/types/checkbox.hbs +9 -0
- package/addon/components/validated-input/types/checkbox.js +10 -6
- package/addon/components/validated-input/types/input.hbs +6 -0
- package/addon/components/validated-input/types/input.js +9 -17
- package/addon/components/validated-input/types/radio-group.hbs +14 -0
- package/addon/components/validated-input/types/radio-group.js +10 -6
- package/addon/components/validated-input/types/select.hbs +17 -0
- package/addon/components/validated-input/types/select.js +3 -7
- package/addon/components/validated-input/types/textarea.hbs +7 -0
- package/addon/components/validated-input/types/textarea.js +9 -17
- package/addon/components/validated-input.hbs +74 -0
- package/addon/components/validated-input.js +61 -59
- package/app/components/validated-form.js +1 -7
- package/app/components/validated-input/types/-themes/bootstrap/checkbox-group.js +1 -0
- package/app/components/validated-input/types/-themes/uikit/checkbox-group.js +1 -0
- package/app/components/validated-input/types/checkbox-group.js +1 -0
- package/config/environment.js +1 -1
- package/package.json +50 -36
- package/.dependabot/config.yml +0 -14
- package/.prettierignore +0 -1
- package/addon/templates/components/validated-button/button.hbs +0 -1
- package/addon/templates/components/validated-button.hbs +0 -7
- package/addon/templates/components/validated-form.hbs +0 -15
- package/addon/templates/components/validated-input/-themes/uikit/render.hbs +0 -94
- package/addon/templates/components/validated-input/error.hbs +0 -1
- package/addon/templates/components/validated-input/hint.hbs +0 -1
- package/addon/templates/components/validated-input/label.hbs +0 -1
- package/addon/templates/components/validated-input/render.hbs +0 -93
- package/addon/templates/components/validated-input/types/-themes/bootstrap/checkbox.hbs +0 -10
- package/addon/templates/components/validated-input/types/-themes/bootstrap/radio-group.hbs +0 -15
- package/addon/templates/components/validated-input/types/-themes/bootstrap/select.hbs +0 -16
- package/addon/templates/components/validated-input/types/-themes/uikit/checkbox.hbs +0 -11
- package/addon/templates/components/validated-input/types/-themes/uikit/radio-group.hbs +0 -17
- package/addon/templates/components/validated-input/types/-themes/uikit/select.hbs +0 -17
- package/addon/templates/components/validated-input/types/checkbox.hbs +0 -9
- package/addon/templates/components/validated-input/types/radio-group.hbs +0 -14
- package/addon/templates/components/validated-input/types/select.hbs +0 -16
- package/addon/templates/components/validated-input.hbs +0 -55
|
@@ -3,7 +3,7 @@ name: Deploy
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
|
-
-
|
|
6
|
+
- main
|
|
7
7
|
release:
|
|
8
8
|
types: [published]
|
|
9
9
|
|
|
@@ -13,7 +13,9 @@ jobs:
|
|
|
13
13
|
runs-on: ubuntu-latest
|
|
14
14
|
steps:
|
|
15
15
|
- uses: actions/checkout@v2
|
|
16
|
-
- uses: actions/setup-node@
|
|
16
|
+
- uses: actions/setup-node@v2
|
|
17
|
+
with:
|
|
18
|
+
node-version: 14
|
|
17
19
|
|
|
18
20
|
- name: Install Dependencies
|
|
19
21
|
run: yarn install
|
|
@@ -23,4 +25,4 @@ jobs:
|
|
|
23
25
|
env:
|
|
24
26
|
CI: true
|
|
25
27
|
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
|
|
26
|
-
|
|
28
|
+
ADDON_DOCS_UPDATE_LATEST: true
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
name: Release
|
|
2
2
|
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- release
|
|
3
|
+
on: workflow_dispatch
|
|
7
4
|
|
|
8
5
|
jobs:
|
|
9
6
|
release:
|
|
@@ -11,7 +8,12 @@ jobs:
|
|
|
11
8
|
runs-on: ubuntu-latest
|
|
12
9
|
steps:
|
|
13
10
|
- uses: actions/checkout@v2
|
|
14
|
-
|
|
11
|
+
with:
|
|
12
|
+
fetch-depth: 0
|
|
13
|
+
persist-credentials: false
|
|
14
|
+
- uses: actions/setup-node@v2
|
|
15
|
+
with:
|
|
16
|
+
node-version: 14
|
|
15
17
|
|
|
16
18
|
- name: Install dependencies
|
|
17
19
|
run: yarn install
|
|
@@ -3,10 +3,10 @@ name: Test
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
|
-
-
|
|
6
|
+
- main
|
|
7
7
|
pull_request:
|
|
8
8
|
branches:
|
|
9
|
-
-
|
|
9
|
+
- main
|
|
10
10
|
|
|
11
11
|
jobs:
|
|
12
12
|
lint:
|
|
@@ -19,9 +19,9 @@ jobs:
|
|
|
19
19
|
|
|
20
20
|
steps:
|
|
21
21
|
- uses: actions/checkout@v2
|
|
22
|
-
- uses: actions/setup-node@
|
|
22
|
+
- uses: actions/setup-node@v2
|
|
23
23
|
with:
|
|
24
|
-
node-version:
|
|
24
|
+
node-version: 14
|
|
25
25
|
|
|
26
26
|
- name: Install dependencies
|
|
27
27
|
run: yarn install
|
|
@@ -36,9 +36,9 @@ jobs:
|
|
|
36
36
|
|
|
37
37
|
steps:
|
|
38
38
|
- uses: actions/checkout@v2
|
|
39
|
-
- uses: actions/setup-node@
|
|
39
|
+
- uses: actions/setup-node@v2
|
|
40
40
|
with:
|
|
41
|
-
node-version:
|
|
41
|
+
node-version: 14
|
|
42
42
|
|
|
43
43
|
- name: Install dependencies (no lockfile)
|
|
44
44
|
run: yarn install --no-lockfile
|
|
@@ -67,16 +67,15 @@ jobs:
|
|
|
67
67
|
strategy:
|
|
68
68
|
matrix:
|
|
69
69
|
scenario:
|
|
70
|
-
- ember-lts-3.
|
|
71
|
-
- ember-lts-3.
|
|
70
|
+
- ember-lts-3.24
|
|
71
|
+
- ember-lts-3.28
|
|
72
72
|
- ember-release
|
|
73
|
-
- legacy-changeset
|
|
74
73
|
|
|
75
74
|
steps:
|
|
76
75
|
- uses: actions/checkout@v2
|
|
77
|
-
- uses: actions/setup-node@
|
|
76
|
+
- uses: actions/setup-node@v2
|
|
78
77
|
with:
|
|
79
|
-
node-version:
|
|
78
|
+
node-version: 14
|
|
80
79
|
|
|
81
80
|
- name: Install dependencies
|
|
82
81
|
run: yarn install
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,69 @@
|
|
|
1
|
+
# [5.0.0](https://github.com/adfinis-sygroup/ember-validated-form/compare/v4.1.0...v5.0.0) (2021-10-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### chore
|
|
5
|
+
|
|
6
|
+
* **deps:** update ember and other dependencies ([41e099c](https://github.com/adfinis-sygroup/ember-validated-form/commit/41e099c4da82135c562493e5b2a4f9420dca73c6))
|
|
7
|
+
* **ember:** remove support for ember 3.20 ([0cfebfc](https://github.com/adfinis-sygroup/ember-validated-form/commit/0cfebfcc5792a1df52093a972878af1617ec8100))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* refactor all components to glimmer and use native classes ([cee7373](https://github.com/adfinis-sygroup/ember-validated-form/commit/cee7373a3c0783a02fe00b5e510c41ba604403c2))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### BREAKING CHANGES
|
|
16
|
+
|
|
17
|
+
* **ember:** Remove support for ember LTS 3.20 since that version
|
|
18
|
+
has a bug with autotracking.
|
|
19
|
+
* **deps:** Require `ember-auto-import` v2+
|
|
20
|
+
* While the public API won't change, there is a huge
|
|
21
|
+
chance that this will break implementations if someone's extending the
|
|
22
|
+
components of this addon. Components that do need to be refactored to
|
|
23
|
+
glimmer.
|
|
24
|
+
|
|
25
|
+
# [4.1.0](https://github.com/adfinis-sygroup/ember-validated-form/compare/v4.0.1...v4.1.0) (2021-09-30)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **deps:** [security] bump handlebars from 4.7.6 to 4.7.7 ([#588](https://github.com/adfinis-sygroup/ember-validated-form/issues/588)) ([d167207](https://github.com/adfinis-sygroup/ember-validated-form/commit/d167207ee059bd9b968a08fb61f18f43dadab0ab))
|
|
31
|
+
* **deps:** [security] bump striptags from 3.1.1 to 3.2.0 ([#637](https://github.com/adfinis-sygroup/ember-validated-form/issues/637)) ([3632f52](https://github.com/adfinis-sygroup/ember-validated-form/commit/3632f52e7fa1fc6f0e17dd3365a74a80ceb92833))
|
|
32
|
+
* **deps:** [security] bump trim-newlines from 3.0.0 to 3.0.1 ([#634](https://github.com/adfinis-sygroup/ember-validated-form/issues/634)) ([10e3974](https://github.com/adfinis-sygroup/ember-validated-form/commit/10e397452b30a3af11a299c5bcdafd703d9b0c18))
|
|
33
|
+
* **deps:** [security] bump ws from 6.2.1 to 6.2.2 ([#624](https://github.com/adfinis-sygroup/ember-validated-form/issues/624)) ([910ec64](https://github.com/adfinis-sygroup/ember-validated-form/commit/910ec64b2f84562fd77a8be14094fd2f326d60b6))
|
|
34
|
+
* call on-update hook correctly ([#641](https://github.com/adfinis-sygroup/ember-validated-form/issues/641)) ([b8688b6](https://github.com/adfinis-sygroup/ember-validated-form/commit/b8688b6d9dedbd9096d34c3b236bf59efb045556))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
* checkbox groups ([#640](https://github.com/adfinis-sygroup/ember-validated-form/issues/640)) ([9099ce8](https://github.com/adfinis-sygroup/ember-validated-form/commit/9099ce81bbedc53c961653dca59c555d96ee9128))
|
|
40
|
+
|
|
41
|
+
## [4.0.1](https://github.com/adfinis-sygroup/ember-validated-form/compare/v4.0.0...v4.0.1) (2021-05-21)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Bug Fixes
|
|
45
|
+
|
|
46
|
+
* **validated-input:** use changeset.set if available to preserve state tracking on nested objects ([#609](https://github.com/adfinis-sygroup/ember-validated-form/issues/609)) ([d3b92ee](https://github.com/adfinis-sygroup/ember-validated-form/commit/d3b92ee5dfb7e0a6f4fbdb1899d9be34b67d1722))
|
|
47
|
+
|
|
48
|
+
# [4.0.0](https://github.com/adfinis-sygroup/ember-validated-form/compare/v3.0.3...v4.0.0) (2021-05-19)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Bug Fixes
|
|
52
|
+
|
|
53
|
+
* **validated-input:** rewrite to glimmer and support nested changesets ([#581](https://github.com/adfinis-sygroup/ember-validated-form/issues/581)) ([2f3e7c5](https://github.com/adfinis-sygroup/ember-validated-form/commit/2f3e7c5c9e13ad39ecba9358305cfcc4bac8f6b8))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### BREAKING CHANGES
|
|
57
|
+
|
|
58
|
+
* **validated-input:** This drops support for Ember LTS 3.16 and `ember-changeset` < 3.0.0 and `ember-changeset-validations` < 3.0.0
|
|
59
|
+
|
|
60
|
+
* refactor(validated-input): refactor dynamic component call to angle-brackets
|
|
61
|
+
|
|
62
|
+
* chore(*): drop node v10 support
|
|
63
|
+
* **validated-input:** drop node v10 support since v10 has reached EOL
|
|
64
|
+
|
|
65
|
+
* fix(themed-component): convert array to string befor using in key path
|
|
66
|
+
|
|
1
67
|
## [3.0.3](https://github.com/adfinis-sygroup/ember-validated-form/compare/v3.0.2...v3.0.3) (2021-04-15)
|
|
2
68
|
|
|
3
69
|
|
package/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/js/ember-validated-form)
|
|
4
4
|
[](https://emberobserver.com/addons/ember-validated-form)
|
|
5
|
-
[](https://github.com/adfinis-sygroup/ember-validated-form/actions?query=workflow%3ATest)
|
|
6
|
+
[](https://github.com/prettier/prettier)
|
|
7
7
|
|
|
8
8
|
Easily create forms with client side validations.
|
|
9
9
|
|
|
10
|
-

|
|
11
11
|
|
|
12
12
|
Want to try it yourself? [View the docs here.](https://adfinis-sygroup.github.io/ember-validated-form/)
|
|
13
13
|
|
|
@@ -1,45 +1,38 @@
|
|
|
1
1
|
import { getOwner } from "@ember/application";
|
|
2
|
-
import { get, computed } from "@ember/object";
|
|
3
2
|
|
|
4
|
-
export default (component)
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
export default function (component) {
|
|
4
|
+
return function (_, propertyName) {
|
|
5
|
+
return {
|
|
6
|
+
get() {
|
|
7
|
+
const parts = component.split("/");
|
|
8
|
+
const componentName = parts.slice(1, parts.length).join("/");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
if (this.args[propertyName]) {
|
|
11
|
+
return this.args[propertyName];
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
const config =
|
|
15
|
+
getOwner(this).resolveRegistration("config:environment")[
|
|
16
|
+
"ember-validated-form"
|
|
17
|
+
] !== undefined
|
|
18
|
+
? getOwner(this).resolveRegistration("config:environment")[
|
|
19
|
+
"ember-validated-form"
|
|
20
|
+
]
|
|
21
|
+
: {};
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
config,
|
|
26
|
-
`defaults.${componentNameParts.join("/")}`
|
|
27
|
-
);
|
|
23
|
+
const theme = config.theme;
|
|
24
|
+
const defaultComponent = config.defaults?.[componentName];
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
const name = parts.pop();
|
|
27
|
+
const basePath = parts.join("/");
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return value;
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
};
|
|
29
|
+
return (
|
|
30
|
+
defaultComponent ||
|
|
31
|
+
(theme
|
|
32
|
+
? `${basePath}/-themes/${theme}/${name}`
|
|
33
|
+
: `${basePath}/${name}`)
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { computed } from "@ember/object";
|
|
2
|
-
|
|
3
1
|
import Component from "../../button";
|
|
4
2
|
|
|
5
|
-
export default Component
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export default class BootstrapButton extends Component {
|
|
4
|
+
get class() {
|
|
5
|
+
const style = this.args.type === "submit" ? "btn-primary" : "btn-default";
|
|
6
|
+
const loading = this.args.loading ? "loading" : "";
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
8
|
+
return `btn ${style} ${loading}`;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { computed } from "@ember/object";
|
|
2
|
-
|
|
3
1
|
import Component from "../../button";
|
|
4
2
|
|
|
5
|
-
export default Component
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export default class UikitButton extends Component {
|
|
4
|
+
get class() {
|
|
5
|
+
const style =
|
|
6
|
+
this.args.type === "submit" ? "uk-button-primary" : "uk-button-default";
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
8
|
+
return `uk-button ${style}`;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import Component from "@
|
|
1
|
+
import Component from "@glimmer/component";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export default Component.extend({
|
|
6
|
-
layout,
|
|
7
|
-
tagName: "button",
|
|
8
|
-
attributeBindings: ["disabled", "type", "action:onclick"],
|
|
9
|
-
});
|
|
3
|
+
// eslint-disable-next-line ember/no-empty-glimmer-component-classes
|
|
4
|
+
export default class ButtonComponent extends Component {}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{{#let
|
|
2
|
+
(component
|
|
3
|
+
this.buttonComponent
|
|
4
|
+
onClick=@action
|
|
5
|
+
loading=@loading
|
|
6
|
+
disabled=@disabled
|
|
7
|
+
label=@label
|
|
8
|
+
type=@type
|
|
9
|
+
)
|
|
10
|
+
as |Button|
|
|
11
|
+
}}
|
|
12
|
+
{{#if (has-block)}}
|
|
13
|
+
<Button ...attributes>{{yield}}</Button>
|
|
14
|
+
{{else}}
|
|
15
|
+
<Button ...attributes />
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{/let}}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import Component from "@
|
|
1
|
+
import Component from "@glimmer/component";
|
|
2
2
|
|
|
3
3
|
import themedComponent from "../-private/themed-component";
|
|
4
|
-
import layout from "../templates/components/validated-button";
|
|
5
4
|
|
|
6
|
-
export default Component
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
tagName: "",
|
|
10
|
-
buttonComponent: themedComponent("validated-button/button"),
|
|
11
|
-
});
|
|
5
|
+
export default class ValidatedButtonComponent extends Component {
|
|
6
|
+
@themedComponent("validated-button/button") buttonComponent;
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<form autocomplete={{@autocomplete}} class={{if this.submitted "submitted"}}>
|
|
2
|
+
{{yield
|
|
3
|
+
(hash
|
|
4
|
+
model=@model
|
|
5
|
+
loading=this.loading
|
|
6
|
+
input=(component
|
|
7
|
+
"validated-input"
|
|
8
|
+
model=@model
|
|
9
|
+
submitted=this.submitted
|
|
10
|
+
validateBeforeSubmit=@validateBeforeSubmit
|
|
11
|
+
)
|
|
12
|
+
submit=(component
|
|
13
|
+
"validated-button"
|
|
14
|
+
type="submit"
|
|
15
|
+
loading=this.loading
|
|
16
|
+
label="Save"
|
|
17
|
+
action=this.submit
|
|
18
|
+
)
|
|
19
|
+
)
|
|
20
|
+
}}
|
|
21
|
+
</form>
|
|
@@ -1,70 +1,56 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { action } from "@ember/object";
|
|
2
|
+
import Component from "@glimmer/component";
|
|
3
|
+
import { tracked } from "@glimmer/tracking";
|
|
2
4
|
import { resolve } from "rsvp";
|
|
3
5
|
|
|
4
|
-
import layout from "../templates/components/validated-form";
|
|
5
|
-
|
|
6
6
|
const PROP_ON_SUBMIT = "on-submit";
|
|
7
7
|
const PROP_ON_INVALID_SUBMIT = "on-invalid-submit";
|
|
8
8
|
|
|
9
|
-
export default Component
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
attributeBindings: ["autocomplete"],
|
|
14
|
-
|
|
15
|
-
loading: false,
|
|
16
|
-
|
|
17
|
-
submitted: false,
|
|
18
|
-
|
|
19
|
-
layout,
|
|
9
|
+
export default class ValidatedFormComponent extends Component {
|
|
10
|
+
@tracked loading = false;
|
|
11
|
+
@tracked submitted = false;
|
|
12
|
+
@tracked validateBeforeSubmit = true;
|
|
20
13
|
|
|
21
|
-
|
|
14
|
+
constructor(...args) {
|
|
15
|
+
super(...args);
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (this.model && this.model.validate) {
|
|
26
|
-
this.model.validate();
|
|
17
|
+
if (this.args.model && this.args.model.validate) {
|
|
18
|
+
this.args.model.validate();
|
|
27
19
|
}
|
|
28
|
-
}
|
|
20
|
+
}
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
@action
|
|
23
|
+
async submit(event) {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
|
|
26
|
+
this.submitted = true;
|
|
27
|
+
const model = this.args.model;
|
|
33
28
|
|
|
34
29
|
if (!model || !model.validate) {
|
|
35
30
|
this.runCallback(PROP_ON_SUBMIT);
|
|
36
31
|
return false;
|
|
37
32
|
}
|
|
38
33
|
|
|
39
|
-
model.validate()
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
await model.validate();
|
|
35
|
+
|
|
36
|
+
if (model.get("isInvalid")) {
|
|
37
|
+
this.runCallback(PROP_ON_INVALID_SUBMIT);
|
|
38
|
+
} else {
|
|
39
|
+
this.runCallback(PROP_ON_SUBMIT);
|
|
40
|
+
}
|
|
44
41
|
|
|
45
|
-
if (model.get("isInvalid")) {
|
|
46
|
-
this.runCallback(PROP_ON_INVALID_SUBMIT);
|
|
47
|
-
} else {
|
|
48
|
-
this.runCallback(PROP_ON_SUBMIT);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
42
|
return false;
|
|
52
|
-
}
|
|
43
|
+
}
|
|
53
44
|
|
|
54
45
|
runCallback(callbackProp) {
|
|
55
|
-
const callback = this.
|
|
46
|
+
const callback = this.args[callbackProp];
|
|
56
47
|
if (typeof callback !== "function") {
|
|
57
48
|
return;
|
|
58
49
|
}
|
|
59
|
-
const model = this.model;
|
|
60
50
|
|
|
61
|
-
this.
|
|
62
|
-
resolve(callback(model)).finally(() => {
|
|
63
|
-
|
|
64
|
-
// We were removed from the DOM while running on-submit()
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
this.set("loading", false);
|
|
51
|
+
this.loading = true;
|
|
52
|
+
resolve(callback(this.args.model)).finally(() => {
|
|
53
|
+
this.loading = false;
|
|
68
54
|
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
55
|
+
}
|
|
56
|
+
}
|