@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.
Files changed (74) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/esm/constants/Constants.js +10 -0
  3. package/esm/constants/Constants.js.map +1 -1
  4. package/esm/constants/Settings.js +5 -1
  5. package/esm/constants/Settings.js.map +1 -1
  6. package/esm/models/attributes/DatetimeAttributeModel.js +39 -4
  7. package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
  8. package/esm/models/attributes/input-constraints/DatetimeFormatConstraint.js +31 -2
  9. package/esm/models/attributes/input-constraints/DatetimeFormatConstraint.js.map +1 -1
  10. package/esm/models/content/SectionModel.js +1 -1
  11. package/esm/models/content/SectionModel.js.map +1 -1
  12. package/esm/models/content/SubSectionModel.js +12 -4
  13. package/esm/models/content/SubSectionModel.js.map +1 -1
  14. package/esm/react-client/client.js +2 -1
  15. package/esm/react-client/client.js.map +1 -1
  16. package/esm/react-server/serverUtil.js +2 -1
  17. package/esm/react-server/serverUtil.js.map +1 -1
  18. package/esm/redux/actions/Preferences.js +15 -1
  19. package/esm/redux/actions/Preferences.js.map +1 -1
  20. package/esm/utils/datetime/DateTimeUtil.js +292 -94
  21. package/esm/utils/datetime/DateTimeUtil.js.map +1 -1
  22. package/lib/constants/Constants.js +11 -1
  23. package/lib/constants/Constants.js.flow +11 -0
  24. package/lib/constants/Constants.js.map +1 -1
  25. package/lib/constants/Settings.js +7 -2
  26. package/lib/constants/Settings.js.flow +6 -0
  27. package/lib/constants/Settings.js.map +1 -1
  28. package/lib/models/attributes/DatetimeAttributeModel.js +38 -3
  29. package/lib/models/attributes/DatetimeAttributeModel.js.flow +54 -4
  30. package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
  31. package/lib/models/attributes/__tests__/DatetimeAttributeModel.spec.js.flow +9 -0
  32. package/lib/models/attributes/__tests__/DatetimeAttributeModel_offset.spec.js.flow +306 -0
  33. package/lib/models/attributes/input-constraints/DatetimeFormatConstraint.js +31 -2
  34. package/lib/models/attributes/input-constraints/DatetimeFormatConstraint.js.flow +42 -3
  35. package/lib/models/attributes/input-constraints/DatetimeFormatConstraint.js.map +1 -1
  36. package/lib/models/content/SectionModel.js +1 -1
  37. package/lib/models/content/SectionModel.js.flow +2 -1
  38. package/lib/models/content/SectionModel.js.map +1 -1
  39. package/lib/models/content/SubSectionModel.js +12 -3
  40. package/lib/models/content/SubSectionModel.js.flow +20 -3
  41. package/lib/models/content/SubSectionModel.js.map +1 -1
  42. package/lib/models/content/__tests__/ContentModel.spec.js.flow +3 -3
  43. package/lib/react-client/client.js +1 -0
  44. package/lib/react-client/client.js.flow +2 -0
  45. package/lib/react-client/client.js.map +1 -1
  46. package/lib/react-server/__tests__/serverUtil.spec.js.flow +12 -0
  47. package/lib/react-server/serverUtil.js +1 -0
  48. package/lib/react-server/serverUtil.js.flow +2 -0
  49. package/lib/react-server/serverUtil.js.map +1 -1
  50. package/lib/redux/actions/Preferences.js +17 -2
  51. package/lib/redux/actions/Preferences.js.flow +22 -0
  52. package/lib/redux/actions/Preferences.js.map +1 -1
  53. package/lib/redux/reducers/__tests__/ModelCatalogReducer.spec.js.flow +23 -0
  54. package/lib/utils/datetime/DateTimeUtil.js +292 -93
  55. package/lib/utils/datetime/DateTimeUtil.js.flow +482 -172
  56. package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
  57. package/lib/utils/datetime/__tests__/DateTime.spec.js.flow +771 -483
  58. package/package.json +11 -9
  59. package/src/constants/Constants.js +11 -0
  60. package/src/constants/Settings.js +6 -0
  61. package/src/models/attributes/DatetimeAttributeModel.js +54 -4
  62. package/src/models/attributes/__tests__/DatetimeAttributeModel.spec.js +9 -0
  63. package/src/models/attributes/__tests__/DatetimeAttributeModel_offset.spec.js +306 -0
  64. package/src/models/attributes/input-constraints/DatetimeFormatConstraint.js +42 -3
  65. package/src/models/content/SectionModel.js +2 -1
  66. package/src/models/content/SubSectionModel.js +20 -3
  67. package/src/models/content/__tests__/ContentModel.spec.js +3 -3
  68. package/src/react-client/client.js +2 -0
  69. package/src/react-server/__tests__/serverUtil.spec.js +12 -0
  70. package/src/react-server/serverUtil.js +2 -0
  71. package/src/redux/actions/Preferences.js +22 -0
  72. package/src/redux/reducers/__tests__/ModelCatalogReducer.spec.js +23 -0
  73. package/src/utils/datetime/DateTimeUtil.js +482 -172
  74. 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(data: Object) {
19
- super(data, {});
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) => new SubSectionModel(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
+ });