@beinformed/ui 1.57.0-contextpath.0 → 1.57.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 +63 -0
- package/esm/constants/Settings.js +10 -2
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useModularUI.js +24 -18
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +52 -41
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +1 -8
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/concepts/ConceptIndexModel.js +1 -1
- package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
- package/esm/models/concepts/ConceptLinkModel.js +8 -9
- package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
- package/esm/models/concepts/ConceptTypeDetailModel.js +3 -20
- package/esm/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceCollection.js +3 -1
- package/esm/models/concepts/SourceReferenceCollection.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.js +9 -3
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/content/ContentLinkModel.js +10 -4
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/SectionModel.js +10 -6
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/error/ErrorResponse.js +20 -5
- package/esm/models/error/ErrorResponse.js.map +1 -1
- package/esm/models/href/Href.js +21 -4
- package/esm/models/href/Href.js.map +1 -1
- package/esm/models/list/ListItemCollection.js +1 -1
- package/esm/models/list/ListItemCollection.js.map +1 -1
- package/esm/modularui/CaptchaRequest.js +12 -3
- package/esm/modularui/CaptchaRequest.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +1 -1
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/modularui/UploadRequest.js +7 -3
- package/esm/modularui/UploadRequest.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +11 -9
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js +4 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/esm/redux/_modularui/ModularUIReducer.js +2 -1
- package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/esm/redux/_modularui/ModularUISelectors.js +7 -6
- package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/redux/actions/Application.js +11 -6
- package/esm/redux/actions/Application.js.map +1 -1
- package/esm/redux/connectors/PanelRenderer.js +0 -2
- package/esm/redux/connectors/PanelRenderer.js.map +1 -1
- package/esm/utils/helpers/checkResource.js +0 -2
- package/esm/utils/helpers/checkResource.js.map +1 -1
- package/esm/utils/helpers/repositoryResource.js +6 -5
- package/esm/utils/helpers/repositoryResource.js.map +1 -1
- package/lib/constants/Settings.js +10 -2
- package/lib/constants/Settings.js.flow +8 -2
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/__tests__/UseModularUIModel.spec.js.flow +11 -4
- package/lib/hooks/__tests__/useAuthentication.spec.js.flow +2 -8
- package/lib/hooks/__tests__/useForm.spec.js.flow +14 -12
- package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +10 -4
- package/lib/hooks/__tests__/useModels.spec.js.flow +3 -12
- package/lib/hooks/__tests__/useModularUIBasic.spec.js.flow +9 -8
- package/lib/hooks/useModularUI.js +23 -17
- package/lib/hooks/useModularUI.js.flow +31 -16
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +52 -41
- package/lib/hooks/useModularUIBasic.js.flow +66 -50
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js +1 -8
- package/lib/models/concepts/ConceptDetailModel.js.flow +2 -7
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/ConceptIndexModel.js +1 -1
- package/lib/models/concepts/ConceptIndexModel.js.flow +7 -1
- package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.js +8 -9
- package/lib/models/concepts/ConceptLinkModel.js.flow +14 -9
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/ConceptTypeDetailModel.js +3 -20
- package/lib/models/concepts/ConceptTypeDetailModel.js.flow +3 -25
- package/lib/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceCollection.js +3 -1
- package/lib/models/concepts/SourceReferenceCollection.js.flow +8 -1
- package/lib/models/concepts/SourceReferenceCollection.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.js +9 -3
- package/lib/models/concepts/SourceReferenceModel.js.flow +19 -3
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/concepts/__mock__/conceptindex.js.flow +15 -0
- package/lib/models/concepts/__tests__/ConceptIndexModel.spec.js.flow +30 -2
- package/lib/models/concepts/__tests__/ConceptTypeDetailModel.spec.js.flow +1 -18
- package/lib/models/content/ContentLinkModel.js +9 -4
- package/lib/models/content/ContentLinkModel.js.flow +19 -4
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/content/SectionModel.js +10 -6
- package/lib/models/content/SectionModel.js.flow +31 -5
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/error/ErrorResponse.js +20 -5
- package/lib/models/error/ErrorResponse.js.flow +34 -5
- package/lib/models/error/ErrorResponse.js.map +1 -1
- package/lib/models/href/Href.js +21 -4
- package/lib/models/href/Href.js.flow +21 -4
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/href/__tests__/Href.spec.js.flow +9 -3
- package/lib/models/list/ListItemCollection.js +1 -1
- package/lib/models/list/ListItemCollection.js.flow +2 -0
- package/lib/models/list/ListItemCollection.js.map +1 -1
- package/lib/modularui/CaptchaRequest.js +11 -2
- package/lib/modularui/CaptchaRequest.js.flow +17 -3
- package/lib/modularui/CaptchaRequest.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +1 -1
- package/lib/modularui/ModularUIRequest.js.flow +3 -1
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/modularui/UploadRequest.js +6 -2
- package/lib/modularui/UploadRequest.js.flow +12 -2
- package/lib/modularui/UploadRequest.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +11 -9
- package/lib/redux/_modularui/ModularUIActions.js.flow +20 -10
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIMiddleware.js +3 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.flow +6 -3
- package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/lib/redux/_modularui/ModularUIReducer.js +2 -1
- package/lib/redux/_modularui/ModularUIReducer.js.flow +1 -0
- package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/ModularUISelectors.js +5 -6
- package/lib/redux/_modularui/ModularUISelectors.js.flow +22 -10
- package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/lib/redux/_modularui/__tests__/actions.spec.js.flow +1 -4
- package/lib/redux/_modularui/types.js.flow +1 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/redux/actions/Application.js +10 -5
- package/lib/redux/actions/Application.js.flow +16 -5
- package/lib/redux/actions/Application.js.map +1 -1
- package/lib/redux/actions/__tests__/Application.spec.js.flow +1 -8
- package/lib/redux/actions/__tests__/Authorization.spec.js.flow +0 -4
- package/lib/redux/connectors/PanelRenderer.js +0 -2
- package/lib/redux/connectors/PanelRenderer.js.flow +0 -1
- package/lib/redux/connectors/PanelRenderer.js.map +1 -1
- package/lib/utils/helpers/checkResource.js +0 -2
- package/lib/utils/helpers/checkResource.js.flow +0 -2
- package/lib/utils/helpers/checkResource.js.map +1 -1
- package/lib/utils/helpers/repositoryResource.js +6 -5
- package/lib/utils/helpers/repositoryResource.js.flow +8 -6
- package/lib/utils/helpers/repositoryResource.js.map +1 -1
- package/package.json +18 -18
- package/src/constants/Settings.js +8 -2
- package/src/hooks/__tests__/UseModularUIModel.spec.js +11 -4
- package/src/hooks/__tests__/useAuthentication.spec.js +2 -8
- package/src/hooks/__tests__/useForm.spec.js +14 -12
- package/src/hooks/__tests__/useModelCatalog.spec.js +10 -4
- package/src/hooks/__tests__/useModels.spec.js +3 -12
- package/src/hooks/__tests__/useModularUIBasic.spec.js +9 -8
- package/src/hooks/useModularUI.js +31 -16
- package/src/hooks/useModularUIBasic.js +66 -50
- package/src/models/concepts/ConceptDetailModel.js +2 -7
- package/src/models/concepts/ConceptIndexModel.js +7 -1
- package/src/models/concepts/ConceptLinkModel.js +14 -9
- package/src/models/concepts/ConceptTypeDetailModel.js +3 -25
- package/src/models/concepts/SourceReferenceCollection.js +8 -1
- package/src/models/concepts/SourceReferenceModel.js +19 -3
- package/src/models/concepts/__mock__/conceptindex.js +15 -0
- package/src/models/concepts/__mock__/conceptindex_contributions.json +86 -0
- package/src/models/concepts/__mock__/conceptindex_data.json +323 -0
- package/src/models/concepts/__mock__/concepttype_hierarchy.json +1 -11
- package/src/models/concepts/__tests__/ConceptIndexModel.spec.js +30 -2
- package/src/models/concepts/__tests__/ConceptTypeDetailModel.spec.js +1 -18
- package/src/models/content/ContentLinkModel.js +19 -4
- package/src/models/content/SectionModel.js +31 -5
- package/src/models/error/ErrorResponse.js +34 -5
- package/src/models/href/Href.js +21 -4
- package/src/models/href/__tests__/Href.spec.js +9 -3
- package/src/models/list/ListItemCollection.js +2 -0
- package/src/modularui/CaptchaRequest.js +17 -3
- package/src/modularui/ModularUIRequest.js +3 -1
- package/src/modularui/UploadRequest.js +12 -2
- package/src/redux/_modularui/ModularUIActions.js +20 -10
- package/src/redux/_modularui/ModularUIMiddleware.js +6 -3
- package/src/redux/_modularui/ModularUIReducer.js +1 -0
- package/src/redux/_modularui/ModularUISelectors.js +22 -10
- package/src/redux/_modularui/__tests__/actions.spec.js +1 -4
- package/src/redux/_modularui/types.js +1 -0
- package/src/redux/actions/Application.js +16 -5
- package/src/redux/actions/__tests__/Application.spec.js +1 -8
- package/src/redux/actions/__tests__/Authorization.spec.js +0 -4
- package/src/redux/connectors/PanelRenderer.js +0 -1
- package/src/utils/helpers/checkResource.js +0 -2
- package/src/utils/helpers/repositoryResource.js +8 -6
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
2
2
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
3
3
|
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
4
|
-
import { getUploadPath, HTTP_METHODS } from "../constants";
|
|
4
|
+
import { getBasePath, getUploadPath, HTTP_METHODS } from "../constants";
|
|
5
5
|
import xhr from "../utils/fetch/xhr";
|
|
6
6
|
import ErrorModel from "../models/error/ErrorModel";
|
|
7
7
|
/**
|
|
8
8
|
* Upload a file to the upload file service of Be Informed
|
|
9
9
|
*/
|
|
10
10
|
class UploadRequest {
|
|
11
|
-
constructor(uploadConstraints, progressHandler) {
|
|
11
|
+
constructor(uploadConstraints, progressHandler, options) {
|
|
12
12
|
_defineProperty(this, "_uploadConstraints", void 0);
|
|
13
13
|
_defineProperty(this, "_progressHandler", void 0);
|
|
14
|
+
_defineProperty(this, "_origin", "");
|
|
15
|
+
_defineProperty(this, "_contextPath", getBasePath());
|
|
14
16
|
this._uploadConstraints = uploadConstraints;
|
|
15
17
|
this._progressHandler = progressHandler;
|
|
18
|
+
this._origin = options?.origin || "";
|
|
19
|
+
this._contextPath = options?.contextPath || getBasePath();
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
/**
|
|
@@ -64,7 +68,7 @@ class UploadRequest {
|
|
|
64
68
|
}, true));
|
|
65
69
|
}
|
|
66
70
|
return xhr({
|
|
67
|
-
url: getUploadPath(),
|
|
71
|
+
url: getUploadPath(this._contextPath, this._origin),
|
|
68
72
|
method: HTTP_METHODS.POST,
|
|
69
73
|
headers: {
|
|
70
74
|
"Content-Type": file.type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadRequest.js","names":["getUploadPath","HTTP_METHODS","xhr","ErrorModel","UploadRequest","constructor","uploadConstraints","progressHandler","_defineProperty","_uploadConstraints","_progressHandler","getFileExtension","file","name","split","pop","toLowerCase","isNotAllowedFileType","allowedFileTypes","fileTypes","length","fileExtension","some","fileType","_context","_includesInstanceProperty","extensions","call","exceedsMaxFileSize","maxFileSize","fileSize","size","uploadFile","error","_Promise","reject","extension","join","url","method","POST","headers","type","encodeURIComponent","toString","onProgress","e","lengthComputable","progress","Math","ceil","loaded","total","data","then","response","token"],"sources":["../../src/modularui/UploadRequest.js"],"sourcesContent":["// @flow\nimport { getUploadPath, HTTP_METHODS } from \"../constants\";\n\nimport xhr from \"../utils/fetch/xhr\";\n\nimport type {\n FilesizeConstraintsType,\n FiletypeConstraintsType,\n} from \"../models\";\nimport ErrorModel from \"../models/error/ErrorModel\";\n\ntype ProgressHandler = (file: File, uploadInfo: Object) => void;\n\ntype UploadResponse = {\n token: string,\n};\n\n/**\n * Upload a file to the upload file service of Be Informed\n */\nclass UploadRequest {\n _uploadConstraints: {\n fileTypes: FiletypeConstraintsType,\n maxFileSize: FilesizeConstraintsType,\n acceptedFiles: Array<string>,\n };\n _progressHandler: ProgressHandler;\n\n constructor(\n uploadConstraints: {\n fileTypes: FiletypeConstraintsType,\n maxFileSize: FilesizeConstraintsType,\n acceptedFiles: Array<string>,\n },\n progressHandler: ProgressHandler,\n ) {\n this._uploadConstraints = uploadConstraints;\n this._progressHandler = progressHandler;\n }\n\n /**\n */\n getFileExtension(file: File): string {\n return file.name.split(\".\").pop().toLowerCase();\n }\n\n /**\n */\n isNotAllowedFileType(file: File): boolean {\n const allowedFileTypes = this._uploadConstraints.fileTypes;\n\n if (allowedFileTypes.length > 0) {\n const fileExtension = this.getFileExtension(file);\n\n return !allowedFileTypes.some((fileType) =>\n fileType.extensions.includes(fileExtension),\n );\n }\n\n return false;\n }\n\n /**\n */\n exceedsMaxFileSize(file: File): boolean {\n const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;\n return maxFileSize > -1 && file.size > maxFileSize;\n }\n\n /**\n */\n uploadFile(file: File): Promise<UploadResponse> {\n const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;\n\n if (this.exceedsMaxFileSize(file)) {\n this._progressHandler(file, { error: \"errorExceedsMaxFileSize\" });\n return Promise.reject(\n new ErrorModel(\n \"Constraint.File.MaxFileSizeExceeded\",\n \"Maximum file upload size is ${max-filesize}\",\n {\n \"max-filesize\": maxFileSize,\n },\n true,\n ),\n );\n }\n\n if (this.isNotAllowedFileType(file)) {\n this._progressHandler(file, { error: \"errorExtensionNotAllowed\" });\n return Promise.reject(\n new ErrorModel(\n \"Constraint.File.InvalidExtension\",\n \"Allowed extensions are: ${extensions}\",\n {\n extension: this.getFileExtension(file),\n extensions: this._uploadConstraints.fileTypes.join(\", \"),\n },\n true,\n ),\n );\n }\n\n return xhr({\n url: getUploadPath(),\n method: HTTP_METHODS.POST,\n headers: {\n \"Content-Type\": file.type,\n \"x-filename\": encodeURIComponent(file.name),\n \"x-filesize\": file.size.toString(),\n },\n onProgress: (e: ProgressEvent) => {\n if (this._progressHandler && e.lengthComputable) {\n this._progressHandler(file, {\n progress: Math.ceil((e.loaded / e.total) * 100),\n });\n }\n },\n data: file,\n }).then((response) => {\n this._progressHandler(file, { progress: 100, token: response.token });\n return response;\n });\n }\n}\n\nexport default UploadRequest;\n"],"mappings":";;;AACA,SAASA,aAAa,EAAEC,YAAY,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"file":"UploadRequest.js","names":["getBasePath","getUploadPath","HTTP_METHODS","xhr","ErrorModel","UploadRequest","constructor","uploadConstraints","progressHandler","options","_defineProperty","_uploadConstraints","_progressHandler","_origin","origin","_contextPath","contextPath","getFileExtension","file","name","split","pop","toLowerCase","isNotAllowedFileType","allowedFileTypes","fileTypes","length","fileExtension","some","fileType","_context","_includesInstanceProperty","extensions","call","exceedsMaxFileSize","maxFileSize","fileSize","size","uploadFile","error","_Promise","reject","extension","join","url","method","POST","headers","type","encodeURIComponent","toString","onProgress","e","lengthComputable","progress","Math","ceil","loaded","total","data","then","response","token"],"sources":["../../src/modularui/UploadRequest.js"],"sourcesContent":["// @flow\nimport { getBasePath, getUploadPath, HTTP_METHODS } from \"../constants\";\n\nimport xhr from \"../utils/fetch/xhr\";\n\nimport type {\n FilesizeConstraintsType,\n FiletypeConstraintsType,\n} from \"../models\";\nimport ErrorModel from \"../models/error/ErrorModel\";\n\ntype ProgressHandler = (file: File, uploadInfo: Object) => void;\n\ntype UploadRequestOptions = {\n origin?: string,\n contextPath?: string,\n};\n\ntype UploadResponse = {\n token: string,\n};\n\n/**\n * Upload a file to the upload file service of Be Informed\n */\nclass UploadRequest {\n _uploadConstraints: {\n fileTypes: FiletypeConstraintsType,\n maxFileSize: FilesizeConstraintsType,\n acceptedFiles: Array<string>,\n };\n _progressHandler: ProgressHandler;\n _origin: string = \"\";\n _contextPath: string = getBasePath();\n\n constructor(\n uploadConstraints: {\n fileTypes: FiletypeConstraintsType,\n maxFileSize: FilesizeConstraintsType,\n acceptedFiles: Array<string>,\n },\n progressHandler: ProgressHandler,\n options?: UploadRequestOptions,\n ) {\n this._uploadConstraints = uploadConstraints;\n this._progressHandler = progressHandler;\n this._origin = options?.origin || \"\";\n this._contextPath = options?.contextPath || getBasePath();\n }\n\n /**\n */\n getFileExtension(file: File): string {\n return file.name.split(\".\").pop().toLowerCase();\n }\n\n /**\n */\n isNotAllowedFileType(file: File): boolean {\n const allowedFileTypes = this._uploadConstraints.fileTypes;\n\n if (allowedFileTypes.length > 0) {\n const fileExtension = this.getFileExtension(file);\n\n return !allowedFileTypes.some((fileType) =>\n fileType.extensions.includes(fileExtension),\n );\n }\n\n return false;\n }\n\n /**\n */\n exceedsMaxFileSize(file: File): boolean {\n const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;\n return maxFileSize > -1 && file.size > maxFileSize;\n }\n\n /**\n */\n uploadFile(file: File): Promise<UploadResponse> {\n const maxFileSize = this._uploadConstraints?.maxFileSize?.fileSize ?? -1;\n\n if (this.exceedsMaxFileSize(file)) {\n this._progressHandler(file, { error: \"errorExceedsMaxFileSize\" });\n return Promise.reject(\n new ErrorModel(\n \"Constraint.File.MaxFileSizeExceeded\",\n \"Maximum file upload size is ${max-filesize}\",\n {\n \"max-filesize\": maxFileSize,\n },\n true,\n ),\n );\n }\n\n if (this.isNotAllowedFileType(file)) {\n this._progressHandler(file, { error: \"errorExtensionNotAllowed\" });\n return Promise.reject(\n new ErrorModel(\n \"Constraint.File.InvalidExtension\",\n \"Allowed extensions are: ${extensions}\",\n {\n extension: this.getFileExtension(file),\n extensions: this._uploadConstraints.fileTypes.join(\", \"),\n },\n true,\n ),\n );\n }\n\n return xhr({\n url: getUploadPath(this._contextPath, this._origin),\n method: HTTP_METHODS.POST,\n headers: {\n \"Content-Type\": file.type,\n \"x-filename\": encodeURIComponent(file.name),\n \"x-filesize\": file.size.toString(),\n },\n onProgress: (e: ProgressEvent) => {\n if (this._progressHandler && e.lengthComputable) {\n this._progressHandler(file, {\n progress: Math.ceil((e.loaded / e.total) * 100),\n });\n }\n },\n data: file,\n }).then((response) => {\n this._progressHandler(file, { progress: 100, token: response.token });\n return response;\n });\n }\n}\n\nexport default UploadRequest;\n"],"mappings":";;;AACA,SAASA,WAAW,EAAEC,aAAa,EAAEC,YAAY,QAAQ,cAAc;AAEvE,OAAOC,GAAG,MAAM,oBAAoB;AAMpC,OAAOC,UAAU,MAAM,4BAA4B;AAanD;AACA;AACA;AACA,MAAMC,aAAa,CAAC;EAUlBC,WAAWA,CACTC,iBAIC,EACDC,eAAgC,EAChCC,OAA8B,EAC9B;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA,kBAXgB,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AAI,CAACC,IAAI,CAAEJ,CAAC,CAACK,MAAM,GAAGL,CAAC,CAACM,KAAK,GAAI,GAAG;UAChD,CAAC,CAAC;QACJ;MACF,CAAC;MACDC,IAAI,EAAEzC;IACR,CAAC,CAAC,CAAC0C,IAAI,CAAEC,QAAQ,IAAK;MACpB,IAAI,CAACjD,gBAAgB,CAACM,IAAI,EAAE;QAAEoC,QAAQ,EAAE,GAAG;QAAEQ,KAAK,EAAED,QAAQ,CAACC;MAAM,CAAC,CAAC;MACrE,OAAOD,QAAQ;IACjB,CAAC,CAAC;EACJ;AACF;AAEA,eAAexD,aAAa","ignoreList":[]}
|
|
@@ -78,6 +78,7 @@ const loadModelSuccessAction = (key, model, updateHandler) => {
|
|
|
78
78
|
export const loadModel = (key, href, options) => ({
|
|
79
79
|
type: "MODULARUI/FETCH",
|
|
80
80
|
payload: {
|
|
81
|
+
key,
|
|
81
82
|
origin: options?.origin,
|
|
82
83
|
contextPath: options?.contextPath,
|
|
83
84
|
href: href instanceof Href ? href : new Href(href, "", options?.origin, options?.contextPath),
|
|
@@ -94,7 +95,7 @@ export const loadModel = (key, href, options) => ({
|
|
|
94
95
|
/**
|
|
95
96
|
*/
|
|
96
97
|
errorAction: error => {
|
|
97
|
-
const errorResponse = new ErrorResponse(error, key);
|
|
98
|
+
const errorResponse = new ErrorResponse(error, key, options?.origin, options?.contextPath);
|
|
98
99
|
if (errorResponse.isChangePassword) {
|
|
99
100
|
return {
|
|
100
101
|
type: "NO_ACTION"
|
|
@@ -109,16 +110,17 @@ export const loadModel = (key, href, options) => ({
|
|
|
109
110
|
|
|
110
111
|
/**
|
|
111
112
|
*/
|
|
112
|
-
export const loadModularUI = (key, href, options) => dispatch => {
|
|
113
|
-
|
|
113
|
+
export const loadModularUI = (key, href, options) => (dispatch, getState) => {
|
|
114
|
+
const modularuiStore = getState()?.modularui;
|
|
115
|
+
if (modularuiStore && modularuiStore[key]?.status === MODULARUI_STATUS.LOADING) {
|
|
116
|
+
// don't create duplicate requests during loading
|
|
117
|
+
return dispatch({
|
|
118
|
+
type: "NO_ACTION"
|
|
119
|
+
});
|
|
120
|
+
}
|
|
114
121
|
dispatch(startProgress());
|
|
115
122
|
const loadModelPromise = dispatch(loadModel(key, href, options));
|
|
116
|
-
return _Promise.resolve(loadModelPromise).then(
|
|
117
|
-
if (response?.type === "FINISH_PROGRESS") {
|
|
118
|
-
dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));
|
|
119
|
-
}
|
|
120
|
-
return dispatch(finishProgress());
|
|
121
|
-
}).catch(error => dispatch(handleError(error)));
|
|
123
|
+
return _Promise.resolve(loadModelPromise).then(() => dispatch(finishProgress())).catch(error => dispatch(handleError(error)));
|
|
122
124
|
};
|
|
123
125
|
|
|
124
126
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","origin","contextPath","method","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","
|
|
1
|
+
{"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","origin","contextPath","method","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","getState","modularuiStore","modularui","LOADING","loadModelPromise","_Promise","resolve","then","catch","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type {\n RequestModularUIOptions,\n UpdateHandler,\n} from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel,\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>,\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\n }\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n key,\n origin: options?.origin,\n contextPath: options?.contextPath,\n href:\n href instanceof Href\n ? href\n : new Href(href, \"\", options?.origin, options?.contextPath),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n cache: options?.cache,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(\n error,\n key,\n options?.origin,\n options?.contextPath,\n );\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n ): ThunkAction =>\n (dispatch: Dispatch, getState) => {\n const modularuiStore = getState()?.modularui;\n if (\n modularuiStore &&\n modularuiStore[key]?.status === MODULARUI_STATUS.LOADING\n ) {\n // don't create duplicate requests during loading\n return dispatch({\n type: \"NO_ACTION\",\n });\n }\n\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then(() => dispatch(finishProgress()))\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";AACA,SAASA,YAAY,EAAEC,gBAAgB,QAAQ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2
|
import ModularUIRequest from "../../modularui/ModularUIRequest";
|
|
3
|
-
import { HTTP_METHODS } from "../../constants/Constants";
|
|
3
|
+
import { HTTP_METHODS, MODULARUI_STATUS } from "../../constants/Constants";
|
|
4
4
|
import { startProgress, finishProgress } from "../actions/ProgressIndicator";
|
|
5
5
|
import { handleError } from "../actions/Error";
|
|
6
|
+
import { updateStatus } from "./ModularUIActions";
|
|
6
7
|
/**
|
|
7
8
|
* Symbol key that carries API call info interpreted by this Redux middleware.
|
|
8
9
|
*/
|
|
@@ -70,12 +71,14 @@ const errorHandler = (next, dispatch, errorAction, err) => {
|
|
|
70
71
|
const handleFetch = (action, locale, dispatch, next) => {
|
|
71
72
|
dispatch(startProgress());
|
|
72
73
|
const {
|
|
74
|
+
key,
|
|
73
75
|
successAction,
|
|
74
76
|
errorAction,
|
|
75
77
|
...requestOptions
|
|
76
78
|
} = action.payload;
|
|
77
79
|
requestOptions.locale = locale;
|
|
78
80
|
const modularuiRequest = createRequest(requestOptions);
|
|
81
|
+
dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));
|
|
79
82
|
return modularuiRequest.fetch().then(model => responseHandler(next, dispatch, successAction, model)).catch(error => errorHandler(next, dispatch, errorAction, error));
|
|
80
83
|
};
|
|
81
84
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIMiddleware.js","names":["ModularUIRequest","HTTP_METHODS","startProgress","finishProgress","handleError","createRequest","modularui","request","href","method","GET","data","locale","childmodels","isReload","cache","origin","contextPath","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_Promise","then","result","catch","error","Error","errorHandler","errorAction","err","errorResult","handleFetch","action","requestOptions","payload","modularuiRequest","fetch","modularUIMiddleware","api","type","getState","i18n"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\
|
|
1
|
+
{"version":3,"file":"ModularUIMiddleware.js","names":["ModularUIRequest","HTTP_METHODS","MODULARUI_STATUS","startProgress","finishProgress","handleError","updateStatus","createRequest","modularui","request","href","method","GET","data","locale","childmodels","isReload","cache","origin","contextPath","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_Promise","then","result","catch","error","Error","errorHandler","errorAction","err","errorResult","handleFetch","action","key","requestOptions","payload","modularuiRequest","LOADING","fetch","modularUIMiddleware","api","type","getState","i18n"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport { updateStatus } from \"./ModularUIActions\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n cache?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n cache: modularui.cache,\n });\n\n if (modularui.origin) {\n request.origin = modularui.origin;\n }\n\n if (modularui.contextPath) {\n request.contextPath = modularui.contextPath;\n }\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n request.forceTargetModel = modularui.forceTargetModel ?? false;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel,\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`,\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any,\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch,\n) => {\n dispatch(startProgress());\n\n const { key, successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch,\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n action,\n api.getState().i18n.locale,\n api.dispatch,\n next,\n );\n }\n\n return next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GAAGpC,aAAa,CAACkC,cAAc,CAAC;EAEtDjB,QAAQ,CAAClB,YAAY,CAACkC,GAAG,EAAEtC,gBAAgB,CAAC0C,OAAO,CAAC,CAAC;EAErD,OAAOD,gBAAgB,CACpBE,KAAK,CAAC,CAAC,CACPhB,IAAI,CAAEH,KAAK,IAAKJ,eAAe,CAACC,IAAI,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,CAAC,CAAC,CACtEK,KAAK,CAAEC,KAAK,IAAKE,YAAY,CAACX,IAAI,EAAEC,QAAQ,EAAEW,WAAW,EAAEH,KAAK,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACA,OAAO,MAAMc,mBAIZ,GACEC,GAAqD,IACrDxB,IAAc,IACdgB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACS,IAAI,KAAK,iBAAiB,EAAE;IACrC,OAAOV,WAAW;IAChB;IACAC,MAAM,EACNQ,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAACpC,MAAM,EAC1BiC,GAAG,CAACvB,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACgB,MAAM,CAAC;AACrB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIReducer.js","names":["IllegalArgumentException","MODULARUI_STATUS","ApplicationModel","updateStatus","state","_ref","key","status","LOADING","lastModification","Date","now","setModel","_ref2","model","initModularUI","models","newState","_Object$assign","forEach","_ref3","
|
|
1
|
+
{"version":3,"file":"ModularUIReducer.js","names":["IllegalArgumentException","MODULARUI_STATUS","ApplicationModel","updateStatus","state","_ref","key","status","LOADING","lastModification","Date","now","setModel","_ref2","model","FINISHED","initModularUI","models","newState","_Object$assign","forEach","_ref3","getModelKey","_context","_findInstanceProperty","_Object$keys","call","connectKey","updateModel","modelKey","Error","removeKey","resetModularUI","initialState","ModularUIReducer","arguments","length","undefined","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> },\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel },\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n status: MODULARUI_STATUS.FINISHED,\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst initModularUI = (\n state: ModularUIState,\n models: Array<{ key: string, model: ModularUIModel }>,\n) => {\n const newState = Object.assign({}, state);\n\n models.forEach(({ key, model }) => {\n newState[key] = {\n status: MODULARUI_STATUS.FINISHED,\n lastModification: Date.now(),\n model,\n };\n });\n\n return newState;\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`,\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action,\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/INIT\":\n return initModularUI(state, action.payload);\n\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n case \"MODULARUI/UPDATE_FORM\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;AACA,SAASA,wBAAwB,QAAQ,kBAAkB;AAC3D,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,gBAAgB,QAAQ,cAAc;AAO/C;AACA;AACA,MAAMC,YAAY,GAAGA,CACnBC,KAAqB,EAAAC,IAAA,KAElB;EAAA,IADH;IAAEC,GAAG;IAAEC;EAAgE,CAAC,GAAAF,IAAA;EAExE;EACA,IAAIE,MAAM,KAAKN,gBAAgB,CAACO,OAAO,IAAI,CAACJ,KAAK,CAACE,GAAG,CAAC,EAAE;IACtD,OAAOF,KAAK;EACd;EAEA,OAAO;IACL,GAAGA,KAAK;IACR,CAACE,GAAG,GAAG;MACL,GAAGF,KAAK,CAACE,GAAG,CAAC;MACbC,MAAM;MACNE,gBAAgB,EAAEC,IAAI,CAACC,GAAG,CAAC;IAC7B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,MAAMC,QAAQ,GAAGA,CACfR,KAAqB,EAAAS,KAAA,KAElB;EAAA,IADH;IAAEP,GAA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EACd;EAEA,QAAQkC,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOvB,aAAa,CAACZ,KAAK,EAAEkC,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAOR,cAAc,CAAC5B,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEkC,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAO5B,QAAQ,CAACR,KAAK,EAAEkC,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;IACvB,KAAK,uBAAuB;MAC1B,OAAOZ,WAAW,CAACxB,KAAK,EAAEkC,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAOT,SAAS,CAACO,MAAM,CAACE,OAAO,EAAEpC,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAChB;AACF,CAAC","ignoreList":[]}
|
|
@@ -4,8 +4,7 @@ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
|
4
4
|
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
5
5
|
import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
|
|
6
6
|
import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
|
|
7
|
-
import
|
|
8
|
-
import { createSelectorCreator, defaultMemoize } from "reselect";
|
|
7
|
+
import { createSelector, createSelectorCreator, defaultMemoize } from "reselect";
|
|
9
8
|
import { has } from "../../utils/helpers/objects";
|
|
10
9
|
import Href from "../../models/href/Href";
|
|
11
10
|
import ContentModel from "../../models/content/ContentModel";
|
|
@@ -14,6 +13,8 @@ import ApplicationModel from "../../models/application/ApplicationModel";
|
|
|
14
13
|
import TabModel from "../../models/tab/TabModel";
|
|
15
14
|
import CaseViewModel from "../../models/caseview/CaseViewModel";
|
|
16
15
|
import FormModel from "../../models/form/FormModel";
|
|
16
|
+
import { MODULARUI_STATUS } from "../../constants";
|
|
17
|
+
|
|
17
18
|
/**
|
|
18
19
|
*/
|
|
19
20
|
export const getAllModelsByInstance = (state, instance) => {
|
|
@@ -241,11 +242,11 @@ export const getModelsByType = (state, type) => {
|
|
|
241
242
|
|
|
242
243
|
/**
|
|
243
244
|
*/
|
|
244
|
-
export const getAllFinishedModels = state => {
|
|
245
|
-
if (
|
|
245
|
+
export const getAllFinishedModels = createSelector(state => state.modularui, modularui => {
|
|
246
|
+
if (modularui) {
|
|
246
247
|
var _context10, _context11;
|
|
247
|
-
return _mapInstanceProperty(_context10 = _filterInstanceProperty(_context11 = _Object$
|
|
248
|
+
return _mapInstanceProperty(_context10 = _filterInstanceProperty(_context11 = _Object$keys(modularui)).call(_context11, key => modularui[key] && modularui[key].status === MODULARUI_STATUS.FINISHED)).call(_context10, key => modularui[key].model);
|
|
248
249
|
}
|
|
249
250
|
return [];
|
|
250
|
-
};
|
|
251
|
+
});
|
|
251
252
|
//# sourceMappingURL=ModularUISelectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUISelectors.js","names":["createSelectorCreator","defaultMemoize","has","Href","ContentModel","ContentTOCModel","ApplicationModel","TabModel","CaseViewModel","FormModel","getAllModelsByInstance","state","instance","locale","i18n","modularui","_context","_context2","_mapInstanceProperty","_filterInstanceProperty","_Object$keys","call","key","model","getFirstModelByInstance","_context3","_findInstanceProperty","getActiveModelByInstance","location","getLocation","_context4","_startsWithInstanceProperty","selfhref","path","getApplication","getTab","getCaseView","getForm","modelByHref","href","_context5","findHref","modelConfigKey","equals","keyByHref","_context6","allKeysByHref","_context7","router","pathname","getModels","models","forEach","modelKey","modelEntry","label","type","modelInfo","selfContentLink","push","getActiveModels","value","other","_JSON$stringify","contextModels","locationParts","split","reduce","accumulator","current","comparePath","decodeURIComponent","replace","foundEntry","encodedHref","toString","getPreference","preferenceName","preferences","getModelsByType","_context8","_context9","getAllFinishedModels","_context10","_context11","_Object$values","entry","status"],"sources":["../../../src/redux/_modularui/ModularUISelectors.js"],"sourcesContent":["// @flow\nimport { createSelectorCreator, defaultMemoize } from \"reselect\";\nimport { has } from \"../../utils/helpers/objects\";\n\nimport Href from \"../../models/href/Href\";\nimport ContentModel from \"../../models/content/ContentModel\";\nimport ContentTOCModel from \"../../models/content/ContentTOCModel\";\nimport ApplicationModel from \"../../models/application/ApplicationModel\";\nimport TabModel from \"../../models/tab/TabModel\";\nimport CaseViewModel from \"../../models/caseview/CaseViewModel\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ReduxState, PreferenceValue } from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\n\n/**\n */\nexport const getAllModelsByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): Array<ModularUIModel> => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n return Object.keys(modularui)\n .filter((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n })\n .map((key) => modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getFirstModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n */\nexport const getActiveModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const location = getLocation(state);\n\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return (\n model instanceof instance &&\n model.locale === locale &&\n location.startsWith(model.selfhref.path)\n );\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the application model, which is the model with selfhref '/'\n */\nexport const getApplication = (state: ReduxState): null | ApplicationModel =>\n getFirstModelByInstance(state, ApplicationModel);\n\n/**\n */\nexport const getTab = (state: ReduxState): null | TabModel =>\n getFirstModelByInstance(state, TabModel);\n\n/**\n */\nexport const getCaseView = (state: ReduxState): null | CaseViewModel =>\n getFirstModelByInstance(state, CaseViewModel);\n\n/**\n */\nexport const getForm = (state: ReduxState): null | FormModel =>\n getFirstModelByInstance(state, FormModel);\n\n/**\n * Get the model by it's href\n */\nexport const modelByHref = (\n state: ReduxState,\n href: Href | string,\n): null | ModularUIModel => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n const modelConfigKey = Object.keys(state.modularui).find((key) => {\n const model = state.modularui[key];\n\n return (\n model.model &&\n model.model.selfhref &&\n model.model.selfhref.equals(findHref)\n );\n });\n\n if (modelConfigKey) {\n return state.modularui[modelConfigKey].model;\n }\n }\n\n return null;\n};\n\n/**\n * Return the key of a model by the selfhref the model is saved in the reducer\n */\nexport const keyByHref = (state: ReduxState, href: Href | string): ?string => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).find((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return null;\n};\n\n/**\n * Returns all model keys found in the store, restrict on href\n */\nexport const allKeysByHref = (\n state: ReduxState,\n href: Href | string,\n): Array<string> => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).filter((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return [];\n};\n\n/**\n */\nconst getLocation = (state: ReduxState): string =>\n state?.router?.location.pathname;\n\n/**\n */\nconst getModels = (state: ReduxState) => {\n const models = [];\n\n Object.keys(state.modularui).forEach((modelKey: string) => {\n const modelEntry = state.modularui[modelKey];\n\n if (has(modelEntry, \"model\")) {\n const { key, selfhref, label, type } = modelEntry.model;\n\n const modelInfo = {\n key,\n selfhref,\n label,\n type,\n selfContentLink: null,\n };\n\n if (\n modelEntry.model instanceof ContentModel ||\n modelEntry.model instanceof ContentTOCModel\n ) {\n models.push({\n ...modelInfo,\n selfContentLink: modelEntry.model.selfContentLink,\n });\n } else {\n models.push(modelInfo);\n }\n }\n });\n\n return models;\n};\n\nexport const getActiveModels: (state: ReduxState) => Array<{\n key: string,\n href: Href,\n label: string,\n type: string,\n}> = createSelectorCreator(\n defaultMemoize,\n (value, other) => JSON.stringify(value) === JSON.stringify(other),\n)([getLocation, getModels], (location, models) => {\n const contextModels = [];\n\n if (location) {\n const locationParts = location.split(\"/\");\n\n locationParts.reduce((accumulator, current) => {\n const path = `${accumulator}/${current}`;\n\n // Remove modelcatalog part to match breadcrumb parts\n const comparePath = decodeURIComponent(path).replace(\n \"/modelcatalog/\",\n \"/\",\n );\n\n const foundEntry = models.find(\n (model) => model.selfhref && model.selfhref.equals(comparePath),\n );\n\n if (foundEntry) {\n const { key, label, type, selfhref, selfContentLink } = foundEntry;\n\n const href =\n path.startsWith(\"/modelcatalog/\") && selfContentLink\n ? new Href(`/modelcatalog${selfContentLink.encodedHref.toString()}`)\n : selfhref;\n\n contextModels.push({ key, href, label, type });\n }\n\n return path;\n });\n }\n\n return contextModels;\n});\n\n/**\n */\nexport const getPreference = (\n state: ReduxState,\n preferenceName: string,\n): null | PreferenceValue => {\n if (state && state.preferences) {\n return state.preferences[preferenceName];\n }\n\n return null;\n};\n\n/**\n * @deprecated - Use getFirstModelByInstance or the appropriate getter for the model type: getApplication, getTab, etc\n */\nexport const getModelsByType = (\n state: ReduxState,\n type: string,\n): Array<ModularUIModel> => {\n if (state && state.modularui) {\n return Object.keys(state.modularui)\n .filter(\n (key) =>\n state.modularui[key] &&\n state.modularui[key].model &&\n state.modularui[key].model.type === type,\n )\n .map((key) => state.modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getAllFinishedModels = (\n state: ReduxState,\n): Array<ModularUIModel> => {\n if (state && state.modularui) {\n return Object.values(state.modularui)\n .filter((entry) => entry.status === \"FINISHED\")\n .map((entry) => entry.model);\n }\n return [];\n};\n"],"mappings":";;;;;;;AACA,SAASA,qBAAqB,EAAEC,cAAc,QAAQ,UAAU;AAChE,SAASC,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,YAAY,MAAM,mCAAmC;AAC5D,OAAOC,eAAe,MAAM,sCAAsC;AAClE,OAAOC,gBAAgB,MAAM,2CAA2C;AACxE,OAAOC,QAAQ,MAAM,2BAA2B;AAChD,OAAOC,aAAa,MAAM,qCAAqC;AAC/D,OAAOC,SAAS,MAAM,6BAA6B;AAKnD;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGA,CACpCC,KAAiB,EACjBC,QAAkB,KACQ;EAC1B,MAAMC,MAAM,GAAGF,KAAK,EAAEG,IAAI,EAAED,MAAM,IAAI,IAAI;EAC1C,MAAME,SAAS,GAAGJ,KAAK,EAAEI,SAAS;EAElC,IAAIA,SAAS,EAAE;IAAA,IAAAC,QAAA,EAAAC,SAAA;IACb,OAAOC,oBAAA,CAAAF,QAAA,GAAAG,uBAAA,CAAAF,SAAA,GAAAG,YAAA,CAAYL,SAAS,CAAC,EAAAM,IAAA,CAAAJ,SAAA,EAClBK,GAAG,IAAK;MACf,MAAM;QAAEC;MAAM,CAAC,GAAGR,SAAS,CAACO,GAAG,CAAC;MAChC,OAAOC,KAAK,YAAYX,QAAQ,IAAIW,KAAK,CAACV,MAAM,KAAKA,MAAM;IAC7D,CAAC,CAAC,EAAAQ,IAAA,CAAAL,QAAA,EACIM,GAAG,IAAKP,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,CAAC;EACvC;EAEA,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AACA,OAAO,MAAMC,uBAAuB,GAAGA,CACrCb,KAAiB,EACjBC,QAAkB,KACL;EACb,MA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,UAAA,EACzCG,KAAK,IAAKA,KAAK,CAAC/D,KAAK,CAAC;EAChC;EACA,OAAO,EAAE;AACX,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ModularUISelectors.js","names":["createSelector","createSelectorCreator","defaultMemoize","has","Href","ContentModel","ContentTOCModel","ApplicationModel","TabModel","CaseViewModel","FormModel","MODULARUI_STATUS","getAllModelsByInstance","state","instance","locale","i18n","modularui","_context","_context2","_mapInstanceProperty","_filterInstanceProperty","_Object$keys","call","key","model","getFirstModelByInstance","_context3","_findInstanceProperty","getActiveModelByInstance","location","getLocation","_context4","_startsWithInstanceProperty","selfhref","path","getApplication","getTab","getCaseView","getForm","modelByHref","href","_context5","findHref","modelConfigKey","equals","keyByHref","_context6","allKeysByHref","_context7","router","pathname","getModels","models","forEach","modelKey","modelEntry","label","type","modelInfo","selfContentLink","push","getActiveModels","value","other","_JSON$stringify","contextModels","locationParts","split","reduce","accumulator","current","comparePath","decodeURIComponent","replace","foundEntry","encodedHref","toString","getPreference","preferenceName","preferences","getModelsByType","_context8","_context9","getAllFinishedModels","_context10","_context11","status","FINISHED"],"sources":["../../../src/redux/_modularui/ModularUISelectors.js"],"sourcesContent":["// @flow\nimport {\n createSelector,\n createSelectorCreator,\n defaultMemoize,\n} from \"reselect\";\nimport { has } from \"../../utils/helpers/objects\";\n\nimport Href from \"../../models/href/Href\";\nimport ContentModel from \"../../models/content/ContentModel\";\nimport ContentTOCModel from \"../../models/content/ContentTOCModel\";\nimport ApplicationModel from \"../../models/application/ApplicationModel\";\nimport TabModel from \"../../models/tab/TabModel\";\nimport CaseViewModel from \"../../models/caseview/CaseViewModel\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ReduxState, PreferenceValue } from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport { MODULARUI_STATUS } from \"../../constants\";\n\n/**\n */\nexport const getAllModelsByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): Array<ModularUIModel> => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n return Object.keys(modularui)\n .filter((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n })\n .map((key) => modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getFirstModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n */\nexport const getActiveModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const location = getLocation(state);\n\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return (\n model instanceof instance &&\n model.locale === locale &&\n location.startsWith(model.selfhref.path)\n );\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the application model, which is the model with selfhref '/'\n */\nexport const getApplication = (state: ReduxState): null | ApplicationModel =>\n getFirstModelByInstance(state, ApplicationModel);\n\n/**\n */\nexport const getTab = (state: ReduxState): null | TabModel =>\n getFirstModelByInstance(state, TabModel);\n\n/**\n */\nexport const getCaseView = (state: ReduxState): null | CaseViewModel =>\n getFirstModelByInstance(state, CaseViewModel);\n\n/**\n */\nexport const getForm = (state: ReduxState): null | FormModel =>\n getFirstModelByInstance(state, FormModel);\n\n/**\n * Get the model by it's href\n */\nexport const modelByHref = (\n state: ReduxState,\n href: Href | string,\n): null | ModularUIModel => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n const modelConfigKey = Object.keys(state.modularui).find((key) => {\n const model = state.modularui[key];\n\n return (\n model.model &&\n model.model.selfhref &&\n model.model.selfhref.equals(findHref)\n );\n });\n\n if (modelConfigKey) {\n return state.modularui[modelConfigKey].model;\n }\n }\n\n return null;\n};\n\n/**\n * Return the key of a model by the selfhref the model is saved in the reducer\n */\nexport const keyByHref = (state: ReduxState, href: Href | string): ?string => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).find((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return null;\n};\n\n/**\n * Returns all model keys found in the store, restrict on href\n */\nexport const allKeysByHref = (\n state: ReduxState,\n href: Href | string,\n): Array<string> => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).filter((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return [];\n};\n\n/**\n */\nconst getLocation = (state: ReduxState): string =>\n state?.router?.location.pathname;\n\n/**\n */\nconst getModels = (state: ReduxState) => {\n const models = [];\n\n Object.keys(state.modularui).forEach((modelKey: string) => {\n const modelEntry = state.modularui[modelKey];\n\n if (has(modelEntry, \"model\")) {\n const { key, selfhref, label, type } = modelEntry.model;\n\n const modelInfo = {\n key,\n selfhref,\n label,\n type,\n selfContentLink: null,\n };\n\n if (\n modelEntry.model instanceof ContentModel ||\n modelEntry.model instanceof ContentTOCModel\n ) {\n models.push({\n ...modelInfo,\n selfContentLink: modelEntry.model.selfContentLink,\n });\n } else {\n models.push(modelInfo);\n }\n }\n });\n\n return models;\n};\n\nexport const getActiveModels: (state: ReduxState) => Array<{\n key: string,\n href: Href,\n label: string,\n type: string,\n}> = createSelectorCreator(\n defaultMemoize,\n (value, other) => JSON.stringify(value) === JSON.stringify(other),\n)([getLocation, getModels], (location, models) => {\n const contextModels = [];\n\n if (location) {\n const locationParts = location.split(\"/\");\n\n locationParts.reduce((accumulator, current) => {\n const path = `${accumulator}/${current}`;\n\n // Remove modelcatalog part to match breadcrumb parts\n const comparePath = decodeURIComponent(path).replace(\n \"/modelcatalog/\",\n \"/\",\n );\n\n const foundEntry = models.find(\n (model) => model.selfhref && model.selfhref.equals(comparePath),\n );\n\n if (foundEntry) {\n const { key, label, type, selfhref, selfContentLink } = foundEntry;\n\n const href =\n path.startsWith(\"/modelcatalog/\") && selfContentLink\n ? new Href(`/modelcatalog${selfContentLink.encodedHref.toString()}`)\n : selfhref;\n\n contextModels.push({ key, href, label, type });\n }\n\n return path;\n });\n }\n\n return contextModels;\n});\n\n/**\n */\nexport const getPreference = (\n state: ReduxState,\n preferenceName: string,\n): null | PreferenceValue => {\n if (state && state.preferences) {\n return state.preferences[preferenceName];\n }\n\n return null;\n};\n\n/**\n * @deprecated - Use getFirstModelByInstance or the appropriate getter for the model type: getApplication, getTab, etc\n */\nexport const getModelsByType = (\n state: ReduxState,\n type: string,\n): Array<ModularUIModel> => {\n if (state && state.modularui) {\n return Object.keys(state.modularui)\n .filter(\n (key) =>\n state.modularui[key] &&\n state.modularui[key].model &&\n state.modularui[key].model.type === type,\n )\n .map((key) => state.modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getAllFinishedModels: (\n state: ReduxState,\n) => Array<ModularUIModel> = createSelector(\n (state: ReduxState) => state.modularui,\n (modularui): Array<ModularUIModel> => {\n if (modularui) {\n return Object.keys(modularui)\n .filter(\n (key) =>\n modularui[key] &&\n modularui[key].status === MODULARUI_STATUS.FINISHED,\n )\n .map((key) => modularui[key].model);\n }\n return [];\n },\n);\n"],"mappings":";;;;;;AACA,SACEA,cAAc,EACdC,qBAAqB,EACrBC,cAAc,QACT,UAAU;AACjB,SAASC,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,YAAY,MAAM,mCAAmC;AAC5D,OAAOC,eAAe,MAAM,sCAAsC;AAClE,OAAOC,gBAAgB,MAAM,2CAA2C;AACxE,OAAOC,QAAQ,MAAM,2BAA2B;AAChD,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C,SAAA;IAC5B,OAAO/D,oBAAA,CAAA8D,SAAA,GAAA7D,uBAAA,CAAA8D,SAAA,GAAA7D,YAAA,CAAYT,KAAK,CAACI,SAAS,CAAC,EAAAM,IAAA,CAAA4D,SAAA,EAE9B3D,GAAG,IACFX,KAAK,CAACI,SAAS,CAACO,GAAG,CAAC,IACpBX,KAAK,CAACI,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,IAC1BZ,KAAK,CAACI,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,CAACiC,IAAI,KAAKA,IACxC,CAAC,EAAAnC,IAAA,CAAA2D,SAAA,EACK1D,GAAG,IAAKX,KAAK,CAACI,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,CAAC;EAC7C;EAEA,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AACA,OAAO,MAAM2D,oBAEa,GAAGpF,cAAc,CACxCa,KAAiB,IAAKA,KAAK,CAACI,SAAS,EACrCA,SAAS,IAA4B;EACpC,IAAIA,SAAS,EAAE;IAAA,IAAAoE,UAAA,EAAAC,UAAA;IACb,OAAOlE,oBAAA,CAAAiE,UAAA,GAAAhE,uBAAA,CAAAiE,UAAA,GAAAhE,YAAA,CAAYL,SAAS,CAAC,EAAAM,IAAA,CAAA+D,UAAA,EAExB9D,GAAG,IACFP,SAAS,CAACO,GAAG,CAAC,IACdP,SAAS,CAACO,GAAG,CAAC,CAAC+D,MAAM,KAAK5E,gBAAgB,CAAC6E,QAC/C,CAAC,EAAAjE,IAAA,CAAA8D,UAAA,EACK7D,GAAG,IAAKP,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,CAAC;EACvC;EACA,OAAO,EAAE;AACX,CACF,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel,\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException,\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n cache?: boolean,\n successAction: (\n model: ModularUIModel,\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>,\n) => ComponentType<any>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel,\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException,\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n key: string,\n origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n cache?: boolean,\n successAction: (\n model: ModularUIModel,\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>,\n) => ComponentType<any>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { loadModularUI, removeModelByKey } from "../_modularui/ModularUIActions";
|
|
2
|
-
import { allKeysByHref } from "../_modularui/ModularUISelectors";
|
|
2
|
+
import { allKeysByHref, getApplication } from "../_modularui/ModularUISelectors";
|
|
3
3
|
import { ApplicationModel, Href } from "../../models";
|
|
4
4
|
import { getLocale } from "../selectors/i18n";
|
|
5
5
|
/**
|
|
6
6
|
*/
|
|
7
7
|
export const reloadApplication = () => (dispatch, getState) => {
|
|
8
|
-
const
|
|
8
|
+
const state = getState();
|
|
9
|
+
let applicationHref = new Href("/", "Application");
|
|
10
|
+
const application = getApplication(state);
|
|
11
|
+
if (application) {
|
|
12
|
+
applicationHref.contextPath = application.contextPath;
|
|
13
|
+
applicationHref.origin = application.origin;
|
|
14
|
+
}
|
|
15
|
+
const allKeys = allKeysByHref(state, applicationHref);
|
|
9
16
|
for (const key of allKeys) {
|
|
10
17
|
dispatch(removeModelByKey(key));
|
|
11
18
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const modelKey = `application(/)(${getLocale(getState())})`;
|
|
15
|
-
return dispatch(loadModularUI(modelKey, new Href("/", "Application"), {
|
|
19
|
+
const modelKey = `application(/)(${getLocale(state)})`;
|
|
20
|
+
return dispatch(loadModularUI(modelKey, applicationHref, {
|
|
16
21
|
targetModel: ApplicationModel
|
|
17
22
|
}));
|
|
18
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Application.js","names":["loadModularUI","removeModelByKey","allKeysByHref","ApplicationModel","Href","getLocale","reloadApplication","dispatch","getState","allKeys","key","modelKey","targetModel"],"sources":["../../../src/redux/actions/Application.js"],"sourcesContent":["// @flow\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../_modularui/ModularUIActions\";\nimport {
|
|
1
|
+
{"version":3,"file":"Application.js","names":["loadModularUI","removeModelByKey","allKeysByHref","getApplication","ApplicationModel","Href","getLocale","reloadApplication","dispatch","getState","state","applicationHref","application","contextPath","origin","allKeys","key","modelKey","targetModel"],"sources":["../../../src/redux/actions/Application.js"],"sourcesContent":["// @flow\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../_modularui/ModularUIActions\";\nimport {\n allKeysByHref,\n getApplication,\n} from \"../_modularui/ModularUISelectors\";\nimport { ApplicationModel, Href } from \"../../models\";\nimport { getLocale } from \"../selectors/i18n\";\n\nimport type { Dispatch, GetState, ThunkAction } from \"../types\";\n\n/**\n */\nexport const reloadApplication =\n (): ThunkAction => (dispatch: Dispatch, getState: GetState) => {\n const state = getState();\n\n let applicationHref = new Href(\"/\", \"Application\");\n const application = getApplication(state);\n if (application) {\n applicationHref.contextPath = application.contextPath;\n applicationHref.origin = application.origin;\n }\n\n const allKeys = allKeysByHref(state, applicationHref);\n for (const key of allKeys) {\n dispatch(removeModelByKey(key));\n }\n\n const modelKey = `application(/)(${getLocale(state)})`;\n return dispatch(\n loadModularUI(modelKey, applicationHref, {\n targetModel: ApplicationModel,\n }),\n );\n };\n"],"mappings":"AACA,SACEA,aAAa,EACbC,gBAAgB,QACX,gCAAgC;AACvC,SACEC,aAAa,EACbC,cAAc,QACT,kCAAkC;AACzC,SAASC,gBAAgB,EAAEC,IAAI,QAAQ,cAAc;AACrD,SAASC,SAAS,QAAQ,mBAAmB;AAI7C;AACA;AACA,OAAO,MAAMC,iBAAiB,GAC5BA,CAAA,KAAmB,CAACC,QAAkB,EAAEC,QAAkB,KAAK;EAC7D,MAAMC,KAAK,GAAGD,QAAQ,CAAC,CAAC;EAExB,IAAIE,eAAe,GAAG,IAAIN,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC;EAClD,MAAMO,WAAW,GAAGT,cAAc,CAACO,KAAK,CAAC;EACzC,IAAIE,WAAW,EAAE;IACfD,eAAe,CAACE,WAAW,GAAGD,WAAW,CAACC,WAAW;IACrDF,eAAe,CAACG,MAAM,GAAGF,WAAW,CAACE,MAAM;EAC7C;EAEA,MAAMC,OAAO,GAAGb,aAAa,CAACQ,KAAK,EAAEC,eAAe,CAAC;EACrD,KAAK,MAAMK,GAAG,IAAID,OAAO,EAAE;IACzBP,QAAQ,CAACP,gBAAgB,CAACe,GAAG,CAAC,CAAC;EACjC;EAEA,MAAMC,QAAQ,GAAG,kBAAkBX,SAAS,CAACI,KAAK,CAAC,GAAG;EACtD,OAAOF,QAAQ,CACbR,aAAa,CAACiB,QAAQ,EAAEN,eAAe,EAAE;IACvCO,WAAW,EAAEd;EACf,CAAC,CACH,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -11,8 +11,6 @@ export const connectPanel = modularui("PanelRenderer", _ref => {
|
|
|
11
11
|
if (!href && !match) {
|
|
12
12
|
throw new Error("Cannot determine panel url because of missing href and match");
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
// TODO SBO: origin and context?
|
|
16
14
|
const panelHref = href ? new Href(href) : new Href(match.url);
|
|
17
15
|
if (match && match.isExact) {
|
|
18
16
|
panelHref.addParametersFromString(querystring);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelRenderer.js","names":["modularui","Href","connectPanel","_ref","href","match","querystring","Error","panelHref","url","isExact","addParametersFromString","propName"],"sources":["../../../src/redux/connectors/PanelRenderer.js"],"sourcesContent":["// @flow\nimport modularui from \"../_modularui/ModularUIConnector\";\nimport Href from \"../../models/href/Href\";\n\nimport type { ModularUIConnector } from \"../_modularui/types\";\n\n/**\n */\nexport const connectPanel: ModularUIConnector = modularui(\n \"PanelRenderer\",\n ({ href, match, querystring = \"\" }) => {\n if (!href && !match) {\n throw new Error(\n \"Cannot determine panel url because of missing href and match\",\n );\n }\n\n
|
|
1
|
+
{"version":3,"file":"PanelRenderer.js","names":["modularui","Href","connectPanel","_ref","href","match","querystring","Error","panelHref","url","isExact","addParametersFromString","propName"],"sources":["../../../src/redux/connectors/PanelRenderer.js"],"sourcesContent":["// @flow\nimport modularui from \"../_modularui/ModularUIConnector\";\nimport Href from \"../../models/href/Href\";\n\nimport type { ModularUIConnector } from \"../_modularui/types\";\n\n/**\n */\nexport const connectPanel: ModularUIConnector = modularui(\n \"PanelRenderer\",\n ({ href, match, querystring = \"\" }) => {\n if (!href && !match) {\n throw new Error(\n \"Cannot determine panel url because of missing href and match\",\n );\n }\n\n const panelHref = href ? new Href(href) : new Href(match.url);\n\n if (match && match.isExact) {\n panelHref.addParametersFromString(querystring);\n }\n\n return panelHref;\n },\n {\n propName: \"panel\",\n },\n);\n"],"mappings":"AACA,OAAOA,SAAS,MAAM,kCAAkC;AACxD,OAAOC,IAAI,MAAM,wBAAwB;AAIzC;AACA;AACA,OAAO,MAAMC,YAAgC,GAAGF,SAAS,CACvD,eAAe,EACfG,IAAA,IAAuC;EAAA,IAAtC;IAAEC,IAAI;IAAEC,KAAK;IAAEC,WAAW,GAAG;EAAG,CAAC,GAAAH,IAAA;EAChC,IAAI,CAACC,IAAI,IAAI,CAACC,KAAK,EAAE;IACnB,MAAM,IAAIE,KAAK,CACb,8DACF,CAAC;EACH;EAEA,MAAMC,SAAS,GAAGJ,IAAI,GAAG,IAAIH,IAAI,CAACG,IAAI,CAAC,GAAG,IAAIH,IAAI,CAACI,KAAK,CAACI,GAAG,CAAC;EAE7D,IAAIJ,KAAK,IAAIA,KAAK,CAACK,OAAO,EAAE;IAC1BF,SAAS,CAACG,uBAAuB,CAACL,WAAW,CAAC;EAChD;EAEA,OAAOE,SAAS;AAClB,CAAC,EACD;EACEI,QAAQ,EAAE;AACZ,CACF,CAAC","ignoreList":[]}
|
|
@@ -9,7 +9,6 @@ import Href from "../../models/href/Href";
|
|
|
9
9
|
* @returns {boolean}
|
|
10
10
|
*/
|
|
11
11
|
export const resourceExists = url => {
|
|
12
|
-
// TODO SBO: origin and context?
|
|
13
12
|
const fullUrl = new Href(url).absolutehref;
|
|
14
13
|
const xhr = new XMLHttpRequest();
|
|
15
14
|
xhr.open("HEAD", fullUrl, false);
|
|
@@ -26,7 +25,6 @@ export const resourceExists = url => {
|
|
|
26
25
|
* @returns {boolean}
|
|
27
26
|
*/
|
|
28
27
|
export const resourceRedirectsToSecureLogin = url => {
|
|
29
|
-
// TODO SBO: origin and context?
|
|
30
28
|
const fullUrl = new Href(url).absolutehref;
|
|
31
29
|
const xhr = new XMLHttpRequest();
|
|
32
30
|
xhr.open("HEAD", fullUrl, false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkResource.js","names":["Href","resourceExists","url","fullUrl","absolutehref","xhr","XMLHttpRequest","open","setRequestHeader","send","status","resourceRedirectsToSecureLogin","responseURL","_endsWithInstanceProperty","call"],"sources":["../../../src/utils/helpers/checkResource.js"],"sourcesContent":["// @flow\nimport Href from \"../../models/href/Href\";\n\n/**\n * Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)\n * When the resource returns a 404, the resource does not exists and the method returns false\n *\n * @param url\n * @returns {boolean}\n */\nexport const resourceExists = (url: string | Href): boolean => {\n
|
|
1
|
+
{"version":3,"file":"checkResource.js","names":["Href","resourceExists","url","fullUrl","absolutehref","xhr","XMLHttpRequest","open","setRequestHeader","send","status","resourceRedirectsToSecureLogin","responseURL","_endsWithInstanceProperty","call"],"sources":["../../../src/utils/helpers/checkResource.js"],"sourcesContent":["// @flow\nimport Href from \"../../models/href/Href\";\n\n/**\n * Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)\n * When the resource returns a 404, the resource does not exists and the method returns false\n *\n * @param url\n * @returns {boolean}\n */\nexport const resourceExists = (url: string | Href): boolean => {\n const fullUrl = new Href(url).absolutehref;\n\n const xhr = new XMLHttpRequest();\n xhr.open(\"HEAD\", fullUrl, false);\n xhr.setRequestHeader(\"Accept\", \"application/json\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n xhr.setRequestHeader(\"X-Requested-With\", \"XMLHttpRequest\");\n\n xhr.send();\n\n return xhr.status !== 404;\n};\n\n/**\n * Indicates if a request to the given url resuls in a redirect to /secureRedirect\n * @param url\n * @returns {boolean}\n */\nexport const resourceRedirectsToSecureLogin = (url: string | Href): boolean => {\n const fullUrl = new Href(url).absolutehref;\n\n const xhr = new XMLHttpRequest();\n xhr.open(\"HEAD\", fullUrl, false);\n xhr.setRequestHeader(\"Accept\", \"application/json\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n xhr.setRequestHeader(\"X-Requested-With\", \"XMLHttpRequest\");\n xhr.send();\n\n const responseURL = xhr.responseURL ?? \"\";\n\n return xhr.status === 400 && responseURL.endsWith(\"/secureLogin\");\n};\n"],"mappings":";AACA,OAAOA,IAAI,MAAM,wBAAwB;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAIC,GAAkB,IAAc;EAC7D,MAAMC,OAAO,GAAG,IAAIH,IAAI,CAACE,GAAG,CAAC,CAACE,YAAY;EAE1C,MAAMC,GAAG,GAAG,IAAIC,cAAc,CAAC,CAAC;EAChCD,GAAG,CAACE,IAAI,CAAC,MAAM,EAAEJ,OAAO,EAAE,KAAK,CAAC;EAChCE,GAAG,CAACG,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,CAAC;EAClDH,GAAG,CAACG,gBAAgB,CAAC,cAAc,EAAE,kBAAkB,CAAC;EACxDH,GAAG,CAACG,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;EAE1DH,GAAG,CAACI,IAAI,CAAC,CAAC;EAEV,OAAOJ,GAAG,CAACK,MAAM,KAAK,GAAG;AAC3B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,8BAA8B,GAAIT,GAAkB,IAAc;EAC7E,MAAMC,OAAO,GAAG,IAAIH,IAAI,CAACE,GAAG,CAAC,CAACE,YAAY;EAE1C,MAAMC,GAAG,GAAG,IAAIC,cAAc,CAAC,CAAC;EAChCD,GAAG,CAACE,IAAI,CAAC,MAAM,EAAEJ,OAAO,EAAE,KAAK,CAAC;EAChCE,GAAG,CAACG,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,CAAC;EAClDH,GAAG,CAACG,gBAAgB,CAAC,cAAc,EAAE,kBAAkB,CAAC;EACxDH,GAAG,CAACG,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;EAC1DH,GAAG,CAACI,IAAI,CAAC,CAAC;EAEV,MAAMG,WAAW,GAAGP,GAAG,CAACO,WAAW,IAAI,EAAE;EAEzC,OAAOP,GAAG,CAACK,MAAM,KAAK,GAAG,IAAIG,yBAAA,CAAAD,WAAW,EAAAE,IAAA,CAAXF,WAAW,EAAU,cAAc,CAAC;AACnE,CAAC","ignoreList":[]}
|
|
@@ -5,14 +5,15 @@ import { getBasePath, RESOURCE_PATH } from "../../constants";
|
|
|
5
5
|
* Creates an url to a resource in the Be Informed repository
|
|
6
6
|
* Only possible when serving using the UI Servlet of Be Informed
|
|
7
7
|
*/
|
|
8
|
-
export const getRepositoryResourceUrl = resourceUrl
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export const getRepositoryResourceUrl = function (resourceUrl) {
|
|
9
|
+
let contextPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getBasePath();
|
|
10
|
+
let origin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
11
|
+
if (_startsWithInstanceProperty(resourceUrl).call(resourceUrl, origin + contextPath)) {
|
|
11
12
|
return resourceUrl;
|
|
12
13
|
}
|
|
13
14
|
if (_startsWithInstanceProperty(resourceUrl).call(resourceUrl, RESOURCE_PATH)) {
|
|
14
|
-
return `${
|
|
15
|
+
return `${origin}${contextPath}${resourceUrl}`;
|
|
15
16
|
}
|
|
16
|
-
return `${
|
|
17
|
+
return `${origin}${contextPath}${RESOURCE_PATH}${resourceUrl}`;
|
|
17
18
|
};
|
|
18
19
|
//# sourceMappingURL=repositoryResource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repositoryResource.js","names":["getBasePath","RESOURCE_PATH","getRepositoryResourceUrl","resourceUrl","
|
|
1
|
+
{"version":3,"file":"repositoryResource.js","names":["getBasePath","RESOURCE_PATH","getRepositoryResourceUrl","resourceUrl","contextPath","arguments","length","undefined","origin","_startsWithInstanceProperty","call"],"sources":["../../../src/utils/helpers/repositoryResource.js"],"sourcesContent":["// @flow\nimport { getBasePath, RESOURCE_PATH } from \"../../constants\";\n\n/**\n * Creates an url to a resource in the Be Informed repository\n * Only possible when serving using the UI Servlet of Be Informed\n */\nexport const getRepositoryResourceUrl = (\n resourceUrl: string,\n contextPath: string = getBasePath(),\n origin: string = \"\",\n): string => {\n if (resourceUrl.startsWith(origin + contextPath)) {\n return resourceUrl;\n }\n\n if (resourceUrl.startsWith(RESOURCE_PATH)) {\n return `${origin}${contextPath}${resourceUrl}`;\n }\n\n return `${origin}${contextPath}${RESOURCE_PATH}${resourceUrl}`;\n};\n"],"mappings":";AACA,SAASA,WAAW,EAAEC,aAAa,QAAQ,iBAAiB;;AAE5D;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAG,SAAAA,CACtCC,WAAmB,EAGR;EAAA,IAFXC,WAAmB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGL,WAAW,CAAC,CAAC;EAAA,IACnCQ,MAAc,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAEnB,IAAII,2BAAA,CAAAN,WAAW,EAAAO,IAAA,CAAXP,WAAW,EAAYK,MAAM,GAAGJ,WAAW,CAAC,EAAE;IAChD,OAAOD,WAAW;EACpB;EAEA,IAAIM,2BAAA,CAAAN,WAAW,EAAAO,IAAA,CAAXP,WAAW,EAAYF,aAAa,CAAC,EAAE;IACzC,OAAO,GAAGO,MAAM,GAAGJ,WAAW,GAAGD,WAAW,EAAE;EAChD;EAEA,OAAO,GAAGK,MAAM,GAAGJ,WAAW,GAAGH,aAAa,GAAGE,WAAW,EAAE;AAChE,CAAC","ignoreList":[]}
|
|
@@ -124,13 +124,21 @@ const getBasePath = () => getSetting("CONTEXT_PATH", "/BeInformed");
|
|
|
124
124
|
* Path to upload service
|
|
125
125
|
*/
|
|
126
126
|
exports.getBasePath = getBasePath;
|
|
127
|
-
const getUploadPath = ()
|
|
127
|
+
const getUploadPath = function () {
|
|
128
|
+
let contextPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBasePath();
|
|
129
|
+
let origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
130
|
+
return `${origin}${contextPath}${_Constants.UPLOAD_PATH}`;
|
|
131
|
+
};
|
|
128
132
|
|
|
129
133
|
/**
|
|
130
134
|
* Path to captcha service
|
|
131
135
|
*/
|
|
132
136
|
exports.getUploadPath = getUploadPath;
|
|
133
|
-
const getCaptchaPath = ()
|
|
137
|
+
const getCaptchaPath = function () {
|
|
138
|
+
let contextPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBasePath();
|
|
139
|
+
let origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
140
|
+
return `${origin}${contextPath}${_Constants.CAPTCHA_PATH}`;
|
|
141
|
+
};
|
|
134
142
|
|
|
135
143
|
/**
|
|
136
144
|
*/
|