@beinformed/ui 1.65.7 → 1.65.8
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 +11 -0
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/index.js.flow +1 -0
- package/esm/hooks/index.js.map +1 -1
- package/esm/hooks/useForm.js +3 -3
- package/esm/hooks/useForm.js.flow +7 -4
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useLookup.js +62 -0
- package/esm/hooks/useLookup.js.flow +82 -0
- package/esm/hooks/useLookup.js.map +1 -0
- package/esm/hooks/useProgressIndicator.js +21 -6
- package/esm/hooks/useProgressIndicator.js.flow +27 -10
- package/esm/hooks/useProgressIndicator.js.map +1 -1
- package/esm/models/attributes/AttributeSetModel.js +1 -1
- package/esm/models/attributes/AttributeSetModel.js.flow +1 -1
- package/esm/models/attributes/AttributeSetModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeModel.js +19 -2
- package/esm/models/attributes/ChoiceAttributeModel.js.flow +23 -2
- package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/esm/models/links/LinkModel.js +17 -1
- package/esm/models/links/LinkModel.js.flow +18 -1
- package/esm/models/links/LinkModel.js.map +1 -1
- package/lib/hooks/index.js +11 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useForm.js +5 -5
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useLookup.js +70 -0
- package/lib/hooks/useLookup.js.map +1 -0
- package/lib/hooks/useProgressIndicator.js +23 -7
- package/lib/hooks/useProgressIndicator.js.map +1 -1
- package/lib/models/attributes/AttributeSetModel.js +1 -1
- package/lib/models/attributes/AttributeSetModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js +18 -1
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/links/LinkModel.js +17 -0
- package/lib/models/links/LinkModel.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/index.js +1 -0
- package/src/hooks/useForm.js +7 -4
- package/src/hooks/useLookup.js +82 -0
- package/src/hooks/useProgressIndicator.js +27 -10
- package/src/models/attributes/AttributeSetModel.js +1 -1
- package/src/models/attributes/ChoiceAttributeModel.js +23 -2
- package/src/models/links/LinkModel.js +18 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceAttributeModel.js","names":["klona","has","AttributeModel","ChoiceAttributeOptionCollection","ChoiceAttributeOptionModel","CompositeAttributeModel","ContentConfigurationElements","RENDER_SECTION_LABEL","SORT_OPTIONS","ATTRIBUTE_WIDTH","ChoiceAttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty","_referenceDate","getData","Date","toISOString","split","_options","create","referenceDate","layouthint","sortOptions","isApplicableModel","contributions","type","optionMode","getContribution","hasLookupLink","lookupLink","lookupListLink","optionType","isUser","getInitialChildModelLinks","links","hasContentConfiguration","hasContentFromData","conceptLink","push","options","setChildModels","models","errors","conceptLinkHref","href","concept","_findInstanceProperty","call","model","selfhref","equalsWithParameters","getLinkByKey","lookupListLabel","lookupList","label","date","selected","_context","_mapInstanceProperty","option","code","readonlyvalue","_context2","join","initvalue","Array","isArray","_initvalue","length","getValue","_context3","hasValue","getInputValue","toggleOption","_context4","_includesInstanceProperty","disableOption","enableOption","isMultiple","deselectAll","select","inputvalue","deselect","addOption","_context5","opt","choicetype","_context6","hint","multiplechoice","isTree","some","reset","mergeAttribute","oldAttribute","addNotExistingOptions","removeNotExistingOptions","readonly","mergeOptions","isValid","update","value","updateLastModification","values","forEach","val","isChoiceAttributeOptionModel","equals","newVal","add","toString","updateByAttribute","otherAttribute","otherValue","getChildrenIds","console","error","addMissingError","receivedAttribute","isChangedSince","_errorCollection","addServerError","_hasContentConfiguration","contentConfiguration","_context7","content","optionElements","optionElementConfig","optionElement","contentElement","placeholder","id","message","properties","ANSWER_OPTION_KEY","_context8","optionKey","foundOption","getContentConfiguredLabel","readonlyWidth","MEDIUM"],"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 ATT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E,IAAIsH,aAAaA,CAAA,EAAkC;IACjD,OAAOrI,eAAe,CAACsI,MAAM;EAC/B;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ChoiceAttributeModel.js","names":["klona","has","AttributeModel","ChoiceAttributeOptionCollection","ChoiceAttributeOptionModel","CompositeAttributeModel","ContentConfigurationElements","RENDER_SECTION_LABEL","SORT_OPTIONS","ATTRIBUTE_WIDTH","PARAMETER_TYPES","HTTP_METHODS","ChoiceAttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty","_referenceDate","getData","Date","toISOString","split","_options","create","referenceDate","layouthint","sortOptions","isApplicableModel","contributions","type","optionMode","getContribution","hasLookupLink","lookupLink","lookupListLink","optionType","isUser","getInitialChildModelLinks","links","hasContentConfiguration","hasContentFromData","conceptLink","push","options","setChildModels","models","errors","conceptLinkHref","href","concept","_findInstanceProperty","call","model","selfhref","equalsWithParameters","link","getLinkByKey","lookupParameterType","BODY","method","POST","parameterType","QUERY","lookupListLabel","lookupList","label","date","selected","_context","_mapInstanceProperty","option","code","readonlyvalue","_context2","join","initvalue","Array","isArray","_initvalue","length","getValue","_context3","hasValue","getInputValue","toggleOption","_context4","_includesInstanceProperty","disableOption","enableOption","isMultiple","deselectAll","select","inputvalue","deselect","addOption","_context5","opt","choicetype","_context6","hint","multiplechoice","isTree","some","reset","mergeAttribute","oldAttribute","addNotExistingOptions","removeNotExistingOptions","readonly","mergeOptions","isValid","update","value","updateLastModification","values","forEach","val","isChoiceAttributeOptionModel","equals","newVal","add","toString","updateByAttribute","otherAttribute","otherValue","getChildrenIds","console","error","addMissingError","receivedAttribute","isChangedSince","_errorCollection","addServerError","_hasContentConfiguration","contentConfiguration","_context7","content","optionElements","optionElementConfig","optionElement","contentElement","placeholder","id","message","properties","ANSWER_OPTION_KEY","_context8","optionKey","foundOption","getContentConfiguredLabel","readonlyWidth","MEDIUM"],"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 {\n ATTRIBUTE_WIDTH,\n PARAMETER_TYPES,\n HTTP_METHODS,\n} 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 const link = this.links.getLinkByKey(\"lookupOptions\");\n if (link && this.lookupParameterType === PARAMETER_TYPES.BODY) {\n link.method = HTTP_METHODS.POST;\n }\n return link;\n }\n\n /**\n * Indicate if the lookup must be done with POST or GET\n */\n get lookupParameterType(): $Values<typeof PARAMETER_TYPES> {\n const parameterType = this.getContribution(\"parameterType\");\n switch (parameterType) {\n case \"bodyParameter\":\n return PARAMETER_TYPES.BODY;\n default:\n return PARAMETER_TYPES.QUERY;\n }\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,SAASA,KAAK,QAAQ,YAAY;AAElC,SAASC,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,+BAA+B,MAAM,mCAAmC;AAC/E,OAAOC,0BAA0B,MAAM,8BAA8B;AACrE,OAAOC,uBAAuB,MAAM,2BAA2B;AAC/D,OAAOC,4BAA4B,MAAM,sDAAsD;AAE/F,SACEC,oBAAoB,EACpBC,YAAY,QACP,6BAA6B;AACpC,SACEC,eAAe,EACfC,eAAe,EACfC,YAAY,QACP,iBAAiB;AAWxB;AACA;AACA;AACA,eAAe,MAAMC,oBAAoB,SAASV,cAAc,CAAC;EAK/D;AACF;AACA;EACEW,WAAWA,CACTC,SAAiB,EACjBC,sBAA8B,EAC9BC,YAA2B,EAC3B;IACA,KAAK,CAACF,SAAS,EAAEC,sBAAsB,EAAEC,YAAY,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAEvD,IAAI,CAACC,cAAc,GAAG,IAAI,CAACC,OAAO,CAChC,eAAe,EACf,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CACvC,CAAC;IACD,IAAI,CAACC,QAAQ,GAAGpB,+BAA+B,CAACqB,MAAM,CACpDV,SAAS,EACTC,sBAAsB,EACtB;MAAE,GAAGC,YAAY;MAAES,aAAa,EAAE,IAAI,CAACA;IAAc,CACvD,CAAC;IAED,I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G,cAAcA,CAACL,KAAsB,EAAE;IACrC,MAAM;MAAEe,EAAE;MAAEC,OAAO;MAAEC,UAAU;MAAEvH;IAAW,CAAC,GAAGsG,KAAK;IAErD,MAAMkB,iBAAiB,GAAG,mBAAmB;IAE7C,IAAID,UAAU,IAAIhJ,GAAG,CAACgJ,UAAU,EAAEC,iBAAiB,CAAC,EAAE;MAAA,IAAAC,SAAA;MACpD,MAAMC,SAAS,GAAGH,UAAU,CAACC,iBAAiB,CAAC;MAC/C,MAAMG,WAAW,GAAGlG,qBAAA,CAAAgG,SAAA,OAAI,CAACvG,OAAO,EAAAQ,IAAA,CAAA+F,SAAA,EAC7B5E,MAAM,IAAKA,MAAM,CAACC,IAAI,KAAK4E,SAC9B,CAAC;MACD,IAAIC,WAAW,EAAE;QACfJ,UAAU,CAACC,iBAAiB,CAAC,GAAGG,WAAW,CAACC,yBAAyB,CACnE,IAAI,CAACf,oBACP,CAAC;MACH;IACF;IAEA,IAAI,CAACH,gBAAgB,CAACC,cAAc,CAACU,EAAE,EAAEC,OAAO,EAAEC,UAAU,EAAEvH,UAAU,CAAC;EAC3E;;EAEA;AACF;EACE,IAAI6H,aAAaA,CAAA,EAAkC;IACjD,OAAO9I,eAAe,CAAC+I,MAAM;EAC/B;AACF","ignoreList":[]}
|
|
@@ -9,7 +9,7 @@ import Href from "../href/Href";
|
|
|
9
9
|
import LinkCollection from "../links/LinkCollection";
|
|
10
10
|
import { INITIAL_FILTER } from "../../constants/LayoutHints";
|
|
11
11
|
import Parameter from "../parameter/Parameter";
|
|
12
|
-
|
|
12
|
+
import { HTTP_METHODS } from "../../constants";
|
|
13
13
|
/**
|
|
14
14
|
* Defines a Link. For instance below example of a link to the tab 'books'
|
|
15
15
|
* <br/>
|
|
@@ -28,7 +28,9 @@ class LinkModel extends BaseModel {
|
|
|
28
28
|
_defineProperty(this, "_isCacheable", void 0);
|
|
29
29
|
_defineProperty(this, "_icon", void 0);
|
|
30
30
|
_defineProperty(this, "_targetModel", void 0);
|
|
31
|
+
_defineProperty(this, "_method", void 0);
|
|
31
32
|
this.createHref(modelOptions);
|
|
33
|
+
this._method = HTTP_METHODS.GET;
|
|
32
34
|
this._isCacheable = false;
|
|
33
35
|
}
|
|
34
36
|
|
|
@@ -109,6 +111,20 @@ class LinkModel extends BaseModel {
|
|
|
109
111
|
this._href = href;
|
|
110
112
|
}
|
|
111
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Indicate how this link must be called, GET by default
|
|
116
|
+
*/
|
|
117
|
+
get method() {
|
|
118
|
+
return this._method;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Set http method for this link
|
|
123
|
+
*/
|
|
124
|
+
set method(method) {
|
|
125
|
+
this._method = method;
|
|
126
|
+
}
|
|
127
|
+
|
|
112
128
|
/**
|
|
113
129
|
* Getting the label of the link
|
|
114
130
|
*/
|
|
@@ -6,9 +6,10 @@ import BaseModel from "../base/BaseModel";
|
|
|
6
6
|
import Href from "../href/Href";
|
|
7
7
|
import LinkCollection from "../links/LinkCollection";
|
|
8
8
|
import { INITIAL_FILTER } from "../../constants/LayoutHints";
|
|
9
|
+
import Parameter from "../parameter/Parameter";
|
|
10
|
+
import { HTTP_METHODS } from "../../constants";
|
|
9
11
|
|
|
10
12
|
import type { ModelOptions, ModularUIModel } from "../types";
|
|
11
|
-
import Parameter from "../parameter/Parameter";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Defines a Link. For instance below example of a link to the tab 'books'
|
|
@@ -23,6 +24,7 @@ class LinkModel extends BaseModel {
|
|
|
23
24
|
_isCacheable: boolean;
|
|
24
25
|
_icon: string;
|
|
25
26
|
_targetModel: ?Class<ModularUIModel>;
|
|
27
|
+
_method: $Keys<typeof HTTP_METHODS>;
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* Create a Link
|
|
@@ -36,6 +38,7 @@ class LinkModel extends BaseModel {
|
|
|
36
38
|
|
|
37
39
|
this.createHref(modelOptions);
|
|
38
40
|
|
|
41
|
+
this._method = HTTP_METHODS.GET;
|
|
39
42
|
this._isCacheable = false;
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -121,6 +124,20 @@ class LinkModel extends BaseModel {
|
|
|
121
124
|
this._href = href;
|
|
122
125
|
}
|
|
123
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Indicate how this link must be called, GET by default
|
|
129
|
+
*/
|
|
130
|
+
get method(): $Keys<typeof HTTP_METHODS> {
|
|
131
|
+
return this._method;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Set http method for this link
|
|
136
|
+
*/
|
|
137
|
+
set method(method: $Keys<typeof HTTP_METHODS>) {
|
|
138
|
+
this._method = method;
|
|
139
|
+
}
|
|
140
|
+
|
|
124
141
|
/**
|
|
125
142
|
* Getting the label of the link
|
|
126
143
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkModel.js","names":["has","ProcessStatusSettingsModel","BaseModel","Href","LinkCollection","INITIAL_FILTER","Parameter","LinkModel","constructor","data","contributions","modelOptions","_defineProperty","createHref","_isCacheable","create","name","href","label","resourcetype","handleInitialFilters","layouthint","_context","filters","_filterInstanceProperty","call","hint","_startsWithInstanceProperty","forEach","param","substr","length","p","fromString","value","push","_Object$keys","key","join","addParameter","group","getContribution","_href","links","components","isActive","link","_context2","icon","_icon","targetModel","_targetModel","isCacheable","filterName","hasProcessStatusSettings","processStatus","getData"],"sources":["../../../src/models/links/LinkModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ProcessStatusSettingsModel from \"../process/ProcessStatusSettingsModel\";\nimport BaseModel from \"../base/BaseModel\";\nimport Href from \"../href/Href\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport { INITIAL_FILTER } from \"../../constants/LayoutHints\";\n\nimport type { ModelOptions, ModularUIModel } from \"../types\";\nimport Parameter from \"../parameter/Parameter\";\n\n/**\n * Defines a Link. For instance below example of a link to the tab 'books'\n * <br/>\n * \"Books\": {\n * \"href\": \"/books\",\n * \"profile\": \"/profiles/tab\"\n * }\n */\nclass LinkModel extends BaseModel {\n _href: Href;\n _isCacheable: boolean;\n _icon: string;\n _targetModel: ?Class<ModularUIModel>;\n\n /**\n * Create a Link\n */\n constructor(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n this.createHref(modelOptions);\n\n this._isCacheable = false;\n }\n\n /**\n * Create a simple Link Model\n */\n static create(\n name: string,\n href: string | Href,\n label: string,\n modelOptions?: ModelOptions,\n ): LinkModel {\n const data = { name, href };\n const contributions = { label };\n return new LinkModel(data, contributions, modelOptions);\n }\n\n /**\n */\n createHref(modelOptions: ?ModelOptions) {\n const href = new Href(this.data.href, this.resourcetype, modelOptions);\n this.handleInitialFilters(href);\n\n this.href = href;\n }\n\n /**\n * Handle initial filter hints\n * @param href\n */\n handleInitialFilters(href: Href) {\n if (this.layouthint.has(INITIAL_FILTER)) {\n const filters: { [string]: Array<string> } = {};\n this.layouthint\n .filter((hint) => hint.startsWith(INITIAL_FILTER))\n .forEach((hint) => {\n const param = hint.substr(INITIAL_FILTER.length);\n const p = Parameter.fromString(param);\n\n if (p != null) {\n if (!filters[p.name]) {\n filters[p.name] = [];\n }\n\n if (p.value != null) {\n filters[p.name].push(p.value);\n }\n }\n });\n\n Object.keys(filters).forEach((key) => {\n const value = filters[key].join(\",\");\n href.addParameter(key, value);\n });\n }\n }\n\n /**\n * Getting link group\n */\n get group(): string {\n return this.getContribution(\"group\", this.data.group);\n }\n\n /**\n * Getting the key/name of this link\n */\n get key(): string {\n return this.data.name;\n }\n\n /**\n * Retrieve the href of the link\n */\n get href(): Href {\n return this._href;\n }\n\n /**\n * Set the href of the Link\n */\n set href(href: Href) {\n this._href = href;\n }\n\n /**\n * Getting the label of the link\n */\n get label(): string {\n return this.getContribution(\"label\", this.key);\n }\n\n /**\n * Getting the type of the link\n */\n get resourcetype(): string {\n return this.getContribution(\"resourcetype\", \"\");\n }\n\n /**\n */\n get links(): LinkCollection {\n if (this.data.components) {\n return new LinkCollection(\n { components: this.data.components },\n { components: this.contributions.components },\n );\n }\n\n return new LinkCollection();\n }\n\n /**\n * Check if the href startswith the URI of the given href\n */\n isActive(link: ?LinkModel): boolean {\n if (link) {\n return link.href.startsWith(this.href);\n }\n\n return false;\n }\n\n /**\n * Setter for icon of LinkModel\n */\n set icon(icon: string) {\n this._icon = icon;\n }\n\n /**\n * Retrieve icon of LinkModel\n */\n get icon(): string {\n return this._icon;\n }\n\n /**\n */\n get targetModel(): ?Class<ModularUIModel> {\n return this._targetModel;\n }\n\n /**\n */\n set targetModel(targetModel: Class<ModularUIModel>) {\n this._targetModel = targetModel;\n }\n\n /**\n */\n get isCacheable(): boolean {\n return this._isCacheable;\n }\n\n /**\n */\n set isCacheable(isCacheable: boolean) {\n this._isCacheable = isCacheable;\n }\n\n /**\n */\n get filterName(): string {\n return this.data.filter.name;\n }\n\n /**\n */\n get hasProcessStatusSettings(): boolean {\n return (\n has(this.data, \"processStatus\") &&\n has(this.contributions, \"processStatus\")\n );\n }\n\n /**\n */\n get processStatus(): ProcessStatusSettingsModel | null {\n if (this.hasProcessStatusSettings) {\n return new ProcessStatusSettingsModel(\n this.getData(\"processStatus\", {}),\n this.getContribution(\"processStatus\", {}),\n );\n }\n\n return null;\n }\n}\n\nexport default LinkModel;\n"],"mappings":";;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,0BAA0B,MAAM,uCAAuC;AAC9E,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,cAAc,MAAM,yBAAyB;AACpD,SAASC,cAAc,QAAQ,6BAA6B;AAG5D,OAAOC,SAAS,MAAM,wBAAwB;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAAS,SAASL,SAAS,CAAC;EAMhC;AACF;AACA;EACEM,WAAWA,C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AAI,EAAQO,IAAI;EAC9B;;EAEA;AACF;EACE,IAAIsC,wBAAwBA,CAAA,EAAY;IACtC,OACEtD,GAAG,CAAC,IAAI,CAACS,IAAI,EAAE,eAAe,CAAC,IAC/BT,GAAG,CAAC,IAAI,CAACU,aAAa,EAAE,eAAe,CAAC;EAE5C;;EAEA;AACF;EACE,IAAI6C,aAAaA,CAAA,EAAsC;IACrD,IAAI,IAAI,CAACD,wBAAwB,EAAE;MACjC,OAAO,IAAIrD,0BAA0B,CACnC,IAAI,CAACuD,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EACjC,IAAI,CAACf,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC,CAC1C,CAAC;IACH;IAEA,OAAO,IAAI;EACb;AACF;AAEA,eAAelC,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"LinkModel.js","names":["has","ProcessStatusSettingsModel","BaseModel","Href","LinkCollection","INITIAL_FILTER","Parameter","HTTP_METHODS","LinkModel","constructor","data","contributions","modelOptions","_defineProperty","createHref","_method","GET","_isCacheable","create","name","href","label","resourcetype","handleInitialFilters","layouthint","_context","filters","_filterInstanceProperty","call","hint","_startsWithInstanceProperty","forEach","param","substr","length","p","fromString","value","push","_Object$keys","key","join","addParameter","group","getContribution","_href","method","links","components","isActive","link","_context2","icon","_icon","targetModel","_targetModel","isCacheable","filterName","hasProcessStatusSettings","processStatus","getData"],"sources":["../../../src/models/links/LinkModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ProcessStatusSettingsModel from \"../process/ProcessStatusSettingsModel\";\nimport BaseModel from \"../base/BaseModel\";\nimport Href from \"../href/Href\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport { INITIAL_FILTER } from \"../../constants/LayoutHints\";\nimport Parameter from \"../parameter/Parameter\";\nimport { HTTP_METHODS } from \"../../constants\";\n\nimport type { ModelOptions, ModularUIModel } from \"../types\";\n\n/**\n * Defines a Link. For instance below example of a link to the tab 'books'\n * <br/>\n * \"Books\": {\n * \"href\": \"/books\",\n * \"profile\": \"/profiles/tab\"\n * }\n */\nclass LinkModel extends BaseModel {\n _href: Href;\n _isCacheable: boolean;\n _icon: string;\n _targetModel: ?Class<ModularUIModel>;\n _method: $Keys<typeof HTTP_METHODS>;\n\n /**\n * Create a Link\n */\n constructor(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n this.createHref(modelOptions);\n\n this._method = HTTP_METHODS.GET;\n this._isCacheable = false;\n }\n\n /**\n * Create a simple Link Model\n */\n static create(\n name: string,\n href: string | Href,\n label: string,\n modelOptions?: ModelOptions,\n ): LinkModel {\n const data = { name, href };\n const contributions = { label };\n return new LinkModel(data, contributions, modelOptions);\n }\n\n /**\n */\n createHref(modelOptions: ?ModelOptions) {\n const href = new Href(this.data.href, this.resourcetype, modelOptions);\n this.handleInitialFilters(href);\n\n this.href = href;\n }\n\n /**\n * Handle initial filter hints\n * @param href\n */\n handleInitialFilters(href: Href) {\n if (this.layouthint.has(INITIAL_FILTER)) {\n const filters: { [string]: Array<string> } = {};\n this.layouthint\n .filter((hint) => hint.startsWith(INITIAL_FILTER))\n .forEach((hint) => {\n const param = hint.substr(INITIAL_FILTER.length);\n const p = Parameter.fromString(param);\n\n if (p != null) {\n if (!filters[p.name]) {\n filters[p.name] = [];\n }\n\n if (p.value != null) {\n filters[p.name].push(p.value);\n }\n }\n });\n\n Object.keys(filters).forEach((key) => {\n const value = filters[key].join(\",\");\n href.addParameter(key, value);\n });\n }\n }\n\n /**\n * Getting link group\n */\n get group(): string {\n return this.getContribution(\"group\", this.data.group);\n }\n\n /**\n * Getting the key/name of this link\n */\n get key(): string {\n return this.data.name;\n }\n\n /**\n * Retrieve the href of the link\n */\n get href(): Href {\n return this._href;\n }\n\n /**\n * Set the href of the Link\n */\n set href(href: Href) {\n this._href = href;\n }\n\n /**\n * Indicate how this link must be called, GET by default\n */\n get method(): $Keys<typeof HTTP_METHODS> {\n return this._method;\n }\n\n /**\n * Set http method for this link\n */\n set method(method: $Keys<typeof HTTP_METHODS>) {\n this._method = method;\n }\n\n /**\n * Getting the label of the link\n */\n get label(): string {\n return this.getContribution(\"label\", this.key);\n }\n\n /**\n * Getting the type of the link\n */\n get resourcetype(): string {\n return this.getContribution(\"resourcetype\", \"\");\n }\n\n /**\n */\n get links(): LinkCollection {\n if (this.data.components) {\n return new LinkCollection(\n { components: this.data.components },\n { components: this.contributions.components },\n );\n }\n\n return new LinkCollection();\n }\n\n /**\n * Check if the href startswith the URI of the given href\n */\n isActive(link: ?LinkModel): boolean {\n if (link) {\n return link.href.startsWith(this.href);\n }\n\n return false;\n }\n\n /**\n * Setter for icon of LinkModel\n */\n set icon(icon: string) {\n this._icon = icon;\n }\n\n /**\n * Retrieve icon of LinkModel\n */\n get icon(): string {\n return this._icon;\n }\n\n /**\n */\n get targetModel(): ?Class<ModularUIModel> {\n return this._targetModel;\n }\n\n /**\n */\n set targetModel(targetModel: Class<ModularUIModel>) {\n this._targetModel = targetModel;\n }\n\n /**\n */\n get isCacheable(): boolean {\n return this._isCacheable;\n }\n\n /**\n */\n set isCacheable(isCacheable: boolean) {\n this._isCacheable = isCacheable;\n }\n\n /**\n */\n get filterName(): string {\n return this.data.filter.name;\n }\n\n /**\n */\n get hasProcessStatusSettings(): boolean {\n return (\n has(this.data, \"processStatus\") &&\n has(this.contributions, \"processStatus\")\n );\n }\n\n /**\n */\n get processStatus(): ProcessStatusSettingsModel | null {\n if (this.hasProcessStatusSettings) {\n return new ProcessStatusSettingsModel(\n this.getData(\"processStatus\", {}),\n this.getContribution(\"processStatus\", {}),\n );\n }\n\n return null;\n }\n}\n\nexport default LinkModel;\n"],"mappings":";;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,0BAA0B,MAAM,uCAAuC;AAC9E,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,cAAc,M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AIA,CAAA,EAAW;IACjB,OAAO,IAAI,CAACC,KAAK;EACnB;;EAEA;AACF;EACE,IAAIC,WAAWA,CAAA,EAA2B;IACxC,OAAO,IAAI,CAACC,YAAY;EAC1B;;EAEA;AACF;EACE,IAAID,WAAWA,CAACA,WAAkC,EAAE;IAClD,IAAI,CAACC,YAAY,GAAGD,WAAW;EACjC;;EAEA;AACF;EACE,IAAIE,WAAWA,CAAA,EAAY;IACzB,OAAO,IAAI,CAACvC,YAAY;EAC1B;;EAEA;AACF;EACE,IAAIuC,WAAWA,CAACA,WAAoB,EAAE;IACpC,IAAI,CAACvC,YAAY,GAAGuC,WAAW;EACjC;;EAEA;AACF;EACE,IAAIC,UAAUA,CAAA,EAAW;IACvB,OAAO9B,uBAAA,KAAI,CAACjB,IAAI,EAAQS,IAAI;EAC9B;;EAEA;AACF;EACE,IAAIuC,wBAAwBA,CAAA,EAAY;IACtC,OACE1D,GAAG,CAAC,IAAI,CAACU,IAAI,EAAE,eAAe,CAAC,IAC/BV,GAAG,CAAC,IAAI,CAACW,aAAa,EAAE,eAAe,CAAC;EAE5C;;EAEA;AACF;EACE,IAAIgD,aAAaA,CAAA,EAAsC;IACrD,IAAI,IAAI,CAACD,wBAAwB,EAAE;MACjC,OAAO,IAAIzD,0BAA0B,CACnC,IAAI,CAAC2D,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EACjC,IAAI,CAAChB,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC,CAC1C,CAAC;IACH;IAEA,OAAO,IAAI;EACb;AACF;AAEA,eAAepC,SAAS","ignoreList":[]}
|
package/lib/hooks/index.js
CHANGED
|
@@ -59,6 +59,17 @@ _Object$keys(_useList).forEach(function (key) {
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
|
+
var _useLookup = require("./useLookup");
|
|
63
|
+
_Object$keys(_useLookup).forEach(function (key) {
|
|
64
|
+
if (key === "default" || key === "__esModule") return;
|
|
65
|
+
if (key in exports && exports[key] === _useLookup[key]) return;
|
|
66
|
+
Object.defineProperty(exports, key, {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _useLookup[key];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
62
73
|
var _useModal = require("./useModal");
|
|
63
74
|
_Object$keys(_useModal).forEach(function (key) {
|
|
64
75
|
if (key === "default" || key === "__esModule") return;
|
package/lib/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_useAuthentication","require","_Object$keys","forEach","key","exports","Object","defineProperty","enumerable","get","_useContent","_useForm","_useI18n","_useList","_useModal","_useModelCatalog","_useModels","_useModularUI","_useModularUIBasic","_useModularUIModel","_useModularUIRequest","_useNotification","_usePanel","_usePreference","_useProgressIndicator","_useRouter","_useAllFormsOnModel"],"sources":["../../src/hooks/index.js"],"sourcesContent":["// @flow\nexport * from \"./useAuthentication\";\nexport * from \"./useContent\";\nexport * from \"./useForm\";\nexport * from \"./useI18n\";\nexport * from \"./useList\";\nexport * from \"./useModal\";\nexport * from \"./useModelCatalog\";\nexport * from \"./useModels\";\nexport * from \"./useModularUI\";\nexport * from \"./useModularUIBasic\";\nexport * from \"./useModularUIModel\";\nexport * from \"./useModularUIRequest\";\nexport * from \"./useNotification\";\nexport * from \"./usePanel\";\nexport * from \"./usePreference\";\nexport * from \"./useProgressIndicator\";\nexport * from \"./useRouter\";\nexport * from \"./useAllFormsOnModel\";\n"],"mappings":";;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AAAAC,YAAA,CAAAF,kBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAJ,kBAAA,CAAAI,GAAA;EAAAE,MAAA,CAAAC,cAAA,CAAAF,OAAA,EAAAD,GAAA;IAAAI,UAAA;IAAAC,G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EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAS,QAAA,CAAAT,GAAA;EAAAE,MAAA,CAAAC,cAAA,CAAAF,OAAA,EAAAD,GAAA;IAAAI,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,QAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AACA,IAAAU,
|
|
1
|
+
{"version":3,"file":"index.js","names":["_useAuthentication","require","_Object$keys","forEach","key","exports","Object","defineProperty","enumerable","get","_useContent","_useForm","_useI18n","_useList","_useLookup","_useModal","_useModelCatalog","_useModels","_useModularUI","_useModularUIBasic","_useModularUIModel","_useModularUIRequest","_useNotification","_usePanel","_usePreference","_useProgressIndicator","_useRouter","_useAllFormsOnModel"],"sources":["../../src/hooks/index.js"],"sourcesContent":["// @flow\nexport * from \"./useAuthentication\";\nexport * from \"./useContent\";\nexport * from \"./useForm\";\nexport * from \"./useI18n\";\nexport * from \"./useList\";\nexport * from \"./useLookup\";\nexport * from \"./useModal\";\nexport * from \"./useModelCatalog\";\nexport * from \"./useModels\";\nexport * from \"./useModularUI\";\nexport * from \"./useModularUIBasic\";\nexport * from \"./useModularUIModel\";\nexport * from \"./useModularUIRequest\";\nexport * from \"./useNotification\";\nexport * from \"./usePanel\";\nexport * from \"./usePreference\";\nexport * from \"./useProgressIndicator\";\nexport * from \"./useRouter\";\nexport * from \"./useAllFormsOnModel\";\n"],"mappings":";;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AAAAC,YAAA,CAAAF,kBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAJ,kBAAA,CAAAI,GAAA;EAAAE,MAAA,CAAAC,cAAA,CAAAF,OAAA,EAAAD,GAAA;IAAAI,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,kBAAA,CAAAI,G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C,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAuB,mBAAA,CAAAvB,GAAA;EAAAE,MAAA,CAAAC,cAAA,CAAAF,OAAA,EAAAD,GAAA;IAAAI,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAkB,mBAAA,CAAAvB,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/lib/hooks/useForm.js
CHANGED
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.useFormNavigation = exports.useForm = exports.useAttributeUpdate = exports.useAttributeSet = void 0;
|
|
8
8
|
var _reactRedux = require("react-redux");
|
|
9
|
-
var _Href = _interopRequireDefault(require("../models/href/Href"));
|
|
10
9
|
var _constants = require("../constants");
|
|
11
|
-
var
|
|
12
|
-
var _useModularUI = require("./useModularUI");
|
|
10
|
+
var _ModularUIActions = require("../redux/_modularui/ModularUIActions");
|
|
13
11
|
var _actions = require("../redux/actions");
|
|
12
|
+
var _Href = _interopRequireDefault(require("../models/href/Href"));
|
|
14
13
|
var _FormModel = _interopRequireDefault(require("../models/form/FormModel"));
|
|
14
|
+
var _useModularUI = require("./useModularUI");
|
|
15
15
|
/**
|
|
16
16
|
* Load a form by href
|
|
17
17
|
*/
|
|
@@ -41,7 +41,7 @@ const useFormNavigation = () => {
|
|
|
41
41
|
const dispatch = (0, _reactRedux.useDispatch)();
|
|
42
42
|
const previous = form => dispatch((0, _actions.previousObject)(form));
|
|
43
43
|
const cancel = form => dispatch((0, _actions.cancelForm)(form));
|
|
44
|
-
const submit = form => dispatch((0,
|
|
44
|
+
const submit = form => dispatch((0, _ModularUIActions.loadModularUI)(form.connectKey, form.selfhref, {
|
|
45
45
|
method: _constants.HTTP_METHODS.POST,
|
|
46
46
|
data: form.formdata,
|
|
47
47
|
updateHandler: newModel => {
|
|
@@ -54,7 +54,7 @@ const useFormNavigation = () => {
|
|
|
54
54
|
},
|
|
55
55
|
targetModel: _FormModel.default
|
|
56
56
|
}));
|
|
57
|
-
const remove = form => dispatch((0,
|
|
57
|
+
const remove = form => dispatch((0, _ModularUIActions.removeModelByKey)(form.connectKey));
|
|
58
58
|
const showFormNotificationAction = form => dispatch((0, _actions.showFormNotification)(form));
|
|
59
59
|
return {
|
|
60
60
|
previous,
|
package/lib/hooks/useForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.js","names":["_reactRedux","require","
|
|
1
|
+
{"version":3,"file":"useForm.js","names":["_reactRedux","require","_constants","_ModularUIActions","_actions","_Href","_interopRequireDefault","_FormModel","_useModularUI","useForm","href","data","formHref","Href","getSetting","addParameter","form","useModularUI","method","HTTP_METHODS","POST","targetModel","FormModel","removeOnUnmount","origin","contextPath","model","exports","useFormNavigation","dispatch","useDispatch","previous","previousObject","cancel","cancelForm","submit","loadModularUI","connectKey","selfhref","formdata","updateHandler","newModel","clonedModel","clone","update","remove","removeModelByKey","showFormNotificationAction","showFormNotification","useAttributeUpdate","object","attribute","value","options","updateFormAttribute","useAttributeSet","save","addRepeatableAttributeSet","cancelRepeatableAttributeSet","removeRepeatableAttributeSet"],"sources":["../../src/hooks/useForm.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport type {\n RemoveModelByKeyAction,\n UpdateFormAction,\n} from \"../redux/_modularui\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport Href from \"../models/href/Href\";\nimport FormModel from \"../models/form/FormModel\";\n\nimport { useModularUI } from \"./useModularUI\";\n\nimport type { AttributeType, FormObjectModel, ModularUIModel } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateFormAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateFormAction,\n cancel: (object: FormObjectModel) => UpdateFormAction,\n remove: (object: FormObjectModel) => UpdateFormAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href, data?: Object): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n data,\n origin: formHref.origin,\n contextPath: formHref.contextPath,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n const clonedModel: FormModel = form.clone();\n clonedModel.update(newModel);\n return clonedModel;\n }\n return newModel;\n },\n targetModel: FormModel,\n }),\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Hook that returns a function to update attributes of a form object.\n * <br >\n * The returned function accepts the following options:\n *\n * - autosubmit: Automatically submit the form after a change\n * - autosav: Automatically save the form (in the background) after a change\n * - autoupdate: Automatically update the current form object after a change\n * - forceUpdate: Force the update even if conditions are not met.\n * - validate: Activate/deactivate the form object validation by an update.\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel,\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"mappings":";;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAMA,IAAAE,iBAAA,GAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AAUA,IAAAI,KAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,UAAA,GAAAD,sBAAA,CAAAL,OAAA;AAEA,IAAAO,aAAA,GAAAP,OAAA;AAyBA;AACA;AACA;AACO,MAAMQ,OAAO,GAAGA,CAACC,IAAmB,EAAEC,IAAa,KAAiB;EACzE,MAAMC,QAAQ,GAAG,IAAIC,aAAI,CAACH,IAAI,CAAC;EAE/B,IAAI,CAAC,IAAAI,qBAAU,EAAC,oBAAoB,CAAC,EAAE;IACrCF,QAAQ,CAACG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;EAC1C;EAEA,MAAMC,IAAI,GAAG,IAAAC,0BAAY,EAAC,MAAM,EAAEL,QAAQ,EAAE;IAC1CM,MAAM,EAAEC,uBAAY,CAACC,IAAI;IACzBC,WAAW,EAAEC,kBAAS;IACtBC,eAAe,EAAE,IAAI;IACrBZ,IAAI;IACJa,MAAM,EAAEZ,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e,QAAQ;IACRE,MAAM;IACNE,MAAM;IACNU,MAAM;IACNG,oBAAoB,EAAED;EACxB,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVApB,OAAA,CAAAC,iBAAA,GAAAA,iBAAA;AAWO,MAAMqB,kBAAkB,GAAGA,CAChCjC,IAAe,EACfkC,MAAuB,KACC;EACxB,MAAMrB,QAAQ,GAAG,IAAAC,uBAAW,EAAC,CAAC;EAE9B,OAAO,CACLqB,SAAwB,EACxBC,KAAa,EACbC,OAA0B,KACvBxB,QAAQ,CAAC,IAAAyB,4BAAmB,EAACtC,IAAI,EAAEkC,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,CAAC,CAAC;AAC7E,CAAC;;AAED;AACA;AACA;AAFA1B,OAAA,CAAAsB,kBAAA,GAAAA,kBAAA;AAGO,MAAMM,eAAe,GAAIvC,IAAe,IAAuB;EACpE,MAAMa,QAAQ,GAAG,IAAAC,uBAAW,EAAC,CAAC;EAE9B,OAAO;IACL0B,IAAI,EAAEA,CAAA,KAAM3B,QAAQ,CAAC,IAAA4B,kCAAyB,EAACzC,IAAI,CAAC,CAAC;IACrDiB,MAAM,EAAGiB,MAAuB,IAC9BrB,QAAQ,CAAC,IAAA6B,qCAA4B,EAAC1C,IAAI,EAAEkC,MAAM,CAAC,CAAC;IACtDL,MAAM,EAAGK,MAAuB,IAC9BrB,QAAQ,CAAC,IAAA8B,qCAA4B,EAAC3C,IAAI,EAAEkC,MAAM,CAAC;EACvD,CAAC;AACH,CAAC;AAACvB,OAAA,CAAA4B,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useLookup = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _constants = require("../constants");
|
|
10
|
+
var _Href = _interopRequireDefault(require("../models/href/Href"));
|
|
11
|
+
var _LinkModel = _interopRequireDefault(require("../models/links/LinkModel"));
|
|
12
|
+
var _LookupOptionsModel = _interopRequireDefault(require("../models/lookup/LookupOptionsModel"));
|
|
13
|
+
var _useModularUIRequest = require("./useModularUIRequest");
|
|
14
|
+
var _useProgressIndicator = require("./useProgressIndicator");
|
|
15
|
+
/**
|
|
16
|
+
* Lookup options call
|
|
17
|
+
*/
|
|
18
|
+
const useLookup = (lookupLink, filterInput = "", minLength = 2, debounceMs = 300) => {
|
|
19
|
+
const {
|
|
20
|
+
start,
|
|
21
|
+
finish
|
|
22
|
+
} = (0, _useProgressIndicator.useProgressIndicator)();
|
|
23
|
+
const modularuiRequest = (0, _useModularUIRequest.useModularUIRequest)();
|
|
24
|
+
const [lookupOptions, setLookupOptions] = (0, _react.useState)(null);
|
|
25
|
+
const [lookupLoading, setLookupLoading] = (0, _react.useState)(false);
|
|
26
|
+
const {
|
|
27
|
+
href,
|
|
28
|
+
filterName,
|
|
29
|
+
method
|
|
30
|
+
} = lookupLink;
|
|
31
|
+
(0, _react.useEffect)(() => {
|
|
32
|
+
if (filterInput.length < minLength) {
|
|
33
|
+
setLookupOptions(null);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const timeoutId = setTimeout(async () => {
|
|
37
|
+
setLookupLoading(true);
|
|
38
|
+
start();
|
|
39
|
+
const lookupHref = new _Href.default(href);
|
|
40
|
+
const requestOptions = {
|
|
41
|
+
method,
|
|
42
|
+
data: undefined
|
|
43
|
+
};
|
|
44
|
+
if (method === _constants.HTTP_METHODS.POST) {
|
|
45
|
+
requestOptions.data = {
|
|
46
|
+
[filterName]: filterInput
|
|
47
|
+
};
|
|
48
|
+
} else {
|
|
49
|
+
lookupHref.addParameter(filterName, filterInput);
|
|
50
|
+
}
|
|
51
|
+
modularuiRequest(lookupHref, requestOptions).fetch().then(lookupResponse => {
|
|
52
|
+
if (lookupResponse instanceof _LookupOptionsModel.default) {
|
|
53
|
+
setLookupOptions(lookupResponse);
|
|
54
|
+
}
|
|
55
|
+
}).finally(() => {
|
|
56
|
+
finish();
|
|
57
|
+
setLookupLoading(false);
|
|
58
|
+
});
|
|
59
|
+
}, debounceMs);
|
|
60
|
+
return () => {
|
|
61
|
+
clearTimeout(timeoutId);
|
|
62
|
+
};
|
|
63
|
+
}, [debounceMs, filterInput, filterName, finish, href, method, minLength, modularuiRequest, start]);
|
|
64
|
+
return {
|
|
65
|
+
lookupOptions,
|
|
66
|
+
lookupLoading
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
exports.useLookup = useLookup;
|
|
70
|
+
//# sourceMappingURL=useLookup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLookup.js","names":["_react","require","_constants","_Href","_interopRequireDefault","_LinkModel","_LookupOptionsModel","_useModularUIRequest","_useProgressIndicator","useLookup","lookupLink","filterInput","minLength","debounceMs","start","finish","useProgressIndicator","modularuiRequest","useModularUIRequest","lookupOptions","setLookupOptions","useState","lookupLoading","setLookupLoading","href","filterName","method","useEffect","length","timeoutId","setTimeout","lookupHref","Href","requestOptions","data","undefined","HTTP_METHODS","POST","addParameter","fetch","then","lookupResponse","LookupOptionsModel","finally","clearTimeout","exports"],"sources":["../../src/hooks/useLookup.js"],"sourcesContent":["// @flow\nimport { useEffect, useState } from \"react\";\n\nimport { HTTP_METHODS } from \"../constants\";\n\nimport Href from \"../models/href/Href\";\nimport LinkModel from \"../models/links/LinkModel\";\nimport LookupOptionsModel from \"../models/lookup/LookupOptionsModel\";\n\nimport { useModularUIRequest } from \"./useModularUIRequest\";\nimport { useProgressIndicator } from \"./useProgressIndicator\";\n\ntype UseLookupHook = {\n lookupOptions: LookupOptionsModel | null,\n lookupLoading: boolean,\n};\n\n/**\n * Lookup options call\n */\nexport const useLookup = (\n lookupLink: LinkModel,\n filterInput: string = \"\",\n minLength: number = 2,\n debounceMs: number = 300,\n): UseLookupHook => {\n const { start, finish } = useProgressIndicator();\n const modularuiRequest = useModularUIRequest();\n\n const [lookupOptions, setLookupOptions] = useState(null);\n const [lookupLoading, setLookupLoading] = useState(false);\n\n const { href, filterName, method } = lookupLink;\n\n useEffect(() => {\n if (filterInput.length < minLength) {\n setLookupOptions(null);\n return;\n }\n\n const timeoutId = setTimeout(async () => {\n setLookupLoading(true);\n start();\n\n const lookupHref = new Href(href);\n const requestOptions = { method, data: undefined };\n if (method === HTTP_METHODS.POST) {\n requestOptions.data = { [filterName]: filterInput };\n } else {\n lookupHref.addParameter(filterName, filterInput);\n }\n\n modularuiRequest(lookupHref, requestOptions)\n .fetch()\n .then((lookupResponse) => {\n if (lookupResponse instanceof LookupOptionsModel) {\n setLookupOptions(lookupResponse);\n }\n })\n .finally(() => {\n finish();\n setLookupLoading(false);\n });\n }, debounceMs);\n\n return () => {\n clearTimeout(timeoutId);\n };\n }, [\n debounceMs,\n filterInput,\n filterName,\n finish,\n href,\n method,\n minLength,\n modularuiRequest,\n start,\n ]);\n\n return { lookupOptions, lookupLoading };\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,mBAAA,GAAAF,sBAAA,CAAAH,OAAA;AAEA,IAAAM,oBAAA,GAAAN,OAAA;AACA,IAAAO,qBAAA,GAAAP,OAAA;AAOA;AACA;AACA;AACO,MAAMQ,SAAS,GAAGA,CACvBC,UAAqB,EACrBC,WAAmB,GAAG,EAAE,EACxBC,SAAiB,GAAG,CAAC,EACrBC,UAAkB,GAAG,GAAG,KACN;EAClB,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAG,IAAAC,0CAAoB,EAAC,CAA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AY,CAACf,SAAS,CAAC;IACzB,CAAC;EACH,CAAC,EAAE,CACDhB,UAAU,EACVF,WAAW,EACXc,UAAU,EACVV,MAAM,EACNS,IAAI,EACJE,MAAM,EACNd,SAAS,EACTK,gBAAgB,EAChBH,KAAK,CACN,CAAC;EAEF,OAAO;IAAEK,aAAa;IAAEG;EAAc,CAAC;AACzC,CAAC;AAACuB,OAAA,CAAApC,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -3,21 +3,37 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useProgressIndicator = void 0;
|
|
6
|
+
exports.useProgressIndicatorState = exports.useProgressIndicator = void 0;
|
|
7
7
|
var _reactRedux = require("react-redux");
|
|
8
8
|
var _ProgressIndicator = require("../redux/actions/ProgressIndicator");
|
|
9
|
+
var _react = require("react");
|
|
9
10
|
/**
|
|
10
11
|
*/
|
|
11
12
|
const useProgressIndicator = () => {
|
|
12
13
|
const dispatch = (0, _reactRedux.useDispatch)();
|
|
13
|
-
const
|
|
14
|
+
const start = (0, _react.useCallback)(() => {
|
|
15
|
+
dispatch((0, _ProgressIndicator.startProgress)());
|
|
16
|
+
}, [dispatch]);
|
|
17
|
+
const finish = (0, _react.useCallback)(() => {
|
|
18
|
+
dispatch((0, _ProgressIndicator.finishProgress)());
|
|
19
|
+
}, [dispatch]);
|
|
20
|
+
const reset = (0, _react.useCallback)(() => {
|
|
21
|
+
dispatch((0, _ProgressIndicator.resetProgress)());
|
|
22
|
+
}, [dispatch]);
|
|
23
|
+
const update = (0, _react.useCallback)(percentComplete => {
|
|
24
|
+
dispatch((0, _ProgressIndicator.updateProgress)(percentComplete));
|
|
25
|
+
}, [dispatch]);
|
|
14
26
|
return {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
update: percentComplete => dispatch((0, _ProgressIndicator.updateProgress)(percentComplete))
|
|
27
|
+
start,
|
|
28
|
+
finish,
|
|
29
|
+
reset,
|
|
30
|
+
update
|
|
20
31
|
};
|
|
21
32
|
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
*/
|
|
22
36
|
exports.useProgressIndicator = useProgressIndicator;
|
|
37
|
+
const useProgressIndicatorState = () => (0, _reactRedux.useSelector)(state => state.progressindicator);
|
|
38
|
+
exports.useProgressIndicatorState = useProgressIndicatorState;
|
|
23
39
|
//# sourceMappingURL=useProgressIndicator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProgressIndicator.js","names":["_reactRedux","require","_ProgressIndicator","useProgressIndicator","dispatch","useDispatch","
|
|
1
|
+
{"version":3,"file":"useProgressIndicator.js","names":["_reactRedux","require","_ProgressIndicator","_react","useProgressIndicator","dispatch","useDispatch","start","useCallback","startProgress","finish","finishProgress","reset","resetProgress","update","percentComplete","updateProgress","exports","useProgressIndicatorState","useSelector","state","progressindicator"],"sources":["../../src/hooks/useProgressIndicator.js"],"sourcesContent":["// @flow\nimport { useDispatch, useSelector } from \"react-redux\";\nimport {\n startProgress,\n finishProgress,\n resetProgress,\n updateProgress,\n} from \"../redux/actions/ProgressIndicator\";\nimport type { ProgressIndicatorState } from \"../redux/types\";\nimport { useCallback } from \"react\";\n\ntype ProgressIndicatorHook = {\n start: () => void,\n finish: () => void,\n reset: () => void,\n update: (percentComplete: number) => void,\n};\n\ntype ProgressIndicatorStateHook = {\n ...ProgressIndicatorState,\n};\n\n/**\n */\nexport const useProgressIndicator = (): ProgressIndicatorHook => {\n const dispatch = useDispatch();\n\n const start = useCallback(() => {\n dispatch(startProgress());\n }, [dispatch]);\n const finish = useCallback(() => {\n dispatch(finishProgress());\n }, [dispatch]);\n const reset = useCallback(() => {\n dispatch(resetProgress());\n }, [dispatch]);\n const update = useCallback(\n (percentComplete: number) => {\n dispatch(updateProgress(percentComplete));\n },\n [dispatch],\n );\n\n return { start, finish, reset, update };\n};\n\n/**\n */\nexport const useProgressIndicatorState = (): ProgressIndicatorStateHook =>\n useSelector((state) => state.progressindicator);\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAOA,IAAAE,MAAA,GAAAF,OAAA;AAaA;AACA;AACO,MAAMG,oBAAoB,GAAGA,CAAA,KAA6B;EAC/D,MAAMC,QAAQ,GAAG,IAAAC,uBAAW,EAAC,CAAC;EAE9B,MAAMC,KAAK,GAAG,IAAAC,kBAAW,EAAC,MAAM;IAC9BH,QAAQ,CAAC,IAAAI,gCAAa,EAAC,CAAC,CAAC;EAC3B,CAAC,EAAE,CAACJ,QAAQ,CAAC,CAAC;EACd,MAAMK,MAAM,GAAG,IAAAF,kBAAW,EAAC,MAAM;IAC/BH,QAAQ,CAAC,IAAAM,iCAAc,EAAC,CAAC,CAAC;EAC5B,CAAC,EAAE,CAACN,QAAQ,CAAC,CAAC;EACd,MAAMO,KAAK,GAAG,IAAAJ,kBAAW,EAAC,MAAM;IAC9BH,QAAQ,CAAC,IAAAQ,gCAAa,EAAC,CAAC,CAAC;EAC3B,CAAC,EAAE,CAACR,QAAQ,CAAC,CAAC;EACd,MAAMS,MAAM,GAAG,IAAAN,kBAAW,EACvBO,eAAuB,IAAK;IAC3BV,QAAQ,CAAC,IAAAW,iCAAc,EAACD,eAAe,CAAC,CAAC;EAC3C,CAAC,EACD,CAACV,QAAQ,CACX,CAAC;EAED,OAAO;IAAEE,KAAK;IAAEG,MAAM;IAAEE,KAAK;IAAEE;EAAO,CAAC;AACzC,CAAC;;AAED;AACA;AADAG,OAAA,CAAAb,oBAAA,GAAAA,oBAAA;AAEO,MAAMc,yBAAyB,GAAGA,CAAA,KACvC,IAAAC,uBAAW,EAAEC,KAAK,IAAKA,KAAK,CAACC,iBAAiB,CAAC;AAACJ,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeSetModel.js","names":["_objects","require","_BaseModel","_interopRequireDefault","_AttributeCollection","AttributeSetModel","BaseModel","constructor","key","data","contributions","modelOptions","_context","_defineProperty2","default","attributeContributions","attributes","_filter","call","contribution","contributionKey","_keys","has","_attributeCollection","AttributeCollection","isReadonly","_key","label","attributeCollection","collection","createChildAttributeSetModel","dataObject","index","dynamicschema","objects","getChildAttributeSets","childAttributeSets","Array","isArray","i","_entries","_context2","push","exports"],"sources":["../../../src/models/attributes/AttributeSetModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport AttributeCollection from \"./AttributeCollection\";\n\nimport type { ModelOptions } from \"../types\";\n\n/**\n */\nexport default class AttributeSetModel extends BaseModel {\n _key: string;\n _attributeCollection: AttributeCollection;\n\n /**\n */\n constructor(\n key: string = \"\",\n data: Object = {},\n contributions: Object = {},\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n const attributeContributions = this.contributions.attributes\n ? this.contributions.attributes.filter((contribution) => {\n const [contributionKey] = Object.keys(contribution);\n return has(this.data, contributionKey);\n })\n : [];\n\n this._attributeCollection = new AttributeCollection(\n this.data,\n attributeContributions,\n { ...modelOptions, isReadonly: true },\n );\n\n this._key = key;\n }\n\n /**\n */\n get key(): string {\n return this._key;\n }\n\n /**\n */\n set key(key: string) {\n this._key = key;\n }\n\n /**\n */\n get label(): ?string {\n return this.contributions.label;\n }\n\n /**\n * Retrieve attribute collection\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n * Set the attributes with a new AttributeCollection\n */\n set attributeCollection(collection: AttributeCollection) {\n this._attributeCollection = collection;\n }\n\n /**\n */\n createChildAttributeSetModel(\n key: string,\n dataObject: Object,\n index?: number,\n ): AttributeSetModel {\n return new AttributeSetModel(\n index ? `${key}-${index + 1}` : key,\n {\n ...dataObject,\n dynamicschema: this.data.dynamicschema,\n },\n this.contributions.objects[key],\n this.modelOptions,\n );\n }\n\n /**\n * Retrieve child
|
|
1
|
+
{"version":3,"file":"AttributeSetModel.js","names":["_objects","require","_BaseModel","_interopRequireDefault","_AttributeCollection","AttributeSetModel","BaseModel","constructor","key","data","contributions","modelOptions","_context","_defineProperty2","default","attributeContributions","attributes","_filter","call","contribution","contributionKey","_keys","has","_attributeCollection","AttributeCollection","isReadonly","_key","label","attributeCollection","collection","createChildAttributeSetModel","dataObject","index","dynamicschema","objects","getChildAttributeSets","childAttributeSets","Array","isArray","i","_entries","_context2","push","exports"],"sources":["../../../src/models/attributes/AttributeSetModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport AttributeCollection from \"./AttributeCollection\";\n\nimport type { ModelOptions } from \"../types\";\n\n/**\n */\nexport default class AttributeSetModel extends BaseModel {\n _key: string;\n _attributeCollection: AttributeCollection;\n\n /**\n */\n constructor(\n key: string = \"\",\n data: Object = {},\n contributions: Object = {},\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n const attributeContributions = this.contributions.attributes\n ? this.contributions.attributes.filter((contribution) => {\n const [contributionKey] = Object.keys(contribution);\n return has(this.data, contributionKey);\n })\n : [];\n\n this._attributeCollection = new AttributeCollection(\n this.data,\n attributeContributions,\n { ...modelOptions, isReadonly: true },\n );\n\n this._key = key;\n }\n\n /**\n */\n get key(): string {\n return this._key;\n }\n\n /**\n */\n set key(key: string) {\n this._key = key;\n }\n\n /**\n */\n get label(): ?string {\n return this.contributions.label;\n }\n\n /**\n * Retrieve attribute collection\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n * Set the attributes with a new AttributeCollection\n */\n set attributeCollection(collection: AttributeCollection) {\n this._attributeCollection = collection;\n }\n\n /**\n */\n createChildAttributeSetModel(\n key: string,\n dataObject: Object,\n index?: number,\n ): AttributeSetModel {\n return new AttributeSetModel(\n index ? `${key}-${index + 1}` : key,\n {\n ...dataObject,\n dynamicschema: this.data.dynamicschema,\n },\n this.contributions.objects[key],\n this.modelOptions,\n );\n }\n\n /**\n * Retrieve child AttributeSetModels\n */\n getChildAttributeSets(): Array<AttributeSetModel> {\n if (!this.contributions.objects) {\n return [];\n }\n\n const childAttributeSets = [];\n for (const key of Object.keys(this.contributions.objects)) {\n if (key in this.data) {\n if (Array.isArray(this.data[key])) {\n for (const [i, dataObject] of this.data[key].entries()) {\n childAttributeSets.push(\n this.createChildAttributeSetModel(key, dataObject, i),\n );\n }\n } else {\n childAttributeSets.push(\n this.createChildAttributeSetModel(key, this.data[key]),\n );\n }\n }\n }\n return childAttributeSets;\n }\n}\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAD,sBAAA,CAAAF,OAAA;AAIA;AACA;AACe,MAAMI,iBAAiB,SAASC,kBAAS,CAAC;EAIvD;AACF;EACEC,WAAWA,CACTC,GAAW,GAAG,EAAE,EAChBC,IAAY,GAAG,CAAC,CAAC,EACjBC,aAAqB,GAAG,CAAC,CAAC,EAC1BC,YAA2B,EAC3B;IAAA,IAAAC,QAAA;IACA,KAAK,CAACH,IAAI,EAAEC,aAAa,EAAEC,YAAY,CAAC;IAAC,IAAAE,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEzC,MAAMC,sBAAsB,GAAG,IAAI,CAACL,aAAa,CAACM,UAAU,GACxD,IAAAC,OAAA,CAAAH,OAAA,EAAAF,QAAA,OAAI,CAACF,aAAa,CAACM,UAAU,EAAAE,IAAA,CAAAN,QAAA,EAASO,YAAY,IAAK;MACrD,MAAM,CAACC,eAAe,CAAC,GAAG,IAAAC,KAAA,CAAAP,OAAA,EAAYK,YAAY,CAAC;MACnD,OAAO,IAAAG,YAAG,EAAC,IAAI,CAACb,IAAI,EAAEW,eAAe,CAAC;IACxC,CAAC,CAAC,GACF,EAAE;IAEN,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