@beinformed/ui 1.27.5 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -1
- package/esm/constants/LayoutHintConfig.js +0 -9
- package/esm/constants/LayoutHintConfig.js.map +1 -1
- package/esm/constants/LayoutHints.js +0 -4
- package/esm/constants/LayoutHints.js.map +1 -1
- package/esm/constants/Settings.js +0 -4
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeModel.js +1 -0
- package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionModel.js +2 -2
- package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/esm/models/attributes/DatetimeAttributeModel.js +3 -29
- package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/esm/react-client/Init.js +2 -2
- package/esm/react-client/Init.js.map +1 -1
- package/esm/react-client/client.js +80 -52
- package/esm/react-client/client.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +7 -0
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIReducer.js +1 -0
- package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/redux/actions/Form.js +2 -2
- package/esm/redux/actions/Form.js.map +1 -1
- package/esm/redux/actions/FormAttributeSet.js +2 -2
- package/esm/redux/actions/FormAttributeSet.js.map +1 -1
- package/esm/redux/actions/FormAttributeSetRepeatable.js +4 -4
- package/esm/redux/actions/FormAttributeSetRepeatable.js.map +1 -1
- package/esm/redux/actions/FormAutosave.js +2 -2
- package/esm/redux/actions/FormAutosave.js.map +1 -1
- package/esm/redux/actions/FormValidations.js +2 -2
- package/esm/redux/actions/FormValidations.js.map +1 -1
- package/esm/redux/connectors/Form.js.map +1 -1
- package/esm/redux/connectors/FormAttributeSet.js.map +1 -1
- package/esm/redux/store/configureStore.js +4 -4
- package/esm/redux/store/configureStore.js.map +1 -1
- package/esm/redux/types.js.map +1 -1
- package/lib/constants/LayoutHintConfig.js +0 -9
- package/lib/constants/LayoutHintConfig.js.flow +0 -9
- package/lib/constants/LayoutHintConfig.js.map +1 -1
- package/lib/constants/LayoutHints.js +2 -7
- package/lib/constants/LayoutHints.js.flow +0 -4
- package/lib/constants/LayoutHints.js.map +1 -1
- package/lib/constants/Settings.js +0 -4
- package/lib/constants/Settings.js.flow +0 -6
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/__tests__/useForm.spec.js.flow +4 -4
- package/lib/hooks/useForm.js.flow +5 -5
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js +1 -0
- package/lib/models/attributes/ChoiceAttributeModel.js.flow +1 -0
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionModel.js +2 -2
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +2 -2
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/lib/models/attributes/DatetimeAttributeModel.js +3 -29
- package/lib/models/attributes/DatetimeAttributeModel.js.flow +7 -41
- package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/lib/models/attributes/__tests__/DateAttributeModel.spec.js.flow +1 -35
- package/lib/models/attributes/__tests__/DatetimeAttributeModel.spec.js.flow +158 -216
- package/lib/models/attributes/__tests__/TimestampModel.spec.js.flow +0 -5
- package/lib/react-client/Init.js +2 -2
- package/lib/react-client/Init.js.flow +3 -3
- package/lib/react-client/Init.js.map +1 -1
- package/lib/react-client/client.js +83 -53
- package/lib/react-client/client.js.flow +106 -67
- package/lib/react-client/client.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +9 -1
- package/lib/redux/_modularui/ModularUIActions.js.flow +8 -0
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIReducer.js +1 -0
- package/lib/redux/_modularui/ModularUIReducer.js.flow +1 -0
- package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/types.js.flow +5 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/redux/actions/Form.js +1 -1
- package/lib/redux/actions/Form.js.flow +4 -4
- package/lib/redux/actions/Form.js.map +1 -1
- package/lib/redux/actions/FormAttributeSet.js +1 -1
- package/lib/redux/actions/FormAttributeSet.js.flow +3 -2
- package/lib/redux/actions/FormAttributeSet.js.map +1 -1
- package/lib/redux/actions/FormAttributeSetRepeatable.js +3 -3
- package/lib/redux/actions/FormAttributeSetRepeatable.js.flow +8 -8
- package/lib/redux/actions/FormAttributeSetRepeatable.js.map +1 -1
- package/lib/redux/actions/FormAutosave.js +1 -1
- package/lib/redux/actions/FormAutosave.js.flow +2 -2
- package/lib/redux/actions/FormAutosave.js.map +1 -1
- package/lib/redux/actions/FormValidations.js +1 -1
- package/lib/redux/actions/FormValidations.js.flow +2 -2
- package/lib/redux/actions/FormValidations.js.map +1 -1
- package/lib/redux/actions/__tests__/Form.spec.js.flow +1 -1
- package/lib/redux/connectors/Form.js.flow +2 -5
- package/lib/redux/connectors/Form.js.map +1 -1
- package/lib/redux/connectors/FormAttributeSet.js.flow +5 -5
- package/lib/redux/connectors/FormAttributeSet.js.map +1 -1
- package/lib/redux/store/configureStore.js +4 -4
- package/lib/redux/store/configureStore.js.flow +5 -5
- package/lib/redux/store/configureStore.js.map +1 -1
- package/lib/redux/types.js.flow +2 -0
- package/lib/redux/types.js.map +1 -1
- package/package.json +17 -19
- package/src/constants/LayoutHintConfig.js +0 -9
- package/src/constants/LayoutHints.js +0 -4
- package/src/constants/Settings.js +0 -6
- package/src/hooks/__tests__/useForm.spec.js +4 -4
- package/src/hooks/useForm.js +5 -5
- package/src/models/attributes/ChoiceAttributeModel.js +1 -0
- package/src/models/attributes/ChoiceAttributeOptionModel.js +2 -2
- package/src/models/attributes/DatetimeAttributeModel.js +7 -41
- package/src/models/attributes/__tests__/DateAttributeModel.spec.js +1 -35
- package/src/models/attributes/__tests__/DatetimeAttributeModel.spec.js +158 -216
- package/src/models/attributes/__tests__/TimestampModel.spec.js +0 -5
- package/src/react-client/Init.js +3 -3
- package/src/react-client/client.js +106 -67
- package/src/redux/_modularui/ModularUIActions.js +8 -0
- package/src/redux/_modularui/ModularUIReducer.js +1 -0
- package/src/redux/_modularui/types.js +5 -0
- package/src/redux/actions/Form.js +4 -4
- package/src/redux/actions/FormAttributeSet.js +3 -2
- package/src/redux/actions/FormAttributeSetRepeatable.js +8 -8
- package/src/redux/actions/FormAutosave.js +2 -2
- package/src/redux/actions/FormValidations.js +2 -2
- package/src/redux/actions/__tests__/Form.spec.js +1 -1
- package/src/redux/connectors/Form.js +2 -5
- package/src/redux/connectors/FormAttributeSet.js +5 -5
- package/src/redux/store/configureStore.js +5 -5
- package/src/redux/types.js +2 -0
- package/types/constants/LayoutHintConfig.d.ts +8 -23
- package/types/constants/LayoutHints.d.ts +0 -4
- package/types/models/actions/ActionCollection.d.ts +1 -1
- package/types/models/attributes/DatetimeAttributeModel.d.ts +8 -2
- package/types/redux/_modularui/types.d.ts +4 -0
- package/types/redux/types.d.ts +1 -1
package/lib/hooks/useForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.js","names":["useForm","href","formHref","Href","getSetting","addParameter","form","useModularUI","method","HTTP_METHODS","POST","targetModel","FormModel","removeOnUnmount","model","useFormNavigation","dispatch","useDispatch","previous","previousObject","cancel","cancelForm","submit","loadModularUI","connectKey","selfhref","data","formdata","updateModel","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 Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { FormObjectModel, AttributeType } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\nimport type {\n RemoveModelByKeyAction,\n
|
|
1
|
+
{"version":3,"file":"useForm.js","names":["useForm","href","formHref","Href","getSetting","addParameter","form","useModularUI","method","HTTP_METHODS","POST","targetModel","FormModel","removeOnUnmount","model","useFormNavigation","dispatch","useDispatch","previous","previousObject","cancel","cancelForm","submit","loadModularUI","connectKey","selfhref","data","formdata","updateModel","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 Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { FormObjectModel, AttributeType } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\nimport type {\n RemoveModelByKeyAction,\n UpdateFormAction,\n} from \"../redux/_modularui\";\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): ?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 });\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 updateModel: form,\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 * Update attributes of a form\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;AAEA;AAEA;AAEA;AACA;AAEA;AAUA;AA6BA;AACA;AACA;AACO,MAAMA,OAAO,GAAIC,IAAmB,IAAiB;EAC1D,MAAMC,QAAQ,GAAG,IAAIC,aAAI,CAACF,IAAI,CAAC;EAE/B,IAAI,CAAC,IAAAG,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;EACnB,CAAC,CAAC;EAEF,IAAIP,IAAI,EAAEQ,KAAK,EAAE;IACf,OAAOR,IAAI,CAACQ,KAAK;EACnB;AACF,CAAC;;AAED;AACA;AACA;AAFA;AAGO,MAAMC,iBAAiB,GAAG,MAA0B;EACzD,MAAMC,QAAQ,GAAG,IAAAC,uBAAW,GAAE;EAE9B,MAAMC,QAAQ,GAAIZ,IAAe,IAAKU,QAAQ,CAAC,IAAAG,uBAAc,EAACb,IAAI,CAAC,CAAC;EAEpE,MAAMc,MAAM,GAAId,IAAe,IAAKU,QAAQ,CAAC,IAAAK,mBAAU,EAACf,IAAI,CAAC,CAAC;EAE9D,MAAMgB,MAAM,GAAIhB,IAAe,IAC7BU,QAAQ,CACN,IAAAO,wBAAa,EAACjB,IAAI,CAACkB,UAAU,EAAElB,IAAI,CAACmB,QAAQ,EAAE;IAC5CjB,MAAM,EAAEC,uBAAY,CAACC,IAAI;IACzBgB,IAAI,EAAEpB,IAAI,CAACqB,QAAQ;IACnBC,WAAW,EAAEtB,IAAI;IACjBK,WAAW,EAAEC;EACf,CAAC,CAAC,CACH;EAEH,MAAMiB,MAAM,GAAIvB,IAAe,IAC7BU,QAAQ,CAAC,IAAAc,2BAAgB,EAACxB,IAAI,CAACkB,UAAU,CAAC,CAAC;EAE7C,MAAMO,0BAA0B,GAAIzB,IAAe,IACjDU,QAAQ,CAAC,IAAAgB,6BAAoB,EAAC1B,IAAI,CAAC,CAAC;EAEtC,OAAO;IACLY,QAAQ;IACRE,MAAM;IACNE,MAAM;IACNO,MAAM;IACNG,oBAAoB,EAAED;EACxB,CAAC;AACH,CAAC;;AAED;AACA;AACA;AAFA;AAGO,MAAME,kBAAkB,GAAG,CAChC3B,IAAe,EACf4B,MAAuB,KACC;EACxB,MAAMlB,QAAQ,GAAG,IAAAC,uBAAW,GAAE;EAE9B,OAAO,CACLkB,SAAwB,EACxBC,KAAa,EACbC,OAA0B,KACvBrB,QAAQ,CAAC,IAAAsB,4BAAmB,EAAChC,IAAI,EAAE4B,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,CAAC,CAAC;AAC7E,CAAC;;AAED;AACA;AACA;AAFA;AAGO,MAAME,eAAe,GAAIjC,IAAe,IAAuB;EACpE,MAAMU,QAAQ,GAAG,IAAAC,uBAAW,GAAE;EAE9B,OAAO;IACLuB,IAAI,EAAE,MAAMxB,QAAQ,CAAC,IAAAyB,kCAAyB,EAACnC,IAAI,CAAC,CAAC;IACrDc,MAAM,EAAGc,MAAuB,IAC9BlB,QAAQ,CAAC,IAAA0B,qCAA4B,EAACpC,IAAI,EAAE4B,MAAM,CAAC,CAAC;IACtDL,MAAM,EAAGK,MAAuB,IAC9BlB,QAAQ,CAAC,IAAA2B,qCAA4B,EAACrC,IAAI,EAAE4B,MAAM,CAAC;EACvD,CAAC;AACH,CAAC;AAAC"}
|
|
@@ -270,6 +270,7 @@ class ChoiceAttributeModel extends _AttributeModel.default {
|
|
|
270
270
|
}
|
|
271
271
|
values.forEach(val => {
|
|
272
272
|
if (val instanceof _ChoiceAttributeOptionModel.default) {
|
|
273
|
+
// option does not exist in existing options, add it. This can happen when lookup list has other options then lookup options
|
|
273
274
|
if (!this.options.some(option => option.equals(val))) {
|
|
274
275
|
this.options.add(val);
|
|
275
276
|
}
|
|
@@ -324,6 +324,7 @@ export default class ChoiceAttributeModel extends AttributeModel {
|
|
|
324
324
|
}
|
|
325
325
|
values.forEach((val) => {
|
|
326
326
|
if (val instanceof ChoiceAttributeOptionModel) {
|
|
327
|
+
// option does not exist in existing options, add it. This can happen when lookup list has other options then lookup options
|
|
327
328
|
if (!this.options.some((option) => option.equals(val))) {
|
|
328
329
|
this.options.add(val);
|
|
329
330
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceAttributeModel.js","names":["ChoiceAttributeModel","AttributeModel","constructor","attribute","attributeContributions","_referenceDate","getData","DateUtil","now","_options","ChoiceAttributeOptionCollection","create","referenceDate","layouthint","has","SORT_OPTIONS","sortOptions","isApplicableModel","contributions","type","optionMode","getContribution","hasLookupLink","lookupLink","lookupListLink","getInitialChildModelLinks","links","hasContentConfiguration","hasContentFromData","conceptLink","push","options","setChildModels","models","conceptLinkHref","href","concept","model","selfhref","equalsWithParameters","getLinkByKey","lookupListLabel","lookupList","label","date","selected","option","code","readonlyvalue","join","initvalue","Array","isArray","_initvalue","length","getValue","hasValue","getInputValue","toggleOption","disableOption","enableOption","isMultiple","deselectAll","select","inputvalue","deselect","addOption","opt","choicetype","hint","multiplechoice","isTree","some","reset","mergeAttribute","oldAttribute","readonly","mergeOptions","isValid","update","value","updateLastModification","values","split","forEach","val","ChoiceAttributeOptionModel","equals","add","toString","_hasContentConfiguration","contentConfiguration","content","optionElements","optionElementConfig","optionElement","contentElement","RENDER_SECTION_LABEL","ContentConfigurationElements","placeholder","addServerError","error","id","message","properties","ANSWER_OPTION_KEY","optionKey","foundOption","getContentConfiguredLabel","_errorCollection","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM"],"sources":["../../../src/models/attributes/ChoiceAttributeModel.js"],"sourcesContent":["// @flow\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 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 { ModularUIModel, AttributeType, FormErrorAnchor } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\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(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this._referenceDate = this.getData(\"referenceDate\", DateUtil.now());\n this._options = ChoiceAttributeOptionCollection.create(\n attribute,\n attributeContributions,\n 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 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>) {\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);\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(oldAttribute: AttributeType) {\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(oldAttribute.options, this.type === \"lookup\");\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 {\n values = [value];\n }\n values.forEach((val) => {\n if (val instanceof ChoiceAttributeOptionModel) {\n if (!this.options.some((option) => option.equals(val))) {\n this.options.add(val);\n }\n\n this.toggleOption(val.code);\n } else if (\n typeof val === \"string\" &&\n this.options.some((option) => option.code.toString() === val)\n ) {\n this.toggleOption(val);\n }\n });\n\n return this;\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 if (this.type === \"lookup\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAIA;AAKA;AACA;AACA;AACe,MAAMA,oBAAoB,SAASC,uBAAc,CAAC;EAK/D;AACF;AACA;EACEC,WAAW,CAACC,SAAiB,EAAEC,sBAA8B,EAAE;IAC7D,KAAK,CAACD,SAAS,EAAEC,sBAAsB,CAAC;IAAC;IAAA;IAAA;IAEzC,IAAI,CAACC,cAAc,GAAG,IAAI,CAACC,OAAO,CAAC,eAAe,EAAEC,sBAAQ,CAACC,GAAG,EAAE,CAAC;IACnE,IAAI,CAACC,QAAQ,GAAGC,wCAA+B,CAACC,MAAM,CACpDR,SAAS,EACTC,sBAAsB,EACtB,IAAI,CAACQ,aAAa,CACnB;IAED,IAAI,IAAI,CAACC,UAAU,CAACC,GAAG,CAACC,yBAAY,CAAC,EAAE;MACrC,IAAI,CAACN,QAAQ,CAACO,WAAW,GAAG,IAAI;IAClC;EACF;;EAEA;AACF;EACE,OAAOC,iBAAiB,CAACC,aAAqB,EAAW;IACvD,OACEA,aAAa,CAACC,IAAI,KAAK,WAAW,IAClCD,aAAa,CAACC,IAAI,KAAK,SAAS,KAC/BD,aAAa,CAACC,IAAI,KAAK,QAAQ,IAC9BD,aAAa,CAACC,IAAI,KAAK,OAAO,IAC9B,IAAAL,YAAG,EAACI,aAAa,EAAE,YAAY,CAAC,IAChC,IAAAJ,YAAG,EAACI,aAAa,EAAE,SAAS,CAAC,CAAC;EAEpC;;EAEA;AACF;E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EAAE,EAAEC,OAAO,EAAEC,UAAU,EAAE3F,UAAU,CAAC;EAC3E;;EAEA;AACF;EACE,IAAIiG,aAAa,GAAkC;IACjD,IAAI,IAAI,CAAC3F,IAAI,KAAK,QAAQ,EAAE;MAC1B,OAAO4F,0BAAe,CAACC,KAAK;IAC9B;IAEA,OAAOD,0BAAe,CAACE,MAAM;EAC/B;AACF;AAAC"}
|
|
1
|
+
{"version":3,"file":"ChoiceAttributeModel.js","names":["ChoiceAttributeModel","AttributeModel","constructor","attribute","attributeContributions","_referenceDate","getData","DateUtil","now","_options","ChoiceAttributeOptionCollection","create","referenceDate","layouthint","has","SORT_OPTIONS","sortOptions","isApplicableModel","contributions","type","optionMode","getContribution","hasLookupLink","lookupLink","lookupListLink","getInitialChildModelLinks","links","hasContentConfiguration","hasContentFromData","conceptLink","push","options","setChildModels","models","conceptLinkHref","href","concept","model","selfhref","equalsWithParameters","getLinkByKey","lookupListLabel","lookupList","label","date","selected","option","code","readonlyvalue","join","initvalue","Array","isArray","_initvalue","length","getValue","hasValue","getInputValue","toggleOption","disableOption","enableOption","isMultiple","deselectAll","select","inputvalue","deselect","addOption","opt","choicetype","hint","multiplechoice","isTree","some","reset","mergeAttribute","oldAttribute","readonly","mergeOptions","isValid","update","value","updateLastModification","values","split","forEach","val","ChoiceAttributeOptionModel","equals","add","toString","_hasContentConfiguration","contentConfiguration","content","optionElements","optionElementConfig","optionElement","contentElement","RENDER_SECTION_LABEL","ContentConfigurationElements","placeholder","addServerError","error","id","message","properties","ANSWER_OPTION_KEY","optionKey","foundOption","getContentConfiguredLabel","_errorCollection","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM"],"sources":["../../../src/models/attributes/ChoiceAttributeModel.js"],"sourcesContent":["// @flow\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 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 { ModularUIModel, AttributeType, FormErrorAnchor } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\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(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this._referenceDate = this.getData(\"referenceDate\", DateUtil.now());\n this._options = ChoiceAttributeOptionCollection.create(\n attribute,\n attributeContributions,\n 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 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>) {\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);\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(oldAttribute: AttributeType) {\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(oldAttribute.options, this.type === \"lookup\");\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 {\n values = [value];\n }\n values.forEach((val) => {\n if (val instanceof ChoiceAttributeOptionModel) {\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 this.options.add(val);\n }\n\n this.toggleOption(val.code);\n } else if (\n typeof val === \"string\" &&\n this.options.some((option) => option.code.toString() === val)\n ) {\n this.toggleOption(val);\n }\n });\n\n return this;\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 if (this.type === \"lookup\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAIA;AAKA;AACA;AACA;AACe,MAAMA,oBAAoB,SAASC,uBAAc,CAAC;EAK/D;AACF;AACA;EACEC,WAAW,CAACC,SAAiB,EAAEC,sBAA8B,EAAE;IAC7D,KAAK,CAACD,SAAS,EAAEC,sBAAsB,CAAC;IAAC;IAAA;IAAA;IAEzC,IAAI,CAACC,cAAc,GAAG,IAAI,CAACC,OAAO,CAAC,eAAe,EAAEC,sBAAQ,CAACC,GAAG,EAAE,CAAC;IACnE,IAAI,CAACC,QAAQ,GAAGC,wCAA+B,CAACC,MAAM,CACpDR,SAAS,EACTC,sBAAsB,EACtB,IAAI,CAACQ,aAAa,CACnB;IAED,IAAI,IAAI,CAACC,UAAU,CAACC,GAAG,CAACC,yBAAY,CAAC,EAAE;MACrC,IAAI,CAACN,QAAQ,CAACO,WAAW,GAAG,IAAI;IAClC;EACF;;EAEA;AACF;EACE,OAAOC,iBAAiB,CAACC,aAAqB,EAAW;IACvD,OACEA,aAAa,CAACC,IAAI,KAAK,WAAW,IAClCD,aAAa,CAACC,IAAI,KAAK,SAAS,KAC/BD,aAAa,CAACC,IAAI,KAAK,QAAQ,IAC9BD,aAAa,CAACC,IAAI,KAAK,OAAO,IAC9B,IAAAL,YAAG,EAACI,aAAa,EAAE,YAAY,CAAC,IAChC,IAAAJ,YAAG,EAACI,aAAa,EAAE,SAAS,CAAC,CAAC;EAEpC;;EAEA;AACF;EACE,IAAIC,IAAI,GAAW;IACjB,MAAMC,UAAU,GAAG,IAAI,CAACC,eAAe,CAAC,YAAY,EAAE,EAAE,CAAC;IACzD,MAAMC,aAAa,GAAG,IAAI,CAACC,UAAU,IAA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AAQ,EAAE;MAC1B,OAAO4F,0BAAe,CAACC,KAAK;IAC9B;IAEA,OAAOD,0BAAe,CAACE,MAAM;EAC/B;AACF;AAAC"}
|
|
@@ -55,8 +55,8 @@ class ChoiceAttributeOptionModel extends _BaseModel.default {
|
|
|
55
55
|
static createFromListItemModel(listitem) {
|
|
56
56
|
const option = new ChoiceAttributeOptionModel();
|
|
57
57
|
option.code = listitem.id.toString();
|
|
58
|
-
option.attributeCollection = listitem.attributeCollection;
|
|
59
|
-
option.links = listitem.links;
|
|
58
|
+
option.attributeCollection = listitem.attributeCollection.clone();
|
|
59
|
+
option.links = listitem.links.clone();
|
|
60
60
|
return option;
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -66,8 +66,8 @@ class ChoiceAttributeOptionModel
|
|
|
66
66
|
const option = new ChoiceAttributeOptionModel();
|
|
67
67
|
|
|
68
68
|
option.code = listitem.id.toString();
|
|
69
|
-
option.attributeCollection = listitem.attributeCollection;
|
|
70
|
-
option.links = listitem.links;
|
|
69
|
+
option.attributeCollection = listitem.attributeCollection.clone();
|
|
70
|
+
option.links = listitem.links.clone();
|
|
71
71
|
|
|
72
72
|
return option;
|
|
73
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceAttributeOptionModel.js","names":["ChoiceAttributeOptionModel","BaseModel","constructor","selectedValues","option","referenceDate","DateUtil","now","code","contributions","key","_isSelected","_referenceDate","_level","_attributeCollection","createAttributeCollection","_children","addChildren","_links","LinkCollection","_content","AttributeContent","content","createFromListItemModel","listitem","id","toString","attributeCollection","links","getInitialChildModelLinks","initialLinks","hasContentFromData","conceptLink","push","children","setChildModels","models","conceptHref","href","concept","model","selfhref","equalsWithParameters","_code","equals","getContribution","has","data","AttributeCollection","label","hasItems","title","getAttributeByLayoutHint","TITLE","readonlyvalue","first","getContentConfiguredLabel","contentConfiguration","configuredLabelProperties","labelConfig","types","length","configuredLabels","getLabelElementByIds","configuredLabel","value","configuredLabelProperty","some","_id","selected","count","ChoiceAttributeOptionCollection","create","options","date","getLinkByKey","addParameter","TIMEVERSION_FILTER_NAME","isCacheable","_concept","ConceptDetailModel","level","isBooleanType","hasAlternativeLabel","mergeOption","withOption","mergeOptions","hasAllContentInData"],"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 { IModelWithChildModels, ModularUIModel } from \"../types\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\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\n /**\n */\n constructor(\n selectedValues: Array<string> = [],\n option: Object = {},\n referenceDate: ISO_DATE = DateUtil.now()\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 = referenceDate;\n\n this._level = 0;\n\n this._attributeCollection = this.createAttributeCollection();\n this._children = this.addChildren(selectedValues, option, referenceDate);\n\n this._links = new LinkCollection(this.contributions._links);\n\n this._content = new AttributeContent(option.content);\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;\n option.links = listitem.links;\n\n return option;\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>) {\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);\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(): 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, true);\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 referenceDate: ISO_DATE = DateUtil.now()\n ): ChoiceAttributeOptionCollection {\n // When contributions contain elements this is a list not nested options\n if (has(option, \"elements\")) {\n return new ChoiceAttributeOptionCollection();\n }\n\n return ChoiceAttributeOptionCollection.create(\n {\n value: selectedValues,\n },\n { options: option?.children ?? [] },\n referenceDate\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 * 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\nexport default ChoiceAttributeOptionModel;\n"],"mappings":";;;;;;;;;;;;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAMA;AACA;AACA,MAAMA,0BAA0B,SACtBC,kBAAS,CAEnB;EAWE;AACF;EACEC,WAAW,GAIT;IAAA,IAHAC,cAA6B,uEAAG,EAAE;IAAA,IAClCC,MAAc,uEAAG,CAAC,CAAC;IAAA,IACnBC,aAAuB,uEAAGC,sBAAQ,CAACC,GAAG,EAAE;IAExC,KAAK,CAAC,CAAC,CAAC,EAAEH,MAAM,CAAC;IAAC;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAElB,IAAI,CA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QAAQ,IAAI,IAAI,IAAImD,UAAU,CAACnD,QAAQ,IAAI,IAAI,EAAE;MACxD,IAAI,CAACA,QAAQ,CAACoD,YAAY,CAACD,UAAU,CAACnD,QAAQ,CAAC;IACjD;EACF;;EAEA;AACF;AACA;EACE,IAAIH,kBAAkB,GAAY;IAChC,OAAO,IAAAwD,6BAAmB,GAAE;EAC9B;;EAEA;AACF;EACE,IAAIjE,OAAO,GAAqB;IAC9B,OAAO,IAAI,CAACF,QAAQ;EACtB;AACF;AAAC,eAEcpB,0BAA0B;AAAA"}
|
|
1
|
+
{"version":3,"file":"ChoiceAttributeOptionModel.js","names":["ChoiceAttributeOptionModel","BaseModel","constructor","selectedValues","option","referenceDate","DateUtil","now","code","contributions","key","_isSelected","_referenceDate","_level","_attributeCollection","createAttributeCollection","_children","addChildren","_links","LinkCollection","_content","AttributeContent","content","createFromListItemModel","listitem","id","toString","attributeCollection","clone","links","getInitialChildModelLinks","initialLinks","hasContentFromData","conceptLink","push","children","setChildModels","models","conceptHref","href","concept","model","selfhref","equalsWithParameters","_code","equals","getContribution","has","data","AttributeCollection","label","hasItems","title","getAttributeByLayoutHint","TITLE","readonlyvalue","first","getContentConfiguredLabel","contentConfiguration","configuredLabelProperties","labelConfig","types","length","configuredLabels","getLabelElementByIds","configuredLabel","value","configuredLabelProperty","some","_id","selected","count","ChoiceAttributeOptionCollection","create","options","date","getLinkByKey","addParameter","TIMEVERSION_FILTER_NAME","isCacheable","_concept","ConceptDetailModel","level","isBooleanType","hasAlternativeLabel","mergeOption","withOption","mergeOptions","hasAllContentInData"],"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 { IModelWithChildModels, ModularUIModel } from \"../types\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\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\n /**\n */\n constructor(\n selectedValues: Array<string> = [],\n option: Object = {},\n referenceDate: ISO_DATE = DateUtil.now()\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 = referenceDate;\n\n this._level = 0;\n\n this._attributeCollection = this.createAttributeCollection();\n this._children = this.addChildren(selectedValues, option, referenceDate);\n\n this._links = new LinkCollection(this.contributions._links);\n\n this._content = new AttributeContent(option.content);\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 */\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>) {\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);\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(): 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, true);\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 referenceDate: ISO_DATE = DateUtil.now()\n ): ChoiceAttributeOptionCollection {\n // When contributions contain elements this is a list not nested options\n if (has(option, \"elements\")) {\n return new ChoiceAttributeOptionCollection();\n }\n\n return ChoiceAttributeOptionCollection.create(\n {\n value: selectedValues,\n },\n { options: option?.children ?? [] },\n referenceDate\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 * 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\nexport default ChoiceAttributeOptionModel;\n"],"mappings":";;;;;;;;;;;;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAMA;AACA;AACA,MAAMA,0BAA0B,SACtBC,kBAAS,CAEnB;EAWE;AACF;EACEC,WAAW,GAIT;IAAA,IAHAC,cAA6B,uEAAG,EAAE;IAAA,IAClCC,MAAc,uEAAG,CAAC,CAAC;IAAA,IACnBC,aAAuB,uEAAGC,sBAAQ,CAACC,GAAG,EAAE;IAExC,KAAK,CAAC,CAAC,CAAC,EAAEH,MAAM,CAAC;IAAC;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAElB,IAAI,CAACI,IAAI,GAAG,IAAI,CAACC,aAAa,CAACD,IAAI,IAAI,IAAI,CAACC,aAAa,CAACC,GAAG,IAAI,EAAE;IAEnE,IAAI,CAACC,WAAW,GAAG,uBAAAR,cAAc,OAAdA,cAAc,EAAU,IAAI,CAACK,IAAI,CAAC;IAErD,IAAI,CAACI,cAAc,GAAGP,aAAa;IAEnC,IAAI,CAACQ,MAAM,GAAG,CAAC;IAEf,IAAI,CAACC,oBAAoB,GAAG,IAAI,CAACC,yBAAyB,EAAE;IAC5D,IAAI,CAACC,SAAS,GAAG,IAAI,CAACC,WAAW,CAACd,cAAc,EAAEC,MAAM,EAAEC,aA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 @@ var _DateTimeTimeFormatConstraint = _interopRequireDefault(require("./input-cons
|
|
|
16
16
|
var _DatetimeFormatConstraint = _interopRequireDefault(require("./input-constraints/DatetimeFormatConstraint"));
|
|
17
17
|
var _DateBoundaryConstraint = _interopRequireDefault(require("./input-constraints/DateBoundaryConstraint"));
|
|
18
18
|
var _constants = require("../../constants");
|
|
19
|
-
var _Settings = require("../../constants/Settings");
|
|
20
|
-
var _LayoutHints = require("../../constants/LayoutHints");
|
|
21
|
-
// date format of default
|
|
22
|
-
const PRODUCT_DEFAULT_DATE_FORMAT = "dd-MM-yyyy";
|
|
23
|
-
|
|
24
19
|
/**
|
|
25
20
|
*/
|
|
26
21
|
class DatetimeAttributeModel extends _StringAttributeModel.default {
|
|
@@ -211,18 +206,7 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
|
|
|
211
206
|
if (!this.hasDate) {
|
|
212
207
|
return "";
|
|
213
208
|
}
|
|
214
|
-
|
|
215
|
-
// setting for date input
|
|
216
|
-
const ignoreFormatSetting = this.layouthint.has(_LayoutHints.IGNORE_FORMAT_SETTING);
|
|
217
|
-
if (!ignoreFormatSetting) {
|
|
218
|
-
const dateInputFormatSetting = (0, _Settings.getSetting)("DATE_INPUT_FORMAT", "");
|
|
219
|
-
if (dateInputFormatSetting) {
|
|
220
|
-
return dateInputFormatSetting;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
let format = this.format;
|
|
224
|
-
let dateFormat = this.hasTime ? (0, _trim.default)(_context7 = format.replace(this.timeInputFormat, "")).call(_context7) : format;
|
|
225
|
-
return dateFormat;
|
|
209
|
+
return this.hasTime ? (0, _trim.default)(_context7 = this.format.replace(this.timeInputFormat, "")).call(_context7) : this.format;
|
|
226
210
|
}
|
|
227
211
|
|
|
228
212
|
/**
|
|
@@ -232,26 +216,16 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
|
|
|
232
216
|
if (!this.hasDate) {
|
|
233
217
|
return "";
|
|
234
218
|
}
|
|
235
|
-
|
|
236
|
-
let dateFormat = this.hasTime ? (0, _trim.default)(_context8 = format.replace(this.timeInputFormat, "")).call(_context8) : format;
|
|
237
|
-
const readonlyFormatSetting = (0, _Settings.getSetting)("DATE_READONLY_FORMAT", "");
|
|
238
|
-
if (dateFormat === PRODUCT_DEFAULT_DATE_FORMAT && readonlyFormatSetting) {
|
|
239
|
-
dateFormat = readonlyFormatSetting;
|
|
240
|
-
}
|
|
241
|
-
return dateFormat;
|
|
219
|
+
return this.hasTime ? (0, _trim.default)(_context8 = this.format.replace(this.timeInputFormat, "")).call(_context8) : this.format;
|
|
242
220
|
}
|
|
243
221
|
|
|
244
222
|
/**
|
|
245
|
-
* return attribute placeholder or
|
|
223
|
+
* return attribute placeholder or return formatlabel without time input format from contributions
|
|
246
224
|
*/
|
|
247
225
|
get placeholder() {
|
|
248
226
|
if (this._placeholder !== "") {
|
|
249
227
|
return this._placeholder;
|
|
250
228
|
}
|
|
251
|
-
const dateInputFormatSetting = (0, _Settings.getSetting)("DATE_INPUT_FORMAT", "");
|
|
252
|
-
if (dateInputFormatSetting) {
|
|
253
|
-
return dateInputFormatSetting.toLowerCase();
|
|
254
|
-
}
|
|
255
229
|
const formatLabel = this.getContribution("formatlabel", "");
|
|
256
230
|
if (this.hasDate && this.hasTime && (0, _includes.default)(formatLabel).call(formatLabel, " ")) {
|
|
257
231
|
// return first part of formatlabel to keep placeholder matching date input
|
|
@@ -17,14 +17,9 @@ import DatetimeFormatConstraint from "./input-constraints/DatetimeFormatConstrai
|
|
|
17
17
|
import DateBoundaryConstraint from "./input-constraints/DateBoundaryConstraint";
|
|
18
18
|
|
|
19
19
|
import { ATTRIBUTE_WIDTH, ISO_DATE_FORMAT } from "../../constants";
|
|
20
|
-
import { getSetting } from "../../constants/Settings";
|
|
21
|
-
import { IGNORE_FORMAT_SETTING } from "../../constants/LayoutHints";
|
|
22
20
|
|
|
23
21
|
import type { FormErrorAnchor, IConstraintModel } from "../types";
|
|
24
22
|
|
|
25
|
-
// date format of default
|
|
26
|
-
const PRODUCT_DEFAULT_DATE_FORMAT = "dd-MM-yyyy";
|
|
27
|
-
|
|
28
23
|
/**
|
|
29
24
|
*/
|
|
30
25
|
class DatetimeAttributeModel extends StringAttributeModel {
|
|
@@ -239,22 +234,9 @@ class DatetimeAttributeModel extends StringAttributeModel {
|
|
|
239
234
|
return "";
|
|
240
235
|
}
|
|
241
236
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const dateInputFormatSetting = getSetting("DATE_INPUT_FORMAT", "");
|
|
246
|
-
if (dateInputFormatSetting) {
|
|
247
|
-
return dateInputFormatSetting;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
let format = this.format;
|
|
252
|
-
|
|
253
|
-
let dateFormat = this.hasTime
|
|
254
|
-
? format.replace(this.timeInputFormat, "").trim()
|
|
255
|
-
: format;
|
|
256
|
-
|
|
257
|
-
return dateFormat;
|
|
237
|
+
return this.hasTime
|
|
238
|
+
? this.format.replace(this.timeInputFormat, "").trim()
|
|
239
|
+
: this.format;
|
|
258
240
|
}
|
|
259
241
|
|
|
260
242
|
/**
|
|
@@ -264,35 +246,19 @@ class DatetimeAttributeModel extends StringAttributeModel {
|
|
|
264
246
|
return "";
|
|
265
247
|
}
|
|
266
248
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
? format.replace(this.timeInputFormat, "").trim()
|
|
271
|
-
: format;
|
|
272
|
-
|
|
273
|
-
const readonlyFormatSetting = getSetting("DATE_READONLY_FORMAT", "");
|
|
274
|
-
|
|
275
|
-
if (dateFormat === PRODUCT_DEFAULT_DATE_FORMAT && readonlyFormatSetting) {
|
|
276
|
-
dateFormat = readonlyFormatSetting;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return dateFormat;
|
|
249
|
+
return this.hasTime
|
|
250
|
+
? this.format.replace(this.timeInputFormat, "").trim()
|
|
251
|
+
: this.format;
|
|
280
252
|
}
|
|
281
253
|
|
|
282
254
|
/**
|
|
283
|
-
* return attribute placeholder or
|
|
255
|
+
* return attribute placeholder or return formatlabel without time input format from contributions
|
|
284
256
|
*/
|
|
285
257
|
get placeholder(): string {
|
|
286
258
|
if (this._placeholder !== "") {
|
|
287
259
|
return this._placeholder;
|
|
288
260
|
}
|
|
289
261
|
|
|
290
|
-
const dateInputFormatSetting = getSetting("DATE_INPUT_FORMAT", "");
|
|
291
|
-
|
|
292
|
-
if (dateInputFormatSetting) {
|
|
293
|
-
return dateInputFormatSetting.toLowerCase();
|
|
294
|
-
}
|
|
295
|
-
|
|
296
262
|
const formatLabel = this.getContribution("formatlabel", "");
|
|
297
263
|
|
|
298
264
|
if (this.hasDate && this.hasTime && formatLabel.includes(" ")) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatetimeAttributeModel.js","names":["PRODUCT_DEFAULT_DATE_FORMAT","DatetimeAttributeModel","StringAttributeModel","constructor","attribute","attributeContributions","updateInitValue","isApplicableModel","contributions","type","formatUtil","TimeUtil","TimestampUtil","DateTimeUtil","DateUtil","getInitValue","value","data","length","split","hasTime","getTimeValue","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","toFormat","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","toISO","format","convertFormat","operator","hasDate","formatLabel","dateInputFormat","ignoreFormatSetting","layouthint","has","IGNORE_FORMAT_SETTING","dateInputFormatSetting","getSetting","dateFormat","replace","dateReadonlyFormat","readonlyFormatSetting","placeholder","_placeholder","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","ISO_DATE_FORMAT","dateTimeReadonlyFormat","readonlyvalue","mindate","maxdate","addServerError","error","id","message","properties","_errorCollection","getFormatConstraint","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","addConstraints","constraints","ConstraintCollection","add","DateBoundaryConstraint","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM"],"sources":["../../../src/models/attributes/DatetimeAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport {\n DateUtil,\n DateTimeUtil,\n TimeUtil,\n TimestampUtil,\n} from \"../../utils/datetime/DateTimeUtil\";\n\nimport StringAttributeModel from \"./StringAttributeModel\";\n\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport DateTimeDateFormatConstraint from \"./input-constraints/DateTimeDateFormatConstraint\";\nimport DateTimeTimeFormatConstraint from \"./input-constraints/DateTimeTimeFormatConstraint\";\nimport DatetimeFormatConstraint from \"./input-constraints/DatetimeFormatConstraint\";\nimport DateBoundaryConstraint from \"./input-constraints/DateBoundaryConstraint\";\n\nimport { ATTRIBUTE_WIDTH, ISO_DATE_FORMAT } from \"../../constants\";\nimport { getSetting } from \"../../constants/Settings\";\nimport { IGNORE_FORMAT_SETTING } from \"../../constants/LayoutHints\";\n\nimport type { FormErrorAnchor, IConstraintModel } from \"../types\";\n\n// date format of default\nconst PRODUCT_DEFAULT_DATE_FORMAT = \"dd-MM-yyyy\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n /**\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this.updateInitValue();\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return [\"date\", \"time\", \"datetime\", \"timestamp\"].includes(\n contributions.type\n );\n }\n\n /**\n */\n get formatUtil():\n | typeof TimeUtil\n | typeof TimestampUtil\n | typeof DateTimeUtil\n | typeof DateUtil {\n switch (this.type) {\n case \"time\":\n return TimeUtil;\n case \"timestamp\":\n return TimestampUtil;\n case \"datetime\":\n return DateTimeUtil;\n default:\n return DateUtil;\n }\n }\n\n /**\n */\n getInitValue(): string | null {\n let value = this.data.value;\n if (value != null) {\n if (this.type === \"time\" && value.length === 5) {\n value = `${value}:00`;\n }\n\n // handle old datetime values, which contained ms\n if (this.type === \"datetime\" && value.includes(\".\")) {\n value = value.split(\".\")[0];\n }\n\n if (this.hasTime) {\n value = this.getTimeValue(value);\n }\n }\n\n return value;\n }\n\n /**\n */\n getTimeValue(value: string): string {\n let timeValue = value;\n if (!this.timeInputFormat.toLowerCase().includes(\"h\")) {\n timeValue = this.formatUtil.setHour(value, 0);\n }\n if (!this.timeInputFormat.includes(\"m\")) {\n timeValue = this.formatUtil.setMinute(value, 0);\n }\n if (!this.timeInputFormat.includes(\"s\")) {\n timeValue = this.formatUtil.setSecond(value, 0);\n }\n if (this.type === \"timestamp\" && !this.timeInputFormat.includes(\"S\")) {\n timeValue = this.formatUtil.setMilliseconds(value, 0);\n }\n return timeValue;\n }\n\n /**\n * Set time in the correct value based on available elements in the time format\n */\n updateInitValue() {\n const value = this.getInitValue();\n if (value != null) {\n this._initvalue = value;\n this._inputvalue = this.getInitialInputValue(value);\n this._value = value;\n }\n }\n\n /**\n * Get initial user input value\n */\n getInitialInputValue(value?: string): string {\n if (!value) {\n return \"\";\n }\n\n let initValue = value;\n if (this.type === \"time\" && value.length === 5) {\n initValue = `${value}:00`;\n }\n\n return this.formatUtil.toFormat(initValue, this.inputFormat);\n }\n\n /**\n * Set type to date\n */\n get type(): string {\n return this.getContribution(\"type\", \"date\");\n }\n\n /**\n * Returns the value as entered by the user. This can differ from the internal iso value that is stored\n */\n getInputValue(): string {\n return this._inputvalue ? this._inputvalue.toString() : \"\";\n }\n\n /**\n * Get input value\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this.validate(value);\n\n this._inputvalue = value;\n\n this.value =\n value !== null && value !== \"\"\n ? this.formatUtil.toISO(value, this.inputFormat)\n : null;\n }\n\n /**\n * Get date format\n */\n get format(): string {\n const format = this.getContribution(\"format\", \"\");\n return this.formatUtil.convertFormat(format);\n }\n\n /**\n */\n get operator(): string {\n return this.getContribution(\"operator\", \"\");\n }\n\n /**\n */\n get hasDate(): boolean {\n return (\n this.type === \"date\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get hasTime(): boolean {\n return (\n this.type === \"time\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get formatLabel(): string {\n switch (this.type) {\n case \"date\":\n return this.dateInputFormat.toLowerCase();\n case \"time\":\n return this.timeInputFormat.toLowerCase();\n default:\n return this.format.toLowerCase();\n }\n }\n\n /**\n */\n get inputFormat(): string {\n if (this.hasDate && this.hasTime) {\n return `${this.dateInputFormat} ${this.timeInputFormat}`.trim();\n }\n\n if (this.hasDate) {\n return this.dateInputFormat;\n }\n\n if (this.hasTime) {\n return this.timeInputFormat;\n }\n\n return \"\";\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n // setting for date input\n const ignoreFormatSetting = this.layouthint.has(IGNORE_FORMAT_SETTING);\n if (!ignoreFormatSetting) {\n const dateInputFormatSetting = getSetting(\"DATE_INPUT_FORMAT\", \"\");\n if (dateInputFormatSetting) {\n return dateInputFormatSetting;\n }\n }\n\n let format = this.format;\n\n let dateFormat = this.hasTime\n ? format.replace(this.timeInputFormat, \"\").trim()\n : format;\n\n return dateFormat;\n }\n\n /**\n */\n get dateReadonlyFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n let format = this.format;\n\n let dateFormat = this.hasTime\n ? format.replace(this.timeInputFormat, \"\").trim()\n : format;\n\n const readonlyFormatSetting = getSetting(\"DATE_READONLY_FORMAT\", \"\");\n\n if (dateFormat === PRODUCT_DEFAULT_DATE_FORMAT && readonlyFormatSetting) {\n dateFormat = readonlyFormatSetting;\n }\n\n return dateFormat;\n }\n\n /**\n * return attribute placeholder or, if DATE_INPUT_FORMAT setting is used, lowercased setting, otherwise return formatlabel without time input format from contributions\n */\n get placeholder(): string {\n if (this._placeholder !== \"\") {\n return this._placeholder;\n }\n\n const dateInputFormatSetting = getSetting(\"DATE_INPUT_FORMAT\", \"\");\n\n if (dateInputFormatSetting) {\n return dateInputFormatSetting.toLowerCase();\n }\n\n const formatLabel = this.getContribution(\"formatlabel\", \"\");\n\n if (this.hasDate && this.hasTime && formatLabel.includes(\" \")) {\n // return first part of formatlabel to keep placeholder matching date input\n return formatLabel.split(\" \")[0];\n }\n\n return formatLabel;\n }\n\n /**\n * Set placeholder text\n */\n set placeholder(placeholder: string) {\n this._placeholder = placeholder;\n }\n\n /**\n */\n get timeInputFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n const format = this.format;\n\n let timeFormatParts = [];\n if (format.includes(\"H\")) {\n timeFormatParts.push(\"HH\");\n } else if (format.includes(\"h\")) {\n timeFormatParts.push(\"hh\");\n }\n if (format.includes(\"m\")) {\n timeFormatParts.push(\"mm\");\n }\n if (format.includes(\"s\")) {\n timeFormatParts.push(\"ss\");\n }\n\n let timeFormat = timeFormatParts.join(\":\");\n if (format.includes(\"S\")) {\n timeFormat = `${timeFormat}.SSS`;\n }\n if (format.includes(\"a\")) {\n return `${timeFormat} a`;\n }\n return timeFormat;\n }\n\n /**\n */\n get timeReadonlyFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n return this.timeInputFormat;\n }\n\n /**\n */\n get dateInputValue(): string {\n return typeof this.value === \"string\" && this.dateInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.dateInputFormat)\n : \"\";\n }\n\n /**\n */\n get timeInputValue(): string {\n return typeof this.value === \"string\" && this.timeInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.timeInputFormat)\n : \"\";\n }\n\n // format value in readonly rendering\n /**\n */\n formatValue(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n // when the value is exactly an iso date, render as date\n if (\n (this.type === \"datetime\" || this.type === \"timestamp\") &&\n DateUtil.hasFormat(value, ISO_DATE_FORMAT)\n ) {\n return DateUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n if (this.hasDate && this.hasTime) {\n const dateTimeReadonlyFormat = `${this.dateReadonlyFormat} ${this.timeReadonlyFormat}`;\n return this.formatUtil.toFormat(value, dateTimeReadonlyFormat);\n }\n\n if (this.type === \"date\") {\n return this.formatUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n return this.formatUtil.toFormat(value, this.format);\n }\n\n /**\n * Retrieve readonly value, the date in the configurated format\n */\n get readonlyvalue(): string {\n if (typeof this.value === \"string\") {\n return this.formatValue(this.value.toString());\n }\n\n return \"\";\n }\n\n /**\n * Get minimum date\n */\n get mindate(): string | null {\n return this.getContribution(\"mindate\");\n }\n\n /**\n * Get maximum date\n */\n get maxdate(): string | null {\n return this.getContribution(\"maxdate\");\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 if (properties && has(properties, \"format\") && this.formatLabel) {\n properties.format = this.formatLabel;\n }\n\n this._errorCollection.addServerError(id, message, properties, layouthint);\n }\n\n /**\n */\n getFormatConstraint(): IConstraintModel {\n switch (this.type) {\n case \"date\":\n return new DateTimeDateFormatConstraint(\n this.dateInputFormat,\n this.formatLabel\n );\n case \"time\":\n return new DateTimeTimeFormatConstraint(\n this.timeInputFormat,\n this.formatLabel\n );\n default:\n return new DatetimeFormatConstraint(\n this.type,\n this.inputFormat,\n this.formatLabel\n );\n }\n }\n\n /**\n * Add Date constraints for attribute\n */\n addConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this.getFormatConstraint());\n\n if (this.mindate || this.maxdate) {\n constraints.add(\n new DateBoundaryConstraint(\n this.type,\n this.mindate,\n this.maxdate,\n this.inputFormat\n )\n );\n }\n\n return constraints;\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"date\" || this.type === \"time\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n}\n\nexport default DatetimeAttributeModel;\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,OAAO,IAAIqC,iCAAwB,CACjC,IAAI,CAAC1E,IAAI,EACT,IAAI,CAAC0B,WAAW,EAChB,IAAI,CAACW,WAAW,CACjB;IAAC;EAER;;EAEA;AACF;AACA;EACEsC,cAAc,GAAyB;IACrC,MAAMC,WAAW,GAAG,IAAIC,6BAAoB,EAAE;IAE9CD,WAAW,CAACE,GAAG,CAAC,IAAI,CAACP,mBAAmB,EAAE,CAAC;IAE3C,IAAI,IAAI,CAACR,OAAO,IAAI,IAAI,CAACC,OAAO,EAAE;MAChCY,WAAW,CAACE,GAAG,CACb,IAAIC,+BAAsB,CACxB,IAAI,CAAC/E,IAAI,EACT,IAAI,CAAC+D,OAAO,EACZ,IAAI,CAACC,OAAO,EACZ,IAAI,CAACtC,WAAW,CACjB,CACF;IACH;IAEA,OAAOkD,WAAW;EACpB;;EAEA;AACF;EACE,IAAII,aAAa,GAAkC;IACjD,IAAI,IAAI,CAAChF,IAAI,KAAK,MAAM,IAAI,IAAI,CAACA,IAAI,KAAK,MAAM,EAAE;MAChD,OAAOiF,0BAAe,CAACC,KAAK;IAC9B;IAEA,OAAOD,0BAAe,CAACE,MAAM;EAC/B;AACF;AAAC,eAEc3F,sBAAsB;AAAA"}
|
|
1
|
+
{"version":3,"file":"DatetimeAttributeModel.js","names":["DatetimeAttributeModel","StringAttributeModel","constructor","attribute","attributeContributions","updateInitValue","isApplicableModel","contributions","type","formatUtil","TimeUtil","TimestampUtil","DateTimeUtil","DateUtil","getInitValue","value","data","length","split","hasTime","getTimeValue","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","toFormat","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","toISO","format","convertFormat","operator","hasDate","formatLabel","dateInputFormat","replace","dateReadonlyFormat","placeholder","_placeholder","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","ISO_DATE_FORMAT","dateTimeReadonlyFormat","readonlyvalue","mindate","maxdate","addServerError","error","id","message","properties","layouthint","has","_errorCollection","getFormatConstraint","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","addConstraints","constraints","ConstraintCollection","add","DateBoundaryConstraint","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM"],"sources":["../../../src/models/attributes/DatetimeAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport {\n DateUtil,\n DateTimeUtil,\n TimeUtil,\n TimestampUtil,\n} from \"../../utils/datetime/DateTimeUtil\";\n\nimport StringAttributeModel from \"./StringAttributeModel\";\n\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport DateTimeDateFormatConstraint from \"./input-constraints/DateTimeDateFormatConstraint\";\nimport DateTimeTimeFormatConstraint from \"./input-constraints/DateTimeTimeFormatConstraint\";\nimport DatetimeFormatConstraint from \"./input-constraints/DatetimeFormatConstraint\";\nimport DateBoundaryConstraint from \"./input-constraints/DateBoundaryConstraint\";\n\nimport { ATTRIBUTE_WIDTH, ISO_DATE_FORMAT } from \"../../constants\";\n\nimport type { FormErrorAnchor, IConstraintModel } from \"../types\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n /**\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this.updateInitValue();\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return [\"date\", \"time\", \"datetime\", \"timestamp\"].includes(\n contributions.type\n );\n }\n\n /**\n */\n get formatUtil():\n | typeof TimeUtil\n | typeof TimestampUtil\n | typeof DateTimeUtil\n | typeof DateUtil {\n switch (this.type) {\n case \"time\":\n return TimeUtil;\n case \"timestamp\":\n return TimestampUtil;\n case \"datetime\":\n return DateTimeUtil;\n default:\n return DateUtil;\n }\n }\n\n /**\n */\n getInitValue(): string | null {\n let value = this.data.value;\n if (value != null) {\n if (this.type === \"time\" && value.length === 5) {\n value = `${value}:00`;\n }\n\n // handle old datetime values, which contained ms\n if (this.type === \"datetime\" && value.includes(\".\")) {\n value = value.split(\".\")[0];\n }\n\n if (this.hasTime) {\n value = this.getTimeValue(value);\n }\n }\n\n return value;\n }\n\n /**\n */\n getTimeValue(value: string): string {\n let timeValue = value;\n if (!this.timeInputFormat.toLowerCase().includes(\"h\")) {\n timeValue = this.formatUtil.setHour(value, 0);\n }\n if (!this.timeInputFormat.includes(\"m\")) {\n timeValue = this.formatUtil.setMinute(value, 0);\n }\n if (!this.timeInputFormat.includes(\"s\")) {\n timeValue = this.formatUtil.setSecond(value, 0);\n }\n if (this.type === \"timestamp\" && !this.timeInputFormat.includes(\"S\")) {\n timeValue = this.formatUtil.setMilliseconds(value, 0);\n }\n return timeValue;\n }\n\n /**\n * Set time in the correct value based on available elements in the time format\n */\n updateInitValue() {\n const value = this.getInitValue();\n if (value != null) {\n this._initvalue = value;\n this._inputvalue = this.getInitialInputValue(value);\n this._value = value;\n }\n }\n\n /**\n * Get initial user input value\n */\n getInitialInputValue(value?: string): string {\n if (!value) {\n return \"\";\n }\n\n let initValue = value;\n if (this.type === \"time\" && value.length === 5) {\n initValue = `${value}:00`;\n }\n\n return this.formatUtil.toFormat(initValue, this.inputFormat);\n }\n\n /**\n * Set type to date\n */\n get type(): string {\n return this.getContribution(\"type\", \"date\");\n }\n\n /**\n * Returns the value as entered by the user. This can differ from the internal iso value that is stored\n */\n getInputValue(): string {\n return this._inputvalue ? this._inputvalue.toString() : \"\";\n }\n\n /**\n * Get input value\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this.validate(value);\n\n this._inputvalue = value;\n\n this.value =\n value !== null && value !== \"\"\n ? this.formatUtil.toISO(value, this.inputFormat)\n : null;\n }\n\n /**\n * Get date format\n */\n get format(): string {\n const format = this.getContribution(\"format\", \"\");\n return this.formatUtil.convertFormat(format);\n }\n\n /**\n */\n get operator(): string {\n return this.getContribution(\"operator\", \"\");\n }\n\n /**\n */\n get hasDate(): boolean {\n return (\n this.type === \"date\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get hasTime(): boolean {\n return (\n this.type === \"time\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get formatLabel(): string {\n switch (this.type) {\n case \"date\":\n return this.dateInputFormat.toLowerCase();\n case \"time\":\n return this.timeInputFormat.toLowerCase();\n default:\n return this.format.toLowerCase();\n }\n }\n\n /**\n */\n get inputFormat(): string {\n if (this.hasDate && this.hasTime) {\n return `${this.dateInputFormat} ${this.timeInputFormat}`.trim();\n }\n\n if (this.hasDate) {\n return this.dateInputFormat;\n }\n\n if (this.hasTime) {\n return this.timeInputFormat;\n }\n\n return \"\";\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\n }\n\n /**\n */\n get dateReadonlyFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\n }\n\n /**\n * return attribute placeholder or return formatlabel without time input format from contributions\n */\n get placeholder(): string {\n if (this._placeholder !== \"\") {\n return this._placeholder;\n }\n\n const formatLabel = this.getContribution(\"formatlabel\", \"\");\n\n if (this.hasDate && this.hasTime && formatLabel.includes(\" \")) {\n // return first part of formatlabel to keep placeholder matching date input\n return formatLabel.split(\" \")[0];\n }\n\n return formatLabel;\n }\n\n /**\n * Set placeholder text\n */\n set placeholder(placeholder: string) {\n this._placeholder = placeholder;\n }\n\n /**\n */\n get timeInputFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n const format = this.format;\n\n let timeFormatParts = [];\n if (format.includes(\"H\")) {\n timeFormatParts.push(\"HH\");\n } else if (format.includes(\"h\")) {\n timeFormatParts.push(\"hh\");\n }\n if (format.includes(\"m\")) {\n timeFormatParts.push(\"mm\");\n }\n if (format.includes(\"s\")) {\n timeFormatParts.push(\"ss\");\n }\n\n let timeFormat = timeFormatParts.join(\":\");\n if (format.includes(\"S\")) {\n timeFormat = `${timeFormat}.SSS`;\n }\n if (format.includes(\"a\")) {\n return `${timeFormat} a`;\n }\n return timeFormat;\n }\n\n /**\n */\n get timeReadonlyFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n return this.timeInputFormat;\n }\n\n /**\n */\n get dateInputValue(): string {\n return typeof this.value === \"string\" && this.dateInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.dateInputFormat)\n : \"\";\n }\n\n /**\n */\n get timeInputValue(): string {\n return typeof this.value === \"string\" && this.timeInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.timeInputFormat)\n : \"\";\n }\n\n // format value in readonly rendering\n /**\n */\n formatValue(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n // when the value is exactly an iso date, render as date\n if (\n (this.type === \"datetime\" || this.type === \"timestamp\") &&\n DateUtil.hasFormat(value, ISO_DATE_FORMAT)\n ) {\n return DateUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n if (this.hasDate && this.hasTime) {\n const dateTimeReadonlyFormat = `${this.dateReadonlyFormat} ${this.timeReadonlyFormat}`;\n return this.formatUtil.toFormat(value, dateTimeReadonlyFormat);\n }\n\n if (this.type === \"date\") {\n return this.formatUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n return this.formatUtil.toFormat(value, this.format);\n }\n\n /**\n * Retrieve readonly value, the date in the configurated format\n */\n get readonlyvalue(): string {\n if (typeof this.value === \"string\") {\n return this.formatValue(this.value.toString());\n }\n\n return \"\";\n }\n\n /**\n * Get minimum date\n */\n get mindate(): string | null {\n return this.getContribution(\"mindate\");\n }\n\n /**\n * Get maximum date\n */\n get maxdate(): string | null {\n return this.getContribution(\"maxdate\");\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 if (properties && has(properties, \"format\") && this.formatLabel) {\n properties.format = this.formatLabel;\n }\n\n this._errorCollection.addServerError(id, message, properties, layouthint);\n }\n\n /**\n */\n getFormatConstraint(): IConstraintModel {\n switch (this.type) {\n case \"date\":\n return new DateTimeDateFormatConstraint(\n this.dateInputFormat,\n this.formatLabel\n );\n case \"time\":\n return new DateTimeTimeFormatConstraint(\n this.timeInputFormat,\n this.formatLabel\n );\n default:\n return new DatetimeFormatConstraint(\n this.type,\n this.inputFormat,\n this.formatLabel\n );\n }\n }\n\n /**\n * Add Date constraints for attribute\n */\n addConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this.getFormatConstraint());\n\n if (this.mindate || this.maxdate) {\n constraints.add(\n new DateBoundaryConstraint(\n this.type,\n this.mindate,\n this.maxdate,\n this.inputFormat\n )\n );\n }\n\n return constraints;\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"date\" || this.type === \"time\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n}\n\nexport default DatetimeAttributeModel;\n"],"mappings":";;;;;;;;;AACA;AAEA;AAOA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAIA;AACA;AACA,MAAMA,sBAAsB,SAASC,6BAAoB,CAAC;EACxD;AACF;EACEC,WAAW,CAACC,SAAiB,EAAEC,sBAA8B,EAAE;IAC7D,KAAK,CAACD,SAAS,EAAEC,sBAAsB,CAAC;IAExC,IAAI,CAACC,eAAe,EAAE;EACxB;;EAEA;AACF;EACE,OAAOC,iBAAiB,CAACC,aAAqB,EAAW;IAAA;IACvD,OAAO,mCAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,iBAC9CA,aAAa,CAACC,IAAI,CACnB;EACH;;EAEA;AACF;EACE,IAAIC,UAAU,GAIM;IAClB,QAAQ,I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OAAO,IAAI+B,iCAAwB,CACjC,IAAI,CAACpE,IAAI,EACT,IAAI,CAAC0B,WAAW,EAChB,IAAI,CAACW,WAAW,CACjB;IAAC;EAER;;EAEA;AACF;AACA;EACEgC,cAAc,GAAyB;IACrC,MAAMC,WAAW,GAAG,IAAIC,6BAAoB,EAAE;IAE9CD,WAAW,CAACE,GAAG,CAAC,IAAI,CAACP,mBAAmB,EAAE,CAAC;IAE3C,IAAI,IAAI,CAACV,OAAO,IAAI,IAAI,CAACC,OAAO,EAAE;MAChCc,WAAW,CAACE,GAAG,CACb,IAAIC,+BAAsB,CACxB,IAAI,CAACzE,IAAI,EACT,IAAI,CAACuD,OAAO,EACZ,IAAI,CAACC,OAAO,EACZ,IAAI,CAAC9B,WAAW,CACjB,CACF;IACH;IAEA,OAAO4C,WAAW;EACpB;;EAEA;AACF;EACE,IAAII,aAAa,GAAkC;IACjD,IAAI,IAAI,CAAC1E,IAAI,KAAK,MAAM,IAAI,IAAI,CAACA,IAAI,KAAK,MAAM,EAAE;MAChD,OAAO2E,0BAAe,CAACC,KAAK;IAC9B;IAEA,OAAOD,0BAAe,CAACE,MAAM;EAC/B;AACF;AAAC,eAEcrF,sBAAsB;AAAA"}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import DatetimeAttributeModel from "../DatetimeAttributeModel";
|
|
2
|
-
import { setSettings } from "../../../constants/Settings";
|
|
3
2
|
|
|
4
3
|
describe("dateAttributeModel", () => {
|
|
5
4
|
describe("with date related settings set", () => {
|
|
6
|
-
beforeAll(() => {
|
|
7
|
-
setSettings({ DATE_INPUT_FORMAT: "dd-MM-yyyy" });
|
|
8
|
-
setSettings({ DATE_READONLY_FORMAT: "dd-MM-yyyy" });
|
|
9
|
-
});
|
|
10
5
|
it("should be able to create an empty Attribute object", () => {
|
|
11
6
|
const attribute = new DatetimeAttributeModel();
|
|
12
7
|
|
|
@@ -51,7 +46,7 @@ describe("dateAttributeModel", () => {
|
|
|
51
46
|
|
|
52
47
|
it("can set input", () => {
|
|
53
48
|
const attribute = new DatetimeAttributeModel({});
|
|
54
|
-
attribute.inputvalue = "
|
|
49
|
+
attribute.inputvalue = "2010-12-10";
|
|
55
50
|
|
|
56
51
|
expect(attribute.readonlyvalue).toBe("2010-12-10");
|
|
57
52
|
|
|
@@ -65,36 +60,7 @@ describe("dateAttributeModel", () => {
|
|
|
65
60
|
});
|
|
66
61
|
});
|
|
67
62
|
|
|
68
|
-
describe("with non default date related settings configured", () => {
|
|
69
|
-
beforeAll(() => {
|
|
70
|
-
setSettings({ DATE_INPUT_FORMAT: "MM/dd/yyyy" });
|
|
71
|
-
setSettings({ DATE_READONLY_FORMAT: "mm/dd/yyyy" });
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("returns the right date formats", () => {
|
|
75
|
-
const attribute = new DatetimeAttributeModel(
|
|
76
|
-
{},
|
|
77
|
-
{
|
|
78
|
-
label: "Date of birth",
|
|
79
|
-
type: "date",
|
|
80
|
-
format: "dd-MM-yyyy",
|
|
81
|
-
formatlabel: "dd-mm-yyyy",
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
// expect date input and readonly format to match the settings
|
|
86
|
-
expect(attribute.format).toBe("dd-MM-yyyy");
|
|
87
|
-
expect(attribute.dateInputFormat).toBe("MM/dd/yyyy");
|
|
88
|
-
expect(attribute.dateReadonlyFormat).toBe("mm/dd/yyyy");
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
63
|
describe("without date input and date readonly settings defined", () => {
|
|
93
|
-
beforeAll(() => {
|
|
94
|
-
// explicitly clear setting
|
|
95
|
-
setSettings({ DATE_INPUT_FORMAT: "" });
|
|
96
|
-
setSettings({ DATE_READONLY_FORMAT: "" });
|
|
97
|
-
});
|
|
98
64
|
it("should be able to return contributions format as date input format", () => {
|
|
99
65
|
const attribute = new DatetimeAttributeModel(
|
|
100
66
|
{},
|