@beinformed/ui 1.60.2 → 1.60.4
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 +15 -0
- package/esm/hooks/__tests__/useModelCatalog.spec.js.flow +0 -2
- package/esm/hooks/useModelCatalog.d.ts +1 -1
- package/esm/hooks/useModelCatalog.js +4 -4
- package/esm/hooks/useModelCatalog.js.flow +5 -5
- package/esm/hooks/useModelCatalog.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionCollection.d.ts +6 -0
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js +19 -6
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js.flow +12 -0
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/esm/models/caseview/CaseViewModel.js +1 -1
- package/esm/models/caseview/CaseViewModel.js.flow +1 -1
- package/esm/models/caseview/CaseViewModel.js.map +1 -1
- package/esm/models/concepts/__tests__/ConceptIndexModel.spec.js.flow +4 -0
- package/esm/models/filters/ConceptIndexFilterModel.js +9 -8
- package/esm/models/filters/ConceptIndexFilterModel.js.flow +15 -11
- package/esm/models/filters/ConceptIndexFilterModel.js.map +1 -1
- package/lib/hooks/useModelCatalog.d.ts +1 -1
- package/lib/hooks/useModelCatalog.js +4 -4
- package/lib/hooks/useModelCatalog.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionCollection.d.ts +6 -0
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js +19 -6
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/lib/models/caseview/CaseViewModel.js +1 -1
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/filters/ConceptIndexFilterModel.js +9 -8
- package/lib/models/filters/ConceptIndexFilterModel.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/__tests__/useModelCatalog.spec.js +0 -2
- package/src/hooks/useModelCatalog.js +5 -5
- package/src/models/attributes/ChoiceAttributeOptionCollection.js +12 -0
- package/src/models/caseview/CaseViewModel.js +1 -1
- package/src/models/concepts/__mock__/conceptindex_data.json +8 -2
- package/src/models/concepts/__tests__/ConceptIndexModel.spec.js +4 -0
- package/src/models/filters/ConceptIndexFilterModel.js +15 -11
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.60.4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.60.3...v1.60.4) (2025-04-01)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **caseview:** use readonly value for casename title ([2934444](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/29344442bd495f9fdc16773ff4198b350752a633))
|
|
11
|
+
|
|
12
|
+
## [1.60.3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.60.2...v1.60.3) (2025-03-06)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **concepts:** prevent duplicate characters in concept index filter ([108cea9](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/108cea96907757b6dd5ec604cdb4bd65962db74e))
|
|
18
|
+
* **concepts:** useContent can also return a ContentTOC ([bf59992](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/bf599922e93de615c2f11b6873beee2edf13ec9f))
|
|
19
|
+
|
|
5
20
|
## [1.60.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.60.1...v1.60.2) (2025-03-03)
|
|
6
21
|
|
|
7
22
|
|
|
@@ -8,7 +8,6 @@ import { useLocation } from "react-router";
|
|
|
8
8
|
import {
|
|
9
9
|
ConceptIndexModel,
|
|
10
10
|
ContentIndexModel,
|
|
11
|
-
ContentModel,
|
|
12
11
|
ContentTypeModel,
|
|
13
12
|
ContentTOCModel,
|
|
14
13
|
Href,
|
|
@@ -147,7 +146,6 @@ describe("modelcatalog hooks", () => {
|
|
|
147
146
|
() => useContent("/contentdetail"),
|
|
148
147
|
"content",
|
|
149
148
|
"/content/contentdetail?entryDate=" + DateUtil.now(),
|
|
150
|
-
ContentModel,
|
|
151
149
|
);
|
|
152
150
|
});
|
|
153
151
|
|
|
@@ -10,7 +10,7 @@ export function useConceptIndex(href: string | Href, key?: string, options?: Use
|
|
|
10
10
|
export function useConceptDetail(concept: string | Href, key?: string, options?: UseModularUIBasicOptions<ConceptDetailModel | BusinessScenarioModel>): (ConceptDetailModel | (BusinessScenarioModel | null)) | null;
|
|
11
11
|
export function useContentIndex(href: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentIndexModel>): ContentIndexModel | null;
|
|
12
12
|
export function useContentTOC(content: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentTOCModel>): ContentTOCModel | null;
|
|
13
|
-
export function useContent(
|
|
13
|
+
export function useContent(content: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentModel>): (ContentModel | (ContentTOCModel | null)) | null;
|
|
14
14
|
export function useContentType(contentType: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentTypeModel>): ContentTypeModel | null;
|
|
15
15
|
export function useConceptSearch(filters: SearchFilter, key?: string, options?: UseModularUIBasicOptions<ConceptIndexModel>): ConceptIndexModel | null;
|
|
16
16
|
export function useContentSearch(filters: SearchFilter, key?: string, options?: UseModularUIBasicOptions<ContentIndexModel>): ContentIndexModel | null;
|
|
@@ -86,16 +86,16 @@ export const useContentTOC = function (content) {
|
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
*/
|
|
89
|
-
export const useContent = function (
|
|
89
|
+
export const useContent = function (content) {
|
|
90
90
|
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "content";
|
|
91
91
|
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
92
92
|
const {
|
|
93
93
|
entryDate
|
|
94
94
|
} = useEntryDate();
|
|
95
|
-
const
|
|
95
|
+
const location = useLocation();
|
|
96
|
+
const href = createHref("content", content, entryDate, location, []);
|
|
96
97
|
return useModularUIBasic(key, href, {
|
|
97
|
-
expectedModels: ["Content"],
|
|
98
|
-
targetModel: ContentModel,
|
|
98
|
+
expectedModels: ["Content", "ContentTOC"],
|
|
99
99
|
...options
|
|
100
100
|
});
|
|
101
101
|
};
|
|
@@ -120,17 +120,17 @@ export const useContentTOC = (
|
|
|
120
120
|
/**
|
|
121
121
|
*/
|
|
122
122
|
export const useContent = (
|
|
123
|
-
|
|
123
|
+
content: string | Href,
|
|
124
124
|
key?: string = "content",
|
|
125
125
|
options?: UseModularUIBasicOptions<ContentModel>,
|
|
126
|
-
): ?ContentModel => {
|
|
126
|
+
): ?ContentModel | ?ContentTOCModel => {
|
|
127
127
|
const { entryDate } = useEntryDate();
|
|
128
|
+
const location = useLocation();
|
|
128
129
|
|
|
129
|
-
const href = createHref("content",
|
|
130
|
+
const href = createHref("content", content, entryDate, location, []);
|
|
130
131
|
|
|
131
132
|
return useModularUIBasic(key, href, {
|
|
132
|
-
expectedModels: ["Content"],
|
|
133
|
-
targetModel: ContentModel,
|
|
133
|
+
expectedModels: ["Content", "ContentTOC"],
|
|
134
134
|
...options,
|
|
135
135
|
});
|
|
136
136
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModelCatalog.js","names":["useSelector","useDispatch","useLocation","createHref","filterParameters","ModelCatalogModel","ConceptIndexModel","ConceptDetailModel","default","BusinessScenarioModel","ContentIndexModel","ContentTOCModel","ContentModel","useModularUIBasic","ContentTypeModel","getEntryDate","updateEntryDate","useModelCatalog","options","expectedModels","targetModel","useConceptIndex","href","key","arguments","length","undefined","entryDate","useEntryDate","url","setParameter","useConceptDetail","concept","location","useContentIndex","useContentTOC","content","useContent","contentSection","useContentType","contentType","getSearchHref","uri","filters","filterString","_Object$keys","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch","dispatch","setEntryDate"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nimport { getEntryDate } from \"../redux/selectors/modelcatalog\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport type Href from \"../models/href/Href\";\nimport type { UseModularUIBasicOptions } from \"./useModularUIBasic\";\nimport type { UpdateEntryDateAction } from \"../redux\";\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n modelCategory?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (\n options?: UseModularUIBasicOptions<ModelCatalogModel>,\n): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n ...options,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string | Href,\n key?: string = \"conceptindex\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\n \"index\",\n \"label\",\n \"modelcategory\",\n \"type\",\n ]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string | Href,\n key?: string = \"conceptdetail\",\n options?: UseModularUIBasicOptions<\n ConceptDetailModel | BusinessScenarioModel,\n >,\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string | Href,\n key?: string = \"contentindex\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string | Href,\n key?: string = \"contenttoc\",\n options?: UseModularUIBasicOptions<ContentTOCModel>,\n): ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContent = (\n contentSection: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel => {\n const { entryDate } = useEntryDate();\n\n const href = createHref(\"content\", contentSection, entryDate, null, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\"],\n targetModel: ContentModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string | Href,\n key?: string = \"contenttypes\",\n options?: UseModularUIBasicOptions<ContentTypeModel>,\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, null, []);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n ...options,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key, options);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key, options);\n};\n\n/**\n * Retrieve and update the entrydate for the modelcatalog\n */\nexport const useEntryDate = (): ({\n entryDate: ISO_DATE,\n setEntryDate: (entryDate: ISO_DATE) => UpdateEntryDateAction,\n}) => {\n const dispatch = useDispatch();\n const entryDate = useSelector(getEntryDate);\n\n return {\n entryDate,\n setEntryDate: (entryDate: ISO_DATE) => dispatch(updateEntryDate(entryDate)),\n };\n};\n"],"mappings":";AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,aAAa;AACtD,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,UAAU,EAAEC,gBAAgB,QAAQ,6BAA6B;AAE1E,OAAOC,iBAAiB,MAAM,0CAA0C;AACxE,OAAOC,iBAAiB,MAAM,sCAAsC;AACpE,OAAOC,kBAAkB,MAAM,uCAAuC;AACtE,SAASC,OAAO,IAAIC,qBAAqB,QAAQ,0CAA0C;AAC3F,OAAOC,iBAAiB,MAAM,qCAAqC;AACnE,OAAO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;;AAED;AACA;AACA,OAAO,MAAMoC,gBAAgB,GAAG,SAAAA,CAC9BX,OAAqB,EAGE;EAAA,IAFvBpB,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAAA,IAC9BN,OAAqD,GAAAM,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAMJ,IAAI,GAAGmB,aAAa,CAAC,UAAU,EAAEE,OAAO,CAAC;EAC/C,OAAOT,eAAe,CAACZ,IAAI,EAAEC,GAAG,EAAEL,OAAO,CAAC;AAC5C,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMU,YAAY,GAAGA,CAAA,KAGtB;EACJ,MAAM2B,QAAQ,GAAGtD,WAAW,CAAC,CAAC;EAC9B,MAAM0B,SAAS,GAAG3B,WAAW,CAACe,YAAY,CAAC;EAE3C,OAAO;IACLY,SAAS;IACT6B,YAAY,EAAG7B,SAAmB,IAAK4B,QAAQ,CAACvC,eAAe,CAACW,SAAS,CAAC;EAC5E,CAAC;AACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useModelCatalog.js","names":["useSelector","useDispatch","useLocation","createHref","filterParameters","ModelCatalogModel","ConceptIndexModel","ConceptDetailModel","default","BusinessScenarioModel","ContentIndexModel","ContentTOCModel","ContentModel","useModularUIBasic","ContentTypeModel","getEntryDate","updateEntryDate","useModelCatalog","options","expectedModels","targetModel","useConceptIndex","href","key","arguments","length","undefined","entryDate","useEntryDate","url","setParameter","useConceptDetail","concept","location","useContentIndex","useContentTOC","content","useContent","useContentType","contentType","getSearchHref","uri","filters","filterString","_Object$keys","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch","dispatch","setEntryDate"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nimport { getEntryDate } from \"../redux/selectors/modelcatalog\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport type Href from \"../models/href/Href\";\nimport type { UseModularUIBasicOptions } from \"./useModularUIBasic\";\nimport type { UpdateEntryDateAction } from \"../redux\";\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n modelCategory?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (\n options?: UseModularUIBasicOptions<ModelCatalogModel>,\n): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n ...options,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string | Href,\n key?: string = \"conceptindex\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\n \"index\",\n \"label\",\n \"modelcategory\",\n \"type\",\n ]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string | Href,\n key?: string = \"conceptdetail\",\n options?: UseModularUIBasicOptions<\n ConceptDetailModel | BusinessScenarioModel,\n >,\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string | Href,\n key?: string = \"contentindex\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string | Href,\n key?: string = \"contenttoc\",\n options?: UseModularUIBasicOptions<ContentTOCModel>,\n): ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContent = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string | Href,\n key?: string = \"contenttypes\",\n options?: UseModularUIBasicOptions<ContentTypeModel>,\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, null, []);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n ...options,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key, options);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key, options);\n};\n\n/**\n * Retrieve and update the entrydate for the modelcatalog\n */\nexport const useEntryDate = (): ({\n entryDate: ISO_DATE,\n setEntryDate: (entryDate: ISO_DATE) => UpdateEntryDateAction,\n}) => {\n const dispatch = useDispatch();\n const entryDate = useSelector(getEntryDate);\n\n return {\n entryDate,\n setEntryDate: (entryDate: ISO_DATE) => dispatch(updateEntryDate(entryDate)),\n };\n};\n"],"mappings":";AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,aAAa;AACtD,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,UAAU,EAAEC,gBAAgB,QAAQ,6BAA6B;AAE1E,OAAOC,iBAAiB,MAAM,0CAA0C;AACxE,OAAOC,iBAAiB,MAAM,sCAAsC;AACpE,OAAOC,kBAAkB,MAAM,uCAAuC;AACtE,SAASC,OAAO,IAAIC,qBAAqB,QAAQ,0CAA0C;AAC3F,OAAOC,iBAAiB,MAAM,qCAAqC;AACnE,OAAOC,eAAe,MAAM,mCAAmC;AAC/D,OAAOC,YAAY,MAAM,gCAAgC;AAEzD,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,gBAAgB,QAAQ,WAAW;AAE5C,SAASC,YAAY,QAAQ,iCAAiC;AAC9D,SAASC,eAA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AA,GAAAF,SAAA,MAAG,eAAe;EAAA,IAC9BN,OAAqD,GAAAM,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAMJ,IAAI,GAAGkB,aAAa,CAAC,UAAU,EAAEE,OAAO,CAAC;EAC/C,OAAOR,eAAe,CAACZ,IAAI,EAAEC,GAAG,EAAEL,OAAO,CAAC;AAC5C,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMU,YAAY,GAAGA,CAAA,KAGtB;EACJ,MAAM0B,QAAQ,GAAGrD,WAAW,CAAC,CAAC;EAC9B,MAAM0B,SAAS,GAAG3B,WAAW,CAACe,YAAY,CAAC;EAE3C,OAAO;IACLY,SAAS;IACT4B,YAAY,EAAG5B,SAAmB,IAAK2B,QAAQ,CAACtC,eAAe,CAACW,SAAS,CAAC;EAC5E,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -39,6 +39,12 @@ declare class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceA
|
|
|
39
39
|
/**
|
|
40
40
|
*/
|
|
41
41
|
addOption(data: string | Array<string>, contributions: Object): ChoiceAttributeOptionCollection;
|
|
42
|
+
/**
|
|
43
|
+
*/
|
|
44
|
+
getOptionByCode(code: string): ChoiceAttributeOptionModel | void;
|
|
45
|
+
/**
|
|
46
|
+
*/
|
|
47
|
+
hasOptionByCode(code: string): boolean;
|
|
42
48
|
/**
|
|
43
49
|
* Get all options that have selected property true
|
|
44
50
|
*/
|
|
@@ -160,6 +160,19 @@ class ChoiceAttributeOptionCollection extends ResourceCollection {
|
|
|
160
160
|
return this;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
/**
|
|
164
|
+
*/
|
|
165
|
+
getOptionByCode(code) {
|
|
166
|
+
var _context4;
|
|
167
|
+
return _findInstanceProperty(_context4 = this.collection).call(_context4, option => option.code === code);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
*/
|
|
172
|
+
hasOptionByCode(code) {
|
|
173
|
+
return this.collection.some(option => option.code === code);
|
|
174
|
+
}
|
|
175
|
+
|
|
163
176
|
/**
|
|
164
177
|
* Get all options that have selected property true
|
|
165
178
|
*/
|
|
@@ -180,8 +193,8 @@ class ChoiceAttributeOptionCollection extends ResourceCollection {
|
|
|
180
193
|
* Deselect all options
|
|
181
194
|
*/
|
|
182
195
|
deselectAll() {
|
|
183
|
-
var
|
|
184
|
-
this.collection = _mapInstanceProperty(
|
|
196
|
+
var _context5;
|
|
197
|
+
this.collection = _mapInstanceProperty(_context5 = this.collection).call(_context5, option => {
|
|
185
198
|
const newOption = option.clone();
|
|
186
199
|
newOption.selected = false;
|
|
187
200
|
if (newOption.children) {
|
|
@@ -209,8 +222,8 @@ class ChoiceAttributeOptionCollection extends ResourceCollection {
|
|
|
209
222
|
* Toggle an option by it's code
|
|
210
223
|
*/
|
|
211
224
|
toggle(optionCode, action) {
|
|
212
|
-
var
|
|
213
|
-
this.collection = _mapInstanceProperty(
|
|
225
|
+
var _context6;
|
|
226
|
+
this.collection = _mapInstanceProperty(_context6 = this.collection).call(_context6, option => {
|
|
214
227
|
const newOption = option.clone();
|
|
215
228
|
if (newOption.code === optionCode) {
|
|
216
229
|
newOption.selected = action === "select";
|
|
@@ -224,8 +237,8 @@ class ChoiceAttributeOptionCollection extends ResourceCollection {
|
|
|
224
237
|
/**
|
|
225
238
|
*/
|
|
226
239
|
setReferenceDate(date) {
|
|
227
|
-
var
|
|
228
|
-
return _mapInstanceProperty(
|
|
240
|
+
var _context7;
|
|
241
|
+
return _mapInstanceProperty(_context7 = this.collection).call(_context7, option => {
|
|
229
242
|
option.referenceDate = date;
|
|
230
243
|
if (option.children) {
|
|
231
244
|
option.children.referenceDate = date;
|
|
@@ -202,6 +202,18 @@ class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttribute
|
|
|
202
202
|
return this;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
/**
|
|
206
|
+
*/
|
|
207
|
+
getOptionByCode(code: string): ChoiceAttributeOptionModel | void {
|
|
208
|
+
return this.collection.find((option) => option.code === code);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
*/
|
|
213
|
+
hasOptionByCode(code: string): boolean {
|
|
214
|
+
return this.collection.some((option) => option.code === code);
|
|
215
|
+
}
|
|
216
|
+
|
|
205
217
|
/**
|
|
206
218
|
* Get all options that have selected property true
|
|
207
219
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceAttributeOptionCollection.js","names":["ResourceCollection","ChoiceAttributeOptionModel","ListHeaderModel","getBasePathModularUI","ChoiceAttributeOptionCollection","constructor","modelOptions","_defineProperty","_modelOptions","origin","contextPath","referenceDate","Date","toISOString","split","sortOptions","_sortOptions","collection","forEach","option","children","create","data","arguments","length","undefined","contributions","type","addBooleanOptions","value","dynamicschema","addDynamicSchema","options","addOptions","addHeaders","all","_context","_sortInstanceProperty","call","a","b","label","localeCompare","getSelectedOptions","selectedOptions","Array","isArray","_context2","_context3","push","_mapInstanceProperty","_filterInstanceProperty","selected","key","toString","getOptionCount","code","foundOption","_findInstanceProperty","count","selectedValues","optionContributions","optionCode","addOption","optionType","optionDynamicschema","elementsContributions","addBooleanOption","defaultLabel","isBooleanType","hasAlternativeLabel","optionValue","optionModel","add","deselectAll","_context4","newOption","clone","select","toggle","deselect","action","_context5","setReferenceDate","date","_context6","headers","_headers","child","mergeOptions","withOptions","addNotExistingOptions","removeNotExistingOptions","newCollection","withOption","mergeOption","some","opt","callbackfn","thisArg","optionIndex","collectionArray","result"],"sources":["../../../src/models/attributes/ChoiceAttributeOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport ListHeaderModel from \"../list/ListHeaderModel\";\n\nimport { getBasePathModularUI } from \"../../constants\";\n\nimport type { ChoiceAttributeOptionModelOptions } from \"./ChoiceAttributeOptionModel\";\n/**\n */\nclass ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n _modelOptions: ChoiceAttributeOptionModelOptions;\n _headers: Array<ListHeaderModel> = [];\n _sortOptions: boolean = false;\n\n constructor(modelOptions?: ChoiceAttributeOptionModelOptions) {\n super();\n this._modelOptions = modelOptions || {\n origin: \"\",\n contextPath: getBasePathModularUI(),\n referenceDate: new Date().toISOString().split(\"T\")[0],\n };\n }\n\n /**\n */\n set sortOptions(sortOptions: boolean) {\n this._sortOptions = sortOptions;\n\n this.collection.forEach((option) => {\n if (option.children) {\n option.children.sortOptions = sortOptions;\n }\n });\n }\n\n /**\n */\n get sortOptions(): boolean {\n return this._sortOptions;\n }\n\n /**\n */\n static create(\n data: Object = {},\n contributions: Object = {},\n modelOptions?: ChoiceAttributeOptionModelOptions,\n ): ChoiceAttributeOptionCollection {\n const collection = new ChoiceAttributeOptionCollection(modelOptions);\n\n if (contributions.type === \"boolean\") {\n collection.addBooleanOptions(data.value, contributions);\n } else if (data.dynamicschema != null) {\n collection.addDynamicSchema(data, contributions);\n } else if (contributions.options != null) {\n collection.addOptions(data, contributions);\n }\n\n if (contributions.children != null) {\n collection.addHeaders(contributions.children);\n }\n\n return collection;\n }\n\n /**\n * Retrieve all items in collection\n */\n get all(): Array<ChoiceAttributeOptionModel> {\n return this.sortOptions\n ? this.collection.sort((a, b) => a.label.localeCompare(b.label))\n : this.collection;\n }\n\n /**\n */\n getSelectedOptions(data: Object): Array<string> {\n const selectedOptions = [];\n\n if (Array.isArray(data.options)) {\n selectedOptions.push(\n ...data.options\n .filter((option) => option.selected)\n .map((option) => option.key),\n );\n } else if (Array.isArray(data.value)) {\n selectedOptions.push(...data.value);\n } else if (typeof data.value === \"boolean\") {\n selectedOptions.push(data.value.toString());\n } else {\n selectedOptions.push(data.value);\n }\n\n return selectedOptions;\n }\n\n /**\n */\n getOptionCount(code: string, options: Array<Object>): number | null {\n if (Array.isArray(options)) {\n const foundOption = options.find((option) => option.key === code);\n if (foundOption) {\n return foundOption.count;\n }\n }\n\n return null;\n }\n\n /**\n */\n addOptions(\n data: Object,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n\n contributions.options.forEach((optionContributions) => {\n const optionCode = optionContributions.code || optionContributions.key;\n\n this.addOption(selectedValues, {\n ...optionContributions,\n count: this.getOptionCount(optionCode, data.options),\n optionType: contributions.optionType ?? \"generic\",\n });\n });\n\n return this;\n }\n\n /**\n * Create options based on data and dynamischema\n */\n addDynamicSchema(\n data: Object,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n data.dynamicschema.forEach((optionDynamicschema) => {\n this.addOption(selectedValues, {\n ...optionDynamicschema,\n count: this.getOptionCount(optionDynamicschema.code, data.options),\n optionType: contributions.optionType ?? \"generic\",\n elementsContributions: contributions.children,\n });\n });\n\n return this;\n }\n\n /**\n */\n addBooleanOption(\n code: \"true\" | \"false\",\n defaultLabel: string,\n data: string | Array<string>,\n options: Array<Object> = [],\n ) {\n const foundOption = options.find((option) => option.code === code);\n\n const label = foundOption ? foundOption.label : defaultLabel;\n\n this.addOption(data, {\n code,\n label,\n isBooleanType: true,\n hasAlternativeLabel: foundOption != null,\n });\n }\n\n /**\n * Create two static options for true and false,\n * there might be alternative labels configured for each option value\n */\n addBooleanOptions(\n value: any,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const optionValue = value == null ? [] : [value.toString()];\n\n this.addBooleanOption(\"true\", \"Yes\", optionValue, contributions.options);\n this.addBooleanOption(\"false\", \"No\", optionValue, contributions.options);\n\n return this;\n }\n\n /**\n */\n addOption(\n data: string | Array<string>,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const optionModel = new ChoiceAttributeOptionModel(\n Array.isArray(data) ? data : [data],\n contributions,\n this._modelOptions,\n );\n\n this.add(optionModel);\n\n return this;\n }\n\n /**\n * Get all options that have selected property true\n */\n get selected(): Array<ChoiceAttributeOptionModel> {\n const selectedOptions = [];\n\n this.collection.forEach((option: ChoiceAttributeOptionModel) => {\n if (option.selected && option.selected === true) {\n selectedOptions.push(option);\n }\n\n if (option.children) {\n selectedOptions.push(...option.children.selected);\n }\n });\n\n return selectedOptions;\n }\n\n /**\n * Deselect all options\n */\n deselectAll() {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n newOption.selected = false;\n\n if (newOption.children) {\n newOption.children.deselectAll();\n }\n\n return newOption;\n });\n }\n\n /**\n * Select an option by it's code\n */\n select(optionCode: string) {\n this.toggle(optionCode, \"select\");\n }\n\n /**\n * Deselect an option by it's code\n */\n deselect(optionCode: string) {\n this.toggle(optionCode, \"deselect\");\n }\n\n /**\n * Toggle an option by it's code\n */\n toggle(optionCode: string, action: \"select\" | \"deselect\") {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n if (newOption.code === optionCode) {\n newOption.selected = action === \"select\";\n } else if (newOption.children) {\n newOption.children.toggle(optionCode, action);\n }\n\n return newOption;\n });\n }\n\n /**\n */\n setReferenceDate(date: ISO_DATE): Array<ChoiceAttributeOptionModel> {\n return this.collection.map((option) => {\n option.referenceDate = date;\n if (option.children) {\n option.children.referenceDate = date;\n }\n\n return option;\n });\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this.collection = this.setReferenceDate(date);\n }\n\n /**\n */\n addHeaders(headers: Array<Object>) {\n this._headers = headers.map((child) => new ListHeaderModel(child));\n }\n\n /**\n */\n get headers(): Array<ListHeaderModel> {\n if (this._headers) {\n return this._headers;\n }\n\n return [];\n }\n\n /**\n */\n mergeOptions(\n withOptions: ChoiceAttributeOptionCollection,\n addNotExistingOptions: boolean = false,\n removeNotExistingOptions: boolean = false,\n ) {\n const newCollection = [];\n\n this.collection.forEach((option) => {\n const foundOption = withOptions.find(\n (withOption) => withOption.code === option.code,\n );\n if (foundOption) {\n option.mergeOption(foundOption);\n newCollection.push(option);\n } else if (!removeNotExistingOptions) {\n newCollection.push(option);\n }\n });\n\n if (addNotExistingOptions) {\n this.collection = [\n ...newCollection,\n ...withOptions.filter(\n (option) => !this.collection.some((opt) => opt.code === option.code),\n ),\n ];\n } else {\n this.collection = newCollection;\n }\n }\n\n /**\n */\n some(\n callbackfn: (\n value: ChoiceAttributeOptionModel,\n index: number,\n array: Array<ChoiceAttributeOptionModel>,\n ) => any,\n thisArg?: any,\n ): boolean {\n return this.collection.some((option, optionIndex, collectionArray) => {\n const result = callbackfn(option, optionIndex, collectionArray);\n if (!result && option.children) {\n return option.children.some(callbackfn, thisArg);\n }\n return result;\n });\n }\n}\n\nexport default ChoiceAttributeOptionCollection;\n"],"mappings":";;;;;AACA,OAAOA,kBAAkB,MAAM,4BAA4B;AAC3D,OAAOC,0BAA0B,MAAM,8BAA8B;AACrE,OAAOC,eAAe,MAAM,yBAAyB;AAErD,SAASC,oBAAoB,QAAQ,iBAAiB;AAGtD;AACA;AACA,MAAMC,+BAA+B,SAASJ,kBAAkB,CAA6B;EAK3FK,WAAWA,CAACC,YAAgD,EAAE;IAC5D,KAAK,CAAC,CAAC;IAACC,eAAA;IAAAA,eAAA,mBAJyB,EAAE;IAAAA,eAAA,uBACb,KAAK;IAI3B,IAAI,CAACC,aAAa,GAAGF,YAAY,IAAI;MACnCG,MAAM,EAAE,EAAE;MACVC,WAAW,EAAEP,oBAAoB,CAAC,CAAC;MACnCQ,aAAa,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;EACH;;EAEA;AACF;EACE,IAAIC,WAAWA,CAACA,WAAoB,EAAE;IACpC,IAAI,CAACC,YAAY,GAAGD,WAAW;IAE/B,IAAI,CAACE,UAAU,CAACC,OAAO,CAAEC,MAAM,IAAK;MAClC,IAAIA,MAAM,CAACC,QAAQ,EAAE;QACnBD,MAAM,CAACC,QAAQ,CAACL,WAAW,GAAGA,WAAW;MAC3C;IACF,CAAC,CAAC;EACJ;;E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,OAAOD,MAAM,CAACC,QAAQ,CAAC4E,IAAI,CAACE,UAAU,EAAEC,OAAO,CAAC;MAClD;MACA,OAAOG,MAAM;IACf,CAAC,CAAC;EACJ;AACF;AAEA,eAAelG,+BAA+B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ChoiceAttributeOptionCollection.js","names":["ResourceCollection","ChoiceAttributeOptionModel","ListHeaderModel","getBasePathModularUI","ChoiceAttributeOptionCollection","constructor","modelOptions","_defineProperty","_modelOptions","origin","contextPath","referenceDate","Date","toISOString","split","sortOptions","_sortOptions","collection","forEach","option","children","create","data","arguments","length","undefined","contributions","type","addBooleanOptions","value","dynamicschema","addDynamicSchema","options","addOptions","addHeaders","all","_context","_sortInstanceProperty","call","a","b","label","localeCompare","getSelectedOptions","selectedOptions","Array","isArray","_context2","_context3","push","_mapInstanceProperty","_filterInstanceProperty","selected","key","toString","getOptionCount","code","foundOption","_findInstanceProperty","count","selectedValues","optionContributions","optionCode","addOption","optionType","optionDynamicschema","elementsContributions","addBooleanOption","defaultLabel","isBooleanType","hasAlternativeLabel","optionValue","optionModel","add","getOptionByCode","_context4","hasOptionByCode","some","deselectAll","_context5","newOption","clone","select","toggle","deselect","action","_context6","setReferenceDate","date","_context7","headers","_headers","child","mergeOptions","withOptions","addNotExistingOptions","removeNotExistingOptions","newCollection","withOption","mergeOption","opt","callbackfn","thisArg","optionIndex","collectionArray","result"],"sources":["../../../src/models/attributes/ChoiceAttributeOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport ListHeaderModel from \"../list/ListHeaderModel\";\n\nimport { getBasePathModularUI } from \"../../constants\";\n\nimport type { ChoiceAttributeOptionModelOptions } from \"./ChoiceAttributeOptionModel\";\n/**\n */\nclass ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n _modelOptions: ChoiceAttributeOptionModelOptions;\n _headers: Array<ListHeaderModel> = [];\n _sortOptions: boolean = false;\n\n constructor(modelOptions?: ChoiceAttributeOptionModelOptions) {\n super();\n this._modelOptions = modelOptions || {\n origin: \"\",\n contextPath: getBasePathModularUI(),\n referenceDate: new Date().toISOString().split(\"T\")[0],\n };\n }\n\n /**\n */\n set sortOptions(sortOptions: boolean) {\n this._sortOptions = sortOptions;\n\n this.collection.forEach((option) => {\n if (option.children) {\n option.children.sortOptions = sortOptions;\n }\n });\n }\n\n /**\n */\n get sortOptions(): boolean {\n return this._sortOptions;\n }\n\n /**\n */\n static create(\n data: Object = {},\n contributions: Object = {},\n modelOptions?: ChoiceAttributeOptionModelOptions,\n ): ChoiceAttributeOptionCollection {\n const collection = new ChoiceAttributeOptionCollection(modelOptions);\n\n if (contributions.type === \"boolean\") {\n collection.addBooleanOptions(data.value, contributions);\n } else if (data.dynamicschema != null) {\n collection.addDynamicSchema(data, contributions);\n } else if (contributions.options != null) {\n collection.addOptions(data, contributions);\n }\n\n if (contributions.children != null) {\n collection.addHeaders(contributions.children);\n }\n\n return collection;\n }\n\n /**\n * Retrieve all items in collection\n */\n get all(): Array<ChoiceAttributeOptionModel> {\n return this.sortOptions\n ? this.collection.sort((a, b) => a.label.localeCompare(b.label))\n : this.collection;\n }\n\n /**\n */\n getSelectedOptions(data: Object): Array<string> {\n const selectedOptions = [];\n\n if (Array.isArray(data.options)) {\n selectedOptions.push(\n ...data.options\n .filter((option) => option.selected)\n .map((option) => option.key),\n );\n } else if (Array.isArray(data.value)) {\n selectedOptions.push(...data.value);\n } else if (typeof data.value === \"boolean\") {\n selectedOptions.push(data.value.toString());\n } else {\n selectedOptions.push(data.value);\n }\n\n return selectedOptions;\n }\n\n /**\n */\n getOptionCount(code: string, options: Array<Object>): number | null {\n if (Array.isArray(options)) {\n const foundOption = options.find((option) => option.key === code);\n if (foundOption) {\n return foundOption.count;\n }\n }\n\n return null;\n }\n\n /**\n */\n addOptions(\n data: Object,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n\n contributions.options.forEach((optionContributions) => {\n const optionCode = optionContributions.code || optionContributions.key;\n\n this.addOption(selectedValues, {\n ...optionContributions,\n count: this.getOptionCount(optionCode, data.options),\n optionType: contributions.optionType ?? \"generic\",\n });\n });\n\n return this;\n }\n\n /**\n * Create options based on data and dynamischema\n */\n addDynamicSchema(\n data: Object,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n data.dynamicschema.forEach((optionDynamicschema) => {\n this.addOption(selectedValues, {\n ...optionDynamicschema,\n count: this.getOptionCount(optionDynamicschema.code, data.options),\n optionType: contributions.optionType ?? \"generic\",\n elementsContributions: contributions.children,\n });\n });\n\n return this;\n }\n\n /**\n */\n addBooleanOption(\n code: \"true\" | \"false\",\n defaultLabel: string,\n data: string | Array<string>,\n options: Array<Object> = [],\n ) {\n const foundOption = options.find((option) => option.code === code);\n\n const label = foundOption ? foundOption.label : defaultLabel;\n\n this.addOption(data, {\n code,\n label,\n isBooleanType: true,\n hasAlternativeLabel: foundOption != null,\n });\n }\n\n /**\n * Create two static options for true and false,\n * there might be alternative labels configured for each option value\n */\n addBooleanOptions(\n value: any,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const optionValue = value == null ? [] : [value.toString()];\n\n this.addBooleanOption(\"true\", \"Yes\", optionValue, contributions.options);\n this.addBooleanOption(\"false\", \"No\", optionValue, contributions.options);\n\n return this;\n }\n\n /**\n */\n addOption(\n data: string | Array<string>,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const optionModel = new ChoiceAttributeOptionModel(\n Array.isArray(data) ? data : [data],\n contributions,\n this._modelOptions,\n );\n\n this.add(optionModel);\n\n return this;\n }\n\n /**\n */\n getOptionByCode(code: string): ChoiceAttributeOptionModel | void {\n return this.collection.find((option) => option.code === code);\n }\n\n /**\n */\n hasOptionByCode(code: string): boolean {\n return this.collection.some((option) => option.code === code);\n }\n\n /**\n * Get all options that have selected property true\n */\n get selected(): Array<ChoiceAttributeOptionModel> {\n const selectedOptions = [];\n\n this.collection.forEach((option: ChoiceAttributeOptionModel) => {\n if (option.selected && option.selected === true) {\n selectedOptions.push(option);\n }\n\n if (option.children) {\n selectedOptions.push(...option.children.selected);\n }\n });\n\n return selectedOptions;\n }\n\n /**\n * Deselect all options\n */\n deselectAll() {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n newOption.selected = false;\n\n if (newOption.children) {\n newOption.children.deselectAll();\n }\n\n return newOption;\n });\n }\n\n /**\n * Select an option by it's code\n */\n select(optionCode: string) {\n this.toggle(optionCode, \"select\");\n }\n\n /**\n * Deselect an option by it's code\n */\n deselect(optionCode: string) {\n this.toggle(optionCode, \"deselect\");\n }\n\n /**\n * Toggle an option by it's code\n */\n toggle(optionCode: string, action: \"select\" | \"deselect\") {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n if (newOption.code === optionCode) {\n newOption.selected = action === \"select\";\n } else if (newOption.children) {\n newOption.children.toggle(optionCode, action);\n }\n\n return newOption;\n });\n }\n\n /**\n */\n setReferenceDate(date: ISO_DATE): Array<ChoiceAttributeOptionModel> {\n return this.collection.map((option) => {\n option.referenceDate = date;\n if (option.children) {\n option.children.referenceDate = date;\n }\n\n return option;\n });\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this.collection = this.setReferenceDate(date);\n }\n\n /**\n */\n addHeaders(headers: Array<Object>) {\n this._headers = headers.map((child) => new ListHeaderModel(child));\n }\n\n /**\n */\n get headers(): Array<ListHeaderModel> {\n if (this._headers) {\n return this._headers;\n }\n\n return [];\n }\n\n /**\n */\n mergeOptions(\n withOptions: ChoiceAttributeOptionCollection,\n addNotExistingOptions: boolean = false,\n removeNotExistingOptions: boolean = false,\n ) {\n const newCollection = [];\n\n this.collection.forEach((option) => {\n const foundOption = withOptions.find(\n (withOption) => withOption.code === option.code,\n );\n if (foundOption) {\n option.mergeOption(foundOption);\n newCollection.push(option);\n } else if (!removeNotExistingOptions) {\n newCollection.push(option);\n }\n });\n\n if (addNotExistingOptions) {\n this.collection = [\n ...newCollection,\n ...withOptions.filter(\n (option) => !this.collection.some((opt) => opt.code === option.code),\n ),\n ];\n } else {\n this.collection = newCollection;\n }\n }\n\n /**\n */\n some(\n callbackfn: (\n value: ChoiceAttributeOptionModel,\n index: number,\n array: Array<ChoiceAttributeOptionModel>,\n ) => any,\n thisArg?: any,\n ): boolean {\n return this.collection.some((option, optionIndex, collectionArray) => {\n const result = callbackfn(option, optionIndex, collectionArray);\n if (!result && option.children) {\n return option.children.some(callbackfn, thisArg);\n }\n return result;\n });\n }\n}\n\nexport default ChoiceAttributeOptionCollection;\n"],"mappings":";;;;;AACA,OAAOA,kBAAkB,MAAM,4BAA4B;AAC3D,OAAOC,0BAA0B,MAAM,8BAA8B;AACrE,OAAOC,eAAe,MAAM,yBAAyB;AAErD,SAASC,oBAAoB,QAAQ,iBAAiB;AAGtD;AACA;AACA,MAAMC,+BAA+B,SAASJ,kBAAkB,CAA6B;EAK3FK,WAAWA,CAACC,YAAgD,EAAE;IAC5D,KAAK,CAAC,CAAC;IAACC,eAAA;IAAAA,eAAA,mBAJyB,EAAE;IAAAA,eAAA,uBACb,KAAK;IAI3B,IAAI,CAACC,aAAa,GAAGF,YAAY,IAAI;MACnCG,MAAM,EAAE,EAAE;MACVC,WAAW,EAAEP,oBAAoB,CAAC,CAAC;MACnCQ,aAAa,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;EACH;;EAEA;AACF;EACE,IAAIC,WAAWA,CAACA,WAAoB,EAAE;IACpC,IAAI,CAACC,YAAY,GAAGD,WAAW;IAE/B,IAAI,CAACE,UAAU,CAACC,OAAO,CAAEC,MAAM,IAAK;MAClC,IAAIA,MAAM,CAACC,QAAQ,EAAE;QACnBD,MAAM,CAACC,QAAQ,CAACL,WAAW,GAAGA,WAAW;M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AG,CAAC5C,IAAI,KAAKrC,MAAM,CAACqC,IAAI,CACrE,CAAC,CACF;IACH,CAAC,MAAM;MACL,IAAI,CAACvC,UAAU,GAAGgF,aAAa;IACjC;EACF;;EAEA;AACF;EACEpB,IAAIA,CACFwB,UAIQ,EACRC,OAAa,EACJ;IACT,OAAO,IAAI,CAACrF,UAAU,CAAC4D,IAAI,CAAC,CAAC1D,MAAM,EAAEoF,WAAW,EAAEC,eAAe,KAAK;MACpE,MAAMC,MAAM,GAAGJ,UAAU,CAAClF,MAAM,EAAEoF,WAAW,EAAEC,eAAe,CAAC;MAC/D,IAAI,CAACC,MAAM,IAAItF,MAAM,CAACC,QAAQ,EAAE;QAC9B,OAAOD,MAAM,CAACC,QAAQ,CAACyD,IAAI,CAACwB,UAAU,EAAEC,OAAO,CAAC;MAClD;MACA,OAAOG,MAAM;IACf,CAAC,CAAC;EACJ;AACF;AAEA,eAAerG,+BAA+B","ignoreList":[]}
|
|
@@ -75,7 +75,7 @@ export default class CaseViewModel extends DetailModel {
|
|
|
75
75
|
* Retrieve the case label, this can be configured with a case property with the layout hint 'title'
|
|
76
76
|
*/
|
|
77
77
|
get label() {
|
|
78
|
-
return this.casename ? this.casename.
|
|
78
|
+
return this.casename ? this.casename.readonlyvalue : "";
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
|
@@ -88,7 +88,7 @@ export default class CaseViewModel extends DetailModel {
|
|
|
88
88
|
* Retrieve the case label, this can be configured with a case property with the layout hint 'title'
|
|
89
89
|
*/
|
|
90
90
|
get label(): string {
|
|
91
|
-
return this.casename ? this.casename.
|
|
91
|
+
return this.casename ? this.casename.readonlyvalue : "";
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaseViewModel.js","names":["DetailModel","Href","TaskGroupCollection","TaskGroupModel","TITLE","IllegalStateException","CaseViewModel","constructor","caseviewData","_defineProperty","createTaskGroupCollection","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","links","getLinksByGroup","all","panelLinks","setChildModels","models","errors","taskGroupModels","i","length","push","taskGroupCollection","add","casename","attributeCollection","getAttributeByLayoutHint","label","
|
|
1
|
+
{"version":3,"file":"CaseViewModel.js","names":["DetailModel","Href","TaskGroupCollection","TaskGroupModel","TITLE","IllegalStateException","CaseViewModel","constructor","caseviewData","_defineProperty","createTaskGroupCollection","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","links","getLinksByGroup","all","panelLinks","setChildModels","models","errors","taskGroupModels","i","length","push","taskGroupCollection","add","casename","attributeCollection","getAttributeByLayoutHint","label","readonlyvalue","viewLabel","getContribution","hasIntroText","introtext","_content","text","message","Array","isArray","texts","selfhref","selfLink","getLinkByKey","href","_context","allTaskgroupData","getData","allTaskgroupContributions","_mapInstanceProperty","_filterInstanceProperty","call","taskgroup","some","taskgroupContribution","name","taskgroupContributions","_findInstanceProperty","create","modelOptions","taskgroups","_taskGroupCollection","hasTaskGroups","hasItems"],"sources":["../../../src/models/caseview/CaseViewModel.js"],"sourcesContent":["// @flow\nimport DetailModel from \"../detail/DetailModel\";\nimport Href from \"../href/Href\";\nimport TaskGroupCollection from \"../taskgroup/TaskGroupCollection\";\nimport TaskGroupModel from \"../taskgroup/TaskGroupModel\";\n\nimport { TITLE } from \"../../constants/LayoutHints\";\n\nimport IllegalStateException from \"../../exceptions/IllegalStateException\";\n\nimport type { ModularUIModel, AttributeType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Model containing the details of one case.\n */\nexport default class CaseViewModel extends DetailModel {\n _taskGroupCollection: TaskGroupCollection;\n\n /**\n */\n constructor(caseviewData: ModularUIResponse) {\n super(caseviewData);\n\n this.createTaskGroupCollection();\n }\n\n /**\n */\n get type(): string {\n return \"CaseView\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"CaseViewModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"CaseView\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this.links.getLinksByGroup(\"taskgroup\").all;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.links.getLinksByGroup(\"panel\");\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n super.setChildModels(models, errors);\n\n const taskGroupModels = [];\n for (let i = 0; i < models.length; i++) {\n if (models[i] instanceof TaskGroupModel) {\n taskGroupModels.push(models[i]);\n }\n }\n\n this.taskGroupCollection.add(taskGroupModels);\n }\n\n /**\n * Getting the case name\n */\n get casename(): ?AttributeType {\n return this.attributeCollection.getAttributeByLayoutHint(TITLE);\n }\n\n /**\n * Retrieve the case label, this can be configured with a case property with the layout hint 'title'\n */\n get label(): string {\n return this.casename ? this.casename.readonlyvalue : \"\";\n }\n\n /**\n * Retrieve the label that was configured on the caseview\n */\n get viewLabel(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Check if an introtext exists for this caseview\n */\n hasIntroText(): boolean {\n return this.introtext !== \"\";\n }\n\n /**\n * Getting the introduction text configured on the case view\n */\n get introtext(): string {\n if (this.data._content) {\n return this.data._content.text.message;\n }\n\n if (this.contributions.text) {\n return this.contributions.text.message ?? this.contributions.text;\n }\n\n if (Array.isArray(this.contributions.texts)) {\n return this.contributions.texts[0].text;\n }\n\n return \"\";\n }\n\n /**\n * Getting the self href\n */\n get selfhref(): Href {\n const selfLink = this.links.getLinkByKey(\"self\");\n\n if (selfLink === null) {\n throw new IllegalStateException(\"No self href available\");\n }\n\n return selfLink.href;\n }\n\n /**\n */\n createTaskGroupCollection() {\n const allTaskgroupData = this.getData(\"taskgroups\", []);\n const allTaskgroupContributions = this.getContribution(\"taskgroups\", []);\n\n this.taskGroupCollection = allTaskgroupData\n .filter((taskgroup) =>\n allTaskgroupContributions.some(\n (taskgroupContribution) =>\n taskgroupContribution.name === taskgroup.name,\n ),\n )\n .map((taskgroup) => {\n const taskgroupContributions = allTaskgroupContributions.find(\n (taskgroupContribution) =>\n taskgroupContribution.name === taskgroup.name,\n );\n\n return TaskGroupModel.create(\n taskgroup.name,\n taskgroup,\n taskgroupContributions,\n this.modelOptions,\n );\n });\n }\n\n /**\n * Setting the taskgroup panel collection\n */\n set taskGroupCollection(taskgroups: Array<TaskGroupModel>) {\n this._taskGroupCollection = new TaskGroupCollection(taskgroups);\n }\n\n /**\n * Getting the taskgrouppanels on the tab\n */\n get taskGroupCollection(): TaskGroupCollection {\n return this._taskGroupCollection;\n }\n\n /**\n * Has taskgroups\n */\n hasTaskGroups(): boolean {\n return this.taskGroupCollection && this.taskGroupCollection.hasItems;\n }\n}\n"],"mappings":";;;;AACA,OAAOA,WAAW,MAAM,uBAAuB;AAC/C,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,mBAAmB,MAAM,kCAAkC;AAClE,OAAOC,cAAc,MAAM,6BAA6B;AAExD,SAASC,KAAK,QAAQ,6BAA6B;AAEnD,OAAOC,qBAAqB,MAAM,wCAAwC;AAQ1E;AACA;AACA;AACA,eAAe,MAAMC,aAAa,SAASN,WAAW,CAAC;EAGrD;AACF;EACEO,WAAWA,CAACC,YAA+B,EAAE;IAC3C,KAAK,CAACA,YAAY,CAAC;IAACC,eAAA;IAEpB,IAAI,CAACC,yBAAyB,CAAC,CAAC;EAClC;;EAEA;AACF;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,UAAU;EACnB;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,eAAe;EACxB;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,IAAuB,EAAW;IACzD,OACEA,IAAI,CAACC,aAAa,CAACC,YAAY,IAC/BF,IAAI,CAACC,aA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,SAAS,IAAK;MAClB,MAAMI,sBAAsB,GAAGC,qBAAA,CAAAT,yBAAyB,EAAAG,IAAA,CAAzBH,yBAAyB,EACrDM,qBAAqB,IACpBA,qBAAqB,CAACC,IAAI,KAAKH,SAAS,CAACG,IAC7C,CAAC;MAED,OAAOzD,cAAc,CAAC4D,MAAM,CAC1BN,SAAS,CAACG,IAAI,EACdH,SAAS,EACTI,sBAAsB,EACtB,IAAI,CAACG,YACP,CAAC;IACH,CAAC,CAAC;EACN;;EAEA;AACF;AACA;EACE,IAAInC,mBAAmBA,CAACoC,UAAiC,EAAE;IACzD,IAAI,CAACC,oBAAoB,GAAG,IAAIhE,mBAAmB,CAAC+D,UAAU,CAAC;EACjE;;EAEA;AACF;AACA;EACE,IAAIpC,mBAAmBA,CAAA,EAAwB;IAC7C,OAAO,IAAI,CAACqC,oBAAoB;EAClC;;EAEA;AACF;AACA;EACEC,aAAaA,CAAA,EAAY;IACvB,OAAO,IAAI,CAACtC,mBAAmB,IAAI,IAAI,CAACA,mBAAmB,CAACuC,QAAQ;EACtE;AACF","ignoreList":[]}
|
|
@@ -34,5 +34,9 @@ describe("conceptIndexModel", () => {
|
|
|
34
34
|
expect(firstItem.conceptTypeLink.href.toString()).toBe(
|
|
35
35
|
"/concepttypes/bundle-com.beinformed.fs.demo.metamodels/High%20level%20requirements.bixml/ArchitecturalSignificantRequirement",
|
|
36
36
|
);
|
|
37
|
+
|
|
38
|
+
const conceptIndexAttribute = conceptIndex.indexfilter?.attribute;
|
|
39
|
+
expect(conceptIndexAttribute.label).toBe("Index");
|
|
40
|
+
expect(conceptIndexAttribute.options.size).toBe(27);
|
|
37
41
|
});
|
|
38
42
|
});
|
|
@@ -11,17 +11,18 @@ export default class ConceptIndexFilterModel extends BaseFilterModel {
|
|
|
11
11
|
*/
|
|
12
12
|
constructor(data, contributions, modelOptions) {
|
|
13
13
|
super(data, contributions, modelOptions);
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (this.attribute instanceof ChoiceAttributeModel) {
|
|
15
|
+
const attribute = this.attribute;
|
|
16
|
+
if (attribute && data.options) {
|
|
17
|
+
var _context, _context2, _context3;
|
|
18
|
+
const selectedValues = _mapInstanceProperty(_context = _filterInstanceProperty(_context2 = data.options).call(_context2, option => option.selected)).call(_context, option => option.key);
|
|
19
|
+
_filterInstanceProperty(_context3 = data.options).call(_context3, option => !attribute.options.hasOptionByCode(option.key)).forEach(option => {
|
|
20
|
+
attribute.options.addOption(selectedValues, {
|
|
20
21
|
code: option.key,
|
|
21
22
|
label: option.key
|
|
22
23
|
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -18,19 +18,23 @@ export default class ConceptIndexFilterModel extends BaseFilterModel {
|
|
|
18
18
|
) {
|
|
19
19
|
super(data, contributions, modelOptions);
|
|
20
20
|
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
.filter((option) => option.selected)
|
|
24
|
-
.map((option) => option.key);
|
|
21
|
+
if (this.attribute instanceof ChoiceAttributeModel) {
|
|
22
|
+
const attribute: ChoiceAttributeModel = this.attribute;
|
|
25
23
|
|
|
26
|
-
data.options
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
if (attribute && data.options) {
|
|
25
|
+
const selectedValues = data.options
|
|
26
|
+
.filter((option) => option.selected)
|
|
27
|
+
.map((option) => option.key);
|
|
28
|
+
|
|
29
|
+
data.options
|
|
30
|
+
.filter((option) => !attribute.options.hasOptionByCode(option.key))
|
|
31
|
+
.forEach((option) => {
|
|
32
|
+
attribute.options.addOption(selectedValues, {
|
|
33
|
+
code: option.key,
|
|
34
|
+
label: option.key,
|
|
35
|
+
});
|
|
31
36
|
});
|
|
32
|
-
|
|
33
|
-
});
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConceptIndexFilterModel.js","names":["BaseFilterModel","ChoiceAttributeModel","ConceptIndexFilterModel","constructor","data","contributions","modelOptions","options","_context","_context2","selectedValues","_mapInstanceProperty","_filterInstanceProperty","call","option","selected","key","
|
|
1
|
+
{"version":3,"file":"ConceptIndexFilterModel.js","names":["BaseFilterModel","ChoiceAttributeModel","ConceptIndexFilterModel","constructor","data","contributions","modelOptions","attribute","options","_context","_context2","_context3","selectedValues","_mapInstanceProperty","_filterInstanceProperty","call","option","selected","key","hasOptionByCode","forEach","addOption","code","label"],"sources":["../../../src/models/filters/ConceptIndexFilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"../filters/BaseFilterModel\";\nimport ChoiceAttributeModel from \"../attributes/ChoiceAttributeModel\";\n\nimport type { ModelOptions } from \"../types\";\n\n/**\n * The concept index model is a special filter used to index all first concept label letters in de modelcatalog.\n */\nexport default class ConceptIndexFilterModel extends BaseFilterModel {\n /**\n * Construct a filter\n */\n constructor(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n if (this.attribute instanceof ChoiceAttributeModel) {\n const attribute: ChoiceAttributeModel = this.attribute;\n\n if (attribute && data.options) {\n const selectedValues = data.options\n .filter((option) => option.selected)\n .map((option) => option.key);\n\n data.options\n .filter((option) => !attribute.options.hasOptionByCode(option.key))\n .forEach((option) => {\n attribute.options.addOption(selectedValues, {\n code: option.key,\n label: option.key,\n });\n });\n }\n }\n }\n}\n"],"mappings":";;AACA,OAAOA,eAAe,MAAM,4BAA4B;AACxD,OAAOC,oBAAoB,MAAM,oCAAoC;AAIrE;AACA;AACA;AACA,eAAe,MAAMC,uBAAuB,SAASF,eAAe,CAAC;EACnE;AACF;AACA;EACEG,WAAWA,CACTC,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EAC3B;IACA,KAAK,CAACF,IAAI,EAAEC,aAAa,EAAEC,YAAY,CAAC;IAExC,IAAI,IAAI,CAACC,SAAS,YAAYN,oBAAoB,EAAE;MAClD,MAAMM,SAA+B,GAAG,IAAI,CAACA,SAAS;MAEtD,IAAIA,SAAS,IAAIH,IAAI,CAACI,OAAO,EAAE;QAAA,IAAAC,QAAA,EAAAC,SAAA,EAAAC,SAAA;QAC7B,MAAMC,cAAc,GAAGC,oBAAA,CAAAJ,QAAA,GAAAK,uBAAA,CAAAJ,SAAA,GAAAN,IAAI,CAACI,OAAO,EAAAO,IAAA,CAAAL,SAAA,EACxBM,MAAM,IAAKA,MAAM,CAACC,QAAQ,CAAC,EAAAF,IAAA,CAAAN,QAAA,EAC9BO,MAAM,IAAKA,MAAM,CAACE,GAAG,CAAC;QAE9BJ,uBAAA,CAAAH,SAAA,GAAAP,IAAI,CAACI,OAAO,EAAAO,IAAA,CAAAJ,SAAA,EACDK,MAAM,IAAK,CAACT,SAAS,CAACC,OAAO,CAACW,eAAe,CAACH,MAAM,CAACE,GAAG,CAAC,CAAC,CAClEE,OAAO,CAAEJ,MAAM,IAAK;UACnBT,SAAS,CAACC,OAAO,CAACa,SAAS,CAACT,cAAc,EAAE;YAC1CU,IAAI,EAAEN,MAAM,CAACE,GAAG;YAChBK,KAAK,EAAEP,MAAM,CAACE;UAChB,CAAC,CAAC;QACJ,CAAC,CAAC;MACN;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -10,7 +10,7 @@ export function useConceptIndex(href: string | Href, key?: string, options?: Use
|
|
|
10
10
|
export function useConceptDetail(concept: string | Href, key?: string, options?: UseModularUIBasicOptions<ConceptDetailModel | BusinessScenarioModel>): (ConceptDetailModel | (BusinessScenarioModel | null)) | null;
|
|
11
11
|
export function useContentIndex(href: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentIndexModel>): ContentIndexModel | null;
|
|
12
12
|
export function useContentTOC(content: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentTOCModel>): ContentTOCModel | null;
|
|
13
|
-
export function useContent(
|
|
13
|
+
export function useContent(content: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentModel>): (ContentModel | (ContentTOCModel | null)) | null;
|
|
14
14
|
export function useContentType(contentType: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentTypeModel>): ContentTypeModel | null;
|
|
15
15
|
export function useConceptSearch(filters: SearchFilter, key?: string, options?: UseModularUIBasicOptions<ConceptIndexModel>): ConceptIndexModel | null;
|
|
16
16
|
export function useContentSearch(filters: SearchFilter, key?: string, options?: UseModularUIBasicOptions<ContentIndexModel>): ContentIndexModel | null;
|
|
@@ -98,16 +98,16 @@ const useContentTOC = function (content) {
|
|
|
98
98
|
/**
|
|
99
99
|
*/
|
|
100
100
|
exports.useContentTOC = useContentTOC;
|
|
101
|
-
const useContent = function (
|
|
101
|
+
const useContent = function (content) {
|
|
102
102
|
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "content";
|
|
103
103
|
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
104
104
|
const {
|
|
105
105
|
entryDate
|
|
106
106
|
} = useEntryDate();
|
|
107
|
-
const
|
|
107
|
+
const location = (0, _useRouter.useLocation)();
|
|
108
|
+
const href = (0, _createHref.createHref)("content", content, entryDate, location, []);
|
|
108
109
|
return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
|
|
109
|
-
expectedModels: ["Content"],
|
|
110
|
-
targetModel: _ContentModel.default,
|
|
110
|
+
expectedModels: ["Content", "ContentTOC"],
|
|
111
111
|
...options
|
|
112
112
|
});
|
|
113
113
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModelCatalog.js","names":["_reactRedux","require","_useRouter","_createHref","_ModelCatalogModel","_interopRequireDefault","_ConceptIndexModel","_ConceptDetailModel","_BusinessScenarioModel","_ContentIndexModel","_ContentTOCModel","_ContentModel","_useModularUIBasic","_models","_modelcatalog","_ModelCatalog","useModelCatalog","options","useModularUIBasic","expectedModels","targetModel","ModelCatalogModel","exports","useConceptIndex","href","key","arguments","length","undefined","entryDate","useEntryDate","url","filterParameters","setParameter","ConceptIndexModel","useConceptDetail","concept","location","useLocation","createHref","useContentIndex","ContentIndexModel","useContentTOC","content","ContentTOCModel","useContent","contentSection","ContentModel","useContentType","contentType","ContentTypeModel","getSearchHref","uri","filters","filterString","_keys","default","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch","dispatch","useDispatch","useSelector","getEntryDate","setEntryDate","updateEntryDate"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nimport { getEntryDate } from \"../redux/selectors/modelcatalog\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport type Href from \"../models/href/Href\";\nimport type { UseModularUIBasicOptions } from \"./useModularUIBasic\";\nimport type { UpdateEntryDateAction } from \"../redux\";\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n modelCategory?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (\n options?: UseModularUIBasicOptions<ModelCatalogModel>,\n): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n ...options,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string | Href,\n key?: string = \"conceptindex\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\n \"index\",\n \"label\",\n \"modelcategory\",\n \"type\",\n ]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string | Href,\n key?: string = \"conceptdetail\",\n options?: UseModularUIBasicOptions<\n ConceptDetailModel | BusinessScenarioModel,\n >,\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string | Href,\n key?: string = \"contentindex\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string | Href,\n key?: string = \"contenttoc\",\n options?: UseModularUIBasicOptions<ContentTOCModel>,\n): ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContent = (\n contentSection: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel => {\n const { entryDate } = useEntryDate();\n\n const href = createHref(\"content\", contentSection, entryDate, null, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\"],\n targetModel: ContentModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string | Href,\n key?: string = \"contenttypes\",\n options?: UseModularUIBasicOptions<ContentTypeModel>,\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, null, []);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n ...options,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key, options);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key, options);\n};\n\n/**\n * Retrieve and update the entrydate for the modelcatalog\n */\nexport const useEntryDate = (): ({\n entryDate: ISO_DATE,\n setEntryDate: (entryDate: ISO_DATE) => UpdateEntryDateAction,\n}) => {\n const dispatch = useDispatch();\n const entryDate = useSelector(getEntryDate);\n\n return {\n entryDate,\n setEntryDate: (entryDate: ISO_DATE) => dispatch(updateEntryDate(entryDate)),\n };\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA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,GAAG,IAAAuC,uBAAW,EAACC,0BAAY,CAAC;EAE3C,OAAO;IACLxC,SAAS;IACTyC,YAAY,EAAGzC,SAAmB,IAAKqC,QAAQ,CAAC,IAAAK,6BAAe,EAAC1C,SAAS,CAAC;EAC5E,CAAC;AACH,CAAC;AAACP,OAAA,CAAAQ,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useModelCatalog.js","names":["_reactRedux","require","_useRouter","_createHref","_ModelCatalogModel","_interopRequireDefault","_ConceptIndexModel","_ConceptDetailModel","_BusinessScenarioModel","_ContentIndexModel","_ContentTOCModel","_ContentModel","_useModularUIBasic","_models","_modelcatalog","_ModelCatalog","useModelCatalog","options","useModularUIBasic","expectedModels","targetModel","ModelCatalogModel","exports","useConceptIndex","href","key","arguments","length","undefined","entryDate","useEntryDate","url","filterParameters","setParameter","ConceptIndexModel","useConceptDetail","concept","location","useLocation","createHref","useContentIndex","ContentIndexModel","useContentTOC","content","ContentTOCModel","useContent","useContentType","contentType","ContentTypeModel","getSearchHref","uri","filters","filterString","_keys","default","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch","dispatch","useDispatch","useSelector","getEntryDate","setEntryDate","updateEntryDate"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nimport { getEntryDate } from \"../redux/selectors/modelcatalog\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport type Href from \"../models/href/Href\";\nimport type { UseModularUIBasicOptions } from \"./useModularUIBasic\";\nimport type { UpdateEntryDateAction } from \"../redux\";\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n modelCategory?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (\n options?: UseModularUIBasicOptions<ModelCatalogModel>,\n): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n ...options,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string | Href,\n key?: string = \"conceptindex\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\n \"index\",\n \"label\",\n \"modelcategory\",\n \"type\",\n ]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string | Href,\n key?: string = \"conceptdetail\",\n options?: UseModularUIBasicOptions<\n ConceptDetailModel | BusinessScenarioModel,\n >,\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string | Href,\n key?: string = \"contentindex\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string | Href,\n key?: string = \"contenttoc\",\n options?: UseModularUIBasicOptions<ContentTOCModel>,\n): ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContent = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string | Href,\n key?: string = \"contenttypes\",\n options?: UseModularUIBasicOptions<ContentTypeModel>,\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, null, []);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n ...options,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key, options);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key, options);\n};\n\n/**\n * Retrieve and update the entrydate for the modelcatalog\n */\nexport const useEntryDate = (): ({\n entryDate: ISO_DATE,\n setEntryDate: (entryDate: ISO_DATE) => UpdateEntryDateAction,\n}) => {\n const dispatch = useDispatch();\n const entryDate = useSelector(getEntryDate);\n\n return {\n entryDate,\n setEntryDate: (entryDate: ISO_DATE) => dispatch(updateEntryDate(entryDate)),\n };\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,kBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,kBAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,mBAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,sBAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,kBAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AACA,IAAAS,gBAAA,GAAAL,sBAAA,CAAAJ,OAAA;AACA,IAAAU,aAAA,GAAAN,sBAAA,CAAAJ,OAAA;AAEA,IAAAW,kBAAA,GAAAX,OAAA;AACA,IAAAY,OAAA,GAAAZ,OAAA;AAEA,IAAAa,aAAA,GAAAb,OAAA;AACA,IAAAc,aAAA,GAAAd,OAAA;AAaA;AACA;AACO,MAAMe,eAAe,GAC1BC,OAAqD,IAErD,IAAAC,oCAAiB,EAAC,cAAc,EAAE,eAAe,EAAE;EACjDC,cAAc,EAAE,CAAC,cAAc,CAAC;EAChCC,WAAW,EAAEC,0BAAiB;EAC9B,GAAGJ;AACL,CAAC,CAAC;;AAEJ;AACA;AADAK,OAAA,CAAAN,eAAA,GAAAA,eAAA;AAEO,MAAMO,eAAe,GAAG,SAAAA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AA,CAC9BZ,OAAqB,EAGE;EAAA,IAFvB1B,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAAA,IAC9BT,OAAqD,GAAAS,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAMJ,IAAI,GAAGyB,aAAa,CAAC,UAAU,EAAEE,OAAO,CAAC;EAC/C,OAAOX,eAAe,CAAChB,IAAI,EAAEC,GAAG,EAAER,OAAO,CAAC;AAC5C,CAAC;;AAED;AACA;AACA;AAFAK,OAAA,CAAAyC,gBAAA,GAAAA,gBAAA;AAGO,MAAMjC,YAAY,GAAGA,CAAA,KAGtB;EACJ,MAAMkC,QAAQ,GAAG,IAAAC,uBAAW,EAAC,CAAC;EAC9B,MAAMpC,SAAS,GAAG,IAAAqC,uBAAW,EAACC,0BAAY,CAAC;EAE3C,OAAO;IACLtC,SAAS;IACTuC,YAAY,EAAGvC,SAAmB,IAAKmC,QAAQ,CAAC,IAAAK,6BAAe,EAACxC,SAAS,CAAC;EAC5E,CAAC;AACH,CAAC;AAACP,OAAA,CAAAQ,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -39,6 +39,12 @@ declare class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceA
|
|
|
39
39
|
/**
|
|
40
40
|
*/
|
|
41
41
|
addOption(data: string | Array<string>, contributions: Object): ChoiceAttributeOptionCollection;
|
|
42
|
+
/**
|
|
43
|
+
*/
|
|
44
|
+
getOptionByCode(code: string): ChoiceAttributeOptionModel | void;
|
|
45
|
+
/**
|
|
46
|
+
*/
|
|
47
|
+
hasOptionByCode(code: string): boolean;
|
|
42
48
|
/**
|
|
43
49
|
* Get all options that have selected property true
|
|
44
50
|
*/
|
|
@@ -167,6 +167,19 @@ class ChoiceAttributeOptionCollection extends _ResourceCollection.default {
|
|
|
167
167
|
return this;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
/**
|
|
171
|
+
*/
|
|
172
|
+
getOptionByCode(code) {
|
|
173
|
+
var _context4;
|
|
174
|
+
return (0, _find.default)(_context4 = this.collection).call(_context4, option => option.code === code);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
*/
|
|
179
|
+
hasOptionByCode(code) {
|
|
180
|
+
return this.collection.some(option => option.code === code);
|
|
181
|
+
}
|
|
182
|
+
|
|
170
183
|
/**
|
|
171
184
|
* Get all options that have selected property true
|
|
172
185
|
*/
|
|
@@ -187,8 +200,8 @@ class ChoiceAttributeOptionCollection extends _ResourceCollection.default {
|
|
|
187
200
|
* Deselect all options
|
|
188
201
|
*/
|
|
189
202
|
deselectAll() {
|
|
190
|
-
var
|
|
191
|
-
this.collection = (0, _map.default)(
|
|
203
|
+
var _context5;
|
|
204
|
+
this.collection = (0, _map.default)(_context5 = this.collection).call(_context5, option => {
|
|
192
205
|
const newOption = option.clone();
|
|
193
206
|
newOption.selected = false;
|
|
194
207
|
if (newOption.children) {
|
|
@@ -216,8 +229,8 @@ class ChoiceAttributeOptionCollection extends _ResourceCollection.default {
|
|
|
216
229
|
* Toggle an option by it's code
|
|
217
230
|
*/
|
|
218
231
|
toggle(optionCode, action) {
|
|
219
|
-
var
|
|
220
|
-
this.collection = (0, _map.default)(
|
|
232
|
+
var _context6;
|
|
233
|
+
this.collection = (0, _map.default)(_context6 = this.collection).call(_context6, option => {
|
|
221
234
|
const newOption = option.clone();
|
|
222
235
|
if (newOption.code === optionCode) {
|
|
223
236
|
newOption.selected = action === "select";
|
|
@@ -231,8 +244,8 @@ class ChoiceAttributeOptionCollection extends _ResourceCollection.default {
|
|
|
231
244
|
/**
|
|
232
245
|
*/
|
|
233
246
|
setReferenceDate(date) {
|
|
234
|
-
var
|
|
235
|
-
return (0, _map.default)(
|
|
247
|
+
var _context7;
|
|
248
|
+
return (0, _map.default)(_context7 = this.collection).call(_context7, option => {
|
|
236
249
|
option.referenceDate = date;
|
|
237
250
|
if (option.children) {
|
|
238
251
|
option.children.referenceDate = date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceAttributeOptionCollection.js","names":["_ResourceCollection","_interopRequireDefault","require","_ChoiceAttributeOptionModel","_ListHeaderModel","_constants","ChoiceAttributeOptionCollection","ResourceCollection","constructor","modelOptions","_defineProperty2","default","_modelOptions","origin","contextPath","getBasePathModularUI","referenceDate","Date","toISOString","split","sortOptions","_sortOptions","collection","forEach","option","children","create","data","arguments","length","undefined","contributions","type","addBooleanOptions","value","dynamicschema","addDynamicSchema","options","addOptions","addHeaders","all","_context","_sort","call","a","b","label","localeCompare","getSelectedOptions","selectedOptions","Array","isArray","_context2","_context3","push","_map","_filter","selected","key","toString","getOptionCount","code","foundOption","_find","count","selectedValues","optionContributions","optionCode","addOption","optionType","optionDynamicschema","elementsContributions","addBooleanOption","defaultLabel","isBooleanType","hasAlternativeLabel","optionValue","optionModel","ChoiceAttributeOptionModel","add","deselectAll","_context4","newOption","clone","select","toggle","deselect","action","_context5","setReferenceDate","date","_context6","headers","_headers","child","ListHeaderModel","mergeOptions","withOptions","addNotExistingOptions","removeNotExistingOptions","newCollection","withOption","mergeOption","some","opt","callbackfn","thisArg","optionIndex","collectionArray","result","_default","exports"],"sources":["../../../src/models/attributes/ChoiceAttributeOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport ListHeaderModel from \"../list/ListHeaderModel\";\n\nimport { getBasePathModularUI } from \"../../constants\";\n\nimport type { ChoiceAttributeOptionModelOptions } from \"./ChoiceAttributeOptionModel\";\n/**\n */\nclass ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n _modelOptions: ChoiceAttributeOptionModelOptions;\n _headers: Array<ListHeaderModel> = [];\n _sortOptions: boolean = false;\n\n constructor(modelOptions?: ChoiceAttributeOptionModelOptions) {\n super();\n this._modelOptions = modelOptions || {\n origin: \"\",\n contextPath: getBasePathModularUI(),\n referenceDate: new Date().toISOString().split(\"T\")[0],\n };\n }\n\n /**\n */\n set sortOptions(sortOptions: boolean) {\n this._sortOptions = sortOptions;\n\n this.collection.forEach((option) => {\n if (option.children) {\n option.children.sortOptions = sortOptions;\n }\n });\n }\n\n /**\n */\n get sortOptions(): boolean {\n return this._sortOptions;\n }\n\n /**\n */\n static create(\n data: Object = {},\n contributions: Object = {},\n modelOptions?: ChoiceAttributeOptionModelOptions,\n ): ChoiceAttributeOptionCollection {\n const collection = new ChoiceAttributeOptionCollection(modelOptions);\n\n if (contributions.type === \"boolean\") {\n collection.addBooleanOptions(data.value, contributions);\n } else if (data.dynamicschema != null) {\n collection.addDynamicSchema(data, contributions);\n } else if (contributions.options != null) {\n collection.addOptions(data, contributions);\n }\n\n if (contributions.children != null) {\n collection.addHeaders(contributions.children);\n }\n\n return collection;\n }\n\n /**\n * Retrieve all items in collection\n */\n get all(): Array<ChoiceAttributeOptionModel> {\n return this.sortOptions\n ? this.collection.sort((a, b) => a.label.localeCompare(b.label))\n : this.collection;\n }\n\n /**\n */\n getSelectedOptions(data: Object): Array<string> {\n const selectedOptions = [];\n\n if (Array.isArray(data.options)) {\n selectedOptions.push(\n ...data.options\n .filter((option) => option.selected)\n .map((option) => option.key),\n );\n } else if (Array.isArray(data.value)) {\n selectedOptions.push(...data.value);\n } else if (typeof data.value === \"boolean\") {\n selectedOptions.push(data.value.toString());\n } else {\n selectedOptions.push(data.value);\n }\n\n return selectedOptions;\n }\n\n /**\n */\n getOptionCount(code: string, options: Array<Object>): number | null {\n if (Array.isArray(options)) {\n const foundOption = options.find((option) => option.key === code);\n if (foundOption) {\n return foundOption.count;\n }\n }\n\n return null;\n }\n\n /**\n */\n addOptions(\n data: Object,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n\n contributions.options.forEach((optionContributions) => {\n const optionCode = optionContributions.code || optionContributions.key;\n\n this.addOption(selectedValues, {\n ...optionContributions,\n count: this.getOptionCount(optionCode, data.options),\n optionType: contributions.optionType ?? \"generic\",\n });\n });\n\n return this;\n }\n\n /**\n * Create options based on data and dynamischema\n */\n addDynamicSchema(\n data: Object,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n data.dynamicschema.forEach((optionDynamicschema) => {\n this.addOption(selectedValues, {\n ...optionDynamicschema,\n count: this.getOptionCount(optionDynamicschema.code, data.options),\n optionType: contributions.optionType ?? \"generic\",\n elementsContributions: contributions.children,\n });\n });\n\n return this;\n }\n\n /**\n */\n addBooleanOption(\n code: \"true\" | \"false\",\n defaultLabel: string,\n data: string | Array<string>,\n options: Array<Object> = [],\n ) {\n const foundOption = options.find((option) => option.code === code);\n\n const label = foundOption ? foundOption.label : defaultLabel;\n\n this.addOption(data, {\n code,\n label,\n isBooleanType: true,\n hasAlternativeLabel: foundOption != null,\n });\n }\n\n /**\n * Create two static options for true and false,\n * there might be alternative labels configured for each option value\n */\n addBooleanOptions(\n value: any,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const optionValue = value == null ? [] : [value.toString()];\n\n this.addBooleanOption(\"true\", \"Yes\", optionValue, contributions.options);\n this.addBooleanOption(\"false\", \"No\", optionValue, contributions.options);\n\n return this;\n }\n\n /**\n */\n addOption(\n data: string | Array<string>,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const optionModel = new ChoiceAttributeOptionModel(\n Array.isArray(data) ? data : [data],\n contributions,\n this._modelOptions,\n );\n\n this.add(optionModel);\n\n return this;\n }\n\n /**\n * Get all options that have selected property true\n */\n get selected(): Array<ChoiceAttributeOptionModel> {\n const selectedOptions = [];\n\n this.collection.forEach((option: ChoiceAttributeOptionModel) => {\n if (option.selected && option.selected === true) {\n selectedOptions.push(option);\n }\n\n if (option.children) {\n selectedOptions.push(...option.children.selected);\n }\n });\n\n return selectedOptions;\n }\n\n /**\n * Deselect all options\n */\n deselectAll() {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n newOption.selected = false;\n\n if (newOption.children) {\n newOption.children.deselectAll();\n }\n\n return newOption;\n });\n }\n\n /**\n * Select an option by it's code\n */\n select(optionCode: string) {\n this.toggle(optionCode, \"select\");\n }\n\n /**\n * Deselect an option by it's code\n */\n deselect(optionCode: string) {\n this.toggle(optionCode, \"deselect\");\n }\n\n /**\n * Toggle an option by it's code\n */\n toggle(optionCode: string, action: \"select\" | \"deselect\") {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n if (newOption.code === optionCode) {\n newOption.selected = action === \"select\";\n } else if (newOption.children) {\n newOption.children.toggle(optionCode, action);\n }\n\n return newOption;\n });\n }\n\n /**\n */\n setReferenceDate(date: ISO_DATE): Array<ChoiceAttributeOptionModel> {\n return this.collection.map((option) => {\n option.referenceDate = date;\n if (option.children) {\n option.children.referenceDate = date;\n }\n\n return option;\n });\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this.collection = this.setReferenceDate(date);\n }\n\n /**\n */\n addHeaders(headers: Array<Object>) {\n this._headers = headers.map((child) => new ListHeaderModel(child));\n }\n\n /**\n */\n get headers(): Array<ListHeaderModel> {\n if (this._headers) {\n return this._headers;\n }\n\n return [];\n }\n\n /**\n */\n mergeOptions(\n withOptions: ChoiceAttributeOptionCollection,\n addNotExistingOptions: boolean = false,\n removeNotExistingOptions: boolean = false,\n ) {\n const newCollection = [];\n\n this.collection.forEach((option) => {\n const foundOption = withOptions.find(\n (withOption) => withOption.code === option.code,\n );\n if (foundOption) {\n option.mergeOption(foundOption);\n newCollection.push(option);\n } else if (!removeNotExistingOptions) {\n newCollection.push(option);\n }\n });\n\n if (addNotExistingOptions) {\n this.collection = [\n ...newCollection,\n ...withOptions.filter(\n (option) => !this.collection.some((opt) => opt.code === option.code),\n ),\n ];\n } else {\n this.collection = newCollection;\n }\n }\n\n /**\n */\n some(\n callbackfn: (\n value: ChoiceAttributeOptionModel,\n index: number,\n array: Array<ChoiceAttributeOptionModel>,\n ) => any,\n thisArg?: any,\n ): boolean {\n return this.collection.some((option, optionIndex, collectionArray) => {\n const result = callbackfn(option, optionIndex, collectionArray);\n if (!result && option.children) {\n return option.children.some(callbackfn, thisArg);\n }\n return result;\n });\n }\n}\n\nexport default ChoiceAttributeOptionCollection;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,gBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AAGA;AACA;AACA,MAAMI,+BAA+B,SAASC,2BAAkB,CAA6B;EAK3FC,WAAWA,CAACC,YAAgD,EAAE;IAC5D,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBAJyB,EAAE;IAAA,IAAAD,gBAAA,CAAAC,OAAA,wBACb,KAAK;IAI3B,IAAI,CAACC,aAAa,GAAGH,YAAY,IAAI;MACnCI,MAAM,EAAE,EAAE;MACVC,WAAW,EAAE,IAAAC,+BAAoB,EAAC,CAAC;MACnCC,aAAa,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;EACH;;EAEA;AACF;EACE,IAAIC,WAAWA,CAACA,WAAoB,EAAE;IACpC,IAAI,CAACC,YAAY,GAAGD,WAAW;IAE/B,IAAI,CAACE,UAAU,CAACC,OAAO,CAAEC,MAAM,IAAK;MAClC,IAAIA,MAAM,CAACC,QAAQ,EAAE;QACnBD,MAAM,CAACC,QAAQ,CAACL,WAAW,GAAGA,WAAW;MAC3C;IACF,CAAC,CAAC;EACJ;;EAEA;AACF;EACE,IAAIA,WAAWA,CAAA,EAAY;IACzB,OAAO,IAAI,CAACC,YAAY;EAC1B;;EAEA;AACF;EACE,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AU,CAACjF,MAAM,EAAEmF,WAAW,EAAEC,eAAe,CAAC;MAC/D,IAAI,CAACC,MAAM,IAAIrF,MAAM,CAACC,QAAQ,EAAE;QAC9B,OAAOD,MAAM,CAACC,QAAQ,CAAC8E,IAAI,CAACE,UAAU,EAAEC,OAAO,CAAC;MAClD;MACA,OAAOG,MAAM;IACf,CAAC,CAAC;EACJ;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAApG,OAAA,GAEcL,+BAA+B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ChoiceAttributeOptionCollection.js","names":["_ResourceCollection","_interopRequireDefault","require","_ChoiceAttributeOptionModel","_ListHeaderModel","_constants","ChoiceAttributeOptionCollection","ResourceCollection","constructor","modelOptions","_defineProperty2","default","_modelOptions","origin","contextPath","getBasePathModularUI","referenceDate","Date","toISOString","split","sortOptions","_sortOptions","collection","forEach","option","children","create","data","arguments","length","undefined","contributions","type","addBooleanOptions","value","dynamicschema","addDynamicSchema","options","addOptions","addHeaders","all","_context","_sort","call","a","b","label","localeCompare","getSelectedOptions","selectedOptions","Array","isArray","_context2","_context3","push","_map","_filter","selected","key","toString","getOptionCount","code","foundOption","_find","count","selectedValues","optionContributions","optionCode","addOption","optionType","optionDynamicschema","elementsContributions","addBooleanOption","defaultLabel","isBooleanType","hasAlternativeLabel","optionValue","optionModel","ChoiceAttributeOptionModel","add","getOptionByCode","_context4","hasOptionByCode","some","deselectAll","_context5","newOption","clone","select","toggle","deselect","action","_context6","setReferenceDate","date","_context7","headers","_headers","child","ListHeaderModel","mergeOptions","withOptions","addNotExistingOptions","removeNotExistingOptions","newCollection","withOption","mergeOption","opt","callbackfn","thisArg","optionIndex","collectionArray","result","_default","exports"],"sources":["../../../src/models/attributes/ChoiceAttributeOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport ListHeaderModel from \"../list/ListHeaderModel\";\n\nimport { getBasePathModularUI } from \"../../constants\";\n\nimport type { ChoiceAttributeOptionModelOptions } from \"./ChoiceAttributeOptionModel\";\n/**\n */\nclass ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n _modelOptions: ChoiceAttributeOptionModelOptions;\n _headers: Array<ListHeaderModel> = [];\n _sortOptions: boolean = false;\n\n constructor(modelOptions?: ChoiceAttributeOptionModelOptions) {\n super();\n this._modelOptions = modelOptions || {\n origin: \"\",\n contextPath: getBasePathModularUI(),\n referenceDate: new Date().toISOString().split(\"T\")[0],\n };\n }\n\n /**\n */\n set sortOptions(sortOptions: boolean) {\n this._sortOptions = sortOptions;\n\n this.collection.forEach((option) => {\n if (option.children) {\n option.children.sortOptions = sortOptions;\n }\n });\n }\n\n /**\n */\n get sortOptions(): boolean {\n return this._sortOptions;\n }\n\n /**\n */\n static create(\n data: Object = {},\n contributions: Object = {},\n modelOptions?: ChoiceAttributeOptionModelOptions,\n ): ChoiceAttributeOptionCollection {\n const collection = new ChoiceAttributeOptionCollection(modelOptions);\n\n if (contributions.type === \"boolean\") {\n collection.addBooleanOptions(data.value, contributions);\n } else if (data.dynamicschema != null) {\n collection.addDynamicSchema(data, contributions);\n } else if (contributions.options != null) {\n collection.addOptions(data, contributions);\n }\n\n if (contributions.children != null) {\n collection.addHeaders(contributions.children);\n }\n\n return collection;\n }\n\n /**\n * Retrieve all items in collection\n */\n get all(): Array<ChoiceAttributeOptionModel> {\n return this.sortOptions\n ? this.collection.sort((a, b) => a.label.localeCompare(b.label))\n : this.collection;\n }\n\n /**\n */\n getSelectedOptions(data: Object): Array<string> {\n const selectedOptions = [];\n\n if (Array.isArray(data.options)) {\n selectedOptions.push(\n ...data.options\n .filter((option) => option.selected)\n .map((option) => option.key),\n );\n } else if (Array.isArray(data.value)) {\n selectedOptions.push(...data.value);\n } else if (typeof data.value === \"boolean\") {\n selectedOptions.push(data.value.toString());\n } else {\n selectedOptions.push(data.value);\n }\n\n return selectedOptions;\n }\n\n /**\n */\n getOptionCount(code: string, options: Array<Object>): number | null {\n if (Array.isArray(options)) {\n const foundOption = options.find((option) => option.key === code);\n if (foundOption) {\n return foundOption.count;\n }\n }\n\n return null;\n }\n\n /**\n */\n addOptions(\n data: Object,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n\n contributions.options.forEach((optionContributions) => {\n const optionCode = optionContributions.code || optionContributions.key;\n\n this.addOption(selectedValues, {\n ...optionContributions,\n count: this.getOptionCount(optionCode, data.options),\n optionType: contributions.optionType ?? \"generic\",\n });\n });\n\n return this;\n }\n\n /**\n * Create options based on data and dynamischema\n */\n addDynamicSchema(\n data: Object,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n data.dynamicschema.forEach((optionDynamicschema) => {\n this.addOption(selectedValues, {\n ...optionDynamicschema,\n count: this.getOptionCount(optionDynamicschema.code, data.options),\n optionType: contributions.optionType ?? \"generic\",\n elementsContributions: contributions.children,\n });\n });\n\n return this;\n }\n\n /**\n */\n addBooleanOption(\n code: \"true\" | \"false\",\n defaultLabel: string,\n data: string | Array<string>,\n options: Array<Object> = [],\n ) {\n const foundOption = options.find((option) => option.code === code);\n\n const label = foundOption ? foundOption.label : defaultLabel;\n\n this.addOption(data, {\n code,\n label,\n isBooleanType: true,\n hasAlternativeLabel: foundOption != null,\n });\n }\n\n /**\n * Create two static options for true and false,\n * there might be alternative labels configured for each option value\n */\n addBooleanOptions(\n value: any,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const optionValue = value == null ? [] : [value.toString()];\n\n this.addBooleanOption(\"true\", \"Yes\", optionValue, contributions.options);\n this.addBooleanOption(\"false\", \"No\", optionValue, contributions.options);\n\n return this;\n }\n\n /**\n */\n addOption(\n data: string | Array<string>,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const optionModel = new ChoiceAttributeOptionModel(\n Array.isArray(data) ? data : [data],\n contributions,\n this._modelOptions,\n );\n\n this.add(optionModel);\n\n return this;\n }\n\n /**\n */\n getOptionByCode(code: string): ChoiceAttributeOptionModel | void {\n return this.collection.find((option) => option.code === code);\n }\n\n /**\n */\n hasOptionByCode(code: string): boolean {\n return this.collection.some((option) => option.code === code);\n }\n\n /**\n * Get all options that have selected property true\n */\n get selected(): Array<ChoiceAttributeOptionModel> {\n const selectedOptions = [];\n\n this.collection.forEach((option: ChoiceAttributeOptionModel) => {\n if (option.selected && option.selected === true) {\n selectedOptions.push(option);\n }\n\n if (option.children) {\n selectedOptions.push(...option.children.selected);\n }\n });\n\n return selectedOptions;\n }\n\n /**\n * Deselect all options\n */\n deselectAll() {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n newOption.selected = false;\n\n if (newOption.children) {\n newOption.children.deselectAll();\n }\n\n return newOption;\n });\n }\n\n /**\n * Select an option by it's code\n */\n select(optionCode: string) {\n this.toggle(optionCode, \"select\");\n }\n\n /**\n * Deselect an option by it's code\n */\n deselect(optionCode: string) {\n this.toggle(optionCode, \"deselect\");\n }\n\n /**\n * Toggle an option by it's code\n */\n toggle(optionCode: string, action: \"select\" | \"deselect\") {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n if (newOption.code === optionCode) {\n newOption.selected = action === \"select\";\n } else if (newOption.children) {\n newOption.children.toggle(optionCode, action);\n }\n\n return newOption;\n });\n }\n\n /**\n */\n setReferenceDate(date: ISO_DATE): Array<ChoiceAttributeOptionModel> {\n return this.collection.map((option) => {\n option.referenceDate = date;\n if (option.children) {\n option.children.referenceDate = date;\n }\n\n return option;\n });\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this.collection = this.setReferenceDate(date);\n }\n\n /**\n */\n addHeaders(headers: Array<Object>) {\n this._headers = headers.map((child) => new ListHeaderModel(child));\n }\n\n /**\n */\n get headers(): Array<ListHeaderModel> {\n if (this._headers) {\n return this._headers;\n }\n\n return [];\n }\n\n /**\n */\n mergeOptions(\n withOptions: ChoiceAttributeOptionCollection,\n addNotExistingOptions: boolean = false,\n removeNotExistingOptions: boolean = false,\n ) {\n const newCollection = [];\n\n this.collection.forEach((option) => {\n const foundOption = withOptions.find(\n (withOption) => withOption.code === option.code,\n );\n if (foundOption) {\n option.mergeOption(foundOption);\n newCollection.push(option);\n } else if (!removeNotExistingOptions) {\n newCollection.push(option);\n }\n });\n\n if (addNotExistingOptions) {\n this.collection = [\n ...newCollection,\n ...withOptions.filter(\n (option) => !this.collection.some((opt) => opt.code === option.code),\n ),\n ];\n } else {\n this.collection = newCollection;\n }\n }\n\n /**\n */\n some(\n callbackfn: (\n value: ChoiceAttributeOptionModel,\n index: number,\n array: Array<ChoiceAttributeOptionModel>,\n ) => any,\n thisArg?: any,\n ): boolean {\n return this.collection.some((option, optionIndex, collectionArray) => {\n const result = callbackfn(option, optionIndex, collectionArray);\n if (!result && option.children) {\n return option.children.some(callbackfn, thisArg);\n }\n return result;\n });\n }\n}\n\nexport default ChoiceAttributeOptionCollection;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,gBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AAGA;AACA;AACA,MAAMI,+BAA+B,SAASC,2BAAkB,CAA6B;EAK3FC,WAAWA,CAACC,YAAgD,EAAE;IAC5D,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBAJyB,EAAE;IAAA,IAAAD,gBAAA,CAAAC,OAAA,wBACb,KAAK;IAI3B,IAAI,CAACC,aAAa,GAAGH,YAAY,IAAI;MACnCI,MAAM,EAAE,EAAE;MACVC,WAAW,EAAE,IAAAC,+BAAoB,EAAC,CAAC;MACnCC,aAAa,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAA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rC,MAAM,CAACqC,IAC7C,CAAC;MACD,IAAIC,WAAW,EAAE;QACftC,MAAM,CAACkF,WAAW,CAAC5C,WAAW,CAAC;QAC/B0C,aAAa,CAAClD,IAAI,CAAC9B,MAAM,CAAC;MAC5B,CAAC,MAAM,IAAI,CAAC+E,wBAAwB,EAAE;QACpCC,aAAa,CAAClD,IAAI,CAAC9B,MAAM,CAAC;MAC5B;IACF,CAAC,CAAC;IAEF,IAAI8E,qBAAqB,EAAE;MACzB,IAAI,CAAChF,UAAU,GAAG,CAChB,GAAGkF,aAAa,EAChB,GAAG,IAAAhD,OAAA,CAAA7C,OAAA,EAAA0F,WAAW,EAAA1D,IAAA,CAAX0D,WAAW,EACX7E,MAAM,IAAK,CAAC,IAAI,CAACF,UAAU,CAAC6D,IAAI,CAAEwB,GAAG,IAAKA,GAAG,CAAC9C,IAAI,KAAKrC,MAAM,CAACqC,IAAI,CACrE,CAAC,CACF;IACH,CAAC,MAAM;MACL,IAAI,CAACvC,UAAU,GAAGkF,aAAa;IACjC;EACF;;EAEA;AACF;EACErB,IAAIA,CACFyB,UAIQ,EACRC,OAAa,EACJ;IACT,OAAO,IAAI,CAACvF,UAAU,CAAC6D,IAAI,CAAC,CAAC3D,MAAM,EAAEsF,WAAW,EAAEC,eAAe,KAAK;MACpE,MAAMC,MAAM,GAAGJ,UAAU,CAACpF,MAAM,EAAEsF,WAAW,EAAEC,eAAe,CAAC;MAC/D,IAAI,CAACC,MAAM,IAAIxF,MAAM,CAACC,QAAQ,EAAE;QAC9B,OAAOD,MAAM,CAACC,QAAQ,CAAC0D,IAAI,CAACyB,UAAU,EAAEC,OAAO,CAAC;MAClD;MACA,OAAOG,MAAM;IACf,CAAC,CAAC;EACJ;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAvG,OAAA,GAEcL,+BAA+B","ignoreList":[]}
|
|
@@ -82,7 +82,7 @@ class CaseViewModel extends _DetailModel.default {
|
|
|
82
82
|
* Retrieve the case label, this can be configured with a case property with the layout hint 'title'
|
|
83
83
|
*/
|
|
84
84
|
get label() {
|
|
85
|
-
return this.casename ? this.casename.
|
|
85
|
+
return this.casename ? this.casename.readonlyvalue : "";
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaseViewModel.js","names":["_DetailModel","_interopRequireDefault","require","_Href","_TaskGroupCollection","_TaskGroupModel","_LayoutHints","_IllegalStateException","CaseViewModel","DetailModel","constructor","caseviewData","_defineProperty2","default","createTaskGroupCollection","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","links","getLinksByGroup","all","panelLinks","setChildModels","models","errors","taskGroupModels","i","length","TaskGroupModel","push","taskGroupCollection","add","casename","attributeCollection","getAttributeByLayoutHint","TITLE","label","
|
|
1
|
+
{"version":3,"file":"CaseViewModel.js","names":["_DetailModel","_interopRequireDefault","require","_Href","_TaskGroupCollection","_TaskGroupModel","_LayoutHints","_IllegalStateException","CaseViewModel","DetailModel","constructor","caseviewData","_defineProperty2","default","createTaskGroupCollection","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","links","getLinksByGroup","all","panelLinks","setChildModels","models","errors","taskGroupModels","i","length","TaskGroupModel","push","taskGroupCollection","add","casename","attributeCollection","getAttributeByLayoutHint","TITLE","label","readonlyvalue","viewLabel","getContribution","hasIntroText","introtext","_content","text","message","Array","isArray","texts","selfhref","selfLink","getLinkByKey","IllegalStateException","href","_context","allTaskgroupData","getData","allTaskgroupContributions","_map","_filter","call","taskgroup","some","taskgroupContribution","name","taskgroupContributions","_find","create","modelOptions","taskgroups","_taskGroupCollection","TaskGroupCollection","hasTaskGroups","hasItems","exports"],"sources":["../../../src/models/caseview/CaseViewModel.js"],"sourcesContent":["// @flow\nimport DetailModel from \"../detail/DetailModel\";\nimport Href from \"../href/Href\";\nimport TaskGroupCollection from \"../taskgroup/TaskGroupCollection\";\nimport TaskGroupModel from \"../taskgroup/TaskGroupModel\";\n\nimport { TITLE } from \"../../constants/LayoutHints\";\n\nimport IllegalStateException from \"../../exceptions/IllegalStateException\";\n\nimport type { ModularUIModel, AttributeType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Model containing the details of one case.\n */\nexport default class CaseViewModel extends DetailModel {\n _taskGroupCollection: TaskGroupCollection;\n\n /**\n */\n constructor(caseviewData: ModularUIResponse) {\n super(caseviewData);\n\n this.createTaskGroupCollection();\n }\n\n /**\n */\n get type(): string {\n return \"CaseView\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"CaseViewModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"CaseView\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this.links.getLinksByGroup(\"taskgroup\").all;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.links.getLinksByGroup(\"panel\");\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n super.setChildModels(models, errors);\n\n const taskGroupModels = [];\n for (let i = 0; i < models.length; i++) {\n if (models[i] instanceof TaskGroupModel) {\n taskGroupModels.push(models[i]);\n }\n }\n\n this.taskGroupCollection.add(taskGroupModels);\n }\n\n /**\n * Getting the case name\n */\n get casename(): ?AttributeType {\n return this.attributeCollection.getAttributeByLayoutHint(TITLE);\n }\n\n /**\n * Retrieve the case label, this can be configured with a case property with the layout hint 'title'\n */\n get label(): string {\n return this.casename ? this.casename.readonlyvalue : \"\";\n }\n\n /**\n * Retrieve the label that was configured on the caseview\n */\n get viewLabel(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Check if an introtext exists for this caseview\n */\n hasIntroText(): boolean {\n return this.introtext !== \"\";\n }\n\n /**\n * Getting the introduction text configured on the case view\n */\n get introtext(): string {\n if (this.data._content) {\n return this.data._content.text.message;\n }\n\n if (this.contributions.text) {\n return this.contributions.text.message ?? this.contributions.text;\n }\n\n if (Array.isArray(this.contributions.texts)) {\n return this.contributions.texts[0].text;\n }\n\n return \"\";\n }\n\n /**\n * Getting the self href\n */\n get selfhref(): Href {\n const selfLink = this.links.getLinkByKey(\"self\");\n\n if (selfLink === null) {\n throw new IllegalStateException(\"No self href available\");\n }\n\n return selfLink.href;\n }\n\n /**\n */\n createTaskGroupCollection() {\n const allTaskgroupData = this.getData(\"taskgroups\", []);\n const allTaskgroupContributions = this.getContribution(\"taskgroups\", []);\n\n this.taskGroupCollection = allTaskgroupData\n .filter((taskgroup) =>\n allTaskgroupContributions.some(\n (taskgroupContribution) =>\n taskgroupContribution.name === taskgroup.name,\n ),\n )\n .map((taskgroup) => {\n const taskgroupContributions = allTaskgroupContributions.find(\n (taskgroupContribution) =>\n taskgroupContribution.name === taskgroup.name,\n );\n\n return TaskGroupModel.create(\n taskgroup.name,\n taskgroup,\n taskgroupContributions,\n this.modelOptions,\n );\n });\n }\n\n /**\n * Setting the taskgroup panel collection\n */\n set taskGroupCollection(taskgroups: Array<TaskGroupModel>) {\n this._taskGroupCollection = new TaskGroupCollection(taskgroups);\n }\n\n /**\n * Getting the taskgrouppanels on the tab\n */\n get taskGroupCollection(): TaskGroupCollection {\n return this._taskGroupCollection;\n }\n\n /**\n * Has taskgroups\n */\n hasTaskGroups(): boolean {\n return this.taskGroupCollection && this.taskGroupCollection.hasItems;\n }\n}\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,oBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,eAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,YAAA,GAAAJ,OAAA;AAEA,IA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,GAAAL,aAAA","ignoreList":[]}
|
|
@@ -18,17 +18,18 @@ class ConceptIndexFilterModel extends _BaseFilterModel.default {
|
|
|
18
18
|
*/
|
|
19
19
|
constructor(data, contributions, modelOptions) {
|
|
20
20
|
super(data, contributions, modelOptions);
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
if (this.attribute instanceof _ChoiceAttributeModel.default) {
|
|
22
|
+
const attribute = this.attribute;
|
|
23
|
+
if (attribute && data.options) {
|
|
24
|
+
var _context, _context2, _context3;
|
|
25
|
+
const selectedValues = (0, _map.default)(_context = (0, _filter.default)(_context2 = data.options).call(_context2, option => option.selected)).call(_context, option => option.key);
|
|
26
|
+
(0, _filter.default)(_context3 = data.options).call(_context3, option => !attribute.options.hasOptionByCode(option.key)).forEach(option => {
|
|
27
|
+
attribute.options.addOption(selectedValues, {
|
|
27
28
|
code: option.key,
|
|
28
29
|
label: option.key
|
|
29
30
|
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConceptIndexFilterModel.js","names":["_BaseFilterModel","_interopRequireDefault","require","_ChoiceAttributeModel","ConceptIndexFilterModel","BaseFilterModel","constructor","data","contributions","modelOptions","options","_context","_context2","selectedValues","_map","default","_filter","call","option","selected","key","
|
|
1
|
+
{"version":3,"file":"ConceptIndexFilterModel.js","names":["_BaseFilterModel","_interopRequireDefault","require","_ChoiceAttributeModel","ConceptIndexFilterModel","BaseFilterModel","constructor","data","contributions","modelOptions","attribute","ChoiceAttributeModel","options","_context","_context2","_context3","selectedValues","_map","default","_filter","call","option","selected","key","hasOptionByCode","forEach","addOption","code","label","exports"],"sources":["../../../src/models/filters/ConceptIndexFilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"../filters/BaseFilterModel\";\nimport ChoiceAttributeModel from \"../attributes/ChoiceAttributeModel\";\n\nimport type { ModelOptions } from \"../types\";\n\n/**\n * The concept index model is a special filter used to index all first concept label letters in de modelcatalog.\n */\nexport default class ConceptIndexFilterModel extends BaseFilterModel {\n /**\n * Construct a filter\n */\n constructor(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n if (this.attribute instanceof ChoiceAttributeModel) {\n const attribute: ChoiceAttributeModel = this.attribute;\n\n if (attribute && data.options) {\n const selectedValues = data.options\n .filter((option) => option.selected)\n .map((option) => option.key);\n\n data.options\n .filter((option) => !attribute.options.hasOptionByCode(option.key))\n .forEach((option) => {\n attribute.options.addOption(selectedValues, {\n code: option.key,\n label: option.key,\n });\n });\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA;AACe,MAAME,uBAAuB,SAASC,wBAAe,CAAC;EACnE;AACF;AACA;EACEC,WAAWA,CACTC,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EAC3B;IACA,KAAK,CAACF,IAAI,EAAEC,aAAa,EAAEC,YAAY,CAAC;IAExC,IAAI,IAAI,CAACC,SAAS,YAAYC,6BAAoB,EAAE;MAClD,MAAMD,SAA+B,GAAG,IAAI,CAACA,SAAS;MAEtD,IAAIA,SAAS,IAAIH,IAAI,CAACK,OAAO,EAAE;QAAA,IAAAC,QAAA,EAAAC,SAAA,EAAAC,SAAA;QAC7B,MAAMC,cAAc,GAAG,IAAAC,IAAA,CAAAC,OAAA,EAAAL,QAAA,OAAAM,OAAA,CAAAD,OAAA,EAAAJ,SAAA,GAAAP,IAAI,CAACK,OAAO,EAAAQ,IAAA,CAAAN,SAAA,EACxBO,MAAM,IAAKA,MAAM,CAACC,QAAQ,CAAC,EAAAF,IAAA,CAAAP,QAAA,EAC9BQ,MAAM,IAAKA,MAAM,CAACE,GAAG,CAAC;QAE9B,IAAAJ,OAAA,CAAAD,OAAA,EAAAH,SAAA,GAAAR,IAAI,CAACK,OAAO,EAAAQ,IAAA,CAAAL,SAAA,EACDM,MAAM,IAAK,CAACX,SAAS,CAACE,OAAO,CAACY,eAAe,CAACH,MAAM,CAACE,GAAG,CAAC,CAAC,CAClEE,OAAO,CAAEJ,MAAM,IAAK;UACnBX,SAAS,CAACE,OAAO,CAACc,SAAS,CAACV,cAAc,EAAE;YAC1CW,IAAI,EAAEN,MAAM,CAACE,GAAG;YAChBK,KAAK,EAAEP,MAAM,CAACE;UAChB,CAAC,CAAC;QACJ,CAAC,CAAC;MACN;IACF;EACF;AACF;AAACM,OAAA,CAAAX,OAAA,GAAAd,uBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -8,7 +8,6 @@ import { useLocation } from "react-router";
|
|
|
8
8
|
import {
|
|
9
9
|
ConceptIndexModel,
|
|
10
10
|
ContentIndexModel,
|
|
11
|
-
ContentModel,
|
|
12
11
|
ContentTypeModel,
|
|
13
12
|
ContentTOCModel,
|
|
14
13
|
Href,
|
|
@@ -147,7 +146,6 @@ describe("modelcatalog hooks", () => {
|
|
|
147
146
|
() => useContent("/contentdetail"),
|
|
148
147
|
"content",
|
|
149
148
|
"/content/contentdetail?entryDate=" + DateUtil.now(),
|
|
150
|
-
ContentModel,
|
|
151
149
|
);
|
|
152
150
|
});
|
|
153
151
|
|
|
@@ -120,17 +120,17 @@ export const useContentTOC = (
|
|
|
120
120
|
/**
|
|
121
121
|
*/
|
|
122
122
|
export const useContent = (
|
|
123
|
-
|
|
123
|
+
content: string | Href,
|
|
124
124
|
key?: string = "content",
|
|
125
125
|
options?: UseModularUIBasicOptions<ContentModel>,
|
|
126
|
-
): ?ContentModel => {
|
|
126
|
+
): ?ContentModel | ?ContentTOCModel => {
|
|
127
127
|
const { entryDate } = useEntryDate();
|
|
128
|
+
const location = useLocation();
|
|
128
129
|
|
|
129
|
-
const href = createHref("content",
|
|
130
|
+
const href = createHref("content", content, entryDate, location, []);
|
|
130
131
|
|
|
131
132
|
return useModularUIBasic(key, href, {
|
|
132
|
-
expectedModels: ["Content"],
|
|
133
|
-
targetModel: ContentModel,
|
|
133
|
+
expectedModels: ["Content", "ContentTOC"],
|
|
134
134
|
...options,
|
|
135
135
|
});
|
|
136
136
|
};
|
|
@@ -202,6 +202,18 @@ class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttribute
|
|
|
202
202
|
return this;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
/**
|
|
206
|
+
*/
|
|
207
|
+
getOptionByCode(code: string): ChoiceAttributeOptionModel | void {
|
|
208
|
+
return this.collection.find((option) => option.code === code);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
*/
|
|
213
|
+
hasOptionByCode(code: string): boolean {
|
|
214
|
+
return this.collection.some((option) => option.code === code);
|
|
215
|
+
}
|
|
216
|
+
|
|
205
217
|
/**
|
|
206
218
|
* Get all options that have selected property true
|
|
207
219
|
*/
|
|
@@ -88,7 +88,7 @@ export default class CaseViewModel extends DetailModel {
|
|
|
88
88
|
* Retrieve the case label, this can be configured with a case property with the layout hint 'title'
|
|
89
89
|
*/
|
|
90
90
|
get label(): string {
|
|
91
|
-
return this.casename ? this.casename.
|
|
91
|
+
return this.casename ? this.casename.readonlyvalue : "";
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -108,7 +108,10 @@
|
|
|
108
108
|
{
|
|
109
109
|
"code": "W",
|
|
110
110
|
"label": "W"
|
|
111
|
-
}
|
|
111
|
+
},
|
|
112
|
+
{ "code": "_", "label": "punctuation" },
|
|
113
|
+
{ "code": "Ö", "label": "Ö" },
|
|
114
|
+
{ "code": "Л", "label": "Л" }
|
|
112
115
|
],
|
|
113
116
|
"type": null
|
|
114
117
|
},
|
|
@@ -188,7 +191,10 @@
|
|
|
188
191
|
},
|
|
189
192
|
{
|
|
190
193
|
"key": "W"
|
|
191
|
-
}
|
|
194
|
+
},
|
|
195
|
+
{ "key": "_" },
|
|
196
|
+
{ "key": "Ö" },
|
|
197
|
+
{ "key": "Л" }
|
|
192
198
|
]
|
|
193
199
|
},
|
|
194
200
|
"label": {
|
|
@@ -34,5 +34,9 @@ describe("conceptIndexModel", () => {
|
|
|
34
34
|
expect(firstItem.conceptTypeLink.href.toString()).toBe(
|
|
35
35
|
"/concepttypes/bundle-com.beinformed.fs.demo.metamodels/High%20level%20requirements.bixml/ArchitecturalSignificantRequirement",
|
|
36
36
|
);
|
|
37
|
+
|
|
38
|
+
const conceptIndexAttribute = conceptIndex.indexfilter?.attribute;
|
|
39
|
+
expect(conceptIndexAttribute.label).toBe("Index");
|
|
40
|
+
expect(conceptIndexAttribute.options.size).toBe(27);
|
|
37
41
|
});
|
|
38
42
|
});
|
|
@@ -18,19 +18,23 @@ export default class ConceptIndexFilterModel extends BaseFilterModel {
|
|
|
18
18
|
) {
|
|
19
19
|
super(data, contributions, modelOptions);
|
|
20
20
|
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
.filter((option) => option.selected)
|
|
24
|
-
.map((option) => option.key);
|
|
21
|
+
if (this.attribute instanceof ChoiceAttributeModel) {
|
|
22
|
+
const attribute: ChoiceAttributeModel = this.attribute;
|
|
25
23
|
|
|
26
|
-
data.options
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
if (attribute && data.options) {
|
|
25
|
+
const selectedValues = data.options
|
|
26
|
+
.filter((option) => option.selected)
|
|
27
|
+
.map((option) => option.key);
|
|
28
|
+
|
|
29
|
+
data.options
|
|
30
|
+
.filter((option) => !attribute.options.hasOptionByCode(option.key))
|
|
31
|
+
.forEach((option) => {
|
|
32
|
+
attribute.options.addOption(selectedValues, {
|
|
33
|
+
code: option.key,
|
|
34
|
+
label: option.key,
|
|
35
|
+
});
|
|
31
36
|
});
|
|
32
|
-
|
|
33
|
-
});
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
}
|