@beinformed/ui 1.17.2 → 1.18.1
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 +22 -2
- package/esm/constants/Constants.js +4 -0
- package/esm/constants/Constants.js.map +1 -1
- package/esm/constants/Settings.js +25 -1
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useForm.js +1 -11
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/i18n/Locale.js +2 -1
- package/esm/i18n/Locale.js.map +1 -1
- package/esm/models/attributes/AttributeContent.js +2 -0
- package/esm/models/attributes/AttributeContent.js.map +1 -1
- package/esm/models/content/SectionModel.js +2 -0
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/modularui/Authenticate.js +9 -9
- package/esm/modularui/Authenticate.js.map +1 -1
- package/esm/react-client/client.js +3 -2
- package/esm/react-client/client.js.map +1 -1
- package/esm/react-server/serverUtil.js +2 -1
- package/esm/react-server/serverUtil.js.map +1 -1
- package/esm/redux/actions/FormAttributeSet.js +5 -11
- package/esm/redux/actions/FormAttributeSet.js.map +1 -1
- package/esm/redux/actions/Preferences.js +32 -2
- package/esm/redux/actions/Preferences.js.map +1 -1
- package/esm/redux/reducers/PreferencesReducer.js +5 -1
- package/esm/redux/reducers/PreferencesReducer.js.map +1 -1
- package/lib/constants/Constants.js +9 -1
- package/lib/constants/Constants.js.flow +5 -0
- package/lib/constants/Constants.js.map +1 -1
- package/lib/constants/Settings.js +37 -1
- package/lib/constants/Settings.js.flow +25 -1
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/useForm.js +2 -15
- package/lib/hooks/useForm.js.flow +0 -10
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/i18n/Locale.js +2 -1
- package/lib/i18n/Locale.js.flow +4 -2
- package/lib/i18n/Locale.js.map +1 -1
- package/lib/i18n/__tests__/Locale.spec.js.flow +3 -2
- package/lib/models/attributes/AttributeContent.js +2 -0
- package/lib/models/attributes/AttributeContent.js.flow +2 -0
- package/lib/models/attributes/AttributeContent.js.map +1 -1
- package/lib/models/content/SectionModel.js +2 -0
- package/lib/models/content/SectionModel.js.flow +2 -0
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/modularui/Authenticate.js +10 -10
- package/lib/modularui/Authenticate.js.flow +11 -7
- package/lib/modularui/Authenticate.js.map +1 -1
- package/lib/react-client/client.js +2 -1
- package/lib/react-client/client.js.flow +5 -1
- package/lib/react-client/client.js.map +1 -1
- package/lib/react-server/__tests__/serverUtil.spec.js.flow +18 -0
- package/lib/react-server/serverUtil.js +1 -0
- package/lib/react-server/serverUtil.js.flow +2 -0
- package/lib/react-server/serverUtil.js.map +1 -1
- package/lib/redux/actions/FormAttributeSet.js +6 -15
- package/lib/redux/actions/FormAttributeSet.js.flow +3 -16
- package/lib/redux/actions/FormAttributeSet.js.map +1 -1
- package/lib/redux/actions/Preferences.js +41 -1
- package/lib/redux/actions/Preferences.js.flow +49 -2
- package/lib/redux/actions/Preferences.js.map +1 -1
- package/lib/redux/actions/__tests__/Preferences.spec.js.flow +11 -0
- package/lib/redux/reducers/PreferencesReducer.js +5 -1
- package/lib/redux/reducers/PreferencesReducer.js.flow +8 -1
- package/lib/redux/reducers/PreferencesReducer.js.map +1 -1
- package/lib/redux/reducers/__tests__/PreferencesReducer.spec.js.flow +12 -0
- package/lib/redux/types.js.flow +5 -0
- package/package.json +26 -24
- package/src/constants/Constants.js +5 -0
- package/src/constants/Settings.js +25 -1
- package/src/hooks/useForm.js +0 -10
- package/src/i18n/Locale.js +4 -2
- package/src/i18n/__tests__/Locale.spec.js +3 -2
- package/src/models/attributes/AttributeContent.js +2 -0
- package/src/models/content/SectionModel.js +2 -0
- package/src/modularui/Authenticate.js +11 -7
- package/src/react-client/client.js +5 -1
- package/src/react-server/__tests__/serverUtil.spec.js +18 -0
- package/src/react-server/serverUtil.js +2 -0
- package/src/redux/actions/FormAttributeSet.js +3 -16
- package/src/redux/actions/Preferences.js +49 -2
- package/src/redux/actions/__tests__/Preferences.spec.js +11 -0
- package/src/redux/reducers/PreferencesReducer.js +8 -1
- package/src/redux/reducers/__tests__/PreferencesReducer.spec.js +12 -0
- package/src/redux/types.js +5 -0
package/lib/i18n/Locale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i18n/Locale.js"],"names":["Locale","locale","_code","code","_messages","fixPlaceHoldersInObject","messages","_errors","errors","_nativeName","nativeName","formatMessage","setup","missingTranslation","aLocale","split","length","language","languages","lang","toUpperCase","IllegalStateException","message","replace","JSON","parse","id","defaultMessage","messageFromLocale","process","env","NODE_ENV","console","
|
|
1
|
+
{"version":3,"sources":["../../src/i18n/Locale.js"],"names":["Locale","locale","_code","code","_messages","fixPlaceHoldersInObject","messages","_errors","errors","_nativeName","nativeName","formatMessage","setup","missingTranslation","aLocale","split","length","language","languages","lang","toUpperCase","IllegalStateException","message","replace","JSON","parse","id","defaultMessage","messageFromLocale","process","env","NODE_ENV","console","debug","fixPlaceHolders","parameters","getBaseMessage"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;;;;;;;AAIA;AACA;AACA;IACMA,M;AAMJ,kBAAYC,MAAZ,EAAyC;AAAA;AAAA;AAAA;AAAA;AAAA;AACvC,SAAKC,KAAL,GAAaD,MAAM,CAACE,IAApB;AAEA,SAAKC,SAAL,GAAiB,KAAKC,uBAAL,CAA6BJ,MAAM,CAACK,QAApC,CAAjB;AACA,SAAKC,OAAL,GAAe,KAAKF,uBAAL,CAA6BJ,MAAM,CAACO,MAApC,CAAf;AAEA,SAAKC,WAAL,GAAmBR,MAAM,CAACS,UAA1B;;AAEAC,4BAAcC,KAAd,CAAoB;AAClBC,MAAAA,kBAAkB,EAAE;AADF,KAApB;AAGD;AAED;AACF;AACA;;;;;SACE,eAAmB;AACjB,aAAO,KAAKX,KAAZ;AACD;AAED;AACF;AACA;;;;SACE,eAAyB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KnB,OAAL,CAAamB,EAAb,CAAhD;;AAEA,UACE,CAAC,OAAOG,OAAP,KAAmB,WAAnB,IACCA,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAD3B,KAEA,CAACH,iBAFD,IAGAF,EAHA,IAIA,2BAAW,8BAAX,CALF,EAME;AAAA;;AACA;AACAM,QAAAA,OAAO,CAACC,KAAR,2DACqBP,EADrB,4CACgD,KAAKvB,IADrD;AAGD;;AACD,aAAOyB,iBAAiB,IAAI,KAAKM,eAAL,CAAqBP,cAArB,CAArB,IAA6DD,EAApE;AACD;AAED;AACF;AACA;;;;WACE,uBAAcJ,OAAd,EAA+Ba,UAA/B,EAAuE;AACrE,UAAIA,UAAJ,EAAgB;AACd,eAAO,6BAAcb,OAAd,EAAuBa,UAAvB,CAAP;AACD;;AAED,aAAOb,OAAP;AACD;AAED;AACF;AACA;;;;WACE,oBACEI,EADF,EAEEC,cAFF,EAGEQ,UAHF,EAIU;AACR,UAAMb,OAAO,GAAG,KAAKc,cAAL,CAAoBV,EAApB,EAAwBC,cAAxB,CAAhB;AACA,aAAO,KAAKhB,aAAL,CAAmBW,OAAnB,EAA4Ba,UAA5B,CAAP;AACD;AAED;AACF;AACA;;;;WACE,kBAAmD;AAAA,UAA5C7B,QAA4C,uEAAzB,EAAyB;AAAA,UAArBE,MAAqB,uEAAJ,EAAI;AACjD,WAAKJ,SAAL,mCACK,KAAKA,SADV,GAEK,KAAKC,uBAAL,CAA6BC,QAA7B,CAFL;AAKA,WAAKC,OAAL,mCACK,KAAKA,OADV,GAEK,KAAKF,uBAAL,CAA6BG,MAA7B,CAFL;AAID;;;;;eAGYR,M","sourcesContent":["// @flow\nimport formatMessage from \"format-message\";\n\nimport languages from \"./languages\";\nimport { IllegalStateException } from \"../exceptions\";\n\nimport { getSetting } from \"../constants\";\n\nimport type { LocaleConfiguration, MessageParameters } from \"./types\";\n\n/**\n * Create a locale\n */\nclass Locale {\n _code: string;\n _messages: { [string]: string };\n _errors: { [string]: string };\n _nativeName: ?string;\n\n constructor(locale: LocaleConfiguration) {\n this._code = locale.code;\n\n this._messages = this.fixPlaceHoldersInObject(locale.messages);\n this._errors = this.fixPlaceHoldersInObject(locale.errors);\n\n this._nativeName = locale.nativeName;\n\n formatMessage.setup({\n missingTranslation: \"ignore\",\n });\n }\n\n /**\n * Retrieve locale code\n */\n get code(): string {\n return this._code;\n }\n\n /**\n * Retrieve nativeName\n */\n get nativeName(): string {\n if (this._nativeName) {\n return this._nativeName;\n }\n\n const aLocale = this.code.split(\"-\");\n\n if (aLocale.length > 0) {\n const language = languages.lang[aLocale[0]];\n\n if (language) {\n return (\n language[1] + (aLocale[1] ? ` (${aLocale[1].toUpperCase()})` : \"\")\n );\n }\n }\n\n throw new IllegalStateException(\n `Can not find language name based on locale: ${this.code}`\n );\n }\n\n /**\n * Exported messages from Be Informed have placeholders in the syntax ${placeholder_name}\n * where the ICU messageformat module uses {placeholder_name}.\n * This method converts the ${} to {}\n */\n fixPlaceHolders(message: ?string): null | string {\n if (typeof message === \"string\") {\n return message\n .replace(/'\\$\\{(?<key>.*?)}'/g, \"''{$<key>}''\")\n .replace(/\\$\\{(?<key>.*?)}/g, \"{$<key>}\");\n }\n\n return null;\n }\n\n /**\n * Exported messages from Be Informed have placeholders in the syntax ${placeholder_name}\n * where the ICU messageformat module uses {placeholder_name}.\n * This method converts the ${} to {}\n */\n fixPlaceHoldersInObject(messages: Object = {}): Object {\n return JSON.parse(\n JSON.stringify(messages)\n .replace(/'\\$\\{(?<key>.*?)}'/g, \"''{$<key>}''\")\n .replace(/\\$\\{(?<key>.*?)}/g, \"{$<key>}\")\n );\n }\n\n /**\n * Retrieve message by id\n */\n getBaseMessage(id: string, defaultMessage?: string): string {\n if (!id && !defaultMessage) {\n return \"[message: id or defaultMessage missing]\";\n }\n\n const messageFromLocale = this._messages[id] || this._errors[id];\n\n if (\n (typeof process === \"undefined\" ||\n process.env.NODE_ENV !== \"production\") &&\n !messageFromLocale &&\n id &&\n getSetting(\"DEBUG_I18N_MESSAGE_NOT_FOUND\")\n ) {\n // eslint-disable-next-line no-console\n console.debug(\n `Message with id ${id} not found for locale ${this.code} in layout translations`\n );\n }\n return messageFromLocale || this.fixPlaceHolders(defaultMessage) || id;\n }\n\n /**\n * Format message using formatMessage library\n */\n formatMessage(message: string, parameters?: MessageParameters): string {\n if (parameters) {\n return formatMessage(message, parameters);\n }\n\n return message;\n }\n\n /**\n * Retrieve a messages with replaced parameters\n */\n getMessage(\n id: string,\n defaultMessage?: string,\n parameters?: MessageParameters\n ): string {\n const message = this.getBaseMessage(id, defaultMessage);\n return this.formatMessage(message, parameters);\n }\n\n /**\n * Add or change messages for this locale. It is not possible to remove messages.\n */\n update(messages: Object = {}, errors: Object = {}) {\n this._messages = {\n ...this._messages,\n ...this.fixPlaceHoldersInObject(messages),\n };\n\n this._errors = {\n ...this._errors,\n ...this.fixPlaceHoldersInObject(errors),\n };\n }\n}\n\nexport default Locale;\n"],"file":"Locale.js"}
|
|
@@ -6,6 +6,7 @@ import { setSetting } from "../../constants";
|
|
|
6
6
|
|
|
7
7
|
global.console = {
|
|
8
8
|
warn: jest.fn(),
|
|
9
|
+
debug: jest.fn(),
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
jest.mock(
|
|
@@ -89,8 +90,8 @@ describe("locale", () => {
|
|
|
89
90
|
|
|
90
91
|
const msg = locale.getMessage("non-existing");
|
|
91
92
|
expect(msg).toBe("non-existing");
|
|
92
|
-
expect(global.console.
|
|
93
|
-
"Message with id non-existing not found for locale de"
|
|
93
|
+
expect(global.console.debug).toHaveBeenCalledWith(
|
|
94
|
+
"Message with id non-existing not found for locale de in layout translations"
|
|
94
95
|
);
|
|
95
96
|
|
|
96
97
|
const msgWithDefault = locale.getMessage("non-existing", "Default");
|
|
@@ -61,6 +61,8 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
|
61
61
|
|
|
62
62
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
*/
|
|
64
66
|
var AttributeContent = /*#__PURE__*/function () {
|
|
65
67
|
function AttributeContent(content) {
|
|
66
68
|
(0, _classCallCheck2.default)(this, AttributeContent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/attributes/AttributeContent.js"],"names":["AttributeContent","content","_content","headerLabel","headerDescription","label","header","description","message","elements","element","propertyElement","layouthint","properties","LayoutHintCollection","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","SectionModel","elementName","collectionName","getContentElements","labels","getContentElementCollections","getContentElementCollectionByLabels","types","type","referredSections","push","getReferredSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;IAaMA,gB;AAGJ,4BAAYC,OAAZ,EAAmC;AAAA;AAAA;AACjC,SAAKC,QAAL,GAAgBD,OAAhB;AACD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,oCAAP;AACD;AAED;AACF;;;;SACE,eAGE;AAAA;;AACA,UAAIE,WAAW,GAAG,IAAlB;AACA,UAAIC,iBAAiB,GAAG,IAAxB;AAEA,UAAMC,KAAK,qBAAG,KAAKH,QAAR,4EAAG,eAAeI,MAAlB,0DAAG,sBAAuBD,KAArC;;AACA,UAAIA,KAAJ,EAAW;AACTF,QAAAA,WAAW,GAAGE,KAAd;AACD;;AAED,UAAME,WAAW,sBAAG,KAAKL,QAAR,6EAAG,gBAAeI,MAAlB,0DAAG,sBAAuBC,WAA3C;;AACA,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AzB;;AAD2D,iDAGrC,KAAKX,QAHgC;AAAA;;AAAA;AAG3D,4DAAqC;AAAA,cAA1BC,OAA0B;AACnCU,UAAAA,gBAAgB,CAACC,IAAjB,OAAAD,gBAAgB,mCAASV,OAAO,CAACY,mBAAR,EAAT,EAAhB;AACD;AAL0D;AAAA;AAAA;AAAA;AAAA;;AAO3D,aAAOF,gBAAP;AACD;;;;;eAGY/B,gB","sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nimport type {\n ContentData,\n ContentElementMapped,\n PropertyData,\n PropertyElementMapped,\n TextFragmentData,\n TextFragmentElementMapped,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\n\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements?.map((element) => {\n if (element.propertyElement) {\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (element.textFragmentElement) {\n const { label, layouthint, textfragments } =\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (element.contentElement) {\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null)\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string): Array<T> {\n // $FlowIssue incompatible-return\n return this.elements.filter((element) => elementName in element);\n }\n\n /**\n */\n getContentElementCollections<T>(\n elementName: string,\n collectionName: string\n ): Array<T> {\n return this.getContentElements(elementName)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n getContentElementCollectionByLabels<T, U>(\n elementName: string,\n collectionName: string,\n labels: Array<string>\n ): Array<U> {\n return (\n this.getContentElements<T>(elementName)\n // $FlowIssue incompatible-use\n .filter((element) => labels.includes(element[elementName].label))\n // $FlowIssue incompatible-use\n .map((element) => element[elementName][collectionName])\n .flat()\n );\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElementCollections<PropertyData>(\n \"propertyElement\",\n \"properties\"\n );\n }\n\n /**\n * Get concept properties by property element label\n */\n getConceptPropertiesByLabels(labels: Array<string>): Array<PropertyData> {\n return this.getContentElementCollectionByLabels<\n PropertyElementMapped,\n PropertyData\n >(\"propertyElement\", \"properties\", labels);\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElementCollections<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\"\n );\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getTextFragmentsByLabels(labels: Array<string>): Array<TextFragmentData> {\n return this.getContentElementCollectionByLabels<\n TextFragmentElementMapped,\n TextFragmentData\n >(\"textFragmentElement\", \"textfragments\", labels);\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElementCollections<SectionModel>(\n \"contentElement\",\n \"sections\"\n );\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getSectionsByLabels(labels: Array<string>): Array<SectionModel> {\n return this.getContentElementCollectionByLabels<\n ContentElementMapped,\n SectionModel\n >(\"contentElement\", \"sections\", labels);\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"file":"AttributeContent.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/models/attributes/AttributeContent.js"],"names":["AttributeContent","content","_content","headerLabel","headerDescription","label","header","description","message","elements","element","propertyElement","layouthint","properties","LayoutHintCollection","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","SectionModel","elementName","collectionName","getContentElements","labels","getContentElementCollections","getContentElementCollectionByLabels","types","type","referredSections","push","getReferredSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;AAaA;AACA;IACMA,gB;AAGJ,4BAAYC,OAAZ,EAAmC;AAAA;AAAA;AACjC,SAAKC,QAAL,GAAgBD,OAAhB;AACD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,oCAAP;AACD;AAED;AACF;;;;SACE,eAGE;AAAA;;AACA,UAAIE,WAAW,GAAG,IAAlB;AACA,UAAIC,iBAAiB,GAAG,IAAxB;AAEA,UAAMC,KAAK,qBAAG,KAAKH,QAAR,4EAAG,eAAeI,MAAlB,0DAAG,sBAAuBD,KAArC;;AACA,UAAIA,KAAJ,EAAW;AACTF,QAAAA,WAAW,GAAGE,KAAd;AACD;;AAED,UAAME,WAAW,sBAAG,KAAKL,QAAR,6EAAG,gBAAeI,MAAlB,0DAAG,sBAAuBC,WAA3C;;AACA,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AzB;;AAD2D,iDAGrC,KAAKX,QAHgC;AAAA;;AAAA;AAG3D,4DAAqC;AAAA,cAA1BC,OAA0B;AACnCU,UAAAA,gBAAgB,CAACC,IAAjB,OAAAD,gBAAgB,mCAASV,OAAO,CAACY,mBAAR,EAAT,EAAhB;AACD;AAL0D;AAAA;AAAA;AAAA;AAAA;;AAO3D,aAAOF,gBAAP;AACD;;;;;eAGY/B,gB","sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nimport type {\n ContentData,\n ContentElementMapped,\n PropertyData,\n PropertyElementMapped,\n TextFragmentData,\n TextFragmentElementMapped,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\n\n/**\n */\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements?.map((element) => {\n if (element.propertyElement) {\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (element.textFragmentElement) {\n const { label, layouthint, textfragments } =\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (element.contentElement) {\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null)\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string): Array<T> {\n // $FlowIssue incompatible-return\n return this.elements.filter((element) => elementName in element);\n }\n\n /**\n */\n getContentElementCollections<T>(\n elementName: string,\n collectionName: string\n ): Array<T> {\n return this.getContentElements(elementName)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n getContentElementCollectionByLabels<T, U>(\n elementName: string,\n collectionName: string,\n labels: Array<string>\n ): Array<U> {\n return (\n this.getContentElements<T>(elementName)\n // $FlowIssue incompatible-use\n .filter((element) => labels.includes(element[elementName].label))\n // $FlowIssue incompatible-use\n .map((element) => element[elementName][collectionName])\n .flat()\n );\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElementCollections<PropertyData>(\n \"propertyElement\",\n \"properties\"\n );\n }\n\n /**\n * Get concept properties by property element label\n */\n getConceptPropertiesByLabels(labels: Array<string>): Array<PropertyData> {\n return this.getContentElementCollectionByLabels<\n PropertyElementMapped,\n PropertyData\n >(\"propertyElement\", \"properties\", labels);\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElementCollections<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\"\n );\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getTextFragmentsByLabels(labels: Array<string>): Array<TextFragmentData> {\n return this.getContentElementCollectionByLabels<\n TextFragmentElementMapped,\n TextFragmentData\n >(\"textFragmentElement\", \"textfragments\", labels);\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElementCollections<SectionModel>(\n \"contentElement\",\n \"sections\"\n );\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getSectionsByLabels(labels: Array<string>): Array<SectionModel> {\n return this.getContentElementCollectionByLabels<\n ContentElementMapped,\n SectionModel\n >(\"contentElement\", \"sections\", labels);\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"file":"AttributeContent.js"}
|
|
@@ -59,6 +59,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
59
59
|
|
|
60
60
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
*/
|
|
62
64
|
var SectionModel = /*#__PURE__*/function (_BaseModel) {
|
|
63
65
|
(0, _inherits2.default)(SectionModel, _BaseModel);
|
|
64
66
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/content/SectionModel.js"],"names":["SectionModel","data","entryDate","_entryDate","referred","_selflink","LinkModel","_links","self","selflink","href","type","sourceLabel","id","_id","getData","number","body","childSections","childSection","ContentLinkModel","section","label","_childSections","sections","subSections","subSection","SubSectionModel","selfhref","push","referredChilds","getReferredSections","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAGA;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/models/content/SectionModel.js"],"names":["SectionModel","data","entryDate","_entryDate","referred","_selflink","LinkModel","_links","self","selflink","href","type","sourceLabel","id","_id","getData","number","body","childSections","childSection","ContentLinkModel","section","label","_childSections","sections","subSections","subSection","SubSectionModel","selfhref","push","referredChilds","getReferredSections","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAGA;;;;;;;;;;;;AAEA;AACA;IACMA,Y;;;;;AAKJ,wBAAYC,IAAZ,EAA0BC,SAA1B,EAAsD;AAAA;;AAAA;AACpD,8BAAMD,IAAN,EAAY,EAAZ;AADoD;AAAA;AAAA;AAGpD,UAAKE,UAAL,GAAkBD,SAAlB;AAHoD;AAIrD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,KAAKD,IAAL,CAAUG,QAAjB;AACD;AAED;AACF;;;;SACE,eAA0B;AACxB,UAAI,CAAC,KAAKC,SAAV,EAAqB;AAAA;;AACnB,aAAKA,SAAL,GAAiB,IAAIC,kBAAJ,sBAAc,KAAKL,IAAL,CAAUM,MAAxB,sDAAc,kBAAkBC,IAAhC,CAAjB;AACD;;AACD,aAAO,KAAKH,SAAZ;AACD;AAED;AACF;;;;SACE,eAAqB;AACnB,aAAO,KAAKI,QAAL,CAAcC,IAArB;AACD;AAED;AACF;;;;SACE,eAAiC;AAC/B,aAAO,KAAKP,UAAZ;AACD;AAED;AACF;;;;SACE,eAAmB;AACjB,aAAO,KAAKF,IAAL,CAAUU,IAAjB;AACD;AAED;AACF;;;;SACE,eAA0B;AACxB,aAAO,KAAKV,IAAL,CAAUW,WAAjB;AACD;AAED;AACF;;;;SACE,eAAiB;AACf,aAAO,KAAKX,IAAL,CAAUY,EAAV,IAAgB,KAAKZ,IAAL,CAAUa,GAAjC;AACD;AAED;AACF;;;;SACE,eAAkB;AAChB,aAAO,KAAKD,EAAZ;AACD;AAED;AACF;AACA;;;;SACE,eAAoB;AAClB,aAAO,KAAKE,OAAL,CAAa,OAAb,EAAsB,EAAtB,CAAP;AACD;AAED;AAC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AP,UAAAA,QAAQ,CAACK,IAAT,OAAAL,QAAQ,mCAASM,eAAT,EAAR;AACD;AAnB0D;AAAA;AAAA;AAAA;AAAA;;AAqB3D,aAAON,QAAP;AACD;;;EAnLwBQ,mB;;eAsLZhC,Y","sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport SubSectionModel from \"./SubSectionModel\";\n\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\nimport LinkModel from \"../links/LinkModel\";\n\nimport type Href from \"../href/Href\";\nimport { retrieveText } from \"../../utils\";\n\n/**\n */\nclass SectionModel extends BaseModel {\n _entryDate: ISO_DATE | null;\n _selflink: ?LinkModel;\n _childSections: Array<SectionModel>;\n\n constructor(data: Object, entryDate: ISO_DATE | null) {\n super(data, {});\n\n this._entryDate = entryDate;\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get selflink(): LinkModel {\n if (!this._selflink) {\n this._selflink = new LinkModel(this.data._links?.self);\n }\n return this._selflink;\n }\n\n /**\n */\n get selfhref(): Href {\n return this.selflink.href;\n }\n\n /**\n */\n get entryDate(): ISO_DATE | null {\n return this._entryDate;\n }\n\n /**\n */\n get type(): string {\n return this.data.type;\n }\n\n /**\n */\n get sourceLabel(): string {\n return this.data.sourceLabel;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n */\n get key(): string {\n return this.id;\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Get content body\n */\n get body(): ?string {\n return retrieveText(this.data.body);\n }\n\n /**\n * Retrieve child section links\n */\n get childSectionLinks(): Array<ContentLinkModel> {\n return this.data.childSections\n ? this.data.childSections.map(\n (childSection) =>\n new ContentLinkModel(\n {\n section: childSection.id || childSection._id,\n _id: childSection.id || childSection._id,\n label: childSection.label,\n sourceLabel: childSection.sourceLabel,\n _links: childSection._links,\n },\n this.entryDate\n )\n )\n : [];\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(\n {\n section: this.id,\n _id: this.id,\n label: this.data.label,\n sourceLabel: this.data.sourceLabel,\n _links: this.data._links,\n },\n this.entryDate\n );\n }\n\n /**\n * Get tree of child sections\n */\n get childSections(): Array<SectionModel> {\n if (!this._childSections && this.data.childSections) {\n this._childSections = this.data.childSections\n .filter((childSection) => \"body\" in childSection)\n .map((childSection) => new SectionModel(childSection, this.entryDate));\n }\n return this._childSections || [];\n }\n\n /**\n * set resolved child sections\n */\n set childSections(sections: Array<SectionModel>) {\n this._childSections = sections || [];\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection)\n )\n : [];\n }\n\n /**\n */\n get referenceHash(): number {\n return createHashFromHref(this.selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel | SectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n for (const childSection of this.childSections) {\n if (childSection.referred) {\n sections.push(childSection);\n }\n\n const referredChilds = childSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n\nexport default SectionModel;\n"],"file":"SectionModel.js"}
|
|
@@ -25,13 +25,10 @@ var _Cache = _interopRequireDefault(require("../utils/browser/Cache"));
|
|
|
25
25
|
|
|
26
26
|
var _exceptions = require("../exceptions");
|
|
27
27
|
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
var usernameField = "j_username";
|
|
31
|
-
var passwordField = "j_password";
|
|
28
|
+
var _constants = require("../constants");
|
|
29
|
+
|
|
32
30
|
/**
|
|
33
31
|
*/
|
|
34
|
-
|
|
35
32
|
var Authenticate = /*#__PURE__*/function () {
|
|
36
33
|
/**
|
|
37
34
|
*/
|
|
@@ -91,8 +88,11 @@ var Authenticate = /*#__PURE__*/function () {
|
|
|
91
88
|
}, {
|
|
92
89
|
key: "createLogin",
|
|
93
90
|
value: function createLogin(username, password) {
|
|
94
|
-
var _context, _context2;
|
|
91
|
+
var _context, _context2, _context3;
|
|
95
92
|
|
|
93
|
+
var LOGIN_PATH = (0, _constants.loginPath)();
|
|
94
|
+
var usernameField = (0, _constants.loginUsernameField)();
|
|
95
|
+
var passwordField = (0, _constants.loginPasswordField)();
|
|
96
96
|
var encodedUsername = encodeURIComponent(username);
|
|
97
97
|
var encodedPassword = encodeURIComponent(password);
|
|
98
98
|
return {
|
|
@@ -102,7 +102,7 @@ var Authenticate = /*#__PURE__*/function () {
|
|
|
102
102
|
Accept: "application/json",
|
|
103
103
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
104
104
|
},
|
|
105
|
-
data: (0, _concat.default)(_context = (0, _concat.default)(_context2 = "".concat(usernameField, "=").
|
|
105
|
+
data: (0, _concat.default)(_context = (0, _concat.default)(_context2 = (0, _concat.default)(_context3 = "".concat(usernameField, "=")).call(_context3, encodedUsername, "&")).call(_context2, passwordField, "=")).call(_context, encodedPassword)
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
@@ -115,9 +115,9 @@ var Authenticate = /*#__PURE__*/function () {
|
|
|
115
115
|
|
|
116
116
|
return this.initLogin(true).then(function () {
|
|
117
117
|
if (_this2.isBasicAuthentication) {
|
|
118
|
-
var
|
|
118
|
+
var _context4;
|
|
119
119
|
|
|
120
|
-
_Cache.default.addItem("basic", btoa((0, _concat.default)(
|
|
120
|
+
_Cache.default.addItem("basic", btoa((0, _concat.default)(_context4 = "".concat(username, ":")).call(_context4, password)));
|
|
121
121
|
|
|
122
122
|
return _promise.default.resolve();
|
|
123
123
|
}
|
|
@@ -132,7 +132,7 @@ var Authenticate = /*#__PURE__*/function () {
|
|
|
132
132
|
key: "logout",
|
|
133
133
|
value: function logout() {
|
|
134
134
|
return (0, _universalFetch.default)({
|
|
135
|
-
url:
|
|
135
|
+
url: (0, _constants.logoutPath)()
|
|
136
136
|
}).then(function () {
|
|
137
137
|
// clear cache because of cached contributions
|
|
138
138
|
_Cache.default.clear();
|
|
@@ -6,12 +6,12 @@ import Cache from "../utils/browser/Cache";
|
|
|
6
6
|
|
|
7
7
|
import { UnauthorizedException } from "../exceptions";
|
|
8
8
|
import type { RequestOptions } from "../utils/fetch/types";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
import {
|
|
10
|
+
loginPasswordField,
|
|
11
|
+
loginPath,
|
|
12
|
+
loginUsernameField,
|
|
13
|
+
logoutPath,
|
|
14
|
+
} from "../constants";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
*/
|
|
@@ -65,6 +65,10 @@ class Authenticate {
|
|
|
65
65
|
/**
|
|
66
66
|
*/
|
|
67
67
|
createLogin(username: string, password: string): $Shape<RequestOptions> {
|
|
68
|
+
const LOGIN_PATH = loginPath();
|
|
69
|
+
const usernameField = loginUsernameField();
|
|
70
|
+
const passwordField = loginPasswordField();
|
|
71
|
+
|
|
68
72
|
const encodedUsername = encodeURIComponent(username);
|
|
69
73
|
const encodedPassword = encodeURIComponent(password);
|
|
70
74
|
|
|
@@ -97,7 +101,7 @@ class Authenticate {
|
|
|
97
101
|
*/
|
|
98
102
|
logout(): Promise<void> {
|
|
99
103
|
return universalFetch({
|
|
100
|
-
url:
|
|
104
|
+
url: logoutPath(),
|
|
101
105
|
}).then(() => {
|
|
102
106
|
// clear cache because of cached contributions
|
|
103
107
|
Cache.clear();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/modularui/Authenticate.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../src/modularui/Authenticate.js"],"names":["Authenticate","_isBasic","isBasicAuthentication","initLogin","resolve","url","BASE","method","HTTP_METHODS","GET","headers","Accept","catch","error","UnauthorizedException","username","password","LOGIN_PATH","usernameField","passwordField","encodedUsername","encodeURIComponent","encodedPassword","POST","data","then","Cache","addItem","btoa","createLogin","clear"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AAOA;AACA;IACMA,Y;AAGJ;AACF;AACE,0BAAc;AAAA;AAAA;AACZ,SAAKC,QAAL,GAAgB,KAAhB;AACD;AAED;AACF;;;;;SACE,eAAqC;AACnC,aAAO,KAAKA,QAAZ;AACD;AAED;AACF;;SACE,aAA0BC,qBAA1B,EAA0D;AACxD,WAAKD,QAAL,GAAgBC,qBAAhB;AACD;AAED;AACF;;;;WACE,mBAAUC,UAAV,EAA4C;AAAA;;AAC1C,UAAI,KAAKD,qBAAL,IAA8B,CAACC,UAAnC,EAA8C;AAC5C,eAAO,iBAAQC,OAAR,CAAgB,IAAhB,CAAP;AACD;;AAED,aAAO,6BAAe;AACpBC,QAAAA,GAAG,YAAKC,eAAL,WADiB;AAEpBC,QAAAA,MAAM,EAAEC,wBAAaC,GAFD;AAGpBC,QAAAA,OAAO,EAAE;AACPC,UAAAA,MAAM,EAAE,kBADD;AAEP,0BAAgB;AAFT;AAHW,OAAf,EAOJC,KAPI,CAOE,UAACC,KAAD,EAAW;AAClB;AACA;AACA;AACA,YAAIA,KAAK,YAAYC,iCAArB,EAA4C;AAC1C,UAAA,KAAI,CAACZ,qBAAL,GAA6B,IAA7B;AACD;;AAED,eAAO,iBAAQE,OAAR,CAAgB,EAAhB,CAAP;AACD,OAhBM,CAAP;AAiBD;AAED;AACF;;;;WACE,qBAAYW,QAAZ,EAA8BC,QAA9B,EAAwE;AAAA;;AACtE,UAAMC,UAAU,GAAG,2BAAnB;AACA,UAAMC,aAAa,GAAG,oCAAtB;AACA,UAAMC,aAAa,GAAG,oCAAtB;AAEA,UAAMC,eAAe,GAAGC,kBAAkB,CAACN,QAAD,CAA1C;AACA,UAAMO,eAAe,GAAGD,kBAAkB,CAACL,QAAD,CAA1C;AAEA,aAAO;AACLX,QAAAA,GAAG,EAAEY,UADA;AAELV,QAAAA,MAAM,EAAEC,wBAAae,IAFhB;AAGLb,QAAAA,OAAO,EAAE;AACPC,UAAAA,MAAM,EAAE,kBADD;AAEP,0BAAgB;AAFT,SAHJ;AAOLa,QAAAA,IAAI,8GAAKN,aAAL,wBAAsBE,eAAtB,wBAAyCD,aAAzC,uBAA0DG,eAA1D;AAPC,OAAP;AASD;AAED;AACF;;;;WACE,eAAMP,QAAN,EAAwBC,QAAxB,EAAwD;AAAA;;AACtD,aAAO,KAAKb,SAAL,CAAe,IAAf,EAAqBsB,IAArB,CAA0B,YAAM;AACrC,YAAI,MAAI,CAACvB,qBAAT,EAAgC;AAAA;;AAC9BwB,yBAAMC,OAAN,CAAc,OAAd,EAAuBC,IAAI,4CAAIb,QAAJ,wBAAgBC,QAAhB,EAA3B;;AAEA,iBAAO,iBAAQZ,OAAR,EAAP;AACD;;AAED,eAAO,6BAAe,MAAI,CAACyB,WAAL,CAAiBd,QAAjB,EAA2BC,QAA3B,CAAf,CAAP;AACD,OARM,CAAP;AASD;AAED;AACF;;;;WACE,kBAAwB;AACtB,aAAO,6BAAe;AACpBX,QAAAA,GAAG,EAAE;AADe,OAAf,EAEJoB,IAFI,CAEC,YAAM;AACZ;AACAC,uBAAMI,KAAN;AACD,OALM,CAAP;AAMD;;;;;eAGY9B,Y","sourcesContent":["// @flow\nimport { BASE, HTTP_METHODS } from \"../constants/Constants\";\n\nimport universalFetch from \"../utils/fetch/universalFetch\";\nimport Cache from \"../utils/browser/Cache\";\n\nimport { UnauthorizedException } from \"../exceptions\";\nimport type { RequestOptions } from \"../utils/fetch/types\";\nimport {\n loginPasswordField,\n loginPath,\n loginUsernameField,\n logoutPath,\n} from \"../constants\";\n\n/**\n */\nclass Authenticate {\n _isBasic: boolean;\n\n /**\n */\n constructor() {\n this._isBasic = false;\n }\n\n /**\n */\n get isBasicAuthentication(): boolean {\n return this._isBasic;\n }\n\n /**\n */\n set isBasicAuthentication(isBasicAuthentication: boolean) {\n this._isBasic = isBasicAuthentication;\n }\n\n /**\n */\n initLogin(initLogin: boolean): Promise<any> {\n if (this.isBasicAuthentication || !initLogin) {\n return Promise.resolve(true);\n }\n\n return universalFetch({\n url: `${BASE}/login`,\n method: HTTP_METHODS.GET,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n }).catch((error) => {\n // when an unauthorizedexception is received on a request to the login service,\n // this indicates a basic authorization scenario\n // in case of form based authentication other exceptions are thrown\n if (error instanceof UnauthorizedException) {\n this.isBasicAuthentication = true;\n }\n\n return Promise.resolve({});\n });\n }\n\n /**\n */\n createLogin(username: string, password: string): $Shape<RequestOptions> {\n const LOGIN_PATH = loginPath();\n const usernameField = loginUsernameField();\n const passwordField = loginPasswordField();\n\n const encodedUsername = encodeURIComponent(username);\n const encodedPassword = encodeURIComponent(password);\n\n return {\n url: LOGIN_PATH,\n method: HTTP_METHODS.POST,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n data: `${usernameField}=${encodedUsername}&${passwordField}=${encodedPassword}`,\n };\n }\n\n /**\n */\n login(username: string, password: string): Promise<any> {\n return this.initLogin(true).then(() => {\n if (this.isBasicAuthentication) {\n Cache.addItem(\"basic\", btoa(`${username}:${password}`));\n\n return Promise.resolve();\n }\n\n return universalFetch(this.createLogin(username, password));\n });\n }\n\n /**\n */\n logout(): Promise<void> {\n return universalFetch({\n url: logoutPath(),\n }).then(() => {\n // clear cache because of cached contributions\n Cache.clear();\n });\n }\n}\n\nexport default Authenticate;\n"],"file":"Authenticate.js"}
|
|
@@ -106,7 +106,8 @@ var client = function client() {
|
|
|
106
106
|
history = _configureStore.history,
|
|
107
107
|
store = _configureStore.store;
|
|
108
108
|
|
|
109
|
-
(0, _Preferences.setAllContentInDataSetting)(store.getState());
|
|
109
|
+
(0, _Preferences.setAllContentInDataSetting)(store.getState());
|
|
110
|
+
(0, _Preferences.setLoginPreferences)(store.getState()); // load existing cache from other browser tabs
|
|
110
111
|
|
|
111
112
|
_Cache.default.loadOtherBrowserTabs(function () {
|
|
112
113
|
if (_Cache.default.getItem("auth")) {
|
|
@@ -19,7 +19,10 @@ import configureStore from "../redux/store/configureStore";
|
|
|
19
19
|
import rehydrate from "./rehydrate";
|
|
20
20
|
import { BASE } from "../constants/Constants";
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
setAllContentInDataSetting,
|
|
24
|
+
setLoginPreferences,
|
|
25
|
+
} from "../redux/actions/Preferences";
|
|
23
26
|
import { showXHRErrorNotification } from "../redux/actions/Notification";
|
|
24
27
|
|
|
25
28
|
import { handleError } from "../redux/actions/Error";
|
|
@@ -99,6 +102,7 @@ const client = ({
|
|
|
99
102
|
);
|
|
100
103
|
|
|
101
104
|
setAllContentInDataSetting(store.getState());
|
|
105
|
+
setLoginPreferences(store.getState());
|
|
102
106
|
|
|
103
107
|
// load existing cache from other browser tabs
|
|
104
108
|
Cache.loadOtherBrowserTabs(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react-client/client.js"],"names":["window","parseDataToJSON","data","JSON","parse","error","JsonParseException","client","customReducers","theme","render","beforeRenderHooks","ErrorFallbackComponent","contextPath","Error","dataElement","document","querySelector","textContent","Cache","clear","browserHistory","basename","BASE","history","store","getState","loadOtherBrowserTabs","getItem","dispatch","FetchException","response","listen","location","action","onunhandledrejection","event","detail","errorMessage","reason","message","toString","body","className","addContentLoadedEvent","addEventListener","applicationNode","isSSR","mount","hydrate","reactRender"],"mappings":";;;;;;;;;;;AAEA;;AAIA;;AAEA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AAEA;;
|
|
1
|
+
{"version":3,"sources":["../../src/react-client/client.js"],"names":["window","parseDataToJSON","data","JSON","parse","error","JsonParseException","client","customReducers","theme","render","beforeRenderHooks","ErrorFallbackComponent","contextPath","Error","dataElement","document","querySelector","textContent","Cache","clear","browserHistory","basename","BASE","history","store","getState","loadOtherBrowserTabs","getItem","dispatch","FetchException","response","listen","location","action","onunhandledrejection","event","detail","errorMessage","reason","message","toString","body","className","addContentLoadedEvent","addEventListener","applicationNode","isSSR","mount","hydrate","reactRender"],"mappings":";;;;;;;;;;;AAEA;;AAIA;;AAEA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AAEA;;AAIA;;AAEA;;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;;;AAnCA;AAEA,6BAAeA,MAAf;AAEA;;AA+CA;AACA;AACA;;AACA;AACA;AACA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,IAAD,EAAU;AAChC,MAAI;AACF,WAAOC,IAAI,CAACC,KAAL,CAAWF,IAAX,CAAP;AACD,GAFD,CAEE,OAAOG,KAAP,EAAc;AACd,UAAM,IAAIC,8BAAJ,iCAAgDJ,IAAhD,EAAN;AACD;AACF,CAND;AAQA;AACA;AACA;;;AACA,IAAMK,MAAM,GAAG,SAATA,MAAS,GAMG;AAAA;;AAAA,iFAAP,EAAO;AAAA,iCALhBC,cAKgB;AAAA,MALhBA,cAKgB,oCALC,EAKD;AAAA,wBAJhBC,KAIgB;AAAA,MAJhBA,KAIgB,2BAJR,EAIQ;AAAA,MAHhBC,MAGgB,QAHhBA,MAGgB;AAAA,MAFhBC,iBAEgB,QAFhBA,iBAEgB;AAAA,MADhBC,sBACgB,QADhBA,sBACgB;;AAChB,MAAI,OAAOZ,MAAM,CAACa,WAAd,KAA8B,WAAlC,EAA+C;AAC7C,UAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;AACD;;AAED,MAAMC,WAAW,GAAGC,QAAQ,CAACC,aAAT,CAClB,4DADkB,CAApB;;AAGA,MAAI,CAACF,WAAL,EAAkB;AAChB,UAAM,IAAID,KAAJ,CAAU,qCAAV,CAAN;AACD,GAFD,MAEO,IAAI,8BAAAC,WAAW,CA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JT;AAKE,QAAA,sBAAsB,EAAEG,sBAL1B;AAAA,kBAOGF,MAAM;AAPT,QADG,EAUHoC,eAVG,CAAL;AAYD,KAfD,MAeO;AACL,YAAM,IAAIhC,KAAJ,CACJ,8DADI,CAAN;AAGD;AACF,GAtBD;AAuBD,CA9BD;;eAgCeP,M","sourcesContent":["// @flow\n/* polyfills needed for ie11 */\nimport elementClosest from \"element-closest\";\nelementClosest(window);\n\n/* polyfill for focus-visible */\nimport \"focus-visible\";\n\nimport { hydrate, render as reactRender } from \"react-dom\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport { BASE } from \"../constants/Constants\";\n\nimport {\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\n\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\n\nimport { locationChange } from \"../redux/_router/actions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport Init from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport type { ComponentType } from \"react\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { CustomReducers } from \"../redux/types\";\nimport type { RouterHistory } from \"react-router\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\nexport type Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: Function,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/*\n * deserialize serialized data from the server to provide a smooth dehydration.\n */\n/**\n */\nconst parseDataToJSON = (data) => {\n try {\n return JSON.parse(data);\n } catch (error) {\n throw new JsonParseException(`Error parsing content ${data}`);\n }\n};\n\n/**\n * Mount the webapplication to the DOM, used client side when JavaScript is enabled.\n */\nconst client = ({\n customReducers = {},\n theme = {},\n render,\n beforeRenderHooks,\n ErrorFallbackComponent,\n}: Props = {}) => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]'\n );\n if (!dataElement) {\n throw new Error(\"Error loading state, json not found\");\n } else if (dataElement.textContent.trim() === \"\") {\n return;\n }\n\n const data = parseDataToJSON(dataElement.textContent);\n\n // remove all resources from cache\n Cache.clear(\"^res:\");\n\n // $FlowExpectedError\n const browserHistory: RouterHistory = createBrowserHistory({\n basename: BASE,\n });\n const { history, store } = configureStore(\n browserHistory,\n customReducers,\n rehydrate(data)\n );\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(store.getState());\n\n // load existing cache from other browser tabs\n Cache.loadOtherBrowserTabs(() => {\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n });\n\n if (has(data, \"error.name\")) {\n const error = new FetchException(data.error.response);\n store.dispatch(handleError(error));\n }\n\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n\n // listen to history change and update the redux router store\n history.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n /**\n */\n window.onunhandledrejection = (event) => {\n if (event.detail) {\n return setImmediate(() => {\n const errorMessage = event.detail.reason.message.toString();\n\n store.dispatch(showXHRErrorNotification(errorMessage));\n throw event.detail.reason;\n });\n }\n\n return event;\n };\n\n if (document.body) {\n document.body.className = \"js\";\n }\n\n handleBeforeRenderHooks(beforeRenderHooks, { store });\n\n addContentLoadedEvent(store, history, theme, render, ErrorFallbackComponent);\n};\n\n/**\n */\nconst addContentLoadedEvent = (\n store,\n history,\n theme,\n render,\n ErrorFallbackComponent\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (applicationNode) {\n const isSSR = applicationNode.querySelector(\".application\");\n const mount = isSSR ? hydrate : reactRender;\n mount(\n <Init\n store={store}\n history={history}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>,\n applicationNode\n );\n } else {\n throw new Error(\n \"No DOM element with id application found to attach client to\"\n );\n }\n });\n};\n\nexport default client;\n"],"file":"client.js"}
|
|
@@ -109,6 +109,15 @@ describe("serverUtil", () => {
|
|
|
109
109
|
hasAllContentInData: false,
|
|
110
110
|
},
|
|
111
111
|
},
|
|
112
|
+
{
|
|
113
|
+
type: "SET_PREFERENCES",
|
|
114
|
+
payload: {
|
|
115
|
+
"FormClient.login_url": "/BeInformed/j_security_check",
|
|
116
|
+
"FormClient.logout_url": "/BeInformed/Logoff",
|
|
117
|
+
"FormClient.password_field_name": "j_password",
|
|
118
|
+
"FormClient.username_field_name": "j_username",
|
|
119
|
+
},
|
|
120
|
+
},
|
|
112
121
|
]);
|
|
113
122
|
});
|
|
114
123
|
|
|
@@ -146,6 +155,15 @@ describe("serverUtil", () => {
|
|
|
146
155
|
hasAllContentInData: false,
|
|
147
156
|
},
|
|
148
157
|
},
|
|
158
|
+
{
|
|
159
|
+
type: "SET_PREFERENCES",
|
|
160
|
+
payload: {
|
|
161
|
+
"FormClient.login_url": "/BeInformed/j_security_check",
|
|
162
|
+
"FormClient.logout_url": "/BeInformed/Logoff",
|
|
163
|
+
"FormClient.password_field_name": "j_password",
|
|
164
|
+
"FormClient.username_field_name": "j_username",
|
|
165
|
+
},
|
|
166
|
+
},
|
|
149
167
|
]);
|
|
150
168
|
});
|
|
151
169
|
});
|
|
@@ -165,6 +165,7 @@ var setServerPreferences = function setServerPreferences(store, serverPreference
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
store.dispatch((0, _Preferences.setAllContentInDataSetting)());
|
|
168
|
+
store.dispatch((0, _Preferences.setLoginPreferences)());
|
|
168
169
|
|
|
169
170
|
if (preferencesProvider && preferencesProvider.isStudioContext && preferencesProvider.isStudioContext()) {
|
|
170
171
|
store.dispatch((0, _Preferences.setPreference)("isStudioContext", true));
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
setThemePreference,
|
|
17
17
|
setPreference,
|
|
18
18
|
setAllContentInDataSetting,
|
|
19
|
+
setLoginPreferences,
|
|
19
20
|
} from "../redux/actions/Preferences";
|
|
20
21
|
|
|
21
22
|
import { getSetting } from "../constants/Settings";
|
|
@@ -126,6 +127,7 @@ const setServerPreferences = (
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
store.dispatch(setAllContentInDataSetting());
|
|
130
|
+
store.dispatch(setLoginPreferences());
|
|
129
131
|
|
|
130
132
|
if (
|
|
131
133
|
preferencesProvider &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react-server/serverUtil.js"],"names":["createReduxStore","requestHref","customReducers","history","initialEntries","toString","store","setI18n","locales","request","Array","isArray","IllegalArgumentException","mergedLocales","locale","code","customLocale","custLocale","forEach","some","push","enabledLocales","localesInstance","Locales","preferredLocale","dispatch","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreferences","preferencesProvider","isStudioContext","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","dataFetcher","fetch","Error","handleErrors","state","getState","error","shouldThrowOnServer","dehydrate","filteredState","modularui","reduce","obj","key","status","model","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AAGA;;AACA;;AAEA;;AAOA;;AAEA;;;;;;;;;;AAaA;AACA;AACA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAmB,CACvBC,WADuB,EAEvBC,cAFuB,EAGR;AACf;AACA,MAAMC,OAAsB,GAAG,kCAA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,aAAa,mCACdL,KADc;AAEjBM,IAAAA,SAAS,EAAE,mBAAYN,KAAK,CAACM,SAAlB,EAA6BC,MAA7B,CAAoC,UAACC,GAAD,EAAMC,GAAN,EAAc;AAC3DD,MAAAA,GAAG,CAACC,GAAD,CAAH,GAAW;AACTC,QAAAA,MAAM,EAAEV,KAAK,CAACM,SAAN,CAAgBG,GAAhB,EAAqBC,MADpB;AAETC,QAAAA,KAAK,EAAEX,KAAK,CAACM,SAAN,CAAgBG,GAAhB,EAAqBE,KAArB,GACHX,KAAK,CAACM,SAAN,CAAgBG,GAAhB,EAAqBE,KAArB,CAA2BP,SAA3B,EADG,GAEH,KAAK;AAJA,OAAX;AAOA,aAAOI,GAAP;AACD,KATU,EASR,EATQ;AAFM,IAAnB;;AAcA,SAAO,wBAAeH,aAAf,EAA8BO,OAA9B,CAAsC,IAAtC,EAA4C,SAA5C,CAAP;AACD,CAlBD;AAoBA;AACA;;;;;AACA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CACjBC,KADiB,EAEjBC,IAFiB,EAGjBC,aAHiB,EAIN;AACX,MAAMC,KAAK,GAAGH,KAAK,CAACI,YAAN,EAAd;AACA,MAAMC,IAAI,GAAGH,aAAa,oCAAOA,aAAa,CAACI,MAAd,CAAqBD,IAA5B,IAAoC,EAA9D;;AAEA,MAAIH,aAAJ,EAAmB;AACjB,2CACKA,aAAa,CAACI,MADnB;AAEEH,MAAAA,KAAK,EAALA,KAFF;AAGEE,MAAAA,IAAI,EAAJA;AAHF;AAKD;;AAED,SAAO;AACLF,IAAAA,KAAK,EAALA,KADK;AAELE,IAAAA,IAAI,EAAJA;AAFK,GAAP;AAID,CApBD","sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/actions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n} from \"../redux/actions/Preferences\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getSetting(\"ENABLED_LOCALES\").includes(locale.code)\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`\n );\n }\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const filteredState = {\n ...state,\n modularui: Object.keys(state.modularui).reduce((obj, key) => {\n obj[key] = {\n status: state.modularui[key].status,\n model: state.modularui[key].model\n ? state.modularui[key].model.dehydrate()\n : void 0,\n };\n\n return obj;\n }, {}),\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"file":"serverUtil.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/react-server/serverUtil.js"],"names":["createReduxStore","requestHref","customReducers","history","initialEntries","toString","store","setI18n","locales","request","Array","isArray","IllegalArgumentException","mergedLocales","locale","code","customLocale","custLocale","forEach","some","push","enabledLocales","localesInstance","Locales","preferredLocale","dispatch","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreferences","preferencesProvider","isStudioContext","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","dataFetcher","fetch","Error","handleErrors","state","getState","error","shouldThrowOnServer","dehydrate","filteredState","modularui","reduce","obj","key","status","model","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AAGA;;AACA;;AAEA;;AAQA;;AAEA;;;;;;;;;;AAaA;AACA;AACA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAmB,CACvBC,WADuB,EAEvBC,cAFuB,EAGR;AACf;AACA,MAAMC,OAAsB,GAAG,kCAAoB;AACjDC,IAAAA,cAAc,EAAE,CAACH,WAAW,CAACI,QAAZ,EAAD;AADiC,GAApB,CAA/B;;AAIA,wBAAkB,8BAAeF,OAAf,EAAwBD,cAAxB,CAAlB;AAAA,MAAQI,KAAR,mBAAQA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MC,GAAN,EAAc;AAC3DD,MAAAA,GAAG,CAACC,GAAD,CAAH,GAAW;AACTC,QAAAA,MAAM,EAAEV,KAAK,CAACM,SAAN,CAAgBG,GAAhB,EAAqBC,MADpB;AAETC,QAAAA,KAAK,EAAEX,KAAK,CAACM,SAAN,CAAgBG,GAAhB,EAAqBE,KAArB,GACHX,KAAK,CAACM,SAAN,CAAgBG,GAAhB,EAAqBE,KAArB,CAA2BP,SAA3B,EADG,GAEH,KAAK;AAJA,OAAX;AAOA,aAAOI,GAAP;AACD,KATU,EASR,EATQ;AAFM,IAAnB;;AAcA,SAAO,wBAAeH,aAAf,EAA8BO,OAA9B,CAAsC,IAAtC,EAA4C,SAA5C,CAAP;AACD,CAlBD;AAoBA;AACA;;;;;AACA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CACjBC,KADiB,EAEjBC,IAFiB,EAGjBC,aAHiB,EAIN;AACX,MAAMC,KAAK,GAAGH,KAAK,CAACI,YAAN,EAAd;AACA,MAAMC,IAAI,GAAGH,aAAa,oCAAOA,aAAa,CAACI,MAAd,CAAqBD,IAA5B,IAAoC,EAA9D;;AAEA,MAAIH,aAAJ,EAAmB;AACjB,2CACKA,aAAa,CAACI,MADnB;AAEEH,MAAAA,KAAK,EAALA,KAFF;AAGEE,MAAAA,IAAI,EAAJA;AAHF;AAKD;;AAED,SAAO;AACLF,IAAAA,KAAK,EAALA,KADK;AAELE,IAAAA,IAAI,EAAJA;AAFK,GAAP;AAID,CApBD","sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/actions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getSetting(\"ENABLED_LOCALES\").includes(locale.code)\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`\n );\n }\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const filteredState = {\n ...state,\n modularui: Object.keys(state.modularui).reduce((obj, key) => {\n obj[key] = {\n status: state.modularui[key].status,\n model: state.modularui[key].model\n ? state.modularui[key].model.dehydrate()\n : void 0,\n };\n\n return obj;\n }, {}),\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"file":"serverUtil.js"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.updateFormAttribute = void 0;
|
|
7
7
|
|
|
8
8
|
var _actions = require("../_modularui/actions");
|
|
9
9
|
|
|
@@ -26,13 +26,15 @@ var updateFormAttribute = function updateFormAttribute(form, formObject, attribu
|
|
|
26
26
|
validate: true
|
|
27
27
|
};
|
|
28
28
|
return function (dispatch) {
|
|
29
|
+
var _newForm$currentFormO, _newForm$currentFormO2;
|
|
30
|
+
|
|
29
31
|
var newForm = form.clone();
|
|
30
32
|
|
|
31
33
|
if (options.validate === undefined) {
|
|
32
34
|
options.validate = true;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
if (newForm.currentFormObject &&
|
|
37
|
+
if ((_newForm$currentFormO = newForm.currentFormObject) !== null && _newForm$currentFormO !== void 0 && _newForm$currentFormO.equals(formObject)) {
|
|
36
38
|
newForm.currentFormObject.updateAttribute(attribute, inputvalue);
|
|
37
39
|
} else {
|
|
38
40
|
newForm.completedFormObjects.forEach(function (completeObject) {
|
|
@@ -54,25 +56,14 @@ var updateFormAttribute = function updateFormAttribute(form, formObject, attribu
|
|
|
54
56
|
dispatch((0, _FormAutosave.autosaveFormObject)(newForm));
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
if (newForm.currentFormObject &&
|
|
59
|
+
if (options.validate && (_newForm$currentFormO2 = newForm.currentFormObject) !== null && _newForm$currentFormO2 !== void 0 && _newForm$currentFormO2.hasDynamicValidations && (0, _Settings.getSetting)("USE_INSTANT_SERVER_VALIDATION")) {
|
|
60
|
+
// server form validations happens async, don't wait for the form to return
|
|
58
61
|
dispatch((0, _FormValidations.validateFormObject)(newForm));
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
return dispatch((0, _actions.updateModel)(newForm));
|
|
62
65
|
};
|
|
63
66
|
};
|
|
64
|
-
/**
|
|
65
|
-
* Validate an attribute on a form
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
67
|
|
|
69
68
|
exports.updateFormAttribute = updateFormAttribute;
|
|
70
|
-
|
|
71
|
-
var validateFormAttribute = function validateFormAttribute(form) {
|
|
72
|
-
return function (dispatch) {
|
|
73
|
-
return dispatch((0, _FormValidations.validateFormObject)(form));
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
exports.validateFormAttribute = validateFormAttribute;
|
|
78
69
|
//# sourceMappingURL=FormAttributeSet.js.map
|
|
@@ -35,10 +35,7 @@ export const updateFormAttribute =
|
|
|
35
35
|
options.validate = true;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if (
|
|
39
|
-
newForm.currentFormObject &&
|
|
40
|
-
newForm.currentFormObject.equals(formObject)
|
|
41
|
-
) {
|
|
38
|
+
if (newForm.currentFormObject?.equals(formObject)) {
|
|
42
39
|
newForm.currentFormObject.updateAttribute(attribute, inputvalue);
|
|
43
40
|
} else {
|
|
44
41
|
newForm.completedFormObjects.forEach((completeObject) => {
|
|
@@ -64,22 +61,12 @@ export const updateFormAttribute =
|
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
if (
|
|
67
|
-
newForm.currentFormObject &&
|
|
68
64
|
options.validate &&
|
|
69
|
-
newForm.currentFormObject
|
|
65
|
+
newForm.currentFormObject?.hasDynamicValidations &&
|
|
70
66
|
getSetting("USE_INSTANT_SERVER_VALIDATION")
|
|
71
67
|
) {
|
|
68
|
+
// server form validations happens async, don't wait for the form to return
|
|
72
69
|
dispatch(validateFormObject(newForm));
|
|
73
70
|
}
|
|
74
|
-
|
|
75
71
|
return dispatch(updateModel(newForm));
|
|
76
72
|
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Validate an attribute on a form
|
|
80
|
-
*/
|
|
81
|
-
export const validateFormAttribute =
|
|
82
|
-
(form: FormModel): ThunkAction =>
|
|
83
|
-
(dispatch: Dispatch) => {
|
|
84
|
-
return dispatch(validateFormObject(form));
|
|
85
|
-
};
|