@beinformed/ui 1.12.1 → 1.13.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 +31 -0
- package/esm/builder/mergeLayoutHintConfigurations.js +3 -3
- package/esm/builder/mergeLayoutHintConfigurations.js.map +1 -1
- package/esm/constants/Settings.js +2 -1
- package/esm/constants/Settings.js.map +1 -1
- package/esm/exceptions/ConfigurationException.js +2 -1
- package/esm/exceptions/ConfigurationException.js.map +1 -1
- package/esm/exceptions/FetchException.js +4 -3
- package/esm/exceptions/FetchException.js.map +1 -1
- package/esm/exceptions/IllegalArgumentException.js +2 -1
- package/esm/exceptions/IllegalArgumentException.js.map +1 -1
- package/esm/exceptions/IllegalReturnException.js +2 -1
- package/esm/exceptions/IllegalReturnException.js.map +1 -1
- package/esm/exceptions/IllegalStateException.js +2 -1
- package/esm/exceptions/IllegalStateException.js.map +1 -1
- package/esm/exceptions/JsonParseException.js +2 -1
- package/esm/exceptions/JsonParseException.js.map +1 -1
- package/esm/exceptions/MissingPropertyException.js +2 -1
- package/esm/exceptions/MissingPropertyException.js.map +1 -1
- package/esm/exceptions/NetworkException.js +2 -1
- package/esm/exceptions/NetworkException.js.map +1 -1
- package/esm/exceptions/NotAllowedUriException.js +2 -1
- package/esm/exceptions/NotAllowedUriException.js.map +1 -1
- package/esm/exceptions/NotFoundException.js +2 -1
- package/esm/exceptions/NotFoundException.js.map +1 -1
- package/esm/exceptions/ServerRequestException.js +2 -1
- package/esm/exceptions/ServerRequestException.js.map +1 -1
- package/esm/exceptions/ThemePropertyException.js +2 -1
- package/esm/exceptions/ThemePropertyException.js.map +1 -1
- package/esm/exceptions/TimeoutException.js +2 -1
- package/esm/exceptions/TimeoutException.js.map +1 -1
- package/esm/exceptions/UnauthorizedException.js +2 -1
- package/esm/exceptions/UnauthorizedException.js.map +1 -1
- package/esm/exceptions/UnsupportedOperationException.js +2 -1
- package/esm/exceptions/UnsupportedOperationException.js.map +1 -1
- package/esm/hooks/useContent.js +2 -2
- package/esm/hooks/useContent.js.map +1 -1
- package/esm/hooks/useDeepCompareEffect.js +2 -1
- package/esm/hooks/useDeepCompareEffect.js.map +1 -1
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useModal.js +2 -2
- package/esm/hooks/useModal.js.map +1 -1
- package/esm/hooks/useModularUI.js +0 -1
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useProgressIndicator.js +2 -2
- package/esm/i18n/Locale.js +11 -4
- package/esm/i18n/Locale.js.map +1 -1
- package/esm/i18n/Locales.js +2 -2
- package/esm/i18n/Message.js +2 -2
- package/esm/i18n/languages.js +2 -1
- package/esm/i18n/languages.js.map +1 -1
- package/esm/models/attributes/AttributeCollection.js +2 -2
- package/esm/models/attributes/AttributeContent.js +58 -30
- package/esm/models/attributes/AttributeContent.js.map +1 -1
- package/esm/models/attributes/AttributeDataHelper.js +2 -2
- package/esm/models/attributes/BooleanAttributeModel.js +2 -2
- package/esm/models/attributes/ChoiceAttributeModel.js +2 -2
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js +2 -2
- package/esm/models/attributes/CompositeAttributeChildCollection.js +2 -2
- package/esm/models/attributes/_createAttribute.js +2 -2
- package/esm/models/base/ResourceModel.js +2 -2
- package/esm/models/caseview/CaseViewModel.js +2 -1
- package/esm/models/caseview/CaseViewModel.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +2 -2
- package/esm/models/concepts/SourceReferenceModel.js +2 -2
- package/esm/models/content/ContentTOCModel.js +2 -2
- package/esm/models/filters/AssignmentFilterModel.js +2 -2
- package/esm/models/filters/BaseFilterModel.js +2 -2
- package/esm/models/filters/ConceptIndexFilterModel.js +2 -1
- package/esm/models/filters/ConceptIndexFilterModel.js.map +1 -1
- package/esm/models/filters/FilterCollection.js +2 -2
- package/esm/models/filters/FilterModel.js +2 -1
- package/esm/models/filters/FilterModel.js.map +1 -1
- package/esm/models/form/FormModel.js +28 -4
- package/esm/models/form/FormModel.js.map +1 -1
- package/esm/models/form/FormObjectModel.js +2 -2
- package/esm/models/grouping/GroupingModel.js +2 -2
- package/esm/models/links/normalizeLinkJSON.js +2 -2
- package/esm/models/list/ListDetailModel.js +2 -2
- package/esm/models/list/ListItemCollection.js +38 -0
- package/esm/models/list/ListItemCollection.js.map +1 -1
- package/esm/models/list/ListItemModel.js +14 -2
- package/esm/models/list/ListItemModel.js.map +1 -1
- package/esm/models/list/ListModel.js +17 -70
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/lookup/LookupOptionCollection.js +2 -2
- package/esm/modularui/ModularUIError.js +2 -1
- package/esm/modularui/ModularUIError.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +71 -49
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/react-server/serverUtil.js +2 -2
- package/esm/react-theme/createTheme.js +2 -2
- package/esm/redux/_i18n/reducer.js +2 -2
- package/esm/redux/_modularui/actions.js +2 -2
- package/esm/redux/_modularui/connector.js +2 -2
- package/esm/redux/_modularui/reducer.js +2 -2
- package/esm/redux/_modularui/selectors.js +2 -2
- package/esm/redux/reducers/AuthReducer.js +2 -2
- package/esm/redux/reducers/ModalsReducer.js +2 -2
- package/esm/redux/reducers/NotificationReducer.js +2 -2
- package/esm/redux/reducers/PreferencesReducer.js +2 -2
- package/esm/redux/reducers/ProgressIndicatorReducer.js +2 -2
- package/esm/redux/store/configureStore.js +2 -2
- package/esm/utils/browser/Cookies.js +18 -32
- package/esm/utils/browser/Cookies.js.map +1 -1
- package/esm/utils/fetch/xhr.js +6 -4
- package/esm/utils/fetch/xhr.js.map +1 -1
- package/lib/builder/mergeLayoutHintConfigurations.js +3 -3
- package/lib/builder/mergeLayoutHintConfigurations.js.flow +3 -3
- package/lib/builder/mergeLayoutHintConfigurations.js.map +1 -1
- package/lib/constants/Settings.js +2 -1
- package/lib/constants/Settings.js.flow +2 -0
- package/lib/constants/Settings.js.map +1 -1
- package/lib/exceptions/ConfigurationException.js +3 -1
- package/lib/exceptions/ConfigurationException.js.map +1 -1
- package/lib/exceptions/FetchException.js +5 -3
- package/lib/exceptions/FetchException.js.map +1 -1
- package/lib/exceptions/IllegalArgumentException.js +3 -1
- package/lib/exceptions/IllegalArgumentException.js.map +1 -1
- package/lib/exceptions/IllegalReturnException.js +3 -1
- package/lib/exceptions/IllegalReturnException.js.map +1 -1
- package/lib/exceptions/IllegalStateException.js +3 -1
- package/lib/exceptions/IllegalStateException.js.map +1 -1
- package/lib/exceptions/JsonParseException.js +3 -1
- package/lib/exceptions/JsonParseException.js.map +1 -1
- package/lib/exceptions/MissingPropertyException.js +3 -1
- package/lib/exceptions/MissingPropertyException.js.map +1 -1
- package/lib/exceptions/NetworkException.js +3 -1
- package/lib/exceptions/NetworkException.js.map +1 -1
- package/lib/exceptions/NotAllowedUriException.js +3 -1
- package/lib/exceptions/NotAllowedUriException.js.map +1 -1
- package/lib/exceptions/NotFoundException.js +3 -1
- package/lib/exceptions/NotFoundException.js.map +1 -1
- package/lib/exceptions/ServerRequestException.js +3 -1
- package/lib/exceptions/ServerRequestException.js.map +1 -1
- package/lib/exceptions/ThemePropertyException.js +3 -1
- package/lib/exceptions/ThemePropertyException.js.map +1 -1
- package/lib/exceptions/TimeoutException.js +3 -1
- package/lib/exceptions/TimeoutException.js.map +1 -1
- package/lib/exceptions/UnauthorizedException.js +3 -1
- package/lib/exceptions/UnauthorizedException.js.map +1 -1
- package/lib/exceptions/UnsupportedOperationException.js +3 -1
- package/lib/exceptions/UnsupportedOperationException.js.map +1 -1
- package/lib/hooks/useContent.js +2 -2
- package/lib/hooks/useContent.js.flow +2 -2
- package/lib/hooks/useContent.js.map +1 -1
- package/lib/hooks/useDeepCompareEffect.js +2 -1
- package/lib/hooks/useDeepCompareEffect.js.flow +1 -1
- package/lib/hooks/useDeepCompareEffect.js.map +1 -1
- package/lib/hooks/useForm.js.flow +1 -2
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useModal.js +2 -2
- package/lib/hooks/useModal.js.flow +1 -1
- package/lib/hooks/useModal.js.map +1 -1
- package/lib/hooks/useModularUI.js +0 -1
- package/lib/hooks/useModularUI.js.flow +0 -2
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useProgressIndicator.js +2 -2
- package/lib/i18n/Locale.js +11 -5
- package/lib/i18n/Locale.js.flow +7 -0
- package/lib/i18n/Locale.js.map +1 -1
- package/lib/i18n/Locales.js +2 -2
- package/lib/i18n/Message.js +2 -2
- package/lib/i18n/__tests__/Locale.spec.js.flow +14 -0
- package/lib/i18n/languages.js +2 -1
- package/lib/i18n/languages.js.flow +1 -0
- package/lib/i18n/languages.js.map +1 -1
- package/lib/i18n/types.js.flow +1 -0
- package/lib/models/attributes/AttributeCollection.js +2 -2
- package/lib/models/attributes/AttributeContent.js +59 -31
- package/lib/models/attributes/AttributeContent.js.flow +63 -16
- package/lib/models/attributes/AttributeContent.js.map +1 -1
- package/lib/models/attributes/AttributeDataHelper.js +2 -2
- package/lib/models/attributes/BooleanAttributeModel.js +2 -2
- package/lib/models/attributes/ChoiceAttributeModel.js +2 -2
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js +2 -2
- package/lib/models/attributes/CompositeAttributeChildCollection.js +2 -2
- package/lib/models/attributes/__tests__/AttributeContent.spec.js.flow +13 -19
- package/lib/models/attributes/__tests__/StringAttributeModel.spec.js.flow +1 -1
- package/lib/models/attributes/_createAttribute.js +2 -2
- package/lib/models/base/ResourceModel.js +2 -2
- package/lib/models/base/__tests__/BaseModel.spec.js.flow +5 -5
- package/lib/models/caseview/CaseViewModel.js +3 -1
- package/lib/models/caseview/CaseViewModel.js.flow +3 -1
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/caseview/__tests__/CaseViewModel.spec.js.flow +38 -1
- package/lib/models/concepts/ConceptDetailModel.js +2 -2
- package/lib/models/concepts/SourceReferenceModel.js +2 -2
- package/lib/models/content/ContentTOCModel.js +2 -2
- package/lib/models/filters/AssignmentFilterModel.js +2 -2
- package/lib/models/filters/BaseFilterModel.js +2 -2
- package/lib/models/filters/ConceptIndexFilterModel.js +3 -1
- package/lib/models/filters/ConceptIndexFilterModel.js.map +1 -1
- package/lib/models/filters/FilterCollection.js +2 -2
- package/lib/models/filters/FilterModel.js +3 -1
- package/lib/models/filters/FilterModel.js.map +1 -1
- package/lib/models/form/FormModel.js +28 -4
- package/lib/models/form/FormModel.js.flow +18 -1
- package/lib/models/form/FormModel.js.map +1 -1
- package/lib/models/form/FormObjectModel.js +2 -2
- package/lib/models/form/__tests__/FormModel.getters.spec.js.flow +15 -0
- package/lib/models/grouping/GroupingModel.js +2 -2
- package/lib/models/links/normalizeLinkJSON.js +2 -2
- package/lib/models/list/ListDetailModel.js +2 -2
- package/lib/models/list/ListItemCollection.js +40 -0
- package/lib/models/list/ListItemCollection.js.flow +38 -1
- package/lib/models/list/ListItemCollection.js.map +1 -1
- package/lib/models/list/ListItemModel.js +14 -2
- package/lib/models/list/ListItemModel.js.flow +15 -0
- package/lib/models/list/ListItemModel.js.map +1 -1
- package/lib/models/list/ListModel.js +16 -71
- package/lib/models/list/ListModel.js.flow +1 -45
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/list/__tests__/ListItemCollection.spec.js.flow +22 -0
- package/lib/models/list/__tests__/ListModel.spec.js.flow +0 -2
- package/lib/models/lookup/LookupOptionCollection.js +2 -2
- package/lib/models/panels/__tests__/GroupingPanelModel.spec.js.flow +38 -21
- package/lib/models/process/__tests__/ProcessStatusSettingsModel.spec.js.flow +11 -0
- package/lib/models/types.js.flow +3 -3
- package/lib/modularui/ModularUIError.js +3 -1
- package/lib/modularui/ModularUIError.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +69 -49
- package/lib/modularui/ModularUIRequest.js.flow +38 -22
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/react-server/serverUtil.js +2 -2
- package/lib/react-theme/createTheme.js +2 -2
- package/lib/redux/_i18n/reducer.js +2 -2
- package/lib/redux/_modularui/actions.js +2 -2
- package/lib/redux/_modularui/connector.js +2 -2
- package/lib/redux/_modularui/reducer.js +2 -2
- package/lib/redux/_modularui/selectors.js +2 -2
- package/lib/redux/reducers/AuthReducer.js +2 -2
- package/lib/redux/reducers/ModalsReducer.js +2 -2
- package/lib/redux/reducers/NotificationReducer.js +2 -2
- package/lib/redux/reducers/PreferencesReducer.js +2 -2
- package/lib/redux/reducers/ProgressIndicatorReducer.js +2 -2
- package/lib/redux/store/configureStore.js +2 -2
- package/lib/utils/browser/Cookies.js +18 -31
- package/lib/utils/browser/Cookies.js.flow +22 -28
- package/lib/utils/browser/Cookies.js.map +1 -1
- package/lib/utils/browser/__tests__/Cookies.spec.js.flow +51 -0
- package/lib/utils/fetch/xhr.js +7 -4
- package/lib/utils/fetch/xhr.js.flow +6 -2
- package/lib/utils/fetch/xhr.js.map +1 -1
- package/package.json +36 -34
- package/src/builder/mergeLayoutHintConfigurations.js +3 -3
- package/src/constants/Settings.js +2 -0
- package/src/hooks/useContent.js +2 -2
- package/src/hooks/useDeepCompareEffect.js +1 -1
- package/src/hooks/useForm.js +1 -2
- package/src/hooks/useModal.js +1 -1
- package/src/hooks/useModularUI.js +0 -2
- package/src/i18n/Locale.js +7 -0
- package/src/i18n/__tests__/Locale.spec.js +14 -0
- package/src/i18n/languages.js +1 -0
- package/src/i18n/types.js +1 -0
- package/src/models/attributes/AttributeContent.js +63 -16
- package/src/models/attributes/__tests__/AttributeContent.spec.js +13 -19
- package/src/models/attributes/__tests__/StringAttributeModel.spec.js +1 -1
- package/src/models/base/__tests__/BaseModel.spec.js +5 -5
- package/src/models/caseview/CaseViewModel.js +3 -1
- package/src/models/caseview/__tests__/CaseViewModel.spec.js +38 -1
- package/src/models/caseview/__tests__/caseview.json +14 -3
- package/src/models/caseview/__tests__/caseviewContributions.json +48 -77
- package/src/models/caseview/__tests__/caseview_local_taskgroup.json +57 -0
- package/src/models/form/FormModel.js +18 -1
- package/src/models/form/__tests__/FormModel.getters.spec.js +15 -0
- package/src/models/list/ListItemCollection.js +38 -1
- package/src/models/list/ListItemModel.js +15 -0
- package/src/models/list/ListModel.js +1 -45
- package/src/models/list/__tests__/ListItemCollection.spec.js +22 -0
- package/src/models/list/__tests__/ListModel.spec.js +0 -2
- package/src/models/panels/__tests__/GroupingPanelModel.spec.js +38 -21
- package/src/models/panels/__tests__/groupingPanel.json +20 -1
- package/src/models/panels/__tests__/groupingPanelContributions.json +14 -1
- package/src/models/process/__tests__/ProcessStatusSettingsModel.spec.js +11 -0
- package/src/models/types.js +3 -3
- package/src/modularui/ModularUIRequest.js +38 -22
- package/src/utils/browser/Cookies.js +22 -28
- package/src/utils/browser/__tests__/Cookies.spec.js +51 -0
- package/src/utils/fetch/xhr.js +6 -2
package/src/hooks/useModal.js
CHANGED
|
@@ -25,7 +25,7 @@ export const useModal: ModalHook = (modalId: string) => {
|
|
|
25
25
|
|
|
26
26
|
const dispatch = useDispatch();
|
|
27
27
|
const modal = useSelector(({ modals }) =>
|
|
28
|
-
modals.modals.find((
|
|
28
|
+
modals.modals.find((m) => m.key === modalId)
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
const show = useCallback(() => {
|
|
@@ -38,8 +38,6 @@ export const useModularUI = (
|
|
|
38
38
|
|
|
39
39
|
// dispatch loadModularUI
|
|
40
40
|
useDeepCompareEffect(() => {
|
|
41
|
-
// console.info({ new: options }, { old: prevOptions.current });
|
|
42
|
-
|
|
43
41
|
// prevent reloads when previous option had the isReload, but the new options not
|
|
44
42
|
const isOldReload =
|
|
45
43
|
prevHref.current === href &&
|
package/src/i18n/Locale.js
CHANGED
|
@@ -15,6 +15,7 @@ class Locale {
|
|
|
15
15
|
_code: string;
|
|
16
16
|
_messages: { [string]: string };
|
|
17
17
|
_errors: { [string]: string };
|
|
18
|
+
_nativeName: ?string;
|
|
18
19
|
|
|
19
20
|
constructor(locale: LocaleConfiguration) {
|
|
20
21
|
this._code = locale.code;
|
|
@@ -22,6 +23,8 @@ class Locale {
|
|
|
22
23
|
this._messages = this.fixPlaceHoldersInObject(locale.messages);
|
|
23
24
|
this._errors = this.fixPlaceHoldersInObject(locale.errors);
|
|
24
25
|
|
|
26
|
+
this._nativeName = locale.nativeName;
|
|
27
|
+
|
|
25
28
|
formatMessage.setup({
|
|
26
29
|
missingTranslation: "ignore",
|
|
27
30
|
});
|
|
@@ -38,6 +41,10 @@ class Locale {
|
|
|
38
41
|
* Retrieve nativeName
|
|
39
42
|
*/
|
|
40
43
|
get nativeName(): string {
|
|
44
|
+
if (this._nativeName) {
|
|
45
|
+
return this._nativeName;
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
const aLocale = this.code.split("-");
|
|
42
49
|
|
|
43
50
|
if (aLocale.length > 0) {
|
|
@@ -39,6 +39,20 @@ describe("locale", () => {
|
|
|
39
39
|
expect(locale.getMessage("testMessage")).toBe("Updated message");
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
it("can handle languages without iso-639-2 code", () => {
|
|
43
|
+
const locale = new Locale({
|
|
44
|
+
code: "pap",
|
|
45
|
+
nativeName: "Papiamento",
|
|
46
|
+
messages: {
|
|
47
|
+
descr: "Papiamento",
|
|
48
|
+
},
|
|
49
|
+
errors: {},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
expect(locale.code).toBe("pap");
|
|
53
|
+
expect(locale.nativeName).toBe("Papiamento");
|
|
54
|
+
});
|
|
55
|
+
|
|
42
56
|
it("throws on non exising locale", () => {
|
|
43
57
|
const locale = new Locale({
|
|
44
58
|
code: "NONEXISTING",
|
package/src/i18n/languages.js
CHANGED
package/src/i18n/types.js
CHANGED
|
@@ -3,15 +3,19 @@ import { retrieveText } from "../../utils/helpers/text";
|
|
|
3
3
|
import { hasAllContentInData } from "../../constants/Settings";
|
|
4
4
|
import SectionModel from "../content/SectionModel";
|
|
5
5
|
|
|
6
|
+
import LayoutHintCollection from "../layouthint/LayoutHintCollection";
|
|
7
|
+
import { isPlainObject } from "../../utils";
|
|
8
|
+
|
|
6
9
|
import type {
|
|
7
10
|
ContentData,
|
|
11
|
+
ContentElementMapped,
|
|
8
12
|
PropertyData,
|
|
13
|
+
PropertyElementMapped,
|
|
9
14
|
TextFragmentData,
|
|
15
|
+
TextFragmentElementMapped,
|
|
10
16
|
ContentAll,
|
|
11
17
|
} from "../types";
|
|
12
18
|
import type SubSectionModel from "../content/SubSectionModel";
|
|
13
|
-
import LayoutHintCollection from "../layouthint/LayoutHintCollection";
|
|
14
|
-
import { isPlainObject } from "../../utils";
|
|
15
19
|
|
|
16
20
|
class AttributeContent {
|
|
17
21
|
_content: ?ContentData;
|
|
@@ -116,51 +120,84 @@ class AttributeContent {
|
|
|
116
120
|
|
|
117
121
|
/**
|
|
118
122
|
*/
|
|
119
|
-
getContentElements<T>(elementName: string
|
|
120
|
-
return
|
|
121
|
-
|
|
123
|
+
getContentElements<T>(elementName: string): Array<T> {
|
|
124
|
+
// $FlowIssue incompatible-return
|
|
125
|
+
return this.elements.filter((element) => elementName in element);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
*/
|
|
130
|
+
getContentElementCollections<T>(
|
|
131
|
+
elementName: string,
|
|
132
|
+
collectionName: string
|
|
133
|
+
): Array<T> {
|
|
134
|
+
return this.getContentElements(elementName)
|
|
122
135
|
.map((element) => element[elementName][collectionName])
|
|
123
136
|
.flat();
|
|
124
137
|
}
|
|
125
138
|
|
|
139
|
+
/**
|
|
140
|
+
*/
|
|
141
|
+
getContentElementCollectionByLabels<T, U>(
|
|
142
|
+
elementName: string,
|
|
143
|
+
collectionName: string,
|
|
144
|
+
labels: Array<string>
|
|
145
|
+
): Array<U> {
|
|
146
|
+
return (
|
|
147
|
+
this.getContentElements<T>(elementName)
|
|
148
|
+
// $FlowIssue incompatible-use
|
|
149
|
+
.filter((element) => labels.includes(element[elementName].label))
|
|
150
|
+
// $FlowIssue incompatible-use
|
|
151
|
+
.map((element) => element[elementName][collectionName])
|
|
152
|
+
.flat()
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
126
156
|
/**
|
|
127
157
|
*/
|
|
128
158
|
get properties(): Array<PropertyData> {
|
|
129
|
-
return this.
|
|
159
|
+
return this.getContentElementCollections<PropertyData>(
|
|
130
160
|
"propertyElement",
|
|
131
161
|
"properties"
|
|
132
162
|
);
|
|
133
163
|
}
|
|
134
164
|
|
|
135
165
|
/**
|
|
136
|
-
* Get concept properties by
|
|
166
|
+
* Get concept properties by property element label
|
|
137
167
|
*/
|
|
138
|
-
|
|
139
|
-
return this.
|
|
168
|
+
getConceptPropertiesByLabels(labels: Array<string>): Array<PropertyData> {
|
|
169
|
+
return this.getContentElementCollectionByLabels<
|
|
170
|
+
PropertyElementMapped,
|
|
171
|
+
PropertyData
|
|
172
|
+
>("propertyElement", "properties", labels);
|
|
140
173
|
}
|
|
141
174
|
|
|
142
175
|
/**
|
|
143
176
|
*/
|
|
144
177
|
get textfragments(): Array<TextFragmentData> {
|
|
145
|
-
return this.
|
|
178
|
+
return this.getContentElementCollections<TextFragmentData>(
|
|
146
179
|
"textFragmentElement",
|
|
147
180
|
"textfragments"
|
|
148
181
|
);
|
|
149
182
|
}
|
|
150
183
|
|
|
151
184
|
/**
|
|
152
|
-
* Get concept text fragments by
|
|
185
|
+
* Get concept text fragments by text fragment element label
|
|
153
186
|
*/
|
|
154
|
-
|
|
155
|
-
return this.
|
|
156
|
-
|
|
157
|
-
|
|
187
|
+
getTextFragmentsByLabels(labels: Array<string>): Array<TextFragmentData> {
|
|
188
|
+
return this.getContentElementCollectionByLabels<
|
|
189
|
+
TextFragmentElementMapped,
|
|
190
|
+
TextFragmentData
|
|
191
|
+
>("textFragmentElement", "textfragments", labels);
|
|
158
192
|
}
|
|
159
193
|
|
|
160
194
|
/**
|
|
161
195
|
*/
|
|
162
196
|
get sections(): Array<SectionModel> {
|
|
163
|
-
return this.
|
|
197
|
+
return this.getContentElementCollections<SectionModel>(
|
|
198
|
+
"contentElement",
|
|
199
|
+
"sections"
|
|
200
|
+
);
|
|
164
201
|
}
|
|
165
202
|
|
|
166
203
|
/**
|
|
@@ -169,6 +206,16 @@ class AttributeContent {
|
|
|
169
206
|
return this.sections.filter((section) => types.includes(section.type));
|
|
170
207
|
}
|
|
171
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Get concept text fragments by text fragment element label
|
|
211
|
+
*/
|
|
212
|
+
getSectionsByLabels(labels: Array<string>): Array<SectionModel> {
|
|
213
|
+
return this.getContentElementCollectionByLabels<
|
|
214
|
+
ContentElementMapped,
|
|
215
|
+
SectionModel
|
|
216
|
+
>("contentElement", "sections", labels);
|
|
217
|
+
}
|
|
218
|
+
|
|
172
219
|
/**
|
|
173
220
|
*/
|
|
174
221
|
getReferredSections(): Array<SectionModel | SubSectionModel> {
|
|
@@ -13,10 +13,8 @@ const json = {
|
|
|
13
13
|
{
|
|
14
14
|
propertyElement: {
|
|
15
15
|
label: "Properties",
|
|
16
|
-
id: "properties",
|
|
17
16
|
properties: [
|
|
18
17
|
{
|
|
19
|
-
type: "Gemiddelde",
|
|
20
18
|
label: "Gemiddelde",
|
|
21
19
|
value: "80%",
|
|
22
20
|
},
|
|
@@ -26,10 +24,8 @@ const json = {
|
|
|
26
24
|
{
|
|
27
25
|
propertyElement: {
|
|
28
26
|
label: "Second Properties",
|
|
29
|
-
id: "secondProperties",
|
|
30
27
|
properties: [
|
|
31
28
|
{
|
|
32
|
-
type: "SecondGemiddelde",
|
|
33
29
|
label: "Second Gemiddelde",
|
|
34
30
|
value: "20%",
|
|
35
31
|
},
|
|
@@ -38,20 +34,15 @@ const json = {
|
|
|
38
34
|
},
|
|
39
35
|
{
|
|
40
36
|
textFragmentElement: {
|
|
41
|
-
label: "Description",
|
|
42
|
-
id: "Description",
|
|
37
|
+
label: "Description TextFragment",
|
|
43
38
|
textfragments: [
|
|
44
|
-
{
|
|
45
|
-
type: "Description",
|
|
46
|
-
label: "Description",
|
|
47
|
-
text: { message: "Dit is een text fragment" },
|
|
48
|
-
},
|
|
39
|
+
{ id: "Description", text: { message: "Dit is een text fragment" } },
|
|
49
40
|
],
|
|
50
41
|
},
|
|
51
42
|
},
|
|
52
43
|
{
|
|
53
44
|
contentElement: {
|
|
54
|
-
label: "Description",
|
|
45
|
+
label: "Description Content",
|
|
55
46
|
sections: [
|
|
56
47
|
{
|
|
57
48
|
id: "Alert",
|
|
@@ -160,26 +151,29 @@ describe("AttributeContent", () => {
|
|
|
160
151
|
expect(content.sections).toHaveLength(1);
|
|
161
152
|
|
|
162
153
|
const firstProperty = content.properties[0];
|
|
163
|
-
expect(firstProperty.type).toBe("Gemiddelde");
|
|
164
154
|
expect(firstProperty.label).toBe("Gemiddelde");
|
|
165
155
|
expect(firstProperty.value).toBe("80%");
|
|
166
156
|
|
|
167
157
|
const firstTextFragment = content.textfragments[0];
|
|
168
|
-
expect(firstTextFragment.type).toBe("Description");
|
|
169
|
-
expect(firstTextFragment.label).toBe("Description");
|
|
170
158
|
expect(firstTextFragment.text).toBe("Dit is een text fragment");
|
|
171
159
|
});
|
|
172
160
|
|
|
173
161
|
it("Can ask for elements by type", () => {
|
|
174
162
|
const content = new AttributeContent(json);
|
|
175
163
|
|
|
176
|
-
expect(content.
|
|
177
|
-
|
|
164
|
+
expect(content.getConceptPropertiesByLabels("not-existing")).toHaveLength(
|
|
165
|
+
0
|
|
166
|
+
);
|
|
167
|
+
expect(content.getTextFragmentsByLabels("not-existing")).toHaveLength(0);
|
|
178
168
|
expect(content.getSectionsByType("not-existing")).toHaveLength(0);
|
|
169
|
+
expect(content.getSectionsByLabels("not-existing")).toHaveLength(0);
|
|
179
170
|
|
|
180
|
-
expect(content.
|
|
181
|
-
expect(
|
|
171
|
+
expect(content.getConceptPropertiesByLabels("Properties")).toHaveLength(1);
|
|
172
|
+
expect(
|
|
173
|
+
content.getTextFragmentsByLabels("Description TextFragment")
|
|
174
|
+
).toHaveLength(1);
|
|
182
175
|
expect(content.getSectionsByType("Reference")).toHaveLength(1);
|
|
176
|
+
expect(content.getSectionsByLabels("Description Content")).toHaveLength(1);
|
|
183
177
|
});
|
|
184
178
|
|
|
185
179
|
it("Creates ContentModel when sections available", () => {
|
|
@@ -73,13 +73,13 @@ describe("baseModel", () => {
|
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
const shallowClone = model.clone();
|
|
76
|
-
expect(model
|
|
77
|
-
expect(model.data.prop
|
|
78
|
-
expect(model.data.prop.child
|
|
76
|
+
expect(model).not.toBe(shallowClone);
|
|
77
|
+
expect(model.data.prop).toBe(shallowClone.data.prop);
|
|
78
|
+
expect(model.data.prop.child).toBe(shallowClone.data.prop.child);
|
|
79
79
|
|
|
80
80
|
const deepClone = model.clone(true);
|
|
81
|
-
expect(model
|
|
81
|
+
expect(model).not.toBe(deepClone);
|
|
82
82
|
expect(model.data.prop === deepClone.data.prop).toBeFalsy();
|
|
83
|
-
expect(model.data.prop.child
|
|
83
|
+
expect(model.data.prop.child).toBe(deepClone.data.prop.child);
|
|
84
84
|
});
|
|
85
85
|
});
|
|
@@ -6,6 +6,8 @@ import TaskGroupModel from "../taskgroup/TaskGroupModel";
|
|
|
6
6
|
|
|
7
7
|
import { TITLE } from "../../constants/LayoutHints";
|
|
8
8
|
|
|
9
|
+
import IllegalStateException from "../../exceptions/IllegalStateException";
|
|
10
|
+
|
|
9
11
|
import type { ModularUIModel, AttributeType } from "../types";
|
|
10
12
|
import type { ModularUIResponse } from "../../modularui";
|
|
11
13
|
import type LinkCollection from "../links/LinkCollection";
|
|
@@ -122,7 +124,7 @@ export default class CaseViewModel extends DetailModel {
|
|
|
122
124
|
const selfLink = this.links.getLinkByKey("self");
|
|
123
125
|
|
|
124
126
|
if (selfLink === null) {
|
|
125
|
-
throw new
|
|
127
|
+
throw new IllegalStateException("No self href available");
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
return new Href(selfLink.href);
|
|
@@ -2,13 +2,26 @@ import CaseViewModel from "../CaseViewModel";
|
|
|
2
2
|
import DetailModel from "../../detail/DetailModel";
|
|
3
3
|
|
|
4
4
|
import caseviewJson from "./caseview.json";
|
|
5
|
+
import caseviewLocalTaskgroupJson from "./caseview_local_taskgroup.json";
|
|
5
6
|
import caseviewContributionsJson from "./caseviewContributions.json";
|
|
6
7
|
|
|
8
|
+
import IllegalStateException from "../../../exceptions/IllegalStateException";
|
|
9
|
+
|
|
7
10
|
describe("caseViewModel", () => {
|
|
8
11
|
it("should be able to create an empty casedetail", () => {
|
|
9
12
|
const caseview = new CaseViewModel({});
|
|
10
13
|
|
|
11
14
|
expect(caseview).toBeInstanceOf(CaseViewModel);
|
|
15
|
+
expect(caseview.getInitialChildModelLinks()).toHaveLength(0);
|
|
16
|
+
expect(caseview.panelLinks).toHaveLength(0);
|
|
17
|
+
expect(caseview.introtext).toBe("");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("throws when no self link is available", () => {
|
|
21
|
+
const caseview = new CaseViewModel({});
|
|
22
|
+
expect(() => {
|
|
23
|
+
caseview.selfhref;
|
|
24
|
+
}).toThrow(IllegalStateException);
|
|
12
25
|
});
|
|
13
26
|
|
|
14
27
|
it("should be able to create a casedetail from a typical modular UI json structure", () => {
|
|
@@ -18,6 +31,8 @@ describe("caseViewModel", () => {
|
|
|
18
31
|
contributions: caseviewContributionsJson,
|
|
19
32
|
});
|
|
20
33
|
|
|
34
|
+
expect(caseDetail.viewLabel).toBe("Book");
|
|
35
|
+
expect(caseDetail.hasIntroText()).toBe(true);
|
|
21
36
|
expect(caseDetail).toBeInstanceOf(CaseViewModel);
|
|
22
37
|
expect(caseDetail).toBeInstanceOf(DetailModel);
|
|
23
38
|
|
|
@@ -25,13 +40,35 @@ describe("caseViewModel", () => {
|
|
|
25
40
|
expect(caseDetail.id).toBe(24);
|
|
26
41
|
|
|
27
42
|
expect(caseDetail.casename.value).toBe("The safety of objects");
|
|
43
|
+
|
|
44
|
+
expect(caseDetail.hasTaskGroups()).toBe(false);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should be able to handle local taskgroup", () => {
|
|
48
|
+
const caseDetail = new CaseViewModel({
|
|
49
|
+
key: "Book",
|
|
50
|
+
data: caseviewLocalTaskgroupJson,
|
|
51
|
+
contributions: caseviewContributionsJson,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
expect(caseDetail.hasTaskGroups()).toBe(true);
|
|
55
|
+
expect(caseDetail.taskGroupCollection).toHaveLength(1);
|
|
28
56
|
});
|
|
29
57
|
|
|
30
58
|
it("should be able to handle different kind of introtext", () => {
|
|
31
59
|
const caseviewOldStructure = new CaseViewModel({
|
|
32
60
|
key: "Book",
|
|
33
61
|
data: caseviewJson,
|
|
34
|
-
contributions:
|
|
62
|
+
contributions: {
|
|
63
|
+
...caseviewContributionsJson,
|
|
64
|
+
text: undefined,
|
|
65
|
+
texts: [
|
|
66
|
+
{
|
|
67
|
+
type: "master",
|
|
68
|
+
text: "<p>This is introtext</p>",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
35
72
|
});
|
|
36
73
|
|
|
37
74
|
expect(caseviewOldStructure.introtext).toBe("<p>This is introtext</p>");
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
"href": "/books/book/24"
|
|
5
5
|
},
|
|
6
6
|
"api_doc": {
|
|
7
|
-
"href": "/api-docs/books/book/
|
|
7
|
+
"href": "/api-docs/v3/books/book/(case-id)"
|
|
8
8
|
},
|
|
9
9
|
"contributions": {
|
|
10
|
-
"href": "/contributions/books/book/
|
|
10
|
+
"href": "/contributions/books/book/(case-id)"
|
|
11
|
+
},
|
|
12
|
+
"Details": {
|
|
13
|
+
"href": "/books/book/24/details"
|
|
11
14
|
},
|
|
12
15
|
"Creator": {
|
|
13
16
|
"href": "/books/book/24/creator"
|
|
@@ -19,6 +22,14 @@
|
|
|
19
22
|
"href": "/books/book/24/activities"
|
|
20
23
|
},
|
|
21
24
|
"taskgroup": [
|
|
25
|
+
{
|
|
26
|
+
"href": "/books/book/24/contributors-tasks",
|
|
27
|
+
"name": "Contributors"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"href": "/books/book/24/delivery-tasks",
|
|
31
|
+
"name": "Delivery"
|
|
32
|
+
},
|
|
22
33
|
{
|
|
23
34
|
"href": "/books/book/24/Tasks",
|
|
24
35
|
"name": "Tasks"
|
|
@@ -35,4 +46,4 @@
|
|
|
35
46
|
"Language": "EN",
|
|
36
47
|
"NumberOfPages": 176,
|
|
37
48
|
"State": "Registered"
|
|
38
|
-
}
|
|
49
|
+
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"label": "Book",
|
|
3
3
|
"resourcetype": "CaseView",
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
],
|
|
4
|
+
"text": {
|
|
5
|
+
"id": "Book_master",
|
|
6
|
+
"message": "<p>This is introtext</p>"
|
|
7
|
+
},
|
|
10
8
|
"_links": {
|
|
11
9
|
"panel": [
|
|
10
|
+
{
|
|
11
|
+
"name": "Details",
|
|
12
|
+
"label": "Details",
|
|
13
|
+
"resourcetype": "CasePropertiesPanel"
|
|
14
|
+
},
|
|
12
15
|
{
|
|
13
16
|
"name": "Creator",
|
|
14
17
|
"label": "Creator",
|
|
@@ -27,12 +30,35 @@
|
|
|
27
30
|
],
|
|
28
31
|
"taskgroup": [
|
|
29
32
|
{
|
|
30
|
-
"name": "
|
|
31
|
-
"label": "
|
|
33
|
+
"name": "Contributors",
|
|
34
|
+
"label": "Contributors",
|
|
35
|
+
"resourcetype": "TaskGroup"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "Delivery",
|
|
39
|
+
"label": "Delivery",
|
|
40
|
+
"resourcetype": "TaskGroup"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "Book",
|
|
44
|
+
"label": "Book",
|
|
32
45
|
"resourcetype": "TaskGroup"
|
|
33
46
|
}
|
|
34
47
|
]
|
|
35
48
|
},
|
|
49
|
+
"taskgroups": [
|
|
50
|
+
{
|
|
51
|
+
"name": "Book",
|
|
52
|
+
"label": "Book",
|
|
53
|
+
"actions": [
|
|
54
|
+
{
|
|
55
|
+
"name": "delete-book",
|
|
56
|
+
"label": "Delete book",
|
|
57
|
+
"type": "form"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
],
|
|
36
62
|
"metadata": {
|
|
37
63
|
"_id": {
|
|
38
64
|
"label": "Id",
|
|
@@ -42,44 +68,25 @@
|
|
|
42
68
|
"attributes": [
|
|
43
69
|
{
|
|
44
70
|
"CaseName": {
|
|
45
|
-
"label": "Case name",
|
|
46
|
-
"type": "string",
|
|
47
|
-
"layouthint": ["title"]
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"CaseType": {
|
|
52
|
-
"label": "Case type",
|
|
53
|
-
"type": "string",
|
|
54
|
-
"layouthint": ["type"]
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"Owner": {
|
|
59
|
-
"label": "Case owner",
|
|
60
|
-
"type": "string",
|
|
61
|
-
"layouthint": ["owner"]
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"State": {
|
|
66
|
-
"label": "State",
|
|
67
71
|
"type": "string",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
]
|
|
72
|
+
"label": "Dossiernaam",
|
|
73
|
+
"layouthint": [
|
|
74
|
+
"title"
|
|
75
|
+
],
|
|
76
|
+
"displaysize": 50,
|
|
77
|
+
"maxLength": 255
|
|
75
78
|
}
|
|
76
79
|
},
|
|
77
80
|
{
|
|
78
81
|
"Format": {
|
|
79
|
-
"label": "Format",
|
|
80
82
|
"type": "string",
|
|
83
|
+
"label": "Format",
|
|
84
|
+
"optionMode": "static",
|
|
81
85
|
"multiplechoice": false,
|
|
82
|
-
"layouthint": [
|
|
86
|
+
"layouthint": [
|
|
87
|
+
"combobox"
|
|
88
|
+
],
|
|
89
|
+
"enumerated": true,
|
|
83
90
|
"options": [
|
|
84
91
|
{
|
|
85
92
|
"code": "Hardcover",
|
|
@@ -102,46 +109,10 @@
|
|
|
102
109
|
},
|
|
103
110
|
{
|
|
104
111
|
"ISBN10": {
|
|
105
|
-
"label": "ISBN10",
|
|
106
|
-
"type": "string",
|
|
107
|
-
"displaysize": 50
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
"ISBN13": {
|
|
112
|
-
"label": "ISBN13",
|
|
113
112
|
"type": "string",
|
|
113
|
+
"label": "ISBN10",
|
|
114
114
|
"displaysize": 50
|
|
115
115
|
}
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
"Language": {
|
|
119
|
-
"label": "Language",
|
|
120
|
-
"type": "string",
|
|
121
|
-
"multiplechoice": false,
|
|
122
|
-
"layouthint": ["radiobutton"],
|
|
123
|
-
"options": [
|
|
124
|
-
{
|
|
125
|
-
"code": "EN",
|
|
126
|
-
"label": "English"
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
"code": "DU",
|
|
130
|
-
"label": "Dutch"
|
|
131
|
-
}
|
|
132
|
-
]
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
"NumberOfPages": {
|
|
137
|
-
"label": "Number of pages",
|
|
138
|
-
"type": "number",
|
|
139
|
-
"format": "0",
|
|
140
|
-
"groupingSeparator": ".",
|
|
141
|
-
"decimalSeparator": ",",
|
|
142
|
-
"minimum": 1,
|
|
143
|
-
"maximum": 1000
|
|
144
|
-
}
|
|
145
116
|
}
|
|
146
117
|
]
|
|
147
|
-
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_links": {
|
|
3
|
+
"self": {
|
|
4
|
+
"href": "/books/book/24"
|
|
5
|
+
},
|
|
6
|
+
"api_doc": {
|
|
7
|
+
"href": "/api-docs/v3/books/book/(case-id)"
|
|
8
|
+
},
|
|
9
|
+
"contributions": {
|
|
10
|
+
"href": "/contributions/books/book/(case-id)"
|
|
11
|
+
},
|
|
12
|
+
"Details": {
|
|
13
|
+
"href": "/books/book/24/details"
|
|
14
|
+
},
|
|
15
|
+
"Creator": {
|
|
16
|
+
"href": "/books/book/24/creator"
|
|
17
|
+
},
|
|
18
|
+
"Editions": {
|
|
19
|
+
"href": "/books/book/24/editions"
|
|
20
|
+
},
|
|
21
|
+
"Activities": {
|
|
22
|
+
"href": "/books/book/24/activities"
|
|
23
|
+
},
|
|
24
|
+
"taskgroup": [
|
|
25
|
+
{
|
|
26
|
+
"href": "/books/book/24/contributors-tasks",
|
|
27
|
+
"name": "Contributors"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"href": "/books/book/24/delivery-tasks",
|
|
31
|
+
"name": "Delivery"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"taskgroups": [
|
|
36
|
+
{
|
|
37
|
+
"name": "Book",
|
|
38
|
+
"actions": [
|
|
39
|
+
{
|
|
40
|
+
"name": "delete-book",
|
|
41
|
+
"method": "POST",
|
|
42
|
+
"href": "/books/book/24/delete-book"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"_id": 24,
|
|
48
|
+
"CaseName": "The safety of objects",
|
|
49
|
+
"CaseType": "Book",
|
|
50
|
+
"Owner": "Arnold",
|
|
51
|
+
"Format": "Paperback",
|
|
52
|
+
"ISBN10": "1847087302",
|
|
53
|
+
"ISBN13": "9781847087300",
|
|
54
|
+
"Language": "EN",
|
|
55
|
+
"NumberOfPages": 176,
|
|
56
|
+
"State": "Registered"
|
|
57
|
+
}
|