@beinformed/ui 1.16.1 → 1.17.2
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 +24 -0
- package/esm/hooks/useForm.js +11 -1
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/models/application/ApplicationModel.js +13 -2
- package/esm/models/application/ApplicationModel.js.map +1 -1
- package/esm/models/href/Href.js +11 -1
- package/esm/models/href/Href.js.map +1 -1
- package/esm/models/index.js +1 -0
- package/esm/models/index.js.map +1 -1
- package/esm/redux/actions/FormAttributeSet.js +10 -1
- package/esm/redux/actions/FormAttributeSet.js.map +1 -1
- package/esm/utils/helpers/checkResource.js +4 -8
- package/esm/utils/helpers/checkResource.js.map +1 -1
- package/lib/hooks/useForm.js +15 -2
- package/lib/hooks/useForm.js.flow +10 -0
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/models/application/ApplicationModel.js +13 -2
- package/lib/models/application/ApplicationModel.js.flow +7 -0
- package/lib/models/application/ApplicationModel.js.map +1 -1
- package/lib/models/href/Href.js +11 -1
- package/lib/models/href/Href.js.flow +12 -1
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/index.js +8 -0
- package/lib/models/index.js.flow +1 -0
- package/lib/models/index.js.map +1 -1
- package/lib/redux/actions/FormAttributeSet.js +14 -2
- package/lib/redux/actions/FormAttributeSet.js.flow +10 -1
- package/lib/redux/actions/FormAttributeSet.js.map +1 -1
- package/lib/utils/helpers/__tests__/checkResource.spec.js.flow +11 -7
- package/lib/utils/helpers/checkResource.js +4 -7
- package/lib/utils/helpers/checkResource.js.flow +7 -5
- package/lib/utils/helpers/checkResource.js.map +1 -1
- package/package.json +6 -6
- package/src/hooks/useForm.js +10 -0
- package/src/models/application/ApplicationModel.js +7 -0
- package/src/models/href/Href.js +12 -1
- package/src/models/index.js +1 -0
- package/src/redux/actions/FormAttributeSet.js +10 -1
- package/src/utils/helpers/__tests__/checkResource.spec.js +11 -7
- package/src/utils/helpers/checkResource.js +7 -5
|
@@ -31,7 +31,7 @@ export const updateFormAttribute =
|
|
|
31
31
|
(dispatch: Dispatch) => {
|
|
32
32
|
const newForm = form.clone();
|
|
33
33
|
|
|
34
|
-
if (
|
|
34
|
+
if (options.validate === undefined) {
|
|
35
35
|
options.validate = true;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -74,3 +74,12 @@ export const updateFormAttribute =
|
|
|
74
74
|
|
|
75
75
|
return dispatch(updateModel(newForm));
|
|
76
76
|
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Validate an attribute on a form
|
|
80
|
+
*/
|
|
81
|
+
export const validateFormAttribute =
|
|
82
|
+
(form: FormModel): ThunkAction =>
|
|
83
|
+
(dispatch: Dispatch) => {
|
|
84
|
+
return dispatch(validateFormObject(form));
|
|
85
|
+
};
|
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
resourceRedirectsToSecureLogin,
|
|
4
4
|
} from "../checkResource";
|
|
5
5
|
|
|
6
|
+
import Href from "../../../models/href/Href";
|
|
7
|
+
|
|
6
8
|
const mockXMLHttpRequest = () => {
|
|
7
9
|
const mock = {
|
|
8
10
|
open: jest.fn(),
|
|
@@ -26,22 +28,22 @@ describe("checkResource", () => {
|
|
|
26
28
|
const mock = mockXMLHttpRequest();
|
|
27
29
|
mock.status = 200;
|
|
28
30
|
|
|
29
|
-
expect.assertions(1);
|
|
30
|
-
|
|
31
31
|
const exists = resourceExists("/");
|
|
32
|
-
|
|
33
32
|
expect(exists).toBe(true);
|
|
33
|
+
|
|
34
|
+
const hrefExists = resourceExists(new Href("/caseview"));
|
|
35
|
+
expect(hrefExists).toBe(true);
|
|
34
36
|
});
|
|
35
37
|
|
|
36
38
|
it("indicates a resource does not exists if it has a status code of 404", () => {
|
|
37
39
|
const mock = mockXMLHttpRequest();
|
|
38
40
|
mock.status = 404;
|
|
39
41
|
|
|
40
|
-
expect.assertions(1);
|
|
41
|
-
|
|
42
42
|
const exists = resourceExists("/");
|
|
43
|
-
|
|
44
43
|
expect(exists).toBe(false);
|
|
44
|
+
|
|
45
|
+
const hrefExists = resourceExists(new Href("/caseview"));
|
|
46
|
+
expect(hrefExists).toBe(false);
|
|
45
47
|
});
|
|
46
48
|
|
|
47
49
|
it("indicates resource request redirects to secureLogin", () => {
|
|
@@ -50,7 +52,9 @@ describe("checkResource", () => {
|
|
|
50
52
|
mock.status = 400;
|
|
51
53
|
|
|
52
54
|
const toLogin = resourceRedirectsToSecureLogin("/");
|
|
53
|
-
|
|
54
55
|
expect(toLogin).toBe(true);
|
|
56
|
+
|
|
57
|
+
const hrefToLogin = resourceExists(new Href("/caseview"));
|
|
58
|
+
expect(hrefToLogin).toBe(true);
|
|
55
59
|
});
|
|
56
60
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import
|
|
2
|
+
import Href from "../../models/href/Href";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)
|
|
@@ -8,8 +8,10 @@ import { BASE } from "../../constants/Constants";
|
|
|
8
8
|
* @param url
|
|
9
9
|
* @returns {boolean}
|
|
10
10
|
*/
|
|
11
|
-
export const resourceExists = (url: string): boolean => {
|
|
12
|
-
const fullUrl =
|
|
11
|
+
export const resourceExists = (url: string | Href): boolean => {
|
|
12
|
+
const fullUrl = new Href(url).absolutehref;
|
|
13
|
+
|
|
14
|
+
// const fullUrl = `${BASE}/${url}`.replace(/\/\//g, "/");
|
|
13
15
|
|
|
14
16
|
const xhr = new XMLHttpRequest();
|
|
15
17
|
xhr.open("HEAD", fullUrl, false);
|
|
@@ -25,8 +27,8 @@ export const resourceExists = (url: string): boolean => {
|
|
|
25
27
|
* @param url
|
|
26
28
|
* @returns {boolean}
|
|
27
29
|
*/
|
|
28
|
-
export const resourceRedirectsToSecureLogin = (url: string): boolean => {
|
|
29
|
-
const fullUrl =
|
|
30
|
+
export const resourceRedirectsToSecureLogin = (url: string | Href): boolean => {
|
|
31
|
+
const fullUrl = new Href(url).absolutehref;
|
|
30
32
|
|
|
31
33
|
const xhr = new XMLHttpRequest();
|
|
32
34
|
xhr.open("HEAD", fullUrl, false);
|