@beinformed/ui 1.65.7 → 1.65.9
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 +18 -0
- package/esm/hooks/__tests__/UseModularUIModel.spec.js.flow +1 -1
- package/esm/hooks/index.js +3 -1
- package/esm/hooks/index.js.flow +3 -1
- 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 +37 -26
- package/esm/hooks/useList.js.flow +140 -83
- 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/useModularUIModel.js +0 -17
- package/esm/hooks/useModularUIModel.js.flow +0 -25
- package/esm/hooks/useModularUIModel.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/hooks/useSearch.js +19 -0
- package/esm/hooks/useSearch.js.flow +31 -0
- package/esm/hooks/useSearch.js.map +1 -0
- 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 +26 -4
- 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 +37 -26
- 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/useModularUIModel.js +1 -20
- package/lib/hooks/useModularUIModel.js.map +1 -1
- package/lib/hooks/useProgressIndicator.js +23 -7
- package/lib/hooks/useProgressIndicator.js.map +1 -1
- package/lib/hooks/useSearch.js +28 -0
- package/lib/hooks/useSearch.js.map +1 -0
- 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/__tests__/UseModularUIModel.spec.js +1 -1
- package/src/hooks/index.js +3 -1
- package/src/hooks/useForm.js +7 -4
- package/src/hooks/useList.js +140 -83
- package/src/hooks/useLookup.js +82 -0
- package/src/hooks/useModularUIModel.js +0 -25
- package/src/hooks/useProgressIndicator.js +27 -10
- package/src/hooks/useSearch.js +31 -0
- 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,24 @@
|
|
|
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.9](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.8...v1.65.9) (2026-01-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **hooks:** extract `useSearch` and enhance `useList` with memoized navigation methods ([7dc27df](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/7dc27df7511abebc356fa94303cb8cd4990d8e22))
|
|
11
|
+
|
|
12
|
+
## [1.65.8](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.5...v1.65.8) (2026-01-07)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **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))
|
|
18
|
+
* **hook:** separate progress indicator state and actions ([cc201ac](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/cc201acee207bb63fe9c23f15e6c45aade3f04c7))
|
|
19
|
+
* **hooks:** extend `useList` with advanced filter and pagination methods ([fe5b8f9](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/fe5b8f96d881e19d7061f2af097973cb3a467d75))
|
|
20
|
+
* **panels:** expect correct target models ([8cce991](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/8cce991864ec89ea447d8c55ad6c983d2f466db0))
|
|
21
|
+
* **server:** use correct import ([f7c81cb](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/f7c81cbb1acdcf6f8480bbfa2c7fd2bddcf84eed))
|
|
22
|
+
|
|
5
23
|
## [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
24
|
|
|
7
25
|
|
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
useCaseView,
|
|
13
13
|
useGroupingPanel,
|
|
14
14
|
useDetailPanel,
|
|
15
|
-
useQuicksearch,
|
|
16
15
|
useUserProfile,
|
|
17
16
|
} from "../useModularUIModel";
|
|
18
17
|
import { useList, useListDetail } from "../useList";
|
|
19
18
|
import { usePanel } from "../usePanel";
|
|
19
|
+
import { useQuicksearch } from "../useSearch";
|
|
20
20
|
import {
|
|
21
21
|
ApplicationModel,
|
|
22
22
|
CaseSearchModel,
|
package/esm/hooks/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
export * from "./useAllFormsOnModel";
|
|
1
2
|
export * from "./useAuthentication";
|
|
2
3
|
export * from "./useContent";
|
|
3
4
|
export * from "./useForm";
|
|
4
5
|
export * from "./useI18n";
|
|
5
6
|
export * from "./useList";
|
|
7
|
+
export * from "./useLookup";
|
|
6
8
|
export * from "./useModal";
|
|
7
9
|
export * from "./useModelCatalog";
|
|
8
10
|
export * from "./useModels";
|
|
@@ -15,5 +17,5 @@ export * from "./usePanel";
|
|
|
15
17
|
export * from "./usePreference";
|
|
16
18
|
export * from "./useProgressIndicator";
|
|
17
19
|
export * from "./useRouter";
|
|
18
|
-
export * from "./
|
|
20
|
+
export * from "./useSearch";
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
package/esm/hooks/index.js.flow
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// @flow
|
|
2
|
+
export * from "./useAllFormsOnModel";
|
|
2
3
|
export * from "./useAuthentication";
|
|
3
4
|
export * from "./useContent";
|
|
4
5
|
export * from "./useForm";
|
|
5
6
|
export * from "./useI18n";
|
|
6
7
|
export * from "./useList";
|
|
8
|
+
export * from "./useLookup";
|
|
7
9
|
export * from "./useModal";
|
|
8
10
|
export * from "./useModelCatalog";
|
|
9
11
|
export * from "./useModels";
|
|
@@ -16,4 +18,4 @@ export * from "./usePanel";
|
|
|
16
18
|
export * from "./usePreference";
|
|
17
19
|
export * from "./useProgressIndicator";
|
|
18
20
|
export * from "./useRouter";
|
|
19
|
-
export * from "./
|
|
21
|
+
export * from "./useSearch";
|
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 \"./
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/hooks/index.js"],"sourcesContent":["// @flow\nexport * from \"./useAllFormsOnModel\";\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 \"./useSearch\";\n"],"mappings":"AACA,cAAc,sBAAsB;AACpC,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,aAAa","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;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAGA,CAACC,IAAmB,EAAEC,IAAa,KAAiB;EACzE,MAAMC,QAAQ,GAAG,IAAIN,IAAI,CAACI,IAAI,CAAC;EAE/B,IAAI,CAACf,UAAU,CAAC,oBAAoB,CAAC,EAAE;IACrCiB,QAAQ,CAACC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;EAC1C;EAEA,MAAMC,IAAI,GAAGN,YAAY,CAAC,MAAM,EAAEI,QAAQ,EAAE;IAC1CG,MAAM,EAAEnB,YAAY,CAACoB,IAAI;IACzBC,WAAW,EAAEV,SAAS;IACtBW,eAAe,EAAE,IAAI;IACrBP,IAAI;IACJQ,MAAM,EAAEP,QAAQ,CAACO,MAAM;IACvBC,WAAW,EAAER,QAAQ,CAACQ;EACxB,CAAC,CAAC;EAEF,IAAIN,IAAI,EAAEO,KAAK,EAAE;IACf,OAAOP,IAAI,CAACO,KAAK;EACnB;AACF,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGA,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,EACbC,OAA0B,KACvBlB,QAAQ,CAAClB,mBAAmB,CAACS,IAAI,EAAEwB,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,CAAC,CAAC;AAC7E,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAI5B,IAAe,IAAuB;EACpE,MAAMS,QAAQ,GAAG7B,WAAW,CAAC,CAAC;EAE9B,OAAO;IACLiD,IAAI,EAAEA,CAAA,KAAMpB,QAAQ,CAACxB,yBAAyB,CAACe,IAAI,CAAC,CAAC;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
|
@@ -11,6 +11,7 @@ import Href from "../models/href/Href";
|
|
|
11
11
|
import FilterCollection from "../models/filters/FilterCollection";
|
|
12
12
|
import AssignmentFilterModel from "../models/filters/AssignmentFilterModel";
|
|
13
13
|
import FilterModel from "../models/filters/FilterModel";
|
|
14
|
+
import { useCallback, useMemo } from "react";
|
|
14
15
|
/**
|
|
15
16
|
*/
|
|
16
17
|
export const useList = (href, options) => useModularUIBasic("list", href, {
|
|
@@ -38,39 +39,49 @@ export const useListDetail = (href, options) => useModularUIBasic("listdetail",
|
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
*/
|
|
41
|
-
export const useListNavigation = (
|
|
42
|
+
export const useListNavigation = ({
|
|
43
|
+
syncLocation,
|
|
44
|
+
historyAction
|
|
45
|
+
} = {
|
|
46
|
+
syncLocation: true,
|
|
47
|
+
historyAction: "push"
|
|
48
|
+
}) => {
|
|
42
49
|
const history = useHistory();
|
|
43
50
|
const dispatch = useDispatch();
|
|
44
|
-
const update = (list, resetPage = false) => {
|
|
51
|
+
const update = useCallback((list, resetPage = false) => {
|
|
45
52
|
const listHref = list.selfhref;
|
|
46
53
|
if (resetPage) {
|
|
47
54
|
listHref.page = null;
|
|
48
55
|
}
|
|
49
56
|
if (list.requestMethod === HTTP_METHODS.POST) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
if (syncLocation) {
|
|
58
|
+
history[historyAction]({
|
|
59
|
+
search: listHref.querystring,
|
|
60
|
+
state: list.formdata
|
|
61
|
+
});
|
|
62
|
+
}
|
|
54
63
|
dispatch(loadModularUI(list.connectKey, listHref, {
|
|
55
64
|
method: HTTP_METHODS.POST,
|
|
56
65
|
data: list.formdata,
|
|
57
66
|
targetModel: [ListModel, CaseSearchModel]
|
|
58
67
|
}));
|
|
59
68
|
} else {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
if (syncLocation) {
|
|
70
|
+
history[historyAction]({
|
|
71
|
+
search: listHref.querystring
|
|
72
|
+
});
|
|
73
|
+
}
|
|
63
74
|
dispatch(loadModularUI(list.connectKey, listHref, {
|
|
64
75
|
method: HTTP_METHODS.GET,
|
|
65
76
|
targetModel: [ListModel, CaseSearchModel]
|
|
66
77
|
}));
|
|
67
78
|
}
|
|
68
|
-
};
|
|
69
|
-
const updateFilters = (list, filters) => {
|
|
79
|
+
}, [dispatch, history, historyAction, syncLocation]);
|
|
80
|
+
const updateFilters = useCallback((list, filters) => {
|
|
70
81
|
list.filterCollection = filters;
|
|
71
82
|
update(list, true);
|
|
72
|
-
};
|
|
73
|
-
const updateFilter = (list, filter, value, attribute) => {
|
|
83
|
+
}, [update]);
|
|
84
|
+
const updateFilter = useCallback((list, filter, value, attribute) => {
|
|
74
85
|
if (attribute) {
|
|
75
86
|
filter.update(attribute, value);
|
|
76
87
|
} else if (filter instanceof AssignmentFilterModel) {
|
|
@@ -79,28 +90,28 @@ export const useListNavigation = () => {
|
|
|
79
90
|
filter.update(filter.attribute, value);
|
|
80
91
|
}
|
|
81
92
|
update(list, true);
|
|
82
|
-
};
|
|
83
|
-
const resetFilters = list => {
|
|
93
|
+
}, [update]);
|
|
94
|
+
const resetFilters = useCallback(list => {
|
|
84
95
|
list.filterCollection.reset();
|
|
85
96
|
update(list, true);
|
|
86
|
-
};
|
|
87
|
-
const removeFilter = (list, filter) => {
|
|
97
|
+
}, [update]);
|
|
98
|
+
const removeFilter = useCallback((list, filter) => {
|
|
88
99
|
list.filterCollection.getFilterByName(filter.name)?.reset();
|
|
89
100
|
update(list, true);
|
|
90
|
-
};
|
|
91
|
-
const updateSort = (list, sortOption) => {
|
|
101
|
+
}, [update]);
|
|
102
|
+
const updateSort = useCallback((list, sortOption) => {
|
|
92
103
|
list.sorting.value = sortOption;
|
|
93
104
|
update(list, true);
|
|
94
|
-
};
|
|
95
|
-
const updatePage = (list, page) => {
|
|
105
|
+
}, [update]);
|
|
106
|
+
const updatePage = useCallback((list, page) => {
|
|
96
107
|
list.paging.page = page;
|
|
97
108
|
update(list);
|
|
98
|
-
};
|
|
99
|
-
const updatePageSize = (list, pagesize) => {
|
|
109
|
+
}, [update]);
|
|
110
|
+
const updatePageSize = useCallback((list, pagesize) => {
|
|
100
111
|
list.paging.pagesize.value = pagesize;
|
|
101
112
|
update(list);
|
|
102
|
-
};
|
|
103
|
-
return {
|
|
113
|
+
}, [update]);
|
|
114
|
+
return useMemo(() => ({
|
|
104
115
|
update,
|
|
105
116
|
updateFilters,
|
|
106
117
|
updateFilter,
|
|
@@ -109,6 +120,6 @@ export const useListNavigation = () => {
|
|
|
109
120
|
updatePageSize,
|
|
110
121
|
resetFilters,
|
|
111
122
|
removeFilter
|
|
112
|
-
};
|
|
123
|
+
}), [removeFilter, resetFilters, update, updateFilter, updateFilters, updatePage, updatePageSize, updateSort]);
|
|
113
124
|
};
|
|
114
125
|
//# sourceMappingURL=useList.js.map
|
|
@@ -18,6 +18,7 @@ import FilterModel from "../models/filters/FilterModel";
|
|
|
18
18
|
|
|
19
19
|
import type { HookOptions } from "./useModularUIBasic";
|
|
20
20
|
import type { AttributeType, IFilter } from "../models/types";
|
|
21
|
+
import { useCallback, useMemo } from "react";
|
|
21
22
|
|
|
22
23
|
type ListNavigationHook = {
|
|
23
24
|
update: (list: ListModel, resetPage?: boolean) => void,
|
|
@@ -35,6 +36,11 @@ type ListNavigationHook = {
|
|
|
35
36
|
removeFilter: (list: ListModel, filter: IFilter) => void,
|
|
36
37
|
};
|
|
37
38
|
|
|
39
|
+
type ListNavigationOptions = {
|
|
40
|
+
syncLocation: boolean,
|
|
41
|
+
historyAction: "push" | "replace",
|
|
42
|
+
};
|
|
43
|
+
|
|
38
44
|
/**
|
|
39
45
|
*/
|
|
40
46
|
export const useList = (
|
|
@@ -74,90 +80,141 @@ export const useListDetail = (
|
|
|
74
80
|
|
|
75
81
|
/**
|
|
76
82
|
*/
|
|
77
|
-
export const useListNavigation = (
|
|
83
|
+
export const useListNavigation = (
|
|
84
|
+
{ syncLocation, historyAction }: ListNavigationOptions = {
|
|
85
|
+
syncLocation: true,
|
|
86
|
+
historyAction: "push",
|
|
87
|
+
},
|
|
88
|
+
): ListNavigationHook => {
|
|
78
89
|
const history = useHistory();
|
|
79
90
|
const dispatch = useDispatch();
|
|
80
91
|
|
|
81
|
-
const update = (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
92
|
+
const update = useCallback(
|
|
93
|
+
(list: ListModel, resetPage: boolean = false) => {
|
|
94
|
+
const listHref = list.selfhref;
|
|
95
|
+
if (resetPage) {
|
|
96
|
+
listHref.page = null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (list.requestMethod === HTTP_METHODS.POST) {
|
|
100
|
+
if (syncLocation) {
|
|
101
|
+
history[historyAction]({
|
|
102
|
+
search: listHref.querystring,
|
|
103
|
+
state: list.formdata,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
dispatch(
|
|
108
|
+
loadModularUI(list.connectKey, listHref, {
|
|
109
|
+
method: HTTP_METHODS.POST,
|
|
110
|
+
data: list.formdata,
|
|
111
|
+
targetModel: [ListModel, CaseSearchModel],
|
|
112
|
+
}),
|
|
113
|
+
);
|
|
114
|
+
} else {
|
|
115
|
+
if (syncLocation) {
|
|
116
|
+
history[historyAction]({ search: listHref.querystring });
|
|
117
|
+
}
|
|
118
|
+
dispatch(
|
|
119
|
+
loadModularUI(list.connectKey, listHref, {
|
|
120
|
+
method: HTTP_METHODS.GET,
|
|
121
|
+
targetModel: [ListModel, CaseSearchModel],
|
|
122
|
+
}),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
[dispatch, history, historyAction, syncLocation],
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const updateFilters = useCallback(
|
|
130
|
+
(list: ListModel, filters: FilterCollection) => {
|
|
131
|
+
list.filterCollection = filters;
|
|
132
|
+
update(list, true);
|
|
133
|
+
},
|
|
134
|
+
[update],
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const updateFilter = useCallback(
|
|
138
|
+
(
|
|
139
|
+
list: ListModel,
|
|
140
|
+
filter: IFilter,
|
|
141
|
+
value: string,
|
|
142
|
+
attribute?: AttributeType,
|
|
143
|
+
) => {
|
|
144
|
+
if (attribute) {
|
|
145
|
+
filter.update(attribute, value);
|
|
146
|
+
} else if (filter instanceof AssignmentFilterModel) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
"Need the attribute to update for AssigmentFilterModel",
|
|
149
|
+
);
|
|
150
|
+
} else if (filter instanceof FilterModel) {
|
|
151
|
+
filter.update(filter.attribute, value);
|
|
152
|
+
}
|
|
153
|
+
update(list, true);
|
|
154
|
+
},
|
|
155
|
+
[update],
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const resetFilters = useCallback(
|
|
159
|
+
(list: ListModel) => {
|
|
160
|
+
list.filterCollection.reset();
|
|
161
|
+
update(list, true);
|
|
162
|
+
},
|
|
163
|
+
[update],
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const removeFilter = useCallback(
|
|
167
|
+
(list: ListModel, filter: IFilter) => {
|
|
168
|
+
list.filterCollection.getFilterByName(filter.name)?.reset();
|
|
169
|
+
update(list, true);
|
|
170
|
+
},
|
|
171
|
+
[update],
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const updateSort = useCallback(
|
|
175
|
+
(list: ListModel, sortOption: string) => {
|
|
176
|
+
list.sorting.value = sortOption;
|
|
177
|
+
update(list, true);
|
|
178
|
+
},
|
|
179
|
+
[update],
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
const updatePage = useCallback(
|
|
183
|
+
(list: ListModel, page: number) => {
|
|
184
|
+
list.paging.page = page;
|
|
185
|
+
update(list);
|
|
186
|
+
},
|
|
187
|
+
[update],
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const updatePageSize = useCallback(
|
|
191
|
+
(list: ListModel, pagesize: number) => {
|
|
192
|
+
list.paging.pagesize.value = pagesize;
|
|
193
|
+
update(list);
|
|
194
|
+
},
|
|
195
|
+
[update],
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
return useMemo(
|
|
199
|
+
() => ({
|
|
200
|
+
update,
|
|
201
|
+
updateFilters,
|
|
202
|
+
updateFilter,
|
|
203
|
+
updateSort,
|
|
204
|
+
updatePage,
|
|
205
|
+
updatePageSize,
|
|
206
|
+
resetFilters,
|
|
207
|
+
removeFilter,
|
|
208
|
+
}),
|
|
209
|
+
[
|
|
210
|
+
removeFilter,
|
|
211
|
+
resetFilters,
|
|
212
|
+
update,
|
|
213
|
+
updateFilter,
|
|
214
|
+
updateFilters,
|
|
215
|
+
updatePage,
|
|
216
|
+
updatePageSize,
|
|
217
|
+
updateSort,
|
|
218
|
+
],
|
|
219
|
+
);
|
|
163
220
|
};
|
package/esm/hooks/useList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,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AQ;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":[]}
|
|
1
|
+
{"version":3,"file":"useList.js","names":["useHistory","useDispatch","useModularUIBasic","HTTP_METHODS","loadModularUI","DetailModel","ListModel","CaseSearchModel","ListDetailModel","Href","FilterCollection","AssignmentFilterModel","FilterModel","useCallback","useMemo","useList","href","options","expectedModels","targetModel","useListOrDetail","useListDetail","forceTargetModel","useListNavigation","syncLocation","historyAction","history","dispatch","update","list","resetPage","listHref","selfhref","page","requestMethod","POST","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\";\nimport { useCallback, useMemo } from \"react\";\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\ntype ListNavigationOptions = {\n syncLocation: boolean,\n historyAction: \"push\" | \"replace\",\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 = (\n { syncLocation, historyAction }: ListNavigationOptions = {\n syncLocation: true,\n historyAction: \"push\",\n },\n): ListNavigationHook => {\n const history = useHistory();\n const dispatch = useDispatch();\n\n const update = useCallback(\n (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 if (syncLocation) {\n history[historyAction]({\n search: listHref.querystring,\n state: list.formdata,\n });\n }\n\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 if (syncLocation) {\n history[historyAction]({ search: listHref.querystring });\n }\n dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.GET,\n targetModel: [ListModel, CaseSearchModel],\n }),\n );\n }\n },\n [dispatch, history, historyAction, syncLocation],\n );\n\n const updateFilters = useCallback(\n (list: ListModel, filters: FilterCollection) => {\n list.filterCollection = filters;\n update(list, true);\n },\n [update],\n );\n\n const updateFilter = useCallback(\n (\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(\n \"Need the attribute to update for AssigmentFilterModel\",\n );\n } else if (filter instanceof FilterModel) {\n filter.update(filter.attribute, value);\n }\n update(list, true);\n },\n [update],\n );\n\n const resetFilters = useCallback(\n (list: ListModel) => {\n list.filterCollection.reset();\n update(list, true);\n },\n [update],\n );\n\n const removeFilter = useCallback(\n (list: ListModel, filter: IFilter) => {\n list.filterCollection.getFilterByName(filter.name)?.reset();\n update(list, true);\n },\n [update],\n );\n\n const updateSort = useCallback(\n (list: ListModel, sortOption: string) => {\n list.sorting.value = sortOption;\n update(list, true);\n },\n [update],\n );\n\n const updatePage = useCallback(\n (list: ListModel, page: number) => {\n list.paging.page = page;\n update(list);\n },\n [update],\n );\n\n const updatePageSize = useCallback(\n (list: ListModel, pagesize: number) => {\n list.paging.pagesize.value = pagesize;\n update(list);\n },\n [update],\n );\n\n return useMemo(\n () => ({\n update,\n updateFilters,\n updateFilter,\n updateSort,\n updatePage,\n updatePageSize,\n resetFilters,\n removeFilter,\n }),\n [\n removeFilter,\n resetFilters,\n update,\n updateFilter,\n updateFilters,\n updatePage,\n updatePageSize,\n updateSort,\n ],\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,SAA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