@beinformed/ui 1.65.7 → 1.65.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/index.js.flow +1 -0
- package/esm/hooks/index.js.map +1 -1
- package/esm/hooks/useForm.js +3 -3
- package/esm/hooks/useForm.js.flow +7 -4
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useLookup.js +62 -0
- package/esm/hooks/useLookup.js.flow +82 -0
- package/esm/hooks/useLookup.js.map +1 -0
- package/esm/hooks/useProgressIndicator.js +21 -6
- package/esm/hooks/useProgressIndicator.js.flow +27 -10
- package/esm/hooks/useProgressIndicator.js.map +1 -1
- package/esm/models/attributes/AttributeSetModel.js +1 -1
- package/esm/models/attributes/AttributeSetModel.js.flow +1 -1
- package/esm/models/attributes/AttributeSetModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeModel.js +19 -2
- package/esm/models/attributes/ChoiceAttributeModel.js.flow +23 -2
- package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/esm/models/links/LinkModel.js +17 -1
- package/esm/models/links/LinkModel.js.flow +18 -1
- package/esm/models/links/LinkModel.js.map +1 -1
- package/lib/hooks/index.js +11 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useForm.js +5 -5
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useLookup.js +70 -0
- package/lib/hooks/useLookup.js.map +1 -0
- package/lib/hooks/useProgressIndicator.js +23 -7
- package/lib/hooks/useProgressIndicator.js.map +1 -1
- package/lib/models/attributes/AttributeSetModel.js +1 -1
- package/lib/models/attributes/AttributeSetModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js +18 -1
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/links/LinkModel.js +17 -0
- package/lib/models/links/LinkModel.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/index.js +1 -0
- package/src/hooks/useForm.js +7 -4
- package/src/hooks/useLookup.js +82 -0
- package/src/hooks/useProgressIndicator.js +27 -10
- package/src/models/attributes/AttributeSetModel.js +1 -1
- package/src/models/attributes/ChoiceAttributeModel.js +23 -2
- package/src/models/links/LinkModel.js +18 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.65.8](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.5...v1.65.8) (2026-01-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **hooks:** add `useLookup` hook and enhance `ChoiceAttributeModel` with dynamic lookup support ([3f9bb94](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/3f9bb944d044bbe5fb5abe23e559db5bcf3908e2))
|
|
11
|
+
* **hook:** separate progress indicator state and actions ([cc201ac](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/cc201acee207bb63fe9c23f15e6c45aade3f04c7))
|
|
12
|
+
* **hooks:** extend `useList` with advanced filter and pagination methods ([fe5b8f9](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/fe5b8f96d881e19d7061f2af097973cb3a467d75))
|
|
13
|
+
* **panels:** expect correct target models ([8cce991](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/8cce991864ec89ea447d8c55ad6c983d2f466db0))
|
|
14
|
+
* **server:** use correct import ([f7c81cb](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/f7c81cbb1acdcf6f8480bbfa2c7fd2bddcf84eed))
|
|
15
|
+
|
|
5
16
|
## [1.65.7](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.5...v1.65.7) (2026-01-06)
|
|
6
17
|
|
|
7
18
|
|
package/esm/hooks/index.js
CHANGED
package/esm/hooks/index.js.flow
CHANGED
package/esm/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/hooks/index.js"],"sourcesContent":["// @flow\nexport * from \"./useAuthentication\";\nexport * from \"./useContent\";\nexport * from \"./useForm\";\nexport * from \"./useI18n\";\nexport * from \"./useList\";\nexport * from \"./useModal\";\nexport * from \"./useModelCatalog\";\nexport * from \"./useModels\";\nexport * from \"./useModularUI\";\nexport * from \"./useModularUIBasic\";\nexport * from \"./useModularUIModel\";\nexport * from \"./useModularUIRequest\";\nexport * from \"./useNotification\";\nexport * from \"./usePanel\";\nexport * from \"./usePreference\";\nexport * from \"./useProgressIndicator\";\nexport * from \"./useRouter\";\nexport * from \"./useAllFormsOnModel\";\n"],"mappings":"AACA,cAAc,qBAAqB;AACnC,cAAc,cAAc;AAC5B,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,mBAAmB;AACjC,cAAc,aAAa;AAC3B,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,mBAAmB;AACjC,cAAc,YAAY;AAC1B,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,aAAa;AAC3B,cAAc,sBAAsB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/hooks/index.js"],"sourcesContent":["// @flow\nexport * from \"./useAuthentication\";\nexport * from \"./useContent\";\nexport * from \"./useForm\";\nexport * from \"./useI18n\";\nexport * from \"./useList\";\nexport * from \"./useLookup\";\nexport * from \"./useModal\";\nexport * from \"./useModelCatalog\";\nexport * from \"./useModels\";\nexport * from \"./useModularUI\";\nexport * from \"./useModularUIBasic\";\nexport * from \"./useModularUIModel\";\nexport * from \"./useModularUIRequest\";\nexport * from \"./useNotification\";\nexport * from \"./usePanel\";\nexport * from \"./usePreference\";\nexport * from \"./useProgressIndicator\";\nexport * from \"./useRouter\";\nexport * from \"./useAllFormsOnModel\";\n"],"mappings":"AACA,cAAc,qBAAqB;AACnC,cAAc,cAAc;AAC5B,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,mBAAmB;AACjC,cAAc,aAAa;AAC3B,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,mBAAmB;AACjC,cAAc,YAAY;AAC1B,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,aAAa;AAC3B,cAAc,sBAAsB","ignoreList":[]}
|
package/esm/hooks/useForm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useDispatch } from "react-redux";
|
|
2
|
-
import Href from "../models/href/Href";
|
|
3
2
|
import { getSetting, HTTP_METHODS } from "../constants";
|
|
4
|
-
import { loadModularUI, removeModelByKey } from "../redux/_modularui";
|
|
5
|
-
import { useModularUI } from "./useModularUI";
|
|
3
|
+
import { loadModularUI, removeModelByKey } from "../redux/_modularui/ModularUIActions";
|
|
6
4
|
import { addRepeatableAttributeSet, cancelForm, cancelRepeatableAttributeSet, previousObject, removeRepeatableAttributeSet, showFormNotification, updateFormAttribute } from "../redux/actions";
|
|
5
|
+
import Href from "../models/href/Href";
|
|
7
6
|
import FormModel from "../models/form/FormModel";
|
|
7
|
+
import { useModularUI } from "./useModularUI";
|
|
8
8
|
/**
|
|
9
9
|
* Load a form by href
|
|
10
10
|
*/
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import { useDispatch } from "react-redux";
|
|
3
3
|
|
|
4
|
-
import Href from "../models/href/Href";
|
|
5
|
-
|
|
6
4
|
import { getSetting, HTTP_METHODS } from "../constants";
|
|
7
5
|
|
|
8
6
|
import type {
|
|
9
7
|
RemoveModelByKeyAction,
|
|
10
8
|
UpdateFormAction,
|
|
11
9
|
} from "../redux/_modularui";
|
|
12
|
-
import {
|
|
13
|
-
|
|
10
|
+
import {
|
|
11
|
+
loadModularUI,
|
|
12
|
+
removeModelByKey,
|
|
13
|
+
} from "../redux/_modularui/ModularUIActions";
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
addRepeatableAttributeSet,
|
|
@@ -22,8 +22,11 @@ import {
|
|
|
22
22
|
updateFormAttribute,
|
|
23
23
|
} from "../redux/actions";
|
|
24
24
|
|
|
25
|
+
import Href from "../models/href/Href";
|
|
25
26
|
import FormModel from "../models/form/FormModel";
|
|
26
27
|
|
|
28
|
+
import { useModularUI } from "./useModularUI";
|
|
29
|
+
|
|
27
30
|
import type { AttributeType, FormObjectModel, ModularUIModel } from "../models";
|
|
28
31
|
import type { UpdateFormOptions } from "../redux/types";
|
|
29
32
|
|
package/esm/hooks/useForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.js","names":["useDispatch","
|
|
1
|
+
{"version":3,"file":"useForm.js","names":["useDispatch","getSetting","HTTP_METHODS","loadModularUI","removeModelByKey","addRepeatableAttributeSet","cancelForm","cancelRepeatableAttributeSet","previousObject","removeRepeatableAttributeSet","showFormNotification","updateFormAttribute","Href","FormModel","useModularUI","useForm","href","data","formHref","addParameter","form","method","POST","targetModel","removeOnUnmount","origin","contextPath","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","formdata","updateHandler","newModel","clonedModel","clone","update","remove","showFormNotificationAction","useAttributeUpdate","object","attribute","value","options","useAttributeSet","save"],"sources":["../../src/hooks/useForm.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport type {\n RemoveModelByKeyAction,\n UpdateFormAction,\n} from \"../redux/_modularui\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport Href from \"../models/href/Href\";\nimport FormModel from \"../models/form/FormModel\";\n\nimport { useModularUI } from \"./useModularUI\";\n\nimport type { AttributeType, FormObjectModel, ModularUIModel } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateFormAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateFormAction,\n cancel: (object: FormObjectModel) => UpdateFormAction,\n remove: (object: FormObjectModel) => UpdateFormAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href, data?: Object): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n data,\n origin: formHref.origin,\n contextPath: formHref.contextPath,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n const clonedModel: FormModel = form.clone();\n clonedModel.update(newModel);\n return clonedModel;\n }\n return newModel;\n },\n targetModel: FormModel,\n }),\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Hook that returns a function to update attributes of a form object.\n * <br >\n * The returned function accepts the following options:\n *\n * - autosubmit: Automatically submit the form after a change\n * - autosav: Automatically save the form (in the background) after a change\n * - autoupdate: Automatically update the current form object after a change\n * - forceUpdate: Force the update even if conditions are not met.\n * - validate: Activate/deactivate the form object validation by an update.\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel,\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,SAASC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AAMvD,SACEC,aAAa,EACbC,gBAAgB,QACX,sCAAsC;AAE7C,SACEC,yBAAyB,EACzBC,UAAU,EACVC,4BAA4B,EAC5BC,cAAc,EACdC,4BAA4B,EAC5BC,oBAAoB,EACpBC,mBAAmB,QACd,kBAAkB;AAEzB,OAAOC,IAAI,MAAM,qBAAqB;AACtC,OAAOC,SAAS,MAAM,0BAA0B;AAEhD,SAASC,YAAY,QAAQ,gBAAgB;AAyB7C;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,62 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { HTTP_METHODS } from "../constants";
|
|
3
|
+
import Href from "../models/href/Href";
|
|
4
|
+
import LinkModel from "../models/links/LinkModel";
|
|
5
|
+
import LookupOptionsModel from "../models/lookup/LookupOptionsModel";
|
|
6
|
+
import { useModularUIRequest } from "./useModularUIRequest";
|
|
7
|
+
import { useProgressIndicator } from "./useProgressIndicator";
|
|
8
|
+
/**
|
|
9
|
+
* Lookup options call
|
|
10
|
+
*/
|
|
11
|
+
export const useLookup = (lookupLink, filterInput = "", minLength = 2, debounceMs = 300) => {
|
|
12
|
+
const {
|
|
13
|
+
start,
|
|
14
|
+
finish
|
|
15
|
+
} = useProgressIndicator();
|
|
16
|
+
const modularuiRequest = useModularUIRequest();
|
|
17
|
+
const [lookupOptions, setLookupOptions] = useState(null);
|
|
18
|
+
const [lookupLoading, setLookupLoading] = useState(false);
|
|
19
|
+
const {
|
|
20
|
+
href,
|
|
21
|
+
filterName,
|
|
22
|
+
method
|
|
23
|
+
} = lookupLink;
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (filterInput.length < minLength) {
|
|
26
|
+
setLookupOptions(null);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const timeoutId = setTimeout(async () => {
|
|
30
|
+
setLookupLoading(true);
|
|
31
|
+
start();
|
|
32
|
+
const lookupHref = new Href(href);
|
|
33
|
+
const requestOptions = {
|
|
34
|
+
method,
|
|
35
|
+
data: undefined
|
|
36
|
+
};
|
|
37
|
+
if (method === HTTP_METHODS.POST) {
|
|
38
|
+
requestOptions.data = {
|
|
39
|
+
[filterName]: filterInput
|
|
40
|
+
};
|
|
41
|
+
} else {
|
|
42
|
+
lookupHref.addParameter(filterName, filterInput);
|
|
43
|
+
}
|
|
44
|
+
modularuiRequest(lookupHref, requestOptions).fetch().then(lookupResponse => {
|
|
45
|
+
if (lookupResponse instanceof LookupOptionsModel) {
|
|
46
|
+
setLookupOptions(lookupResponse);
|
|
47
|
+
}
|
|
48
|
+
}).finally(() => {
|
|
49
|
+
finish();
|
|
50
|
+
setLookupLoading(false);
|
|
51
|
+
});
|
|
52
|
+
}, debounceMs);
|
|
53
|
+
return () => {
|
|
54
|
+
clearTimeout(timeoutId);
|
|
55
|
+
};
|
|
56
|
+
}, [debounceMs, filterInput, filterName, finish, href, method, minLength, modularuiRequest, start]);
|
|
57
|
+
return {
|
|
58
|
+
lookupOptions,
|
|
59
|
+
lookupLoading
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=useLookup.js.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { HTTP_METHODS } from "../constants";
|
|
5
|
+
|
|
6
|
+
import Href from "../models/href/Href";
|
|
7
|
+
import LinkModel from "../models/links/LinkModel";
|
|
8
|
+
import LookupOptionsModel from "../models/lookup/LookupOptionsModel";
|
|
9
|
+
|
|
10
|
+
import { useModularUIRequest } from "./useModularUIRequest";
|
|
11
|
+
import { useProgressIndicator } from "./useProgressIndicator";
|
|
12
|
+
|
|
13
|
+
type UseLookupHook = {
|
|
14
|
+
lookupOptions: LookupOptionsModel | null,
|
|
15
|
+
lookupLoading: boolean,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Lookup options call
|
|
20
|
+
*/
|
|
21
|
+
export const useLookup = (
|
|
22
|
+
lookupLink: LinkModel,
|
|
23
|
+
filterInput: string = "",
|
|
24
|
+
minLength: number = 2,
|
|
25
|
+
debounceMs: number = 300,
|
|
26
|
+
): UseLookupHook => {
|
|
27
|
+
const { start, finish } = useProgressIndicator();
|
|
28
|
+
const modularuiRequest = useModularUIRequest();
|
|
29
|
+
|
|
30
|
+
const [lookupOptions, setLookupOptions] = useState(null);
|
|
31
|
+
const [lookupLoading, setLookupLoading] = useState(false);
|
|
32
|
+
|
|
33
|
+
const { href, filterName, method } = lookupLink;
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (filterInput.length < minLength) {
|
|
37
|
+
setLookupOptions(null);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const timeoutId = setTimeout(async () => {
|
|
42
|
+
setLookupLoading(true);
|
|
43
|
+
start();
|
|
44
|
+
|
|
45
|
+
const lookupHref = new Href(href);
|
|
46
|
+
const requestOptions = { method, data: undefined };
|
|
47
|
+
if (method === HTTP_METHODS.POST) {
|
|
48
|
+
requestOptions.data = { [filterName]: filterInput };
|
|
49
|
+
} else {
|
|
50
|
+
lookupHref.addParameter(filterName, filterInput);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
modularuiRequest(lookupHref, requestOptions)
|
|
54
|
+
.fetch()
|
|
55
|
+
.then((lookupResponse) => {
|
|
56
|
+
if (lookupResponse instanceof LookupOptionsModel) {
|
|
57
|
+
setLookupOptions(lookupResponse);
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
.finally(() => {
|
|
61
|
+
finish();
|
|
62
|
+
setLookupLoading(false);
|
|
63
|
+
});
|
|
64
|
+
}, debounceMs);
|
|
65
|
+
|
|
66
|
+
return () => {
|
|
67
|
+
clearTimeout(timeoutId);
|
|
68
|
+
};
|
|
69
|
+
}, [
|
|
70
|
+
debounceMs,
|
|
71
|
+
filterInput,
|
|
72
|
+
filterName,
|
|
73
|
+
finish,
|
|
74
|
+
href,
|
|
75
|
+
method,
|
|
76
|
+
minLength,
|
|
77
|
+
modularuiRequest,
|
|
78
|
+
start,
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
return { lookupOptions, lookupLoading };
|
|
82
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLookup.js","names":["useEffect","useState","HTTP_METHODS","Href","LinkModel","LookupOptionsModel","useModularUIRequest","useProgressIndicator","useLookup","lookupLink","filterInput","minLength","debounceMs","start","finish","modularuiRequest","lookupOptions","setLookupOptions","lookupLoading","setLookupLoading","href","filterName","method","length","timeoutId","setTimeout","lookupHref","requestOptions","data","undefined","POST","addParameter","fetch","then","lookupResponse","finally","clearTimeout"],"sources":["../../src/hooks/useLookup.js"],"sourcesContent":["// @flow\nimport { useEffect, useState } from \"react\";\n\nimport { HTTP_METHODS } from \"../constants\";\n\nimport Href from \"../models/href/Href\";\nimport LinkModel from \"../models/links/LinkModel\";\nimport LookupOptionsModel from \"../models/lookup/LookupOptionsModel\";\n\nimport { useModularUIRequest } from \"./useModularUIRequest\";\nimport { useProgressIndicator } from \"./useProgressIndicator\";\n\ntype UseLookupHook = {\n lookupOptions: LookupOptionsModel | null,\n lookupLoading: boolean,\n};\n\n/**\n * Lookup options call\n */\nexport const useLookup = (\n lookupLink: LinkModel,\n filterInput: string = \"\",\n minLength: number = 2,\n debounceMs: number = 300,\n): UseLookupHook => {\n const { start, finish } = useProgressIndicator();\n const modularuiRequest = useModularUIRequest();\n\n const [lookupOptions, setLookupOptions] = useState(null);\n const [lookupLoading, setLookupLoading] = useState(false);\n\n const { href, filterName, method } = lookupLink;\n\n useEffect(() => {\n if (filterInput.length < minLength) {\n setLookupOptions(null);\n return;\n }\n\n const timeoutId = setTimeout(async () => {\n setLookupLoading(true);\n start();\n\n const lookupHref = new Href(href);\n const requestOptions = { method, data: undefined };\n if (method === HTTP_METHODS.POST) {\n requestOptions.data = { [filterName]: filterInput };\n } else {\n lookupHref.addParameter(filterName, filterInput);\n }\n\n modularuiRequest(lookupHref, requestOptions)\n .fetch()\n .then((lookupResponse) => {\n if (lookupResponse instanceof LookupOptionsModel) {\n setLookupOptions(lookupResponse);\n }\n })\n .finally(() => {\n finish();\n setLookupLoading(false);\n });\n }, debounceMs);\n\n return () => {\n clearTimeout(timeoutId);\n };\n }, [\n debounceMs,\n filterInput,\n filterName,\n finish,\n href,\n method,\n minLength,\n modularuiRequest,\n start,\n ]);\n\n return { lookupOptions, lookupLoading };\n};\n"],"mappings":"AACA,S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MACrD,CAAC,MAAM;QACLgB,UAAU,CAACK,YAAY,CAACV,UAAU,EAAEX,WAAW,CAAC;MAClD;MAEAK,gBAAgB,CAACW,UAAU,EAAEC,cAAc,CAAC,CACzCK,KAAK,CAAC,CAAC,CACPC,IAAI,CAAEC,cAAc,IAAK;QACxB,IAAIA,cAAc,YAAY7B,kBAAkB,EAAE;UAChDY,gBAAgB,CAACiB,cAAc,CAAC;QAClC;MACF,CAAC,CAAC,CACDC,OAAO,CAAC,MAAM;QACbrB,MAAM,CAAC,CAAC;QACRK,gBAAgB,CAAC,KAAK,CAAC;MACzB,CAAC,CAAC;IACN,CAAC,EAAEP,UAAU,CAAC;IAEd,OAAO,MAAM;MACXwB,YAAY,CAACZ,SAAS,CAAC;IACzB,CAAC;EACH,CAAC,EAAE,CACDZ,UAAU,EACVF,WAAW,EACXW,UAAU,EACVP,MAAM,EACNM,IAAI,EACJE,MAAM,EACNX,SAAS,EACTI,gBAAgB,EAChBF,KAAK,CACN,CAAC;EAEF,OAAO;IAAEG,aAAa;IAAEE;EAAc,CAAC;AACzC,CAAC","ignoreList":[]}
|
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
import { useDispatch, useSelector } from "react-redux";
|
|
2
2
|
import { startProgress, finishProgress, resetProgress, updateProgress } from "../redux/actions/ProgressIndicator";
|
|
3
|
+
import { useCallback } from "react";
|
|
3
4
|
/**
|
|
4
5
|
*/
|
|
5
6
|
export const useProgressIndicator = () => {
|
|
6
7
|
const dispatch = useDispatch();
|
|
7
|
-
const
|
|
8
|
+
const start = useCallback(() => {
|
|
9
|
+
dispatch(startProgress());
|
|
10
|
+
}, [dispatch]);
|
|
11
|
+
const finish = useCallback(() => {
|
|
12
|
+
dispatch(finishProgress());
|
|
13
|
+
}, [dispatch]);
|
|
14
|
+
const reset = useCallback(() => {
|
|
15
|
+
dispatch(resetProgress());
|
|
16
|
+
}, [dispatch]);
|
|
17
|
+
const update = useCallback(percentComplete => {
|
|
18
|
+
dispatch(updateProgress(percentComplete));
|
|
19
|
+
}, [dispatch]);
|
|
8
20
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
update: percentComplete => dispatch(updateProgress(percentComplete))
|
|
21
|
+
start,
|
|
22
|
+
finish,
|
|
23
|
+
reset,
|
|
24
|
+
update
|
|
14
25
|
};
|
|
15
26
|
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
*/
|
|
30
|
+
export const useProgressIndicatorState = () => useSelector(state => state.progressindicator);
|
|
16
31
|
//# sourceMappingURL=useProgressIndicator.js.map
|
|
@@ -7,27 +7,44 @@ import {
|
|
|
7
7
|
updateProgress,
|
|
8
8
|
} from "../redux/actions/ProgressIndicator";
|
|
9
9
|
import type { ProgressIndicatorState } from "../redux/types";
|
|
10
|
+
import { useCallback } from "react";
|
|
10
11
|
|
|
11
12
|
type ProgressIndicatorHook = {
|
|
12
|
-
...ProgressIndicatorState,
|
|
13
13
|
start: () => void,
|
|
14
14
|
finish: () => void,
|
|
15
15
|
reset: () => void,
|
|
16
16
|
update: (percentComplete: number) => void,
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
type ProgressIndicatorStateHook = {
|
|
20
|
+
...ProgressIndicatorState,
|
|
21
|
+
};
|
|
22
|
+
|
|
19
23
|
/**
|
|
20
24
|
*/
|
|
21
25
|
export const useProgressIndicator = (): ProgressIndicatorHook => {
|
|
22
26
|
const dispatch = useDispatch();
|
|
23
|
-
const progress = useSelector((state) => state.progressindicator);
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const start = useCallback(() => {
|
|
29
|
+
dispatch(startProgress());
|
|
30
|
+
}, [dispatch]);
|
|
31
|
+
const finish = useCallback(() => {
|
|
32
|
+
dispatch(finishProgress());
|
|
33
|
+
}, [dispatch]);
|
|
34
|
+
const reset = useCallback(() => {
|
|
35
|
+
dispatch(resetProgress());
|
|
36
|
+
}, [dispatch]);
|
|
37
|
+
const update = useCallback(
|
|
38
|
+
(percentComplete: number) => {
|
|
39
|
+
dispatch(updateProgress(percentComplete));
|
|
40
|
+
},
|
|
41
|
+
[dispatch],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return { start, finish, reset, update };
|
|
33
45
|
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*/
|
|
49
|
+
export const useProgressIndicatorState = (): ProgressIndicatorStateHook =>
|
|
50
|
+
useSelector((state) => state.progressindicator);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProgressIndicator.js","names":["useDispatch","useSelector","startProgress","finishProgress","resetProgress","updateProgress","useProgressIndicator","dispatch","
|
|
1
|
+
{"version":3,"file":"useProgressIndicator.js","names":["useDispatch","useSelector","startProgress","finishProgress","resetProgress","updateProgress","useCallback","useProgressIndicator","dispatch","start","finish","reset","update","percentComplete","useProgressIndicatorState","state","progressindicator"],"sources":["../../src/hooks/useProgressIndicator.js"],"sourcesContent":["// @flow\nimport { useDispatch, useSelector } from \"react-redux\";\nimport {\n startProgress,\n finishProgress,\n resetProgress,\n updateProgress,\n} from \"../redux/actions/ProgressIndicator\";\nimport type { ProgressIndicatorState } from \"../redux/types\";\nimport { useCallback } from \"react\";\n\ntype ProgressIndicatorHook = {\n start: () => void,\n finish: () => void,\n reset: () => void,\n update: (percentComplete: number) => void,\n};\n\ntype ProgressIndicatorStateHook = {\n ...ProgressIndicatorState,\n};\n\n/**\n */\nexport const useProgressIndicator = (): ProgressIndicatorHook => {\n const dispatch = useDispatch();\n\n const start = useCallback(() => {\n dispatch(startProgress());\n }, [dispatch]);\n const finish = useCallback(() => {\n dispatch(finishProgress());\n }, [dispatch]);\n const reset = useCallback(() => {\n dispatch(resetProgress());\n }, [dispatch]);\n const update = useCallback(\n (percentComplete: number) => {\n dispatch(updateProgress(percentComplete));\n },\n [dispatch],\n );\n\n return { start, finish, reset, update };\n};\n\n/**\n */\nexport const useProgressIndicatorState = (): ProgressIndicatorStateHook =>\n useSelector((state) => state.progressindicator);\n"],"mappings":"AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,aAAa;AACtD,SACEC,aAAa,EACbC,cAAc,EACdC,aAAa,EACbC,cAAc,QACT,oCAAoC;AAE3C,SAASC,WAAW,QAAQ,OAAO;AAanC;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAA6B;EAC/D,MAAMC,QAAQ,GAAGR,WAAW,CAAC,CAAC;EAE9B,MAAMS,KAAK,GAAGH,WAAW,CAAC,MAAM;IAC9BE,QAAQ,CAACN,aAAa,CAAC,CAAC,CAAC;EAC3B,CAAC,EAAE,CAACM,QAAQ,CAAC,CAAC;EACd,MAAME,MAAM,GAAGJ,WAAW,CAAC,MAAM;IAC/BE,QAAQ,CAACL,cAAc,CAAC,CAAC,CAAC;EAC5B,CAAC,EAAE,CAACK,QAAQ,CAAC,CAAC;EACd,MAAMG,KAAK,GAAGL,WAAW,CAAC,MAAM;IAC9BE,QAAQ,CAACJ,aAAa,CAAC,CAAC,CAAC;EAC3B,CAAC,EAAE,CAACI,QAAQ,CAAC,CAAC;EACd,MAAMI,MAAM,GAAGN,WAAW,CACvBO,eAAuB,IAAK;IAC3BL,QAAQ,CAACH,cAAc,CAACQ,eAAe,CAAC,CAAC;EAC3C,CAAC,EACD,CAACL,QAAQ,CACX,CAAC;EAED,OAAO;IAAEC,KAAK;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC;AACzC,CAAC;;AAED;AACA;AACA,OAAO,MAAME,yBAAyB,GAAGA,CAAA,KACvCb,WAAW,CAAEc,KAAK,IAAKA,KAAK,CAACC,iBAAiB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeSetModel.js","names":["has","BaseModel","AttributeCollection","AttributeSetModel","constructor","key","data","contributions","modelOptions","_context","_defineProperty","attributeContributions","attributes","_filterInstanceProperty","call","contribution","contributionKey","_Object$keys","_attributeCollection","isReadonly","_key","label","attributeCollection","collection","createChildAttributeSetModel","dataObject","index","dynamicschema","objects","getChildAttributeSets","childAttributeSets","Array","isArray","i","_entriesInstanceProperty","_context2","push"],"sources":["../../../src/models/attributes/AttributeSetModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport AttributeCollection from \"./AttributeCollection\";\n\nimport type { ModelOptions } from \"../types\";\n\n/**\n */\nexport default class AttributeSetModel extends BaseModel {\n _key: string;\n _attributeCollection: AttributeCollection;\n\n /**\n */\n constructor(\n key: string = \"\",\n data: Object = {},\n contributions: Object = {},\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n const attributeContributions = this.contributions.attributes\n ? this.contributions.attributes.filter((contribution) => {\n const [contributionKey] = Object.keys(contribution);\n return has(this.data, contributionKey);\n })\n : [];\n\n this._attributeCollection = new AttributeCollection(\n this.data,\n attributeContributions,\n { ...modelOptions, isReadonly: true },\n );\n\n this._key = key;\n }\n\n /**\n */\n get key(): string {\n return this._key;\n }\n\n /**\n */\n set key(key: string) {\n this._key = key;\n }\n\n /**\n */\n get label(): ?string {\n return this.contributions.label;\n }\n\n /**\n * Retrieve attribute collection\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n * Set the attributes with a new AttributeCollection\n */\n set attributeCollection(collection: AttributeCollection) {\n this._attributeCollection = collection;\n }\n\n /**\n */\n createChildAttributeSetModel(\n key: string,\n dataObject: Object,\n index?: number,\n ): AttributeSetModel {\n return new AttributeSetModel(\n index ? `${key}-${index + 1}` : key,\n {\n ...dataObject,\n dynamicschema: this.data.dynamicschema,\n },\n this.contributions.objects[key],\n this.modelOptions,\n );\n }\n\n /**\n * Retrieve child
|
|
1
|
+
{"version":3,"file":"AttributeSetModel.js","names":["has","BaseModel","AttributeCollection","AttributeSetModel","constructor","key","data","contributions","modelOptions","_context","_defineProperty","attributeContributions","attributes","_filterInstanceProperty","call","contribution","contributionKey","_Object$keys","_attributeCollection","isReadonly","_key","label","attributeCollection","collection","createChildAttributeSetModel","dataObject","index","dynamicschema","objects","getChildAttributeSets","childAttributeSets","Array","isArray","i","_entriesInstanceProperty","_context2","push"],"sources":["../../../src/models/attributes/AttributeSetModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport AttributeCollection from \"./AttributeCollection\";\n\nimport type { ModelOptions } from \"../types\";\n\n/**\n */\nexport default class AttributeSetModel extends BaseModel {\n _key: string;\n _attributeCollection: AttributeCollection;\n\n /**\n */\n constructor(\n key: string = \"\",\n data: Object = {},\n contributions: Object = {},\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n const attributeContributions = this.contributions.attributes\n ? this.contributions.attributes.filter((contribution) => {\n const [contributionKey] = Object.keys(contribution);\n return has(this.data, contributionKey);\n })\n : [];\n\n this._attributeCollection = new AttributeCollection(\n this.data,\n attributeContributions,\n { ...modelOptions, isReadonly: true },\n );\n\n this._key = key;\n }\n\n /**\n */\n get key(): string {\n return this._key;\n }\n\n /**\n */\n set key(key: string) {\n this._key = key;\n }\n\n /**\n */\n get label(): ?string {\n return this.contributions.label;\n }\n\n /**\n * Retrieve attribute collection\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n * Set the attributes with a new AttributeCollection\n */\n set attributeCollection(collection: AttributeCollection) {\n this._attributeCollection = collection;\n }\n\n /**\n */\n createChildAttributeSetModel(\n key: string,\n dataObject: Object,\n index?: number,\n ): AttributeSetModel {\n return new AttributeSetModel(\n index ? `${key}-${index + 1}` : key,\n {\n ...dataObject,\n dynamicschema: this.data.dynamicschema,\n },\n this.contributions.objects[key],\n this.modelOptions,\n );\n }\n\n /**\n * Retrieve child AttributeSetModels\n */\n getChildAttributeSets(): Array<AttributeSetModel> {\n if (!this.contributions.objects) {\n return [];\n }\n\n const childAttributeSets = [];\n for (const key of Object.keys(this.contributions.objects)) {\n if (key in this.data) {\n if (Array.isArray(this.data[key])) {\n for (const [i, dataObject] of this.data[key].entries()) {\n childAttributeSets.push(\n this.createChildAttributeSetModel(key, dataObject, i),\n );\n }\n } else {\n childAttributeSets.push(\n this.createChildAttributeSetModel(key, this.data[key]),\n );\n }\n }\n }\n return childAttributeSets;\n }\n}\n"],"mappings":";;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,mBAAmB,MAAM,uBAAuB;AAIvD;AACA;AACA,eAAe,MAAMC,iBAAiB,SAASF,SAAS,CAAC;EAIvD;AACF;EACEG,WAAWA,CACTC,GAAW,GAAG,EAAE,EAChBC,IAAY,GAAG,CAAC,CAAC,EACjBC,aAAqB,GAAG,CAAC,CAAC,EAC1BC,YAA2B,EAC3B;IAAA,IAAAC,QAAA;IACA,KAAK,CAACH,IAAI,EAAEC,aAAa,EAAEC,YAAY,CAAC;IAACE,eAAA;IAAAA,eAAA;IAEzC,MAAMC,sBAAsB,GAAG,IAAI,CAACJ,aAAa,CAACK,UAAU,GACxDC,uBAAA,CAAAJ,QAAA,OAAI,CAACF,aAAa,CAACK,UAAU,EAAAE,IAAA,CAAAL,QAAA,EAASM,YAAY,IAAK;MACrD,MAAM,CAACC,eAAe,CAAC,GAAGC,YAAA,CAAYF,YAAY,CAAC;MACnD,OAAOf,GAAG,CAAC,IAAI,CAACM,IAAI,EAAEU,eAAe,CAAC;IACxC,CAAC,CAAC,GACF,EAAE;IAEN,IAAI,CAACE,oBAAoB,GAAG,IAAIhB,mBAAmB,CACjD,IAAI,CAACI,IAAI,EACTK,sBAAsB,EACtB;MAAE,GAAGH,YAAY;MAAEW,UAAU,EAAE;IAAK,CACtC,CAAC;IAED,IAAI,CAACC,IAAI,GAAGf,GAAG;EACjB;;EAEA;AACF;EACE,IAAIA,GAAGA,CAAA,EAAW;IA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AAAC,SAAA,OAAI,CAAC7B,IAAI,CAACD,GAAG,CAAC,EAAAS,IAAA,CAAAqB,SAAS,CAAC,EAAE;YAAA,IAAAA,SAAA;YACtDL,kBAAkB,CAACM,IAAI,CACrB,IAAI,CAACZ,4BAA4B,CAACnB,GAAG,EAAEoB,UAAU,EAAEQ,CAAC,CACtD,CAAC;UACH;QACF,CAAC,MAAM;UACLH,kBAAkB,CAACM,IAAI,CACrB,IAAI,CAACZ,4BAA4B,CAACnB,GAAG,EAAE,IAAI,CAACC,IAAI,CAACD,GAAG,CAAC,CACvD,CAAC;QACH;MACF;IACF;IACA,OAAOyB,kBAAkB;EAC3B;AACF","ignoreList":[]}
|
|
@@ -10,7 +10,7 @@ import ChoiceAttributeOptionModel from "./ChoiceAttributeOptionModel";
|
|
|
10
10
|
import CompositeAttributeModel from "./CompositeAttributeModel";
|
|
11
11
|
import ContentConfigurationElements from "../contentconfiguration/ContentConfigurationElements";
|
|
12
12
|
import { RENDER_SECTION_LABEL, SORT_OPTIONS } from "../../constants/LayoutHints";
|
|
13
|
-
import { ATTRIBUTE_WIDTH } from "../../constants";
|
|
13
|
+
import { ATTRIBUTE_WIDTH, PARAMETER_TYPES, HTTP_METHODS } from "../../constants";
|
|
14
14
|
/**
|
|
15
15
|
* Model for a choice attribute
|
|
16
16
|
*/
|
|
@@ -89,7 +89,24 @@ export default class ChoiceAttributeModel extends AttributeModel {
|
|
|
89
89
|
* Retrieve lookup service link
|
|
90
90
|
*/
|
|
91
91
|
get lookupLink() {
|
|
92
|
-
|
|
92
|
+
const link = this.links.getLinkByKey("lookupOptions");
|
|
93
|
+
if (link && this.lookupParameterType === PARAMETER_TYPES.BODY) {
|
|
94
|
+
link.method = HTTP_METHODS.POST;
|
|
95
|
+
}
|
|
96
|
+
return link;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Indicate if the lookup must be done with POST or GET
|
|
101
|
+
*/
|
|
102
|
+
get lookupParameterType() {
|
|
103
|
+
const parameterType = this.getContribution("parameterType");
|
|
104
|
+
switch (parameterType) {
|
|
105
|
+
case "bodyParameter":
|
|
106
|
+
return PARAMETER_TYPES.BODY;
|
|
107
|
+
default:
|
|
108
|
+
return PARAMETER_TYPES.QUERY;
|
|
109
|
+
}
|
|
93
110
|
}
|
|
94
111
|
|
|
95
112
|
/**
|
|
@@ -13,7 +13,11 @@ import {
|
|
|
13
13
|
RENDER_SECTION_LABEL,
|
|
14
14
|
SORT_OPTIONS,
|
|
15
15
|
} from "../../constants/LayoutHints";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
ATTRIBUTE_WIDTH,
|
|
18
|
+
PARAMETER_TYPES,
|
|
19
|
+
HTTP_METHODS,
|
|
20
|
+
} from "../../constants";
|
|
17
21
|
|
|
18
22
|
import type {
|
|
19
23
|
ModularUIModel,
|
|
@@ -133,7 +137,24 @@ export default class ChoiceAttributeModel extends AttributeModel {
|
|
|
133
137
|
* Retrieve lookup service link
|
|
134
138
|
*/
|
|
135
139
|
get lookupLink(): LinkModel | null {
|
|
136
|
-
|
|
140
|
+
const link = this.links.getLinkByKey("lookupOptions");
|
|
141
|
+
if (link && this.lookupParameterType === PARAMETER_TYPES.BODY) {
|
|
142
|
+
link.method = HTTP_METHODS.POST;
|
|
143
|
+
}
|
|
144
|
+
return link;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Indicate if the lookup must be done with POST or GET
|
|
149
|
+
*/
|
|
150
|
+
get lookupParameterType(): $Values<typeof PARAMETER_TYPES> {
|
|
151
|
+
const parameterType = this.getContribution("parameterType");
|
|
152
|
+
switch (parameterType) {
|
|
153
|
+
case "bodyParameter":
|
|
154
|
+
return PARAMETER_TYPES.BODY;
|
|
155
|
+
default:
|
|
156
|
+
return PARAMETER_TYPES.QUERY;
|
|
157
|
+
}
|
|
137
158
|
}
|
|
138
159
|
|
|
139
160
|
/**
|