@beinformed/ui 1.58.3 → 1.59.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/CHANGELOG.md +24 -0
- package/esm/constants/Constants.js +10 -0
- package/esm/constants/Constants.js.map +1 -1
- package/esm/constants/Settings.js +5 -1
- package/esm/constants/Settings.js.map +1 -1
- package/esm/models/attributes/DatetimeAttributeModel.js +39 -4
- package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/esm/models/attributes/input-constraints/DatetimeFormatConstraint.js +31 -2
- package/esm/models/attributes/input-constraints/DatetimeFormatConstraint.js.map +1 -1
- package/esm/models/content/SectionModel.js +1 -1
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/content/SubSectionModel.js +12 -4
- package/esm/models/content/SubSectionModel.js.map +1 -1
- package/esm/react-client/client.js +2 -1
- package/esm/react-client/client.js.map +1 -1
- package/esm/react-server/serverUtil.js +2 -1
- package/esm/react-server/serverUtil.js.map +1 -1
- package/esm/redux/actions/Preferences.js +15 -1
- package/esm/redux/actions/Preferences.js.map +1 -1
- package/esm/utils/datetime/DateTimeUtil.js +292 -94
- package/esm/utils/datetime/DateTimeUtil.js.map +1 -1
- package/lib/constants/Constants.js +11 -1
- package/lib/constants/Constants.js.flow +11 -0
- package/lib/constants/Constants.js.map +1 -1
- package/lib/constants/Settings.js +7 -2
- package/lib/constants/Settings.js.flow +6 -0
- package/lib/constants/Settings.js.map +1 -1
- package/lib/models/attributes/DatetimeAttributeModel.js +38 -3
- package/lib/models/attributes/DatetimeAttributeModel.js.flow +54 -4
- package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/lib/models/attributes/__tests__/DatetimeAttributeModel.spec.js.flow +9 -0
- package/lib/models/attributes/__tests__/DatetimeAttributeModel_offset.spec.js.flow +306 -0
- package/lib/models/attributes/input-constraints/DatetimeFormatConstraint.js +31 -2
- package/lib/models/attributes/input-constraints/DatetimeFormatConstraint.js.flow +42 -3
- package/lib/models/attributes/input-constraints/DatetimeFormatConstraint.js.map +1 -1
- package/lib/models/content/SectionModel.js +1 -1
- package/lib/models/content/SectionModel.js.flow +2 -1
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/content/SubSectionModel.js +12 -3
- package/lib/models/content/SubSectionModel.js.flow +20 -3
- package/lib/models/content/SubSectionModel.js.map +1 -1
- package/lib/models/content/__tests__/ContentModel.spec.js.flow +3 -3
- package/lib/react-client/client.js +1 -0
- package/lib/react-client/client.js.flow +2 -0
- package/lib/react-client/client.js.map +1 -1
- package/lib/react-server/__tests__/serverUtil.spec.js.flow +12 -0
- package/lib/react-server/serverUtil.js +1 -0
- package/lib/react-server/serverUtil.js.flow +2 -0
- package/lib/react-server/serverUtil.js.map +1 -1
- package/lib/redux/actions/Preferences.js +17 -2
- package/lib/redux/actions/Preferences.js.flow +22 -0
- package/lib/redux/actions/Preferences.js.map +1 -1
- package/lib/redux/reducers/__tests__/ModelCatalogReducer.spec.js.flow +23 -0
- package/lib/utils/datetime/DateTimeUtil.js +292 -93
- package/lib/utils/datetime/DateTimeUtil.js.flow +482 -172
- package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
- package/lib/utils/datetime/__tests__/DateTime.spec.js.flow +771 -483
- package/package.json +11 -9
- package/src/constants/Constants.js +11 -0
- package/src/constants/Settings.js +6 -0
- package/src/models/attributes/DatetimeAttributeModel.js +54 -4
- package/src/models/attributes/__tests__/DatetimeAttributeModel.spec.js +9 -0
- package/src/models/attributes/__tests__/DatetimeAttributeModel_offset.spec.js +306 -0
- package/src/models/attributes/input-constraints/DatetimeFormatConstraint.js +42 -3
- package/src/models/content/SectionModel.js +2 -1
- package/src/models/content/SubSectionModel.js +20 -3
- package/src/models/content/__tests__/ContentModel.spec.js +3 -3
- package/src/react-client/client.js +2 -0
- package/src/react-server/__tests__/serverUtil.spec.js +12 -0
- package/src/react-server/serverUtil.js +2 -0
- package/src/redux/actions/Preferences.js +22 -0
- package/src/redux/reducers/__tests__/ModelCatalogReducer.spec.js +23 -0
- package/src/utils/datetime/DateTimeUtil.js +482 -172
- package/src/utils/datetime/__tests__/DateTime.spec.js +771 -483
|
@@ -6,17 +6,25 @@ import LinkCollection from "../links/LinkCollection";
|
|
|
6
6
|
import Href from "../href/Href";
|
|
7
7
|
import LinkModel from "../links/LinkModel";
|
|
8
8
|
import { retrieveText } from "../../utils";
|
|
9
|
+
import type { ModelOptions } from "../types";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Link to a concept
|
|
12
13
|
*/
|
|
13
14
|
export default class SubSectionModel extends BaseModel {
|
|
15
|
+
_entryDate: ISO_DATE | null;
|
|
14
16
|
_links: LinkCollection;
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
*/
|
|
18
|
-
constructor(
|
|
19
|
-
|
|
20
|
+
constructor(
|
|
21
|
+
data: Object,
|
|
22
|
+
entryDate: ISO_DATE | null,
|
|
23
|
+
modelOptions?: ModelOptions,
|
|
24
|
+
) {
|
|
25
|
+
super(data, {}, modelOptions);
|
|
26
|
+
|
|
27
|
+
this._entryDate = entryDate;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
/**
|
|
@@ -66,7 +74,8 @@ export default class SubSectionModel extends BaseModel {
|
|
|
66
74
|
get subSections(): Array<SubSectionModel> {
|
|
67
75
|
return this.data.subSections
|
|
68
76
|
? this.data.subSections.map(
|
|
69
|
-
(subSection) =>
|
|
77
|
+
(subSection) =>
|
|
78
|
+
new SubSectionModel(subSection, this.entryDate, this.modelOptions),
|
|
70
79
|
)
|
|
71
80
|
: [];
|
|
72
81
|
}
|
|
@@ -99,6 +108,12 @@ export default class SubSectionModel extends BaseModel {
|
|
|
99
108
|
return this.selflink ? this.selflink.href : null;
|
|
100
109
|
}
|
|
101
110
|
|
|
111
|
+
/**
|
|
112
|
+
*/
|
|
113
|
+
get entryDate(): ISO_DATE | null {
|
|
114
|
+
return this._entryDate;
|
|
115
|
+
}
|
|
116
|
+
|
|
102
117
|
/**
|
|
103
118
|
*/
|
|
104
119
|
get relatedConceptsHrefs(): Array<Href> {
|
|
@@ -131,7 +146,9 @@ export default class SubSectionModel extends BaseModel {
|
|
|
131
146
|
: "";
|
|
132
147
|
}
|
|
133
148
|
|
|
149
|
+
href.addParameter("entryDate", this.entryDate);
|
|
134
150
|
href.setReferenceHash(this.referenceHash);
|
|
151
|
+
|
|
135
152
|
return href;
|
|
136
153
|
}
|
|
137
154
|
|
|
@@ -133,10 +133,10 @@ describe("contentmodel", () => {
|
|
|
133
133
|
"/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1/relatedConcepts?entryDate=2024-07-17",
|
|
134
134
|
);
|
|
135
135
|
expect(contentModel.relatedConceptsHrefs[1].toString()).toBe(
|
|
136
|
-
"/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1a/relatedConcepts",
|
|
136
|
+
"/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1a/relatedConcepts?entryDate=2024-07-17",
|
|
137
137
|
);
|
|
138
138
|
expect(contentModel.relatedConceptsHrefs[2].toString()).toBe(
|
|
139
|
-
"/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1b/relatedConcepts",
|
|
139
|
+
"/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1b/relatedConcepts?entryDate=2024-07-17",
|
|
140
140
|
);
|
|
141
141
|
});
|
|
142
142
|
|
|
@@ -196,7 +196,7 @@ describe("contentmodel", () => {
|
|
|
196
196
|
);
|
|
197
197
|
expect(firstSubSection.relatedConceptsHrefs).toHaveLength(1);
|
|
198
198
|
expect(firstSubSection.relatedConceptsHref.href.toString()).toBe(
|
|
199
|
-
"/content/Incident/Business design/Content/Blaastest subsections.formalsource/Pass/relatedConcepts",
|
|
199
|
+
"/content/Incident/Business design/Content/Blaastest subsections.formalsource/Pass/relatedConcepts?entryDate=2021-08-31",
|
|
200
200
|
);
|
|
201
201
|
expect(firstSubSection.relatedConceptsHref.getReferenceHash()).toBe(
|
|
202
202
|
145842294,
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
|
|
22
22
|
import {
|
|
23
23
|
setAllContentInDataSetting,
|
|
24
|
+
setDateTimeSettings,
|
|
24
25
|
setLoginPreferences,
|
|
25
26
|
} from "../redux/actions/Preferences";
|
|
26
27
|
import { showXHRErrorNotification } from "../redux/actions/Notification";
|
|
@@ -175,6 +176,7 @@ export const setupClient = (
|
|
|
175
176
|
|
|
176
177
|
setAllContentInDataSetting(store.getState());
|
|
177
178
|
setLoginPreferences(store.getState());
|
|
179
|
+
setDateTimeSettings(store.getState());
|
|
178
180
|
|
|
179
181
|
// load existing cache from other browser tabs
|
|
180
182
|
Cache.loadOtherBrowserTabs(() => {
|
|
@@ -119,6 +119,12 @@ describe("serverUtil", () => {
|
|
|
119
119
|
"security.clients": null,
|
|
120
120
|
},
|
|
121
121
|
},
|
|
122
|
+
{
|
|
123
|
+
type: "SET_PREFERENCE",
|
|
124
|
+
payload: {
|
|
125
|
+
isIncludeTimeOffsetInDateTimes: false,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
122
128
|
]);
|
|
123
129
|
});
|
|
124
130
|
|
|
@@ -166,6 +172,12 @@ describe("serverUtil", () => {
|
|
|
166
172
|
"security.clients": null,
|
|
167
173
|
},
|
|
168
174
|
},
|
|
175
|
+
{
|
|
176
|
+
type: "SET_PREFERENCE",
|
|
177
|
+
payload: {
|
|
178
|
+
isIncludeTimeOffsetInDateTimes: false,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
169
181
|
]);
|
|
170
182
|
});
|
|
171
183
|
});
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
setPreference,
|
|
18
18
|
setAllContentInDataSetting,
|
|
19
19
|
setLoginPreferences,
|
|
20
|
+
setDateTimeSettings,
|
|
20
21
|
} from "../redux/actions/Preferences";
|
|
21
22
|
|
|
22
23
|
import { getSetting } from "../constants/Settings";
|
|
@@ -134,6 +135,7 @@ const setServerPreferences = (
|
|
|
134
135
|
|
|
135
136
|
store.dispatch(setAllContentInDataSetting());
|
|
136
137
|
store.dispatch(setLoginPreferences());
|
|
138
|
+
store.dispatch(setDateTimeSettings());
|
|
137
139
|
|
|
138
140
|
if (
|
|
139
141
|
preferencesProvider &&
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
ALL_CONTENT_IN_DATA_SETTING,
|
|
16
|
+
INCLUDE_TIME_OFFSET,
|
|
16
17
|
LOGIN_TYPE,
|
|
17
18
|
LOGIN_PASSWORD_SETTING,
|
|
18
19
|
LOGIN_PATH_SETTING,
|
|
@@ -116,6 +117,27 @@ export const setAllContentInDataSetting = (
|
|
|
116
117
|
return setPreference(ALL_CONTENT_IN_DATA_SETTING, allContentInDataSetting);
|
|
117
118
|
};
|
|
118
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Retrieve settings for date time conversion
|
|
122
|
+
*/
|
|
123
|
+
export const setDateTimeSettings = (
|
|
124
|
+
state?: ReduxState,
|
|
125
|
+
): SetPreferenceAction => {
|
|
126
|
+
let isIncludeTimeOffsetInDateTimes: PreferenceValue = false;
|
|
127
|
+
if (
|
|
128
|
+
typeof preferencesProvider !== "undefined" &&
|
|
129
|
+
typeof preferencesProvider.isIncludeTimeOffsetInDateTimes !== "undefined"
|
|
130
|
+
) {
|
|
131
|
+
isIncludeTimeOffsetInDateTimes =
|
|
132
|
+
preferencesProvider.isIncludeTimeOffsetInDateTimes();
|
|
133
|
+
} else if (typeof state !== "undefined") {
|
|
134
|
+
isIncludeTimeOffsetInDateTimes = state.preferences[INCLUDE_TIME_OFFSET];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
setSetting(INCLUDE_TIME_OFFSET, !!isIncludeTimeOffsetInDateTimes);
|
|
138
|
+
return setPreference(INCLUDE_TIME_OFFSET, isIncludeTimeOffsetInDateTimes);
|
|
139
|
+
};
|
|
140
|
+
|
|
119
141
|
/**
|
|
120
142
|
* Retrieves login settings from runtime preferences and sets them as setting in the preference reducer
|
|
121
143
|
*/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import ModelCatalogReducer from "../ModelCatalogReducer";
|
|
2
|
+
import { DateUtil } from "../../../utils";
|
|
3
|
+
import { INCLUDE_TIME_OFFSET, setSettings } from "../../../constants";
|
|
4
|
+
|
|
5
|
+
describe("modelcatalog reducer", () => {
|
|
6
|
+
it("should return the initial state", () => {
|
|
7
|
+
setSettings({ [INCLUDE_TIME_OFFSET]: false });
|
|
8
|
+
|
|
9
|
+
expect(ModelCatalogReducer(undefined, {})).toStrictEqual({
|
|
10
|
+
entryDate: DateUtil.now(),
|
|
11
|
+
});
|
|
12
|
+
expect(ModelCatalogReducer()).toStrictEqual({ entryDate: DateUtil.now() });
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should handle UPDATE_ENTRYDATE", () => {
|
|
16
|
+
expect(
|
|
17
|
+
ModelCatalogReducer(undefined, {
|
|
18
|
+
type: "UPDATE_ENTRYDATE",
|
|
19
|
+
payload: "2024-01-01",
|
|
20
|
+
}),
|
|
21
|
+
).toStrictEqual({ entryDate: "2024-01-01" });
|
|
22
|
+
});
|
|
23
|
+
});
|