@beinformed/ui 1.59.18 → 1.59.20
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/models/attributes/AttributeModel.js +1 -2
- package/esm/models/attributes/AttributeModel.js.map +1 -1
- package/esm/models/attributes/BooleanAttributeModel.js +1 -2
- package/esm/models/attributes/BooleanAttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeModel.js +1 -2
- package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js +1 -2
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionModel.js +1 -2
- package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/esm/models/lookup/LookupOptionCollection.js +1 -2
- package/esm/models/lookup/LookupOptionCollection.js.map +1 -1
- package/esm/models/process/ProcessStatusSettingsModel.js +1 -2
- package/esm/models/process/ProcessStatusSettingsModel.js.map +1 -1
- package/esm/redux/reducers/ModelCatalogReducer.js +1 -2
- package/esm/redux/reducers/ModelCatalogReducer.js.map +1 -1
- package/esm/redux/selectors/modelcatalog.js +1 -2
- package/esm/redux/selectors/modelcatalog.js.map +1 -1
- package/esm/utils/browser/Cache.js +2 -1
- package/esm/utils/browser/Cache.js.map +1 -1
- package/esm/utils/datetime/DateTimeUtil.js +16 -1
- package/esm/utils/datetime/DateTimeUtil.js.map +1 -1
- package/lib/models/attributes/AttributeModel.js +1 -2
- package/lib/models/attributes/AttributeModel.js.flow +4 -2
- package/lib/models/attributes/AttributeModel.js.map +1 -1
- package/lib/models/attributes/BooleanAttributeModel.js +1 -2
- package/lib/models/attributes/BooleanAttributeModel.js.flow +4 -3
- package/lib/models/attributes/BooleanAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js +1 -2
- package/lib/models/attributes/ChoiceAttributeModel.js.flow +4 -2
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js +1 -2
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js.flow +1 -3
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionModel.js +1 -2
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +2 -2
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/lib/models/lookup/LookupOptionCollection.js +1 -2
- package/lib/models/lookup/LookupOptionCollection.js.flow +4 -2
- package/lib/models/lookup/LookupOptionCollection.js.map +1 -1
- package/lib/models/process/ProcessStatusSettingsModel.js +1 -2
- package/lib/models/process/ProcessStatusSettingsModel.js.flow +1 -2
- package/lib/models/process/ProcessStatusSettingsModel.js.map +1 -1
- package/lib/redux/reducers/ModelCatalogReducer.js +1 -2
- package/lib/redux/reducers/ModelCatalogReducer.js.flow +1 -2
- package/lib/redux/reducers/ModelCatalogReducer.js.map +1 -1
- package/lib/redux/selectors/modelcatalog.js +1 -2
- package/lib/redux/selectors/modelcatalog.js.flow +3 -3
- package/lib/redux/selectors/modelcatalog.js.map +1 -1
- package/lib/utils/browser/Cache.js +2 -1
- package/lib/utils/browser/Cache.js.flow +4 -1
- package/lib/utils/browser/Cache.js.map +1 -1
- package/lib/utils/datetime/DateTimeUtil.js +52 -37
- package/lib/utils/datetime/DateTimeUtil.js.flow +17 -18
- package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
- package/package.json +13 -13
- package/src/models/attributes/AttributeModel.js +4 -2
- package/src/models/attributes/BooleanAttributeModel.js +4 -3
- package/src/models/attributes/ChoiceAttributeModel.js +4 -2
- package/src/models/attributes/ChoiceAttributeOptionCollection.js +1 -3
- package/src/models/attributes/ChoiceAttributeOptionModel.js +2 -2
- package/src/models/lookup/LookupOptionCollection.js +4 -2
- package/src/models/process/ProcessStatusSettingsModel.js +1 -2
- package/src/redux/reducers/ModelCatalogReducer.js +1 -2
- package/src/redux/selectors/modelcatalog.js +3 -3
- package/src/utils/browser/Cache.js +4 -1
- package/src/utils/datetime/DateTimeUtil.js +17 -18
|
@@ -11,7 +11,6 @@ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-s
|
|
|
11
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
12
12
|
var _full = require("klona/full");
|
|
13
13
|
var _objects = require("../../utils/helpers/objects");
|
|
14
|
-
var _DateTimeUtil = require("../../utils/datetime/DateTimeUtil");
|
|
15
14
|
var _AttributeModel = _interopRequireDefault(require("./AttributeModel"));
|
|
16
15
|
var _ChoiceAttributeOptionCollection = _interopRequireDefault(require("./ChoiceAttributeOptionCollection"));
|
|
17
16
|
var _ChoiceAttributeOptionModel = _interopRequireDefault(require("./ChoiceAttributeOptionModel"));
|
|
@@ -31,7 +30,7 @@ class ChoiceAttributeModel extends _AttributeModel.default {
|
|
|
31
30
|
(0, _defineProperty2.default)(this, "_referenceDate", void 0);
|
|
32
31
|
(0, _defineProperty2.default)(this, "_options", void 0);
|
|
33
32
|
(0, _defineProperty2.default)(this, "_hasContentConfiguration", void 0);
|
|
34
|
-
this._referenceDate = this.getData("referenceDate",
|
|
33
|
+
this._referenceDate = this.getData("referenceDate", new Date().toISOString().split("T")[0]);
|
|
35
34
|
this._options = _ChoiceAttributeOptionCollection.default.create(attribute, attributeContributions, {
|
|
36
35
|
...modelOptions,
|
|
37
36
|
referenceDate: this.referenceDate
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { klona } from "klona/full";
|
|
3
3
|
|
|
4
4
|
import { has } from "../../utils/helpers/objects";
|
|
5
|
-
import { DateUtil } from "../../utils/datetime/DateTimeUtil";
|
|
6
5
|
|
|
7
6
|
import AttributeModel from "./AttributeModel";
|
|
8
7
|
import ChoiceAttributeOptionCollection from "./ChoiceAttributeOptionCollection";
|
|
@@ -43,7 +42,10 @@ export default class ChoiceAttributeModel extends AttributeModel {
|
|
|
43
42
|
) {
|
|
44
43
|
super(attribute, attributeContributions, modelOptions);
|
|
45
44
|
|
|
46
|
-
this._referenceDate = this.getData(
|
|
45
|
+
this._referenceDate = this.getData(
|
|
46
|
+
"referenceDate",
|
|
47
|
+
new Date().toISOString().split("T")[0],
|
|
48
|
+
);
|
|
47
49
|
this._options = ChoiceAttributeOptionCollection.create(
|
|
48
50
|
attribute,
|
|
49
51
|
attributeContributions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceAttributeModel.js","names":["_full","require","_objects","_DateTimeUtil","_AttributeModel","_interopRequireDefault","_ChoiceAttributeOptionCollection","_ChoiceAttributeOptionModel","_CompositeAttributeModel","_ContentConfigurationElements","_LayoutHints","_constants","ChoiceAttributeModel","AttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty2","default","_referenceDate","getData","DateUtil","now","_options","ChoiceAttributeOptionCollection","create","referenceDate","layouthint","has","SORT_OPTIONS","sortOptions","isApplicableModel","contributions","type","optionMode","getContribution","hasLookupLink","lookupLink","lookupListLink","optionType","isUser","getInitialChildModelLinks","links","hasContentConfiguration","hasContentFromData","conceptLink","push","options","setChildModels","models","errors","conceptLinkHref","href","concept","_find","call","model","selfhref","equalsWithParameters","getLinkByKey","lookupListLabel","lookupList","label","date","selected","_context","_map","option","code","readonlyvalue","_context2","join","initvalue","Array","isArray","_initvalue","length","getValue","_context3","hasValue","getInputValue","toggleOption","_context4","_includes","disableOption","enableOption","isMultiple","deselectAll","select","inputvalue","deselect","addOption","_context5","opt","choicetype","_context6","hint","multiplechoice","isTree","some","reset","mergeAttribute","oldAttribute","addNotExistingOptions","arguments","undefined","removeNotExistingOptions","readonly","mergeOptions","isValid","update","value","updateLastModification","values","split","forEach","val","isChoiceAttributeOptionModel","equals","newVal","klona","add","toString","updateByAttribute","otherAttribute","CompositeAttributeModel","otherValue","getChildrenIds","console","error","addMissingError","receivedAttribute","isChangedSince","_errorCollection","addServerError","_hasContentConfiguration","contentConfiguration","_context7","content","optionElements","optionElementConfig","optionElement","contentElement","RENDER_SECTION_LABEL","ContentConfigurationElements","placeholder","id","message","properties","ANSWER_OPTION_KEY","_context8","optionKey","foundOption","getContentConfiguredLabel","readonlyWidth","ATTRIBUTE_WIDTH","MEDIUM","exports"],"sources":["../../../src/models/attributes/ChoiceAttributeModel.js"],"sourcesContent":["// @flow\nimport { klona } from \"klona/full\";\n\nimport { has } from \"../../utils/helpers/objects\";\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\n\nimport AttributeModel from \"./AttributeModel\";\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport CompositeAttributeModel from \"./CompositeAttributeModel\";\nimport ContentConfigurationElements from \"../contentconfiguration/ContentConfigurationElements\";\n\nimport {\n RENDER_SECTION_LABEL,\n SORT_OPTIONS,\n} from \"../../constants/LayoutHints\";\nimport { ATTRIBUTE_WIDTH } from \"../../constants\";\n\nimport type {\n ModularUIModel,\n AttributeType,\n FormErrorAnchor,\n ModelOptions,\n} from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Model for a choice attribute\n */\nexport default class ChoiceAttributeModel extends AttributeModel {\n _referenceDate: ISO_DATE;\n _options: ChoiceAttributeOptionCollection;\n _hasContentConfiguration: boolean;\n\n /**\n * Constructs a choice attribute\n */\n constructor(\n attribute: Object,\n attributeContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(attribute, attributeContributions, modelOptions);\n\n this._referenceDate = this.getData(\"referenceDate\", DateUtil.now());\n this._options = ChoiceAttributeOptionCollection.create(\n attribute,\n attributeContributions,\n { ...modelOptions, referenceDate: this.referenceDate },\n );\n\n if (this.layouthint.has(SORT_OPTIONS)) {\n this._options.sortOptions = true;\n }\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return (\n contributions.type !== \"composite\" &&\n contributions.type !== \"boolean\" &&\n (contributions.type === \"choice\" ||\n contributions.type === \"array\" ||\n has(contributions, \"enumerated\") ||\n has(contributions, \"options\"))\n );\n }\n\n /**\n */\n get type(): string {\n const optionMode = this.getContribution(\"optionMode\", \"\");\n const hasLookupLink = this.lookupLink || this.lookupListLink;\n\n if (\n optionMode === \"lookup\" ||\n (optionMode === \"dynamicWithThreshold\" && hasLookupLink)\n ) {\n return \"lookup\";\n }\n\n return \"choice\";\n }\n\n /**\n */\n get optionType(): string {\n return this.contributions?.optionType ?? \"generic\";\n }\n\n /**\n */\n get isUser(): boolean {\n return this.optionType === \"user\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const links = [];\n\n if (this.hasContentConfiguration) {\n if (!this.hasContentFromData && this.conceptLink) {\n links.push(this.conceptLink);\n }\n\n links.push(...this.options.getInitialChildModelLinks());\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n const conceptLinkHref = this.conceptLink?.href;\n if (conceptLinkHref) {\n this.concept = models.find(\n (model) =>\n model.type === \"ConceptDetail\" &&\n model.selfhref.equalsWithParameters(conceptLinkHref),\n );\n }\n\n this.options.setChildModels(models, errors);\n }\n\n /**\n * Retrieve lookup service link\n */\n get lookupLink(): LinkModel | null {\n return this.links.getLinkByKey(\"lookupOptions\");\n }\n\n /**\n * Retrieve lookup service as list link\n */\n get lookupListLink(): LinkModel | null {\n return this.links.getLinkByKey(\"lookupList\");\n }\n\n /**\n */\n get lookupListLabel(): string {\n return this.contributions.lookupList?.label ?? \"\";\n }\n\n /**\n * Retrieve reference date of attribute which can be used as entryDate for content\n */\n get referenceDate(): ISO_DATE {\n return this._referenceDate;\n }\n\n /**\n * Set reference date for concepts and content\n */\n set referenceDate(date: string) {\n this._referenceDate = date;\n\n this.options.referenceDate = date;\n }\n\n /**\n * Retrieve available choice options\n */\n get options(): ChoiceAttributeOptionCollection {\n return this._options;\n }\n\n /**\n * Getting all enabled options\n */\n get selected(): Array<string> {\n // $FlowFixMe[incompatible-call]\n return this.options.selected.map<string, ChoiceAttributeOptionModel>(\n (option: ChoiceAttributeOptionModel) => option.code,\n );\n }\n\n /**\n * Flatten options and filter out the options that are not selected\n */\n get readonlyvalue(): string {\n return this.options.selected.map((option) => option.label).join(\", \");\n }\n\n /**\n */\n get initvalue(): any {\n if (Array.isArray(this._initvalue) && this._initvalue.length === 0) {\n return null;\n }\n\n return this._initvalue;\n }\n\n /**\n * Retrieve list of selected options, joined with comma\n */\n getValue(): string | null {\n return this.options.selected.length > 0\n ? this.options.selected.map((option) => option.code).join(\",\")\n : null;\n }\n\n /**\n */\n hasValue(): boolean {\n return this.options.selected.length > 0;\n }\n\n /**\n * Get input value of attribute\n */\n getInputValue(): string {\n return this.selected.join(\",\");\n }\n\n /**\n * Setting an option selected or unselected based on the current state\n */\n toggleOption(code: string) {\n if (this.selected.includes(code)) {\n this.disableOption(code);\n } else {\n this.enableOption(code);\n }\n }\n\n /**\n * Enable a option\n */\n enableOption(code: string) {\n if (!this.isMultiple) {\n this.options.deselectAll();\n }\n\n this.options.select(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Disable a option\n */\n disableOption(code: string) {\n this.options.deselect(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Add a new option to the collection of lookup options\n */\n addOption(option: Object) {\n if (!this.isMultiple) {\n this.options.deselectAll();\n }\n\n if (this.options.find((opt) => opt.code === option.code) === null) {\n this.options.addOption(option.code, option);\n }\n }\n\n /**\n * Getting the type of choice filter. For instance checkbox, radiobutton, combobox.\n */\n get choicetype():\n | \"checkbox\"\n | \"radiobutton\"\n | \"combobox\"\n | \"list\"\n | \"listview\"\n | \"table\"\n | \"longlist\"\n | \"toggle\" {\n return (\n [\n \"checkbox\",\n \"radiobutton\",\n \"combobox\",\n \"list\",\n \"listview\",\n \"table\",\n \"longlist\",\n \"toggle\",\n ].find((hint) => this.layouthint.has(hint)) || \"checkbox\"\n );\n }\n\n /**\n * Can multiple options be selected\n */\n get isMultiple(): boolean {\n return this.contributions.multiplechoice || this.choicetype === \"checkbox\";\n }\n\n /**\n * Check if options need to be rendered as tree\n */\n get isTree(): boolean {\n return (\n has(this.contributions, \"options\") &&\n this.contributions.options.some((option) => has(option, \"children\"))\n );\n }\n\n /**\n * Reset choice attribute to unselected list\n */\n reset() {\n this.options.deselectAll();\n }\n\n /**\n */\n mergeAttribute(\n oldAttribute: AttributeType,\n addNotExistingOptions: boolean = false,\n removeNotExistingOptions: boolean = false,\n ) {\n // when attribute is readonly, don't merge the options no modifications necessary\n if (!this.readonly && oldAttribute instanceof ChoiceAttributeModel) {\n this.concept = oldAttribute.concept;\n this.options.mergeOptions(\n oldAttribute.options,\n addNotExistingOptions ?? this.type === \"lookup\",\n removeNotExistingOptions,\n );\n this.options.deselectAll();\n\n if (oldAttribute.isValid && oldAttribute.inputvalue !== null) {\n this.update(oldAttribute.inputvalue);\n }\n }\n }\n\n /**\n * Update attribute by name and value\n */\n update(value: any): ChoiceAttributeModel {\n if (this.readonly) {\n return this;\n }\n\n this.updateLastModification();\n\n let values = [];\n\n if (Array.isArray(value)) {\n values = value;\n } else if (typeof value === \"string\" && this.isMultiple) {\n values = value.split(\",\");\n } else if (value != null) {\n values = [value];\n }\n values.forEach((val) => {\n if (typeof val === \"object\" && val.isChoiceAttributeOptionModel) {\n // option does not exist in existing options, add it. This can happen when lookup list has other options then lookup options\n if (!this.options.some((option) => option.equals(val))) {\n const newVal = klona(val);\n newVal.selected = false;\n this.options.add(newVal);\n }\n this.toggleOption(val.code);\n } else if (\n (typeof val === \"number\" ||\n typeof val === \"string\" ||\n typeof val === \"boolean\") &&\n this.options.some((option) => option.code.toString() === val.toString())\n ) {\n this.toggleOption(val.toString());\n }\n });\n\n return this;\n }\n\n /**\n */\n updateByAttribute(otherAttribute: AttributeType): void {\n this.reset();\n if (\n otherAttribute instanceof ChoiceAttributeModel ||\n otherAttribute instanceof CompositeAttributeModel\n ) {\n let otherValue;\n if (otherAttribute instanceof ChoiceAttributeModel) {\n otherValue = otherAttribute.options.selected;\n } else if (otherAttribute instanceof CompositeAttributeModel) {\n otherValue = otherAttribute.getChildrenIds();\n }\n if (otherValue !== null) {\n this.update(otherValue);\n }\n } else {\n console.error(\n `update of choice attribute with ${otherAttribute.type} not supported`,\n );\n }\n }\n\n /**\n * Registers a missing error that was received from the server\n */\n addMissingError(receivedAttribute?: AttributeType): void {\n if (this.isChangedSince(0)) {\n this._errorCollection.addServerError(\"Constraint.Missing\");\n }\n // update choice options\n if (receivedAttribute instanceof ChoiceAttributeModel) {\n this.mergeAttribute(receivedAttribute, true, true);\n }\n }\n\n /**\n */\n set hasContentConfiguration(hasContentConfiguration: boolean) {\n this._hasContentConfiguration =\n this.contentConfiguration !== null || hasContentConfiguration;\n }\n\n /**\n */\n get hasContentConfiguration(): boolean {\n return this._hasContentConfiguration;\n }\n\n /**\n * Get content configuration configured on the attribute.\n * Only applicable for taxonomy element and knowledge codemaps,\n * content configuration for instrument questions is available on the form object\n */\n get contentConfiguration(): ContentConfigurationElements | null {\n if (\n !this.contributions.content ||\n !this.contributions.content.optionElements\n ) {\n return null;\n }\n\n // Add RENDER_SECTION_LABEL to all content configuration to make sure the label of a section is always rendered on taxonomy and knowlege codemaps\n const optionElementConfig = this.contributions.content.optionElements.map(\n (optionElement) => {\n if (\"contentElement\" in optionElement) {\n return {\n contentElement: {\n ...optionElement.contentElement,\n layouthint: [RENDER_SECTION_LABEL],\n },\n };\n }\n\n return optionElement;\n },\n );\n\n return new ContentConfigurationElements(optionElementConfig);\n }\n\n /**\n * Get placeholder text\n */\n get placeholder(): string {\n return this.getContribution(\"placeholder\", \"\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties, layouthint } = error;\n\n const ANSWER_OPTION_KEY = \"answer-option-key\";\n\n if (properties && has(properties, ANSWER_OPTION_KEY)) {\n const optionKey = properties[ANSWER_OPTION_KEY];\n const foundOption = this.options.find(\n (option) => option.code === optionKey,\n );\n if (foundOption) {\n properties[ANSWER_OPTION_KEY] = foundOption.getContentConfiguredLabel(\n this.contentConfiguration,\n );\n }\n }\n\n this._errorCollection.addServerError(id, message, properties, layouthint);\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n}\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAEA,IAAAG,eAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,gCAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,2BAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,wBAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,6BAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AAEA,IAAAS,YAAA,GAAAT,OAAA;AAIA,IAAAU,UAAA,GAAAV,OAAA;AAWA;AACA;AACA;AACe,MAAMW,oBAAoB,SAASC,uBAAc,CAAC;EAK/D;AACF;AACA;EACEC,WAAWA,CACTC,SAAiB,EACjBC,sBAA8B,EAC9BC,YAA2B,EAC3B;IACA,KAAK,CAACF,SAAS,EAAEC,sBAAsB,EAAEC,YAAY,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEvD,IAAI,CAACC,cAAc,GAAG,IAAI,CAACC,OAAO,CAAC,eAAe,EAAEC,sBAAQ,CAACC,GAAG,CAAC,CAAC,CAAC;IACnE,IAAI,CAACC,QAAQ,GAAGC,wCAA+B,CAACC,MAAM,CACpDX,SAAS,EACTC,sBAAsB,EACtB;MAAE,GAAGC,YAAY;MAAEU,aAAa,EAAE,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,UAAU;MAAEzH;IAAW,CAAC,GAAGsG,KAAK;IAErD,MAAMoB,iBAAiB,GAAG,mBAAmB;IAE7C,IAAID,UAAU,IAAI,IAAAxH,YAAG,EAACwH,UAAU,EAAEC,iBAAiB,CAAC,EAAE;MAAA,IAAAC,SAAA;MACpD,MAAMC,SAAS,GAAGH,UAAU,CAACC,iBAAiB,CAAC;MAC/C,MAAMG,WAAW,GAAG,IAAAlG,KAAA,CAAApC,OAAA,EAAAoI,SAAA,OAAI,CAACvG,OAAO,EAAAQ,IAAA,CAAA+F,SAAA,EAC7BnF,MAAM,IAAKA,MAAM,CAACC,IAAI,KAAKmF,SAC9B,CAAC;MACD,IAAIC,WAAW,EAAE;QACfJ,UAAU,CAACC,iBAAiB,CAAC,GAAGG,WAAW,CAACC,yBAAyB,CACnE,IAAI,CAACjB,oBACP,CAAC;MACH;IACF;IAEA,IAAI,CAACH,gBAAgB,CAACC,cAAc,CAACY,EAAE,EAAEC,OAAO,EAAEC,UAAU,EAAEzH,UAAU,CAAC;EAC3E;;EAEA;AACF;EACE,IAAI+H,aAAaA,CAAA,EAAkC;IACjD,OAAOC,0BAAe,CAACC,MAAM;EAC/B;AACF;AAACC,OAAA,CAAA3I,OAAA,GAAAP,oBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ChoiceAttributeModel.js","names":["_full","require","_objects","_AttributeModel","_interopRequireDefault","_ChoiceAttributeOptionCollection","_ChoiceAttributeOptionModel","_CompositeAttributeModel","_ContentConfigurationElements","_LayoutHints","_constants","ChoiceAttributeModel","AttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty2","default","_referenceDate","getData","Date","toISOString","split","_options","ChoiceAttributeOptionCollection","create","referenceDate","layouthint","has","SORT_OPTIONS","sortOptions","isApplicableModel","contributions","type","optionMode","getContribution","hasLookupLink","lookupLink","lookupListLink","optionType","isUser","getInitialChildModelLinks","links","hasContentConfiguration","hasContentFromData","conceptLink","push","options","setChildModels","models","errors","conceptLinkHref","href","concept","_find","call","model","selfhref","equalsWithParameters","getLinkByKey","lookupListLabel","lookupList","label","date","selected","_context","_map","option","code","readonlyvalue","_context2","join","initvalue","Array","isArray","_initvalue","length","getValue","_context3","hasValue","getInputValue","toggleOption","_context4","_includes","disableOption","enableOption","isMultiple","deselectAll","select","inputvalue","deselect","addOption","_context5","opt","choicetype","_context6","hint","multiplechoice","isTree","some","reset","mergeAttribute","oldAttribute","addNotExistingOptions","arguments","undefined","removeNotExistingOptions","readonly","mergeOptions","isValid","update","value","updateLastModification","values","forEach","val","isChoiceAttributeOptionModel","equals","newVal","klona","add","toString","updateByAttribute","otherAttribute","CompositeAttributeModel","otherValue","getChildrenIds","console","error","addMissingError","receivedAttribute","isChangedSince","_errorCollection","addServerError","_hasContentConfiguration","contentConfiguration","_context7","content","optionElements","optionElementConfig","optionElement","contentElement","RENDER_SECTION_LABEL","ContentConfigurationElements","placeholder","id","message","properties","ANSWER_OPTION_KEY","_context8","optionKey","foundOption","getContentConfiguredLabel","readonlyWidth","ATTRIBUTE_WIDTH","MEDIUM","exports"],"sources":["../../../src/models/attributes/ChoiceAttributeModel.js"],"sourcesContent":["// @flow\nimport { klona } from \"klona/full\";\n\nimport { has } from \"../../utils/helpers/objects\";\n\nimport AttributeModel from \"./AttributeModel\";\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport CompositeAttributeModel from \"./CompositeAttributeModel\";\nimport ContentConfigurationElements from \"../contentconfiguration/ContentConfigurationElements\";\n\nimport {\n RENDER_SECTION_LABEL,\n SORT_OPTIONS,\n} from \"../../constants/LayoutHints\";\nimport { ATTRIBUTE_WIDTH } from \"../../constants\";\n\nimport type {\n ModularUIModel,\n AttributeType,\n FormErrorAnchor,\n ModelOptions,\n} from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Model for a choice attribute\n */\nexport default class ChoiceAttributeModel extends AttributeModel {\n _referenceDate: ISO_DATE;\n _options: ChoiceAttributeOptionCollection;\n _hasContentConfiguration: boolean;\n\n /**\n * Constructs a choice attribute\n */\n constructor(\n attribute: Object,\n attributeContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(attribute, attributeContributions, modelOptions);\n\n this._referenceDate = this.getData(\n \"referenceDate\",\n new Date().toISOString().split(\"T\")[0],\n );\n this._options = ChoiceAttributeOptionCollection.create(\n attribute,\n attributeContributions,\n { ...modelOptions, referenceDate: this.referenceDate },\n );\n\n if (this.layouthint.has(SORT_OPTIONS)) {\n this._options.sortOptions = true;\n }\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return (\n contributions.type !== \"composite\" &&\n contributions.type !== \"boolean\" &&\n (contributions.type === \"choice\" ||\n contributions.type === \"array\" ||\n has(contributions, \"enumerated\") ||\n has(contributions, \"options\"))\n );\n }\n\n /**\n */\n get type(): string {\n const optionMode = this.getContribution(\"optionMode\", \"\");\n const hasLookupLink = this.lookupLink || this.lookupListLink;\n\n if (\n optionMode === \"lookup\" ||\n (optionMode === \"dynamicWithThreshold\" && hasLookupLink)\n ) {\n return \"lookup\";\n }\n\n return \"choice\";\n }\n\n /**\n */\n get optionType(): string {\n return this.contributions?.optionType ?? \"generic\";\n }\n\n /**\n */\n get isUser(): boolean {\n return this.optionType === \"user\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const links = [];\n\n if (this.hasContentConfiguration) {\n if (!this.hasContentFromData && this.conceptLink) {\n links.push(this.conceptLink);\n }\n\n links.push(...this.options.getInitialChildModelLinks());\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n const conceptLinkHref = this.conceptLink?.href;\n if (conceptLinkHref) {\n this.concept = models.find(\n (model) =>\n model.type === \"ConceptDetail\" &&\n model.selfhref.equalsWithParameters(conceptLinkHref),\n );\n }\n\n this.options.setChildModels(models, errors);\n }\n\n /**\n * Retrieve lookup service link\n */\n get lookupLink(): LinkModel | null {\n return this.links.getLinkByKey(\"lookupOptions\");\n }\n\n /**\n * Retrieve lookup service as list link\n */\n get lookupListLink(): LinkModel | null {\n return this.links.getLinkByKey(\"lookupList\");\n }\n\n /**\n */\n get lookupListLabel(): string {\n return this.contributions.lookupList?.label ?? \"\";\n }\n\n /**\n * Retrieve reference date of attribute which can be used as entryDate for content\n */\n get referenceDate(): ISO_DATE {\n return this._referenceDate;\n }\n\n /**\n * Set reference date for concepts and content\n */\n set referenceDate(date: string) {\n this._referenceDate = date;\n\n this.options.referenceDate = date;\n }\n\n /**\n * Retrieve available choice options\n */\n get options(): ChoiceAttributeOptionCollection {\n return this._options;\n }\n\n /**\n * Getting all enabled options\n */\n get selected(): Array<string> {\n // $FlowFixMe[incompatible-call]\n return this.options.selected.map<string, ChoiceAttributeOptionModel>(\n (option: ChoiceAttributeOptionModel) => option.code,\n );\n }\n\n /**\n * Flatten options and filter out the options that are not selected\n */\n get readonlyvalue(): string {\n return this.options.selected.map((option) => option.label).join(\", \");\n }\n\n /**\n */\n get initvalue(): any {\n if (Array.isArray(this._initvalue) && this._initvalue.length === 0) {\n return null;\n }\n\n return this._initvalue;\n }\n\n /**\n * Retrieve list of selected options, joined with comma\n */\n getValue(): string | null {\n return this.options.selected.length > 0\n ? this.options.selected.map((option) => option.code).join(\",\")\n : null;\n }\n\n /**\n */\n hasValue(): boolean {\n return this.options.selected.length > 0;\n }\n\n /**\n * Get input value of attribute\n */\n getInputValue(): string {\n return this.selected.join(\",\");\n }\n\n /**\n * Setting an option selected or unselected based on the current state\n */\n toggleOption(code: string) {\n if (this.selected.includes(code)) {\n this.disableOption(code);\n } else {\n this.enableOption(code);\n }\n }\n\n /**\n * Enable a option\n */\n enableOption(code: string) {\n if (!this.isMultiple) {\n this.options.deselectAll();\n }\n\n this.options.select(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Disable a option\n */\n disableOption(code: string) {\n this.options.deselect(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Add a new option to the collection of lookup options\n */\n addOption(option: Object) {\n if (!this.isMultiple) {\n this.options.deselectAll();\n }\n\n if (this.options.find((opt) => opt.code === option.code) === null) {\n this.options.addOption(option.code, option);\n }\n }\n\n /**\n * Getting the type of choice filter. For instance checkbox, radiobutton, combobox.\n */\n get choicetype():\n | \"checkbox\"\n | \"radiobutton\"\n | \"combobox\"\n | \"list\"\n | \"listview\"\n | \"table\"\n | \"longlist\"\n | \"toggle\" {\n return (\n [\n \"checkbox\",\n \"radiobutton\",\n \"combobox\",\n \"list\",\n \"listview\",\n \"table\",\n \"longlist\",\n \"toggle\",\n ].find((hint) => this.layouthint.has(hint)) || \"checkbox\"\n );\n }\n\n /**\n * Can multiple options be selected\n */\n get isMultiple(): boolean {\n return this.contributions.multiplechoice || this.choicetype === \"checkbox\";\n }\n\n /**\n * Check if options need to be rendered as tree\n */\n get isTree(): boolean {\n return (\n has(this.contributions, \"options\") &&\n this.contributions.options.some((option) => has(option, \"children\"))\n );\n }\n\n /**\n * Reset choice attribute to unselected list\n */\n reset() {\n this.options.deselectAll();\n }\n\n /**\n */\n mergeAttribute(\n oldAttribute: AttributeType,\n addNotExistingOptions: boolean = false,\n removeNotExistingOptions: boolean = false,\n ) {\n // when attribute is readonly, don't merge the options no modifications necessary\n if (!this.readonly && oldAttribute instanceof ChoiceAttributeModel) {\n this.concept = oldAttribute.concept;\n this.options.mergeOptions(\n oldAttribute.options,\n addNotExistingOptions ?? this.type === \"lookup\",\n removeNotExistingOptions,\n );\n this.options.deselectAll();\n\n if (oldAttribute.isValid && oldAttribute.inputvalue !== null) {\n this.update(oldAttribute.inputvalue);\n }\n }\n }\n\n /**\n * Update attribute by name and value\n */\n update(value: any): ChoiceAttributeModel {\n if (this.readonly) {\n return this;\n }\n\n this.updateLastModification();\n\n let values = [];\n\n if (Array.isArray(value)) {\n values = value;\n } else if (typeof value === \"string\" && this.isMultiple) {\n values = value.split(\",\");\n } else if (value != null) {\n values = [value];\n }\n values.forEach((val) => {\n if (typeof val === \"object\" && val.isChoiceAttributeOptionModel) {\n // option does not exist in existing options, add it. This can happen when lookup list has other options then lookup options\n if (!this.options.some((option) => option.equals(val))) {\n const newVal = klona(val);\n newVal.selected = false;\n this.options.add(newVal);\n }\n this.toggleOption(val.code);\n } else if (\n (typeof val === \"number\" ||\n typeof val === \"string\" ||\n typeof val === \"boolean\") &&\n this.options.some((option) => option.code.toString() === val.toString())\n ) {\n this.toggleOption(val.toString());\n }\n });\n\n return this;\n }\n\n /**\n */\n updateByAttribute(otherAttribute: AttributeType): void {\n this.reset();\n if (\n otherAttribute instanceof ChoiceAttributeModel ||\n otherAttribute instanceof CompositeAttributeModel\n ) {\n let otherValue;\n if (otherAttribute instanceof ChoiceAttributeModel) {\n otherValue = otherAttribute.options.selected;\n } else if (otherAttribute instanceof CompositeAttributeModel) {\n otherValue = otherAttribute.getChildrenIds();\n }\n if (otherValue !== null) {\n this.update(otherValue);\n }\n } else {\n console.error(\n `update of choice attribute with ${otherAttribute.type} not supported`,\n );\n }\n }\n\n /**\n * Registers a missing error that was received from the server\n */\n addMissingError(receivedAttribute?: AttributeType): void {\n if (this.isChangedSince(0)) {\n this._errorCollection.addServerError(\"Constraint.Missing\");\n }\n // update choice options\n if (receivedAttribute instanceof ChoiceAttributeModel) {\n this.mergeAttribute(receivedAttribute, true, true);\n }\n }\n\n /**\n */\n set hasContentConfiguration(hasContentConfiguration: boolean) {\n this._hasContentConfiguration =\n this.contentConfiguration !== null || hasContentConfiguration;\n }\n\n /**\n */\n get hasContentConfiguration(): boolean {\n return this._hasContentConfiguration;\n }\n\n /**\n * Get content configuration configured on the attribute.\n * Only applicable for taxonomy element and knowledge codemaps,\n * content configuration for instrument questions is available on the form object\n */\n get contentConfiguration(): ContentConfigurationElements | null {\n if (\n !this.contributions.content ||\n !this.contributions.content.optionElements\n ) {\n return null;\n }\n\n // Add RENDER_SECTION_LABEL to all content configuration to make sure the label of a section is always rendered on taxonomy and knowlege codemaps\n const optionElementConfig = this.contributions.content.optionElements.map(\n (optionElement) => {\n if (\"contentElement\" in optionElement) {\n return {\n contentElement: {\n ...optionElement.contentElement,\n layouthint: [RENDER_SECTION_LABEL],\n },\n };\n }\n\n return optionElement;\n },\n );\n\n return new ContentConfigurationElements(optionElementConfig);\n }\n\n /**\n * Get placeholder text\n */\n get placeholder(): string {\n return this.getContribution(\"placeholder\", \"\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties, layouthint } = error;\n\n const ANSWER_OPTION_KEY = \"answer-option-key\";\n\n if (properties && has(properties, ANSWER_OPTION_KEY)) {\n const optionKey = properties[ANSWER_OPTION_KEY];\n const foundOption = this.options.find(\n (option) => option.code === optionKey,\n );\n if (foundOption) {\n properties[ANSWER_OPTION_KEY] = foundOption.getContentConfiguredLabel(\n this.contentConfiguration,\n );\n }\n }\n\n this._errorCollection.addServerError(id, message, properties, layouthint);\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n}\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,gCAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,2BAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,wBAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,6BAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAEA,IAAAQ,YAAA,GAAAR,OAAA;AAIA,IAAAS,UAAA,GAAAT,OAAA;AAWA;AACA;AACA;AACe,MAAMU,oBAAoB,SAASC,uBAAc,CAAC;EAK/D;AACF;AACA;EACEC,WAAWA,CACTC,SAAiB,EACjBC,sBAA8B,EAC9BC,YA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A","ignoreList":[]}
|
|
@@ -14,7 +14,6 @@ var _ResourceCollection = _interopRequireDefault(require("../base/ResourceCollec
|
|
|
14
14
|
var _ChoiceAttributeOptionModel = _interopRequireDefault(require("./ChoiceAttributeOptionModel"));
|
|
15
15
|
var _ListHeaderModel = _interopRequireDefault(require("../list/ListHeaderModel"));
|
|
16
16
|
var _constants = require("../../constants");
|
|
17
|
-
var _utils = require("../../utils");
|
|
18
17
|
/**
|
|
19
18
|
*/
|
|
20
19
|
class ChoiceAttributeOptionCollection extends _ResourceCollection.default {
|
|
@@ -26,7 +25,7 @@ class ChoiceAttributeOptionCollection extends _ResourceCollection.default {
|
|
|
26
25
|
this._modelOptions = modelOptions || {
|
|
27
26
|
origin: "",
|
|
28
27
|
contextPath: (0, _constants.getBasePathModularUI)(),
|
|
29
|
-
referenceDate:
|
|
28
|
+
referenceDate: new Date().toISOString().split("T")[0]
|
|
30
29
|
};
|
|
31
30
|
}
|
|
32
31
|
|
|
@@ -5,8 +5,6 @@ import ListHeaderModel from "../list/ListHeaderModel";
|
|
|
5
5
|
|
|
6
6
|
import { getBasePathModularUI } from "../../constants";
|
|
7
7
|
|
|
8
|
-
import { DateUtil } from "../../utils";
|
|
9
|
-
|
|
10
8
|
import type { ChoiceAttributeOptionModelOptions } from "./ChoiceAttributeOptionModel";
|
|
11
9
|
/**
|
|
12
10
|
*/
|
|
@@ -20,7 +18,7 @@ class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttribute
|
|
|
20
18
|
this._modelOptions = modelOptions || {
|
|
21
19
|
origin: "",
|
|
22
20
|
contextPath: getBasePathModularUI(),
|
|
23
|
-
referenceDate:
|
|
21
|
+
referenceDate: new Date().toISOString().split("T")[0],
|
|
24
22
|
};
|
|
25
23
|
}
|
|
26
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceAttributeOptionCollection.js","names":["_ResourceCollection","_interopRequireDefault","require","_ChoiceAttributeOptionModel","_ListHeaderModel","_constants","_utils","ChoiceAttributeOptionCollection","ResourceCollection","constructor","modelOptions","_defineProperty2","default","_modelOptions","origin","contextPath","getBasePathModularUI","referenceDate","DateUtil","now","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 { DateUtil } from \"../../utils\";\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: DateUtil.now(),\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 }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AEC,OAAO,CAAC;MAClD;MACA,OAAOG,MAAM;IACf,CAAC,CAAC;EACJ;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAnG,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","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;;EAE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F,IAAI,CAAC,CAAC/E,MAAM,EAAEmF,WAAW,EAAEC,eAAe,KAAK;MACpE,MAAMC,MAAM,GAAGJ,UAAU,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":[]}
|
|
@@ -12,7 +12,6 @@ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable
|
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
13
13
|
var _BaseModel = _interopRequireDefault(require("../base/BaseModel"));
|
|
14
14
|
var _ChoiceAttributeOptionCollection = _interopRequireDefault(require("./ChoiceAttributeOptionCollection"));
|
|
15
|
-
var _DateTimeUtil = require("../../utils/datetime/DateTimeUtil");
|
|
16
15
|
var _objects = require("../../utils/helpers/objects");
|
|
17
16
|
var _Constants = require("../../constants/Constants");
|
|
18
17
|
var _LayoutHints = require("../../constants/LayoutHints");
|
|
@@ -43,7 +42,7 @@ class ChoiceAttributeOptionModel extends _BaseModel.default {
|
|
|
43
42
|
(0, _defineProperty2.default)(this, "_isUser", false);
|
|
44
43
|
this.code = this.contributions.code ?? this.contributions.key ?? "";
|
|
45
44
|
this._isSelected = (0, _includes.default)(selectedValues).call(selectedValues, this.code);
|
|
46
|
-
this._referenceDate = modelOptions?.referenceDate ||
|
|
45
|
+
this._referenceDate = modelOptions?.referenceDate || new Date().toISOString().split("T")[0];
|
|
47
46
|
this._level = 0;
|
|
48
47
|
this._attributeCollection = this.createAttributeCollection(modelOptions);
|
|
49
48
|
this._children = this.addChildren(selectedValues, option, modelOptions);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import BaseModel from "../base/BaseModel";
|
|
3
3
|
import ChoiceAttributeOptionCollection from "./ChoiceAttributeOptionCollection";
|
|
4
4
|
|
|
5
|
-
import { DateUtil } from "../../utils/datetime/DateTimeUtil";
|
|
6
5
|
import { has } from "../../utils/helpers/objects";
|
|
7
6
|
import { TIMEVERSION_FILTER_NAME } from "../../constants/Constants";
|
|
8
7
|
import { TITLE } from "../../constants/LayoutHints";
|
|
@@ -57,7 +56,8 @@ class ChoiceAttributeOptionModel
|
|
|
57
56
|
|
|
58
57
|
this._isSelected = selectedValues.includes(this.code);
|
|
59
58
|
|
|
60
|
-
this._referenceDate =
|
|
59
|
+
this._referenceDate =
|
|
60
|
+
modelOptions?.referenceDate || new Date().toISOString().split("T")[0];
|
|
61
61
|
|
|
62
62
|
this._level = 0;
|
|
63
63
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceAttributeOptionModel.js","names":["_BaseModel","_interopRequireDefault","require","_ChoiceAttributeOptionCollection","_DateTimeUtil","_objects","_Constants","_LayoutHints","_Settings","_LinkCollection","_AttributeCollection","_ConceptDetailModel","_AttributeContent","ChoiceAttributeOptionModel","BaseModel","constructor","selectedValues","arguments","length","undefined","option","modelOptions","_defineProperty2","default","code","contributions","key","_isSelected","_includes","call","_referenceDate","referenceDate","DateUtil","now","_level","_attributeCollection","createAttributeCollection","_children","addChildren","_links","LinkCollection","origin","contextPath","_content","AttributeContent","content","_isUser","optionType","createFromListItemModel","listitem","id","toString","attributeCollection","clone","links","isChoiceAttributeOptionModel","getInitialChildModelLinks","initialLinks","hasContentFromData","conceptLink","push","children","setChildModels","models","errors","conceptHref","href","concept","_find","model","selfhref","equalsWithParameters","_code","equals","getContribution","has","data","AttributeCollection","isReadonly","label","hasItems","title","getAttributeByLayoutHint","TITLE","readonlyvalue","first","getContentConfiguredLabel","contentConfiguration","configuredLabelProperties","labelConfig","types","_context","configuredLabels","_filter","getLabelElementByIds","configuredLabel","value","_context2","_map","configuredLabelProperty","some","_id","selected","count","ChoiceAttributeOptionCollection","create","options","date","getLinkByKey","addParameter","TIMEVERSION_FILTER_NAME","isCacheable","avatarLink","_concept","ConceptDetailModel","level","isBooleanType","hasAlternativeLabel","mergeOption","withOption","mergeOptions","hasAllContentInData","isUser","_default","exports"],"sources":["../../../src/models/attributes/ChoiceAttributeOptionModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\n\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\nimport { has } from \"../../utils/helpers/objects\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport { TITLE } from \"../../constants/LayoutHints\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\n\nimport LinkCollection from \"../links/LinkCollection\";\nimport AttributeCollection from \"./AttributeCollection\";\nimport ConceptDetailModel from \"../concepts/ConceptDetailModel\";\nimport AttributeContent from \"./AttributeContent\";\n\nimport type {\n IModelWithChildModels,\n ModelOptions,\n ModularUIModel,\n} from \"../types\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\nexport type ChoiceAttributeOptionModelOptions = {\n ...ModelOptions,\n referenceDate: ISO_DATE,\n};\n\n/**\n */\nclass ChoiceAttributeOptionModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _code: string;\n _isSelected: boolean;\n _referenceDate: ISO_DATE;\n _level: number;\n _children: ChoiceAttributeOptionCollection;\n _concept: ?ConceptDetailModel;\n _links: LinkCollection;\n _attributeCollection: AttributeCollection;\n _content: AttributeContent;\n _isUser: boolean = false;\n\n /**\n */\n constructor(\n selectedValues: Array<string> = [],\n option: Object = {},\n modelOptions?: ChoiceAttributeOptionModelOptions,\n ) {\n super({}, option);\n\n this.code = this.contributions.code ?? this.contributions.key ?? \"\";\n\n this._isSelected = selectedValues.includes(this.code);\n\n this._referenceDate = modelOptions?.referenceDate || DateUtil.now();\n\n this._level = 0;\n\n this._attributeCollection = this.createAttributeCollection(modelOptions);\n this._children = this.addChildren(selectedValues, option, modelOptions);\n\n this._links = new LinkCollection(\n this.contributions._links,\n {},\n { origin: modelOptions?.origin, contextPath: modelOptions?.contextPath },\n );\n\n this._content = new AttributeContent(option.content);\n\n this._isUser = option.optionType === \"user\";\n }\n\n /**\n */\n static createFromListItemModel(\n listitem: ListItemModel,\n ): ChoiceAttributeOptionModel {\n const option = new ChoiceAttributeOptionModel();\n\n option.code = listitem.id.toString();\n option.attributeCollection = listitem.attributeCollection.clone();\n option.links = listitem.links.clone();\n\n return option;\n }\n\n /**\n * Indicates that this a choice attribute option model, used when adding options to a choice attribute\n * @returns {boolean}\n */\n get isChoiceAttributeOptionModel(): boolean {\n return true;\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const initialLinks = [];\n\n if (!this.hasContentFromData && this.conceptLink !== null) {\n initialLinks.push(this.conceptLink);\n }\n\n if (this.children) {\n initialLinks.push(...this.children.getInitialChildModelLinks());\n }\n\n return initialLinks;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n if (this.conceptLink !== null) {\n const conceptHref = this.conceptLink.href;\n\n this.concept = models.find((model) =>\n model.selfhref.equalsWithParameters(conceptHref),\n );\n }\n\n if (this.children) {\n this.children.setChildModels(models, errors);\n }\n }\n\n /**\n * Get code of option\n */\n get code(): string {\n return this._code;\n }\n\n /**\n */\n set code(code: string) {\n this._code = code;\n }\n\n /**\n */\n equals(model: ChoiceAttributeOptionModel): boolean {\n return this.code.toString() === model.code.toString();\n }\n\n /**\n * Retrieve attributes for Composite codemaps (e.g. table and case list codemaps)\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(attributeCollection: AttributeCollection) {\n this._attributeCollection = attributeCollection;\n }\n\n /**\n */\n createAttributeCollection(\n modelOptions?: ChoiceAttributeOptionModelOptions,\n ): AttributeCollection {\n const contributions = this.getContribution(\"elementsContributions\", []);\n\n if (has(this.contributions, \"elements\")) {\n const data = this.getContribution(\"elements\", {});\n return new AttributeCollection(data, contributions, {\n origin: modelOptions?.origin,\n contextPath: modelOptions?.contextPath,\n isReadonly: true,\n });\n }\n\n return new AttributeCollection();\n }\n\n /**\n * Get label of option for simple codemaps (e.g. static codemap)\n */\n get label(): string {\n if (this.contributions.label) {\n return this.contributions.label;\n }\n\n if (this.attributeCollection.hasItems) {\n const title = this.attributeCollection.getAttributeByLayoutHint(TITLE);\n\n if (title) {\n return title.readonlyvalue;\n }\n\n if (this.attributeCollection.first) {\n return this.attributeCollection.first.readonlyvalue;\n }\n }\n\n return \"\";\n }\n\n /**\n * Retrieve the first permitted label to render when a concept and contentConfiguration is available\n * Be aware that permission could be in place for labels from a concept.\n */\n getContentConfiguredLabel(contentConfiguration: Object): string {\n const configuredLabelProperties =\n contentConfiguration?.labelConfig?.[0]?.types ?? [];\n\n if (\n !this.hasContentFromData &&\n this.concept &&\n configuredLabelProperties.length > 0\n ) {\n const configuredLabels = this.concept\n .getLabelElementByIds(configuredLabelProperties)\n .filter(\n (configuredLabel) =>\n configuredLabel.value && configuredLabel.value !== \"\",\n );\n\n if (configuredLabels.length > 0) {\n return configuredLabelProperties\n .filter((configuredLabelProperty) =>\n configuredLabels.some(\n (configuredLabel) =>\n configuredLabel._id === configuredLabelProperty,\n ),\n )\n .map((configuredLabelProperty) =>\n configuredLabels.find(\n (configuredLabel) =>\n configuredLabel._id === configuredLabelProperty,\n ),\n )[0].value;\n }\n }\n\n return this.label;\n }\n\n /**\n * Indicates if option is selected\n */\n get selected(): boolean {\n return this._isSelected;\n }\n\n /**\n * Set selected property of option\n */\n set selected(selected: boolean) {\n this._isSelected = selected;\n }\n\n /**\n * Retrieve count of filter for option\n */\n get count(): number | null {\n return this.getContribution(\"count\");\n }\n\n /**\n */\n addChildren(\n selectedValues: Array<string> = [],\n option: Object = {},\n modelOptions?: ChoiceAttributeOptionModelOptions,\n ): ChoiceAttributeOptionCollection {\n // When contributions contain elements this is a list not nested options\n if (has(option, \"elements\")) {\n return new ChoiceAttributeOptionCollection(modelOptions);\n }\n\n return ChoiceAttributeOptionCollection.create(\n {\n value: selectedValues,\n },\n { options: option?.children ?? [] },\n modelOptions,\n );\n }\n\n /**\n * get children of option\n */\n get children(): ChoiceAttributeOptionCollection {\n return this._children;\n }\n\n /**\n * Retrieve links of attribute\n */\n get links(): LinkCollection {\n return this._links;\n }\n\n /**\n */\n set links(links: LinkCollection) {\n this._links = links;\n }\n\n /**\n * referenceDate received from attribute\n */\n get referenceDate(): ISO_DATE {\n return this._referenceDate;\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this._referenceDate = date;\n }\n\n /**\n * Retrieve concept link of attribute when available\n */\n get conceptLink(): LinkModel | null {\n const conceptLink = this.links.getLinkByKey(\"concept\");\n if (conceptLink !== null) {\n conceptLink.href = conceptLink.href.addParameter(\n TIMEVERSION_FILTER_NAME,\n this.referenceDate,\n );\n\n conceptLink.isCacheable = true;\n }\n\n return conceptLink;\n }\n\n /**\n *\n */\n get avatarLink(): LinkModel | null {\n return this.links.getLinkByKey(\"avatar\");\n }\n\n /**\n * Get concept information\n */\n get concept(): ConceptDetailModel | null {\n return this._concept || null;\n }\n\n /**\n * Set the concept\n */\n set concept(concept: ?ModularUIModel) {\n this._concept = concept instanceof ConceptDetailModel ? concept : null;\n }\n\n /**\n * Get level of option, used in tree view choice attributes (taxonomy)\n */\n get level(): number {\n return this._level;\n }\n\n /**\n * Set level of option\n */\n set level(level: number) {\n this._level = level;\n }\n\n /**\n */\n get isBooleanType(): boolean {\n return this.getContribution(\"isBooleanType\", false);\n }\n\n /**\n */\n get hasAlternativeLabel(): boolean {\n return this.getContribution(\"hasAlternativeLabel\", false);\n }\n\n /**\n */\n mergeOption(withOption: ChoiceAttributeOptionModel) {\n this.concept = withOption.concept;\n\n if (this.children != null && withOption.children != null) {\n this.children.mergeOptions(withOption.children);\n }\n }\n\n /**\n * Indicates if content comes from the data service\n */\n get hasContentFromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get content(): AttributeContent {\n return this._content;\n }\n\n /**\n */\n get isUser(): boolean {\n return this._isUser;\n }\n}\n\nexport default ChoiceAttributeOptionModel;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gCAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAEA,IAAAO,eAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,oBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,mBAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,iBAAA,GAAAX,sBAAA,CAAAC,OAAA;AAgBA;AACA;AACA,MAAMW,0BAA0B,SACtBC,kBAAS,CAEnB;EAYE;AACF;EACEC,WAAWA,CAAA,EAIT;IAAA,IAHAC,cAA6B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAAA,IAClCG,MAAc,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,IACnBI,YAAgD,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAEhD,KAAK,CAAC,CAAC,CAAC,EAAEC,MAAM,CAAC;IAAC,IAAAE,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IA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E,IAAIC,aAAaA,CAAA,EAAY;IAC3B,OAAO,IAAI,CAAC1C,eAAe,CAAC,eAAe,EAAE,KAAK,CAAC;EACrD;;EAEA;AACF;EACE,IAAI2C,mBAAmBA,CAAA,EAAY;IACjC,OAAO,IAAI,CAAC3C,eAAe,CAAC,qBAAqB,EAAE,KAAK,CAAC;EAC3D;;EAEA;AACF;EACE4C,WAAWA,CAACC,UAAsC,EAAE;IAClD,IAAI,CAACpD,OAAO,GAAGoD,UAAU,CAACpD,OAAO;IAEjC,IAAI,IAAI,CAACN,QAAQ,IAAI,IAAI,IAAI0D,UAAU,CAAC1D,QAAQ,IAAI,IAAI,EAAE;MACxD,IAAI,CAACA,QAAQ,CAAC2D,YAAY,CAACD,UAAU,CAAC1D,QAAQ,CAAC;IACjD;EACF;;EAEA;AACF;AACA;EACE,IAAIH,kBAAkBA,CAAA,EAAY;IAChC,OAAO,IAAA+D,6BAAmB,EAAC,CAAC;EAC9B;;EAEA;AACF;EACE,IAAI5E,OAAOA,CAAA,EAAqB;IAC9B,OAAO,IAAI,CAACF,QAAQ;EACtB;;EAEA;AACF;EACE,IAAI+E,MAAMA,CAAA,EAAY;IACpB,OAAO,IAAI,CAAC5E,OAAO;EACrB;AACF;AAAC,IAAA6E,QAAA,GAAAC,OAAA,CAAArG,OAAA,GAEcV,0BAA0B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ChoiceAttributeOptionModel.js","names":["_BaseModel","_interopRequireDefault","require","_ChoiceAttributeOptionCollection","_objects","_Constants","_LayoutHints","_Settings","_LinkCollection","_AttributeCollection","_ConceptDetailModel","_AttributeContent","ChoiceAttributeOptionModel","BaseModel","constructor","selectedValues","arguments","length","undefined","option","modelOptions","_defineProperty2","default","code","contributions","key","_isSelected","_includes","call","_referenceDate","referenceDate","Date","toISOString","split","_level","_attributeCollection","createAttributeCollection","_children","addChildren","_links","LinkCollection","origin","contextPath","_content","AttributeContent","content","_isUser","optionType","createFromListItemModel","listitem","id","toString","attributeCollection","clone","links","isChoiceAttributeOptionModel","getInitialChildModelLinks","initialLinks","hasContentFromData","conceptLink","push","children","setChildModels","models","errors","conceptHref","href","concept","_find","model","selfhref","equalsWithParameters","_code","equals","getContribution","has","data","AttributeCollection","isReadonly","label","hasItems","title","getAttributeByLayoutHint","TITLE","readonlyvalue","first","getContentConfiguredLabel","contentConfiguration","configuredLabelProperties","labelConfig","types","_context","configuredLabels","_filter","getLabelElementByIds","configuredLabel","value","_context2","_map","configuredLabelProperty","some","_id","selected","count","ChoiceAttributeOptionCollection","create","options","date","getLinkByKey","addParameter","TIMEVERSION_FILTER_NAME","isCacheable","avatarLink","_concept","ConceptDetailModel","level","isBooleanType","hasAlternativeLabel","mergeOption","withOption","mergeOptions","hasAllContentInData","isUser","_default","exports"],"sources":["../../../src/models/attributes/ChoiceAttributeOptionModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\n\nimport { has } from \"../../utils/helpers/objects\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport { TITLE } from \"../../constants/LayoutHints\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\n\nimport LinkCollection from \"../links/LinkCollection\";\nimport AttributeCollection from \"./AttributeCollection\";\nimport ConceptDetailModel from \"../concepts/ConceptDetailModel\";\nimport AttributeContent from \"./AttributeContent\";\n\nimport type {\n IModelWithChildModels,\n ModelOptions,\n ModularUIModel,\n} from \"../types\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\nexport type ChoiceAttributeOptionModelOptions = {\n ...ModelOptions,\n referenceDate: ISO_DATE,\n};\n\n/**\n */\nclass ChoiceAttributeOptionModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _code: string;\n _isSelected: boolean;\n _referenceDate: ISO_DATE;\n _level: number;\n _children: ChoiceAttributeOptionCollection;\n _concept: ?ConceptDetailModel;\n _links: LinkCollection;\n _attributeCollection: AttributeCollection;\n _content: AttributeContent;\n _isUser: boolean = false;\n\n /**\n */\n constructor(\n selectedValues: Array<string> = [],\n option: Object = {},\n modelOptions?: ChoiceAttributeOptionModelOptions,\n ) {\n super({}, option);\n\n this.code = this.contributions.code ?? this.contributions.key ?? \"\";\n\n this._isSelected = selectedValues.includes(this.code);\n\n this._referenceDate =\n modelOptions?.referenceDate || new Date().toISOString().split(\"T\")[0];\n\n this._level = 0;\n\n this._attributeCollection = this.createAttributeCollection(modelOptions);\n this._children = this.addChildren(selectedValues, option, modelOptions);\n\n this._links = new LinkCollection(\n this.contributions._links,\n {},\n { origin: modelOptions?.origin, contextPath: modelOptions?.contextPath },\n );\n\n this._content = new AttributeContent(option.content);\n\n this._isUser = option.optionType === \"user\";\n }\n\n /**\n */\n static createFromListItemModel(\n listitem: ListItemModel,\n ): ChoiceAttributeOptionModel {\n const option = new ChoiceAttributeOptionModel();\n\n option.code = listitem.id.toString();\n option.attributeCollection = listitem.attributeCollection.clone();\n option.links = listitem.links.clone();\n\n return option;\n }\n\n /**\n * Indicates that this a choice attribute option model, used when adding options to a choice attribute\n * @returns {boolean}\n */\n get isChoiceAttributeOptionModel(): boolean {\n return true;\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const initialLinks = [];\n\n if (!this.hasContentFromData && this.conceptLink !== null) {\n initialLinks.push(this.conceptLink);\n }\n\n if (this.children) {\n initialLinks.push(...this.children.getInitialChildModelLinks());\n }\n\n return initialLinks;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n if (this.conceptLink !== null) {\n const conceptHref = this.conceptLink.href;\n\n this.concept = models.find((model) =>\n model.selfhref.equalsWithParameters(conceptHref),\n );\n }\n\n if (this.children) {\n this.children.setChildModels(models, errors);\n }\n }\n\n /**\n * Get code of option\n */\n get code(): string {\n return this._code;\n }\n\n /**\n */\n set code(code: string) {\n this._code = code;\n }\n\n /**\n */\n equals(model: ChoiceAttributeOptionModel): boolean {\n return this.code.toString() === model.code.toString();\n }\n\n /**\n * Retrieve attributes for Composite codemaps (e.g. table and case list codemaps)\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(attributeCollection: AttributeCollection) {\n this._attributeCollection = attributeCollection;\n }\n\n /**\n */\n createAttributeCollection(\n modelOptions?: ChoiceAttributeOptionModelOptions,\n ): AttributeCollection {\n const contributions = this.getContribution(\"elementsContributions\", []);\n\n if (has(this.contributions, \"elements\")) {\n const data = this.getContribution(\"elements\", {});\n return new AttributeCollection(data, contributions, {\n origin: modelOptions?.origin,\n contextPath: modelOptions?.contextPath,\n isReadonly: true,\n });\n }\n\n return new AttributeCollection();\n }\n\n /**\n * Get label of option for simple codemaps (e.g. static codemap)\n */\n get label(): string {\n if (this.contributions.label) {\n return this.contributions.label;\n }\n\n if (this.attributeCollection.hasItems) {\n const title = this.attributeCollection.getAttributeByLayoutHint(TITLE);\n\n if (title) {\n return title.readonlyvalue;\n }\n\n if (this.attributeCollection.first) {\n return this.attributeCollection.first.readonlyvalue;\n }\n }\n\n return \"\";\n }\n\n /**\n * Retrieve the first permitted label to render when a concept and contentConfiguration is available\n * Be aware that permission could be in place for labels from a concept.\n */\n getContentConfiguredLabel(contentConfiguration: Object): string {\n const configuredLabelProperties =\n contentConfiguration?.labelConfig?.[0]?.types ?? [];\n\n if (\n !this.hasContentFromData &&\n this.concept &&\n configuredLabelProperties.length > 0\n ) {\n const configuredLabels = this.concept\n .getLabelElementByIds(configuredLabelProperties)\n .filter(\n (configuredLabel) =>\n configuredLabel.value && configuredLabel.value !== \"\",\n );\n\n if (configuredLabels.length > 0) {\n return configuredLabelProperties\n .filter((configuredLabelProperty) =>\n configuredLabels.some(\n (configuredLabel) =>\n configuredLabel._id === configuredLabelProperty,\n ),\n )\n .map((configuredLabelProperty) =>\n configuredLabels.find(\n (configuredLabel) =>\n configuredLabel._id === configuredLabelProperty,\n ),\n )[0].value;\n }\n }\n\n return this.label;\n }\n\n /**\n * Indicates if option is selected\n */\n get selected(): boolean {\n return this._isSelected;\n }\n\n /**\n * Set selected property of option\n */\n set selected(selected: boolean) {\n this._isSelected = selected;\n }\n\n /**\n * Retrieve count of filter for option\n */\n get count(): number | null {\n return this.getContribution(\"count\");\n }\n\n /**\n */\n addChildren(\n selectedValues: Array<string> = [],\n option: Object = {},\n modelOptions?: ChoiceAttributeOptionModelOptions,\n ): ChoiceAttributeOptionCollection {\n // When contributions contain elements this is a list not nested options\n if (has(option, \"elements\")) {\n return new ChoiceAttributeOptionCollection(modelOptions);\n }\n\n return ChoiceAttributeOptionCollection.create(\n {\n value: selectedValues,\n },\n { options: option?.children ?? [] },\n modelOptions,\n );\n }\n\n /**\n * get children of option\n */\n get children(): ChoiceAttributeOptionCollection {\n return this._children;\n }\n\n /**\n * Retrieve links of attribute\n */\n get links(): LinkCollection {\n return this._links;\n }\n\n /**\n */\n set links(links: LinkCollection) {\n this._links = links;\n }\n\n /**\n * referenceDate received from attribute\n */\n get referenceDate(): ISO_DATE {\n return this._referenceDate;\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this._referenceDate = date;\n }\n\n /**\n * Retrieve concept link of attribute when available\n */\n get conceptLink(): LinkModel | null {\n const conceptLink = this.links.getLinkByKey(\"concept\");\n if (conceptLink !== null) {\n conceptLink.href = conceptLink.href.addParameter(\n TIMEVERSION_FILTER_NAME,\n this.referenceDate,\n );\n\n conceptLink.isCacheable = true;\n }\n\n return conceptLink;\n }\n\n /**\n *\n */\n get avatarLink(): LinkModel | null {\n return this.links.getLinkByKey(\"avatar\");\n }\n\n /**\n * Get concept information\n */\n get concept(): ConceptDetailModel | null {\n return this._concept || null;\n }\n\n /**\n * Set the concept\n */\n set concept(concept: ?ModularUIModel) {\n this._concept = concept instanceof ConceptDetailModel ? concept : null;\n }\n\n /**\n * Get level of option, used in tree view choice attributes (taxonomy)\n */\n get level(): number {\n return this._level;\n }\n\n /**\n * Set level of option\n */\n set level(level: number) {\n this._level = level;\n }\n\n /**\n */\n get isBooleanType(): boolean {\n return this.getContribution(\"isBooleanType\", false);\n }\n\n /**\n */\n get hasAlternativeLabel(): boolean {\n return this.getContribution(\"hasAlternativeLabel\", false);\n }\n\n /**\n */\n mergeOption(withOption: ChoiceAttributeOptionModel) {\n this.concept = withOption.concept;\n\n if (this.children != null && withOption.children != null) {\n this.children.mergeOptions(withOption.children);\n }\n }\n\n /**\n * Indicates if content comes from the data service\n */\n get hasContentFromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get content(): AttributeContent {\n return this._content;\n }\n\n /**\n */\n get isUser(): boolean {\n return this._isUser;\n }\n}\n\nexport default ChoiceAttributeOptionModel;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gCAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA,IAAAM,eAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,oBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,mBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,iBAAA,GAAAV,sBAAA,CAAAC,OAAA;AAgBA;AACA;AACA,MAAMU,0BAA0B,SACtBC,kBAAS,CAEnB;EAYE;AACF;EACEC,WAAWA,CAAA,EAIT;IAAA,IAHAC,cAA6B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAAA,IAClCG,MAAc,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,IACnBI,YAAgD,GAAAJ,S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AQ,GAAG9C,OAAO,YAAY+C,2BAAkB,GAAG/C,OAAO,GAAG,IAAI;EACxE;;EAEA;AACF;AACA;EACE,IAAIgD,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACjF,MAAM;EACpB;;EAEA;AACF;AACA;EACE,IAAIiF,KAAKA,CAACA,KAAa,EAAE;IACvB,IAAI,CAACjF,MAAM,GAAGiF,KAAK;EACrB;;EAEA;AACF;EACE,IAAIC,aAAaA,CAAA,EAAY;IAC3B,OAAO,IAAI,CAAC1C,eAAe,CAAC,eAAe,EAAE,KAAK,CAAC;EACrD;;EAEA;AACF;EACE,IAAI2C,mBAAmBA,CAAA,EAAY;IACjC,OAAO,IAAI,CAAC3C,eAAe,CAAC,qBAAqB,EAAE,KAAK,CAAC;EAC3D;;EAEA;AACF;EACE4C,WAAWA,CAACC,UAAsC,EAAE;IAClD,IAAI,CAACpD,OAAO,GAAGoD,UAAU,CAACpD,OAAO;IAEjC,IAAI,IAAI,CAACN,QAAQ,IAAI,IAAI,IAAI0D,UAAU,CAAC1D,QAAQ,IAAI,IAAI,EAAE;MACxD,IAAI,CAACA,QAAQ,CAAC2D,YAAY,CAACD,UAAU,CAAC1D,QAAQ,CAAC;IACjD;EACF;;EAEA;AACF;AACA;EACE,IAAIH,kBAAkBA,CAAA,EAAY;IAChC,OAAO,IAAA+D,6BAAmB,EAAC,CAAC;EAC9B;;EAEA;AACF;EACE,IAAI5E,OAAOA,CAAA,EAAqB;IAC9B,OAAO,IAAI,CAACF,QAAQ;EACtB;;EAEA;AACF;EACE,IAAI+E,MAAMA,CAAA,EAAY;IACpB,OAAO,IAAI,CAAC5E,OAAO;EACrB;AACF;AAAC,IAAA6E,QAAA,GAAAC,OAAA,CAAAtG,OAAA,GAEcV,0BAA0B","ignoreList":[]}
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _ResourceCollection = _interopRequireDefault(require("../base/ResourceCollection"));
|
|
9
9
|
var _ChoiceAttributeOptionModel = _interopRequireDefault(require("../attributes/ChoiceAttributeOptionModel"));
|
|
10
|
-
var _utils = require("../../utils");
|
|
11
10
|
/**
|
|
12
11
|
*/
|
|
13
12
|
class LookupOptionCollection extends _ResourceCollection.default {
|
|
@@ -23,7 +22,7 @@ class LookupOptionCollection extends _ResourceCollection.default {
|
|
|
23
22
|
elementsContributions: contributions.options[0].elements
|
|
24
23
|
}, {
|
|
25
24
|
...modelOptions,
|
|
26
|
-
referenceDate:
|
|
25
|
+
referenceDate: new Date().toISOString().split("T")[0]
|
|
27
26
|
}));
|
|
28
27
|
});
|
|
29
28
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import ResourceCollection from "../base/ResourceCollection";
|
|
3
3
|
import ChoiceAttributeOptionModel from "../attributes/ChoiceAttributeOptionModel";
|
|
4
|
-
import { DateUtil } from "../../utils";
|
|
5
4
|
|
|
6
5
|
import type { ModelOptions } from "../types";
|
|
7
6
|
|
|
@@ -27,7 +26,10 @@ class LookupOptionCollection extends ResourceCollection<ChoiceAttributeOptionMod
|
|
|
27
26
|
optionType: this.getOptionType(option, contributions),
|
|
28
27
|
elementsContributions: contributions.options[0].elements,
|
|
29
28
|
},
|
|
30
|
-
{
|
|
29
|
+
{
|
|
30
|
+
...modelOptions,
|
|
31
|
+
referenceDate: new Date().toISOString().split("T")[0],
|
|
32
|
+
},
|
|
31
33
|
),
|
|
32
34
|
);
|
|
33
35
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LookupOptionCollection.js","names":["_ResourceCollection","_interopRequireDefault","require","_ChoiceAttributeOptionModel","
|
|
1
|
+
{"version":3,"file":"LookupOptionCollection.js","names":["_ResourceCollection","_interopRequireDefault","require","_ChoiceAttributeOptionModel","LookupOptionCollection","ResourceCollection","create","data","contributions","modelOptions","collection","options","forEach","option","add","ChoiceAttributeOptionModel","optionType","getOptionType","elementsContributions","elements","referenceDate","Date","toISOString","split","_links","download","name","_default","exports","default"],"sources":["../../../src/models/lookup/LookupOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"../attributes/ChoiceAttributeOptionModel\";\n\nimport type { ModelOptions } from \"../types\";\n\n/**\n */\nclass LookupOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n /**\n */\n static create(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): LookupOptionCollection {\n const collection = new LookupOptionCollection();\n\n if (data.options && contributions.options) {\n data.options.forEach((option) => {\n collection.add(\n new ChoiceAttributeOptionModel(\n [],\n {\n ...option,\n optionType: this.getOptionType(option, contributions),\n elementsContributions: contributions.options[0].elements,\n },\n {\n ...modelOptions,\n referenceDate: new Date().toISOString().split(\"T\")[0],\n },\n ),\n );\n });\n }\n\n return collection;\n }\n\n /**\n */\n static getOptionType(option: Object, contributions: Object): string {\n if (contributions.optionType) {\n return contributions.optionType;\n }\n if (option._links?.download?.[0].name === \"avatar\") {\n return \"user\";\n }\n return \"generic\";\n }\n}\n\nexport default LookupOptionCollection;\n"],"mappings":";;;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAF,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA,MAAME,sBAAsB,SAASC,2BAAkB,CAA6B;EAClF;AACF;EACE,OAAOC,MAAMA,CACXC,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EACH;IACxB,MAAMC,UAAU,GAAG,IAAIN,sBAAsB,CAAC,CAAC;IAE/C,IAAIG,IAAI,CAACI,OAAO,IAAIH,aAAa,CAACG,OAAO,EAAE;MACzCJ,IAAI,CAACI,OAAO,CAACC,OAAO,CAAEC,MAAM,IAAK;QAC/BH,UAAU,CAACI,GAAG,CACZ,IAAIC,mCAA0B,CAC5B,EAAE,EACF;UACE,GAAGF,MAAM;UACTG,UAAU,EAAE,IAAI,CAACC,aAAa,CAACJ,MAAM,EAAEL,aAAa,CAAC;UACrDU,qBAAqB,EAAEV,aAAa,CAACG,OAAO,CAAC,CAAC,CAAC,CAACQ;QAClD,CAAC,EACD;UACE,GAAGV,YAAY;UACfW,aAAa,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QACtD,CACF,CACF,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAOb,UAAU;EACnB;;EAEA;AACF;EACE,OAAOO,aAAaA,CAACJ,MAAc,EAAEL,aAAqB,EAAU;IAClE,IAAIA,aAAa,CAACQ,UAAU,EAAE;MAC5B,OAAOR,aAAa,CAACQ,UAAU;IACjC;IACA,IAAIH,MAAM,CAACW,MAAM,EAAEC,QAAQ,GAAG,CAAC,CAAC,CAACC,IAAI,KAAK,QAAQ,EAAE;MAClD,OAAO,MAAM;IACf;IACA,OAAO,SAAS;EAClB;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEczB,sBAAsB","ignoreList":[]}
|
|
@@ -8,7 +8,6 @@ exports.default = void 0;
|
|
|
8
8
|
var _BaseModel = _interopRequireDefault(require("../base/BaseModel"));
|
|
9
9
|
var _Constants = require("../../constants/Constants");
|
|
10
10
|
var _LinkCollection = _interopRequireDefault(require("../links/LinkCollection"));
|
|
11
|
-
var _DateTimeUtil = require("../../utils/datetime/DateTimeUtil");
|
|
12
11
|
/**
|
|
13
12
|
*/
|
|
14
13
|
class ProcessStatusSettingsModel extends _BaseModel.default {
|
|
@@ -67,7 +66,7 @@ class ProcessStatusSettingsModel extends _BaseModel.default {
|
|
|
67
66
|
/**
|
|
68
67
|
*/
|
|
69
68
|
get referenceDate() {
|
|
70
|
-
return
|
|
69
|
+
return new Date().toISOString().split("T")[0];
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
/**
|
|
@@ -3,7 +3,6 @@ import BaseModel from "../base/BaseModel";
|
|
|
3
3
|
|
|
4
4
|
import { TIMEVERSION_FILTER_NAME } from "../../constants/Constants";
|
|
5
5
|
import LinkCollection from "../links/LinkCollection";
|
|
6
|
-
import { DateUtil } from "../../utils/datetime/DateTimeUtil";
|
|
7
6
|
|
|
8
7
|
import type LinkModel from "../links/LinkModel";
|
|
9
8
|
|
|
@@ -67,7 +66,7 @@ export default class ProcessStatusSettingsModel extends BaseModel {
|
|
|
67
66
|
/**
|
|
68
67
|
*/
|
|
69
68
|
get referenceDate(): ISO_DATE {
|
|
70
|
-
return
|
|
69
|
+
return new Date().toISOString().split("T")[0];
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcessStatusSettingsModel.js","names":["_BaseModel","_interopRequireDefault","require","_Constants","_LinkCollection","
|
|
1
|
+
{"version":3,"file":"ProcessStatusSettingsModel.js","names":["_BaseModel","_interopRequireDefault","require","_Constants","_LinkCollection","ProcessStatusSettingsModel","BaseModel","concequenceType","getContribution","toLowerCase","transition","isApplicable","getData","isCompleted","isNeeded","needed","state","canComplete","links","LinkCollection","contributions","_links","referenceDate","Date","toISOString","split","conceptLink","getLinkByKey","href","addParameter","TIMEVERSION_FILTER_NAME","isCacheable","exports","default"],"sources":["../../../src/models/process/ProcessStatusSettingsModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport LinkCollection from \"../links/LinkCollection\";\n\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n */\nexport default class ProcessStatusSettingsModel extends BaseModel {\n /**\n */\n get concequenceType(): string {\n return this.getContribution(\"consequenceType\", \"\").toLowerCase();\n }\n\n /**\n */\n get transition(): string {\n return this.getContribution(\"transition\", \"\").toLowerCase();\n }\n\n /**\n */\n get isApplicable(): boolean {\n return this.getData(\"applicable\", false);\n }\n\n /**\n */\n get isCompleted(): boolean {\n return this.getData(\"completed\", false);\n }\n\n /**\n */\n get isNeeded(): boolean | null {\n const needed = this.getData(\"needed\", \"unknown\");\n\n if (needed === \"unknown\") {\n return null;\n }\n\n return needed === \"true\";\n }\n\n /**\n */\n get state(): string | null {\n return this.getData(\"state\");\n }\n\n /**\n */\n get canComplete(): boolean | null {\n return this.getData(\"canComplete\");\n }\n\n /**\n */\n get links(): LinkCollection {\n return new LinkCollection(this.contributions._links);\n }\n\n /**\n */\n get referenceDate(): ISO_DATE {\n return new Date().toISOString().split(\"T\")[0];\n }\n\n /**\n * Retrieve concept link of attribute when available\n */\n get conceptLink(): LinkModel | null {\n const conceptLink = this.links.getLinkByKey(\"concept\");\n if (conceptLink !== null) {\n conceptLink.href = conceptLink.href.addParameter(\n TIMEVERSION_FILTER_NAME,\n this.referenceDate,\n );\n\n conceptLink.isCacheable = true;\n }\n\n return conceptLink;\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAH,sBAAA,CAAAC,OAAA;AAIA;AACA;AACe,MAAMG,0BAA0B,SAASC,kBAAS,CAAC;EAChE;AACF;EACE,IAAIC,eAAeA,CAAA,EAAW;IAC5B,OAAO,IAAI,CAACC,eAAe,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAACC,WAAW,CAAC,CAAC;EAClE;;EAEA;AACF;EACE,IAAIC,UAAUA,CAAA,EAAW;IACvB,OAAO,IAAI,CAACF,eAAe,CAAC,YAAY,EAAE,EAAE,CAAC,CAACC,WAAW,CAAC,CAAC;EAC7D;;EAEA;AACF;EACE,IAAIE,YAAYA,CAAA,EAAY;IAC1B,OAAO,IAAI,CAACC,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC;EAC1C;;EAEA;AACF;EACE,IAAIC,WAAWA,CAAA,EAAY;IACzB,OAAO,IAAI,CAACD,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC;EACzC;;EAEA;AACF;EACE,IAAIE,QAAQA,CAAA,EAAmB;IAC7B,MAAMC,MAAM,GAAG,IAAI,CAACH,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC;IAEhD,IAAIG,MAAM,KAAK,SAAS,EAAE;MACxB,OAAO,IAAI;IACb;IAEA,OAAOA,MAAM,KAAK,MAAM;EAC1B;;EAEA;AACF;EACE,IAAIC,KAAKA,CAAA,EAAkB;IACzB,OAAO,IAAI,CAACJ,OAAO,CAAC,OAAO,CAAC;EAC9B;;EAEA;AACF;EACE,IAAIK,WAAWA,CAAA,EAAmB;IAChC,OAAO,IAAI,CAACL,OAAO,CAAC,aAAa,CAAC;EACpC;;EAEA;AACF;EACE,IAAIM,KAAKA,CAAA,EAAmB;IAC1B,OAAO,IAAIC,uBAAc,CAAC,IAAI,CAACC,aAAa,CAACC,MAAM,CAAC;EACtD;;EAEA;AACF;EACE,IAAIC,aAAaA,CAAA,EAAa;IAC5B,OAAO,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EAC/C;;EAEA;AACF;AACA;EACE,IAAIC,WAAWA,CAAA,EAAqB;IAClC,MAAMA,WAAW,GAAG,IAAI,CAACR,KAAK,CAACS,YAAY,CAAC,SAAS,CAAC;IACtD,IAAID,WAAW,KAAK,IAAI,EAAE;MACxBA,WAAW,CAACE,IAAI,GAAGF,WAAW,CAACE,IAAI,CAACC,YAAY,CAC9CC,kCAAuB,EACvB,IAAI,CAACR,aACP,CAAC;MAEDI,WAAW,CAACK,WAAW,GAAG,IAAI;IAChC;IAEA,OAAOL,WAAW;EACpB;AACF;AAACM,OAAA,CAAAC,OAAA,GAAA5B,0BAAA","ignoreList":[]}
|
|
@@ -5,10 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _utils = require("../../utils");
|
|
9
8
|
var _Cache = _interopRequireDefault(require("../../utils/browser/Cache"));
|
|
10
9
|
const initialState = {
|
|
11
|
-
entryDate:
|
|
10
|
+
entryDate: new Date().toISOString().split("T")[0]
|
|
12
11
|
};
|
|
13
12
|
|
|
14
13
|
/**
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import { DateUtil } from "../../utils";
|
|
3
2
|
import Cache from "../../utils/browser/Cache";
|
|
4
3
|
|
|
5
4
|
import type { Reducer } from "redux";
|
|
6
5
|
import type { ReduxAction, ModelCatalogState } from "../types";
|
|
7
6
|
|
|
8
7
|
const initialState: ModelCatalogState = {
|
|
9
|
-
entryDate:
|
|
8
|
+
entryDate: new Date().toISOString().split("T")[0],
|
|
10
9
|
};
|
|
11
10
|
|
|
12
11
|
/**
|