@beinformed/ui 1.65.6 → 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 +20 -0
- package/esm/hooks/__tests__/UseModularUIModel.spec.js.flow +1 -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/useList.js +47 -3
- package/esm/hooks/useList.js.flow +74 -2
- package/esm/hooks/useList.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/usePanel.js +6 -1
- package/esm/hooks/usePanel.js.flow +6 -4
- package/esm/hooks/usePanel.js.map +1 -1
- 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/filters/AssignmentFilterModel.js +1 -12
- package/esm/models/filters/AssignmentFilterModel.js.flow +6 -14
- package/esm/models/filters/AssignmentFilterModel.js.map +1 -1
- package/esm/models/filters/BaseFilterModel.js +12 -0
- package/esm/models/filters/BaseFilterModel.js.flow +12 -0
- package/esm/models/filters/BaseFilterModel.js.map +1 -1
- package/esm/models/filters/ConceptIndexFilterModel.js.flow +5 -2
- package/esm/models/filters/ConceptIndexFilterModel.js.map +1 -1
- package/esm/models/filters/FilterCollection.js +26 -8
- package/esm/models/filters/FilterCollection.js.flow +23 -6
- package/esm/models/filters/FilterCollection.js.map +1 -1
- package/esm/models/filters/FilterModel.js.flow +2 -2
- package/esm/models/filters/FilterModel.js.map +1 -1
- package/esm/models/filters/RangeFilterModel.js.flow +2 -2
- package/esm/models/filters/RangeFilterModel.js.map +1 -1
- package/esm/models/filters/StringFilterModel.js.flow +2 -2
- package/esm/models/filters/StringFilterModel.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/esm/models/list/ListModel.js.flow +2 -2
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/search/CaseSearchModel.js.flow +2 -2
- package/esm/models/search/CaseSearchModel.js.map +1 -1
- package/esm/models/types.js +1 -1
- package/esm/models/types.js.flow +28 -10
- package/esm/models/types.js.map +1 -1
- package/esm/react-server/serverUtil.js +2 -2
- package/esm/react-server/serverUtil.js.flow +2 -2
- package/esm/react-server/serverUtil.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/useList.js +47 -3
- package/lib/hooks/useList.js.map +1 -1
- package/lib/hooks/useLookup.js +70 -0
- package/lib/hooks/useLookup.js.map +1 -0
- package/lib/hooks/usePanel.js +6 -1
- package/lib/hooks/usePanel.js.map +1 -1
- 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/filters/AssignmentFilterModel.js +0 -12
- package/lib/models/filters/AssignmentFilterModel.js.map +1 -1
- package/lib/models/filters/BaseFilterModel.js +12 -0
- package/lib/models/filters/BaseFilterModel.js.map +1 -1
- package/lib/models/filters/ConceptIndexFilterModel.js.map +1 -1
- package/lib/models/filters/FilterCollection.js +26 -8
- package/lib/models/filters/FilterCollection.js.map +1 -1
- package/lib/models/filters/FilterModel.js.map +1 -1
- package/lib/models/filters/RangeFilterModel.js.map +1 -1
- package/lib/models/filters/StringFilterModel.js.map +1 -1
- package/lib/models/links/LinkModel.js +17 -0
- package/lib/models/links/LinkModel.js.map +1 -1
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/search/CaseSearchModel.js.map +1 -1
- package/lib/models/types.js +2 -0
- package/lib/models/types.js.map +1 -1
- package/lib/react-server/serverUtil.js +5 -5
- package/lib/react-server/serverUtil.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/__tests__/UseModularUIModel.spec.js +1 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/useForm.js +7 -4
- package/src/hooks/useList.js +74 -2
- package/src/hooks/useLookup.js +82 -0
- package/src/hooks/usePanel.js +6 -4
- 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/filters/AssignmentFilterModel.js +6 -14
- package/src/models/filters/BaseFilterModel.js +12 -0
- package/src/models/filters/ConceptIndexFilterModel.js +5 -2
- package/src/models/filters/FilterCollection.js +23 -6
- package/src/models/filters/FilterModel.js +2 -2
- package/src/models/filters/RangeFilterModel.js +2 -2
- package/src/models/filters/StringFilterModel.js +2 -2
- package/src/models/links/LinkModel.js +18 -1
- package/src/models/list/ListModel.js +2 -2
- package/src/models/search/CaseSearchModel.js +2 -2
- package/src/models/types.js +28 -10
- package/src/react-server/serverUtil.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
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
|
+
|
|
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)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* **hooks:** extend `useList` with advanced filter and pagination methods ([fe5b8f9](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/fe5b8f96d881e19d7061f2af097973cb3a467d75))
|
|
22
|
+
* **panels:** expect correct target models ([8cce991](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/8cce991864ec89ea447d8c55ad6c983d2f466db0))
|
|
23
|
+
* **server:** use correct import ([f7c81cb](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/f7c81cbb1acdcf6f8480bbfa2c7fd2bddcf84eed))
|
|
24
|
+
|
|
5
25
|
## [1.65.6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.5...v1.65.6) (2026-01-06)
|
|
6
26
|
|
|
7
27
|
## [1.65.5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.1...v1.65.5) (2026-01-05)
|
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,Q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AAC;IACrDW,MAAM,EAAGa,MAAuB,IAC9Bf,QAAQ,CAACtB,4BAA4B,CAACa,IAAI,EAAEwB,MAAM,CAAC,CAAC;IACtDH,MAAM,EAAGG,MAAuB,IAC9Bf,QAAQ,CAACpB,4BAA4B,CAACW,IAAI,EAAEwB,MAAM,CAAC;EACvD,CAAC;AACH,CAAC","ignoreList":[]}
|
package/esm/hooks/useList.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useHistory } from "react-router";
|
|
2
2
|
import { useDispatch } from "react-redux";
|
|
3
|
+
import { useModularUIBasic } from "./useModularUIBasic";
|
|
3
4
|
import { HTTP_METHODS } from "../constants/Constants";
|
|
4
5
|
import { loadModularUI } from "../redux";
|
|
5
6
|
import DetailModel from "../models/detail/DetailModel";
|
|
@@ -7,7 +8,9 @@ import ListModel from "../models/list/ListModel";
|
|
|
7
8
|
import CaseSearchModel from "../models/search/CaseSearchModel";
|
|
8
9
|
import ListDetailModel from "../models/list/ListDetailModel";
|
|
9
10
|
import Href from "../models/href/Href";
|
|
10
|
-
import
|
|
11
|
+
import FilterCollection from "../models/filters/FilterCollection";
|
|
12
|
+
import AssignmentFilterModel from "../models/filters/AssignmentFilterModel";
|
|
13
|
+
import FilterModel from "../models/filters/FilterModel";
|
|
11
14
|
/**
|
|
12
15
|
*/
|
|
13
16
|
export const useList = (href, options) => useModularUIBasic("list", href, {
|
|
@@ -63,8 +66,49 @@ export const useListNavigation = () => {
|
|
|
63
66
|
}));
|
|
64
67
|
}
|
|
65
68
|
};
|
|
69
|
+
const updateFilters = (list, filters) => {
|
|
70
|
+
list.filterCollection = filters;
|
|
71
|
+
update(list, true);
|
|
72
|
+
};
|
|
73
|
+
const updateFilter = (list, filter, value, attribute) => {
|
|
74
|
+
if (attribute) {
|
|
75
|
+
filter.update(attribute, value);
|
|
76
|
+
} else if (filter instanceof AssignmentFilterModel) {
|
|
77
|
+
throw new Error("Need the attribute to update for AssigmentFilterModel");
|
|
78
|
+
} else if (filter instanceof FilterModel) {
|
|
79
|
+
filter.update(filter.attribute, value);
|
|
80
|
+
}
|
|
81
|
+
update(list, true);
|
|
82
|
+
};
|
|
83
|
+
const resetFilters = list => {
|
|
84
|
+
list.filterCollection.reset();
|
|
85
|
+
update(list, true);
|
|
86
|
+
};
|
|
87
|
+
const removeFilter = (list, filter) => {
|
|
88
|
+
list.filterCollection.getFilterByName(filter.name)?.reset();
|
|
89
|
+
update(list, true);
|
|
90
|
+
};
|
|
91
|
+
const updateSort = (list, sortOption) => {
|
|
92
|
+
list.sorting.value = sortOption;
|
|
93
|
+
update(list, true);
|
|
94
|
+
};
|
|
95
|
+
const updatePage = (list, page) => {
|
|
96
|
+
list.paging.page = page;
|
|
97
|
+
update(list);
|
|
98
|
+
};
|
|
99
|
+
const updatePageSize = (list, pagesize) => {
|
|
100
|
+
list.paging.pagesize.value = pagesize;
|
|
101
|
+
update(list);
|
|
102
|
+
};
|
|
66
103
|
return {
|
|
67
|
-
update
|
|
104
|
+
update,
|
|
105
|
+
updateFilters,
|
|
106
|
+
updateFilter,
|
|
107
|
+
updateSort,
|
|
108
|
+
updatePage,
|
|
109
|
+
updatePageSize,
|
|
110
|
+
resetFilters,
|
|
111
|
+
removeFilter
|
|
68
112
|
};
|
|
69
113
|
};
|
|
70
114
|
//# sourceMappingURL=useList.js.map
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import {
|
|
2
|
+
import { useHistory } from "react-router";
|
|
3
3
|
import { useDispatch } from "react-redux";
|
|
4
|
+
|
|
5
|
+
import { useModularUIBasic } from "./useModularUIBasic";
|
|
4
6
|
import { HTTP_METHODS } from "../constants/Constants";
|
|
7
|
+
|
|
5
8
|
import { loadModularUI } from "../redux";
|
|
9
|
+
|
|
6
10
|
import DetailModel from "../models/detail/DetailModel";
|
|
7
11
|
import ListModel from "../models/list/ListModel";
|
|
8
12
|
import CaseSearchModel from "../models/search/CaseSearchModel";
|
|
9
13
|
import ListDetailModel from "../models/list/ListDetailModel";
|
|
10
14
|
import Href from "../models/href/Href";
|
|
15
|
+
import FilterCollection from "../models/filters/FilterCollection";
|
|
16
|
+
import AssignmentFilterModel from "../models/filters/AssignmentFilterModel";
|
|
17
|
+
import FilterModel from "../models/filters/FilterModel";
|
|
11
18
|
|
|
12
19
|
import type { HookOptions } from "./useModularUIBasic";
|
|
13
|
-
import {
|
|
20
|
+
import type { AttributeType, IFilter } from "../models/types";
|
|
14
21
|
|
|
15
22
|
type ListNavigationHook = {
|
|
16
23
|
update: (list: ListModel, resetPage?: boolean) => void,
|
|
24
|
+
updateFilters: (list: ListModel, filters: FilterCollection) => void,
|
|
25
|
+
updateFilter: (
|
|
26
|
+
list: ListModel,
|
|
27
|
+
filter: IFilter,
|
|
28
|
+
value: string,
|
|
29
|
+
attribute?: AttributeType,
|
|
30
|
+
) => void,
|
|
31
|
+
updateSort: (list: ListModel, sortOption: string) => void,
|
|
32
|
+
updatePage: (list: ListModel, page: number) => void,
|
|
33
|
+
updatePageSize: (list: ListModel, pagesize: number) => void,
|
|
34
|
+
resetFilters: (list: ListModel) => void,
|
|
35
|
+
removeFilter: (list: ListModel, filter: IFilter) => void,
|
|
17
36
|
};
|
|
18
37
|
|
|
19
38
|
/**
|
|
@@ -85,7 +104,60 @@ export const useListNavigation = (): ListNavigationHook => {
|
|
|
85
104
|
}
|
|
86
105
|
};
|
|
87
106
|
|
|
107
|
+
const updateFilters = (list: ListModel, filters: FilterCollection) => {
|
|
108
|
+
list.filterCollection = filters;
|
|
109
|
+
update(list, true);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const updateFilter = (
|
|
113
|
+
list: ListModel,
|
|
114
|
+
filter: IFilter,
|
|
115
|
+
value: string,
|
|
116
|
+
attribute?: AttributeType,
|
|
117
|
+
) => {
|
|
118
|
+
if (attribute) {
|
|
119
|
+
filter.update(attribute, value);
|
|
120
|
+
} else if (filter instanceof AssignmentFilterModel) {
|
|
121
|
+
throw new Error("Need the attribute to update for AssigmentFilterModel");
|
|
122
|
+
} else if (filter instanceof FilterModel) {
|
|
123
|
+
filter.update(filter.attribute, value);
|
|
124
|
+
}
|
|
125
|
+
update(list, true);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const resetFilters = (list: ListModel) => {
|
|
129
|
+
list.filterCollection.reset();
|
|
130
|
+
update(list, true);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const removeFilter = (list: ListModel, filter: IFilter) => {
|
|
134
|
+
list.filterCollection.getFilterByName(filter.name)?.reset();
|
|
135
|
+
update(list, true);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const updateSort = (list: ListModel, sortOption: string) => {
|
|
139
|
+
list.sorting.value = sortOption;
|
|
140
|
+
update(list, true);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const updatePage = (list: ListModel, page: number) => {
|
|
144
|
+
list.paging.page = page;
|
|
145
|
+
update(list);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const updatePageSize = (list: ListModel, pagesize: number) => {
|
|
149
|
+
list.paging.pagesize.value = pagesize;
|
|
150
|
+
update(list);
|
|
151
|
+
};
|
|
152
|
+
|
|
88
153
|
return {
|
|
89
154
|
update,
|
|
155
|
+
updateFilters,
|
|
156
|
+
updateFilter,
|
|
157
|
+
updateSort,
|
|
158
|
+
updatePage,
|
|
159
|
+
updatePageSize,
|
|
160
|
+
resetFilters,
|
|
161
|
+
removeFilter,
|
|
90
162
|
};
|
|
91
163
|
};
|
package/esm/hooks/useList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.js","names":["
|
|
1
|
+
{"version":3,"file":"useList.js","names":["useHistory","useDispatch","useModularUIBasic","HTTP_METHODS","loadModularUI","DetailModel","ListModel","CaseSearchModel","ListDetailModel","Href","FilterCollection","AssignmentFilterModel","FilterModel","useList","href","options","expectedModels","targetModel","useListOrDetail","useListDetail","forceTargetModel","useListNavigation","history","dispatch","update","list","resetPage","listHref","selfhref","page","requestMethod","POST","push","search","querystring","state","formdata","connectKey","method","data","GET","updateFilters","filters","filterCollection","updateFilter","filter","value","attribute","Error","resetFilters","reset","removeFilter","getFilterByName","name","updateSort","sortOption","sorting","updatePage","paging","updatePageSize","pagesize"],"sources":["../../src/hooks/useList.js"],"sourcesContent":["// @flow\nimport { useHistory } from \"react-router\";\nimport { useDispatch } from \"react-redux\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { HTTP_METHODS } from \"../constants/Constants\";\n\nimport { loadModularUI } from \"../redux\";\n\nimport DetailModel from \"../models/detail/DetailModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport Href from \"../models/href/Href\";\nimport FilterCollection from \"../models/filters/FilterCollection\";\nimport AssignmentFilterModel from \"../models/filters/AssignmentFilterModel\";\nimport FilterModel from \"../models/filters/FilterModel\";\n\nimport type { HookOptions } from \"./useModularUIBasic\";\nimport type { AttributeType, IFilter } from \"../models/types\";\n\ntype ListNavigationHook = {\n update: (list: ListModel, resetPage?: boolean) => void,\n updateFilters: (list: ListModel, filters: FilterCollection) => void,\n updateFilter: (\n list: ListModel,\n filter: IFilter,\n value: string,\n attribute?: AttributeType,\n ) => void,\n updateSort: (list: ListModel, sortOption: string) => void,\n updatePage: (list: ListModel, page: number) => void,\n updatePageSize: (list: ListModel, pagesize: number) => void,\n resetFilters: (list: ListModel) => void,\n removeFilter: (list: ListModel, filter: IFilter) => void,\n};\n\n/**\n */\nexport const useList = (\n href: string | Href,\n options?: HookOptions,\n): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"CaseSearch\"],\n targetModel: [ListModel, CaseSearchModel],\n ...options,\n });\n\n/**\n */\nexport const useListOrDetail = (\n href: string | Href,\n options?: HookOptions,\n): ListModel | DetailModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"CaseSearch\", \"Detail\"],\n targetModel: [ListModel, CaseSearchModel, DetailModel],\n ...options,\n });\n\n/**\n */\nexport const useListDetail = (\n href: string | Href,\n options?: HookOptions,\n): ListDetailModel | null =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n forceTargetModel: true,\n ...options,\n });\n\n/**\n */\nexport const useListNavigation = (): ListNavigationHook => {\n const history = useHistory();\n const dispatch = useDispatch();\n\n const update = (list: ListModel, resetPage: boolean = false) => {\n const listHref = list.selfhref;\n if (resetPage) {\n listHref.page = null;\n }\n\n if (list.requestMethod === HTTP_METHODS.POST) {\n history.push({ search: listHref.querystring, state: list.formdata });\n dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.POST,\n data: list.formdata,\n targetModel: [ListModel, CaseSearchModel],\n }),\n );\n } else {\n history.push({ search: listHref.querystring });\n dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.GET,\n targetModel: [ListModel, CaseSearchModel],\n }),\n );\n }\n };\n\n const updateFilters = (list: ListModel, filters: FilterCollection) => {\n list.filterCollection = filters;\n update(list, true);\n };\n\n const updateFilter = (\n list: ListModel,\n filter: IFilter,\n value: string,\n attribute?: AttributeType,\n ) => {\n if (attribute) {\n filter.update(attribute, value);\n } else if (filter instanceof AssignmentFilterModel) {\n throw new Error(\"Need the attribute to update for AssigmentFilterModel\");\n } else if (filter instanceof FilterModel) {\n filter.update(filter.attribute, value);\n }\n update(list, true);\n };\n\n const resetFilters = (list: ListModel) => {\n list.filterCollection.reset();\n update(list, true);\n };\n\n const removeFilter = (list: ListModel, filter: IFilter) => {\n list.filterCollection.getFilterByName(filter.name)?.reset();\n update(list, true);\n };\n\n const updateSort = (list: ListModel, sortOption: string) => {\n list.sorting.value = sortOption;\n update(list, true);\n };\n\n const updatePage = (list: ListModel, page: number) => {\n list.paging.page = page;\n update(list);\n };\n\n const updatePageSize = (list: ListModel, pagesize: number) => {\n list.paging.pagesize.value = pagesize;\n update(list);\n };\n\n return {\n update,\n updateFilters,\n updateFilter,\n updateSort,\n updatePage,\n updatePageSize,\n resetFilters,\n removeFilter,\n };\n};\n"],"mappings":"AACA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,YAAY,QAAQ,wBAAwB;AAErD,SAASC,aAAa,QAAQ,UAAU;AAExC,OAAOC,WAAW,MAAM,8BAA8B;AACtD,OAAOC,SAAS,MAAM,0BAA0B;AAChD,OAAOC,eAAe,MAAM,kCAAkC;AAC9D,OAAOC,eAAe,MAAM,gCAAgC;AAC5D,OAAOC,IAAI,MAAM,qBAAqB;AACtC,OAAOC,gBAAgB,MAAM,oCAAoC;AACjE,OAAOC,qBAAqB,MAAM,yCAAyC;AAC3E,OAAOC,WAAW,MAAM,+BAA+B;AAqBvD;AACA;AACA,OAAO,MAAMC,OAAO,GAAGA,CACrBC,IAAmB,EACnBC,OAAqB,KAErBb,iBAAiB,CAAC,MAAM,EAAEY,IAAI,EAAE;EAC9BE,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC;EACtCC,WAAW,EAAE,CAACX,SAAS,EAAEC,eAAe,CAAC;EACzC,GAAGQ;AACL,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAMG,eAAe,GAAGA,CAC7BJ,IAAmB,EACnBC,OAAqB,KAErBb,iBAAiB,CAAC,MAAM,EAAEY,IAAI,EAAE;EAC9BE,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC;EAChDC,WAAW,EAAE,CAACX,SAAS,EAAEC,eAAe,EAAEF,WAAW,CAAC;EACtD,GAAGU;AACL,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAMI,aAAa,GAAGA,CAC3BL,IAAmB,EACnBC,OAAqB,KAErBb,iBAAiB,CAAC,YAAY,EAAEY,IAAI,EAAE;E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AAM,CAACC,IAAI,CAAC;EACd,CAAC;EAED,MAAMkC,cAAc,GAAGA,CAAClC,IAAe,EAAEmC,QAAgB,KAAK;IAC5DnC,IAAI,CAACiC,MAAM,CAACE,QAAQ,CAACd,KAAK,GAAGc,QAAQ;IACrCpC,MAAM,CAACC,IAAI,CAAC;EACd,CAAC;EAED,OAAO;IACLD,MAAM;IACNiB,aAAa;IACbG,YAAY;IACZU,UAAU;IACVG,UAAU;IACVE,cAAc;IACdV,YAAY;IACZE;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,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,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,SAASC,YAAY,QAAQ,cAAc;AAE3C,OAAOC,IAAI,MAAM,qBAAqB;AACtC,OAAOC,SAAS,MAAM,2BAA2B;AACjD,OAAOC,kBAAkB,MAAM,qCAAqC;AAEpE,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,oBAAoB,QAAQ,wBAAwB;AAO7D;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAGA,CACvBC,UAAqB,EACrBC,WAAmB,GAAG,EAAE,EACxBC,SAAiB,GAAG,CAAC,EACrBC,UAAkB,GAAG,GAAG,KACN;EAClB,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGP,oBAAoB,CAAC,CAAC;EAChD,MAAMQ,gBAAgB,GAAGT,mBAAmB,CAAC,CAAC;EAE9C,MAAM,CAACU,aAAa,EAAEC,gBAAgB,CAAC,GAAGhB,QAAQ,CAAC,IAAI,CAAC;EACxD,MAAM,CAACiB,aAAa,EAAEC,gBAAgB,CAAC,GAAGlB,QAAQ,CAAC,KAAK,CAAC;EAEzD,MAAM;IAAEmB,IAAI;IAAEC,UAAU;IAAEC;EAAO,CAAC,GAAGb,UAAU;EAE/CT,SAAS,CAAC,MAAM;IACd,IAAIU,WAAW,CAACa,MAAM,GAAGZ,SAAS,EAAE;MAClCM,gBAAgB,CAAC,IAAI,CAAC;MACtB;IACF;IAEA,MAAMO,SAAS,GAAGC,UAAU,CAAC,YAAY;MACvCN,gBAAgB,CAAC,IAAI,CAAC;MACtBN,KAAK,CAAC,CAAC;MAEP,MAAMa,UAAU,GAAG,IAAIvB,IAAI,CAACiB,IAAI,CAAC;MACjC,MAAMO,cAAc,GAAG;QAAEL,MAAM;QAAEM,IAAI,EAAEC;MAAU,CAAC;MAClD,IAAIP,MAAM,KAAKpB,YAAY,CAAC4B,IAAI,EAAE;QAChCH,cAAc,CAACC,IAAI,GAAG;UAAE,CAACP,UAAU,GAAGX;QAAY,CAAC;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":[]}
|
package/esm/hooks/usePanel.js
CHANGED
|
@@ -3,6 +3,10 @@ import { useState, useMemo } from "react";
|
|
|
3
3
|
import { useLocation, useRouteMatch } from "react-router";
|
|
4
4
|
import Href from "../models/href/Href";
|
|
5
5
|
import { useModularUIBasic } from "./useModularUIBasic";
|
|
6
|
+
import GroupingPanelModel from "../models/panels/GroupingPanelModel";
|
|
7
|
+
import ListModel from "../models/list/ListModel";
|
|
8
|
+
import DetailModel from "../models/detail/DetailModel";
|
|
9
|
+
import CaseSearchModel from "../models/search/CaseSearchModel";
|
|
6
10
|
const useUrl = (href, fromRoute = false) => {
|
|
7
11
|
const [previousUrl, setPreviousUrl] = useState(null);
|
|
8
12
|
const [previousExact, setPreviousExact] = useState(false);
|
|
@@ -46,7 +50,8 @@ export const usePanel = (href, options) => {
|
|
|
46
50
|
};
|
|
47
51
|
const url = useUrl(href, fromRoute || false);
|
|
48
52
|
const basicOptions = {
|
|
49
|
-
expectedModels: ["List", "GroupingPanel", "Detail"],
|
|
53
|
+
expectedModels: ["List", "GroupingPanel", "Detail", "CaseSearch"],
|
|
54
|
+
targetModel: [ListModel, GroupingPanelModel, DetailModel, CaseSearchModel],
|
|
50
55
|
...hookOptions
|
|
51
56
|
};
|
|
52
57
|
return useModularUIBasic("panel", url, basicOptions);
|
|
@@ -5,9 +5,10 @@ import Href from "../models/href/Href";
|
|
|
5
5
|
import { useModularUIBasic } from "./useModularUIBasic";
|
|
6
6
|
|
|
7
7
|
import type { HookOptions } from "./useModularUIBasic";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
8
|
+
import GroupingPanelModel from "../models/panels/GroupingPanelModel";
|
|
9
|
+
import ListModel from "../models/list/ListModel";
|
|
10
|
+
import DetailModel from "../models/detail/DetailModel";
|
|
11
|
+
import CaseSearchModel from "../models/search/CaseSearchModel";
|
|
11
12
|
|
|
12
13
|
const useUrl = (href?: string | Href, fromRoute: boolean = false) => {
|
|
13
14
|
const [previousUrl, setPreviousUrl] = useState(null);
|
|
@@ -69,7 +70,8 @@ export const usePanel = (
|
|
|
69
70
|
|
|
70
71
|
const url = useUrl(href, fromRoute || false);
|
|
71
72
|
const basicOptions = {
|
|
72
|
-
expectedModels: ["List", "GroupingPanel", "Detail"],
|
|
73
|
+
expectedModels: ["List", "GroupingPanel", "Detail", "CaseSearch"],
|
|
74
|
+
targetModel: [ListModel, GroupingPanelModel, DetailModel, CaseSearchModel],
|
|
73
75
|
...(hookOptions: HookOptions),
|
|
74
76
|
};
|
|
75
77
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePanel.js","names":["useState","useMemo","useLocation","useRouteMatch","Href","useModularUIBasic","useUrl","href","fromRoute","previousUrl","setPreviousUrl","previousExact","setPreviousExact","match","location","_context","url","isExact","addParametersFromString","search","equalsWithParameters","shouldUpdate","Function","call","bind","_startsWithInstanceProperty","usePanel","options","hookOptions","basicOptions","expectedModels"],"sources":["../../src/hooks/usePanel.js"],"sourcesContent":["// @flow\nimport { useState, useMemo } from \"react\";\nimport { useLocation, useRouteMatch } from \"react-router\";\nimport Href from \"../models/href/Href\";\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\nimport type { HookOptions } from \"./useModularUIBasic\";\nimport
|
|
1
|
+
{"version":3,"file":"usePanel.js","names":["useState","useMemo","useLocation","useRouteMatch","Href","useModularUIBasic","GroupingPanelModel","ListModel","DetailModel","CaseSearchModel","useUrl","href","fromRoute","previousUrl","setPreviousUrl","previousExact","setPreviousExact","match","location","_context","url","isExact","addParametersFromString","search","equalsWithParameters","shouldUpdate","Function","call","bind","_startsWithInstanceProperty","usePanel","options","hookOptions","basicOptions","expectedModels","targetModel"],"sources":["../../src/hooks/usePanel.js"],"sourcesContent":["// @flow\nimport { useState, useMemo } from \"react\";\nimport { useLocation, useRouteMatch } from \"react-router\";\nimport Href from \"../models/href/Href\";\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\nimport type { HookOptions } from \"./useModularUIBasic\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\n\nconst useUrl = (href?: string | Href, fromRoute: boolean = false) => {\n const [previousUrl, setPreviousUrl] = useState(null);\n const [previousExact, setPreviousExact] = useState(false);\n\n const match = useRouteMatch();\n const location = useLocation();\n\n return useMemo(() => {\n if (href == null && previousUrl == null) {\n return new Href(\"\");\n }\n\n const url = href instanceof Href ? href : new Href(href);\n\n if (!fromRoute) {\n return url;\n }\n\n if (match.isExact) {\n url.addParametersFromString(location.search);\n }\n\n // Check equality to prevent unnecessary state updates\n if (url.equalsWithParameters(previousUrl)) {\n return previousUrl || url;\n }\n\n const shouldUpdate =\n match.isExact === true ||\n previousExact === match.isExact ||\n !previousUrl?.startsWith(match.url);\n\n if (shouldUpdate) {\n setPreviousUrl(url);\n setPreviousExact(match.isExact);\n return url;\n }\n\n return previousUrl || new Href(\"\");\n }, [\n href,\n previousUrl,\n fromRoute,\n match.isExact,\n match.url,\n previousExact,\n location.search,\n ]);\n};\n\n/**\n */\nexport const usePanel = (\n href?: string | Href,\n options?: HookOptions & { fromRoute?: boolean },\n): ListModel | GroupingPanelModel | DetailModel | null => {\n const { fromRoute, ...hookOptions } = options || { fromRoute: false };\n\n const url = useUrl(href, fromRoute || false);\n const basicOptions = {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\", \"CaseSearch\"],\n targetModel: [ListModel, GroupingPanelModel, DetailModel, CaseSearchModel],\n ...(hookOptions: HookOptions),\n };\n\n return useModularUIBasic(\"panel\", url, basicOptions);\n};\n"],"mappings":";AACA,SAASA,QAAQ,EAAEC,OAAO,QAAQ,OAAO;AACzC,SAASC,WAAW,EAAEC,aAAa,QAAQ,cAAc;AACzD,OAAOC,IAAI,MAAM,qBAAqB;AACtC,SAASC,iBAAiB,QAAQ,qBAAqB;AAGvD,OAAOC,kBAAkB,MAAM,qCAAqC;AACpE,OAAOC,SAAS,MAAM,0BAA0B;AAChD,OAAOC,WAAW,MAAM,8BAA8B;AACtD,OAAOC,eAAe,MAAM,kCAAkC;AAE9D,MAAMC,MAAM,GAAGA,CAACC,IAAoB,EAAEC,SAAkB,GAAG,KAAK,KAAK;EACnE,MAAM,C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,WAAW,EACXD,SAAS,EACTK,KAAK,CAACI,OAAO,EACbJ,KAAK,CAACG,GAAG,EACTL,aAAa,EACbG,QAAQ,CAACK,MAAM,CAChB,CAAC;AACJ,CAAC;;AAED;AACA;AACA,OAAO,MAAMO,QAAQ,GAAGA,CACtBnB,IAAoB,EACpBoB,OAA+C,KACS;EACxD,MAAM;IAAEnB,SAAS;IAAE,GAAGoB;EAAY,CAAC,GAAGD,OAAO,IAAI;IAAEnB,SAAS,EAAE;EAAM,CAAC;EAErE,MAAMQ,GAAG,GAAGV,MAAM,CAACC,IAAI,EAAEC,SAAS,IAAI,KAAK,CAAC;EAC5C,MAAMqB,YAAY,GAAG;IACnBC,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,CAAC;IACjEC,WAAW,EAAE,CAAC5B,SAAS,EAAED,kBAAkB,EAAEE,WAAW,EAAEC,eAAe,CAAC;IAC1E,GAAIuB;EACN,CAAC;EAED,OAAO3B,iBAAiB,CAAC,OAAO,EAAEe,GAAG,EAAEa,YAAY,CAAC;AACtD,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
|