@irontec/ivoz-ui 1.4.6 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,9 +9,7 @@ import useFirstColumn from './hook/useFirstColumn';
9
9
  import useFirstColumnCriteria from './hook/useFirstColumnCriteria';
10
10
  const FastSearchField = (props, ref) => {
11
11
  const { className, path, entityService, ignoreColumn } = props;
12
- const queryStringCriteria = useStoreState((state) => [
13
- ...state.route.queryStringCriteria,
14
- ]);
12
+ const storeQueryStringCriteria = useStoreState((state) => state.route.queryStringCriteria);
15
13
  const setQueryStringCriteria = useStoreActions((actions) => {
16
14
  return actions.route.setQueryStringCriteria;
17
15
  });
@@ -43,6 +41,7 @@ const FastSearchField = (props, ref) => {
43
41
  }
44
42
  let match = false;
45
43
  let matchIdx;
44
+ const queryStringCriteria = [...storeQueryStringCriteria];
46
45
  for (const idx in queryStringCriteria) {
47
46
  if (queryStringCriteria[idx].name !== firstColumnCriteria.name) {
48
47
  continue;
@@ -61,7 +60,8 @@ const FastSearchField = (props, ref) => {
61
60
  else if (value === '' && matchIdx) {
62
61
  queryStringCriteria.splice(parseInt(matchIdx, 10), 1);
63
62
  }
64
- setQueryStringCriteria(queryStringCriteria);
63
+ const queryStringCriteriaWithoutPagination = queryStringCriteria.filter((criteria) => criteria.name !== '_page');
64
+ setQueryStringCriteria(queryStringCriteriaWithoutPagination);
65
65
  };
66
66
  const changeHandler = ({ target, }) => {
67
67
  const { value } = target;
@@ -4,9 +4,7 @@ import { getI18n } from 'react-i18next';
4
4
  const useFirstColumnCriteria = (props) => {
5
5
  const { entityService, ignoreColumn, path } = props;
6
6
  const [firstColumnCriteria, setFirstColumnCriteria] = useState(undefined);
7
- const queryStringCriteria = useStoreState((state) => [
8
- ...state.route.queryStringCriteria,
9
- ]);
7
+ const queryStringCriteria = useStoreState((state) => state.route.queryStringCriteria);
10
8
  const storeState = useStoreState((state) => state, () => {
11
9
  return true;
12
10
  });
@@ -67,6 +67,7 @@ export default function ContentFilterSelector(props) {
67
67
  type: defaultFilter,
68
68
  value: '',
69
69
  }, columns: columns, fkChoices: fkChoices, fieldNames: fieldNames, isLast: true, setRow: setRow, removeRow: removeRow }, criteria.length)] })), mobile && (_jsx(Box, { children: _jsx(FilterCriteria, { entityService: entityService, fkChoices: fkChoices, removeFilter: removeRow, path: path, criteriaOverride: criteria }) })), _jsxs(Box, Object.assign({ className: 'actions' }, { children: [_jsx(Box, { children: _jsx("a", Object.assign({ href: '#', onClick: resetCriteria, className: 'link' }, { children: _('Clear all filters') })) }), _jsxs(Box, Object.assign({ className: 'buttons' }, { children: [_jsx(OutlinedButton, Object.assign({ variant: 'contained', onClick: close }, { children: _('Cancel') })), _jsx(SolidButton, Object.assign({ variant: 'contained', disabled: criteria.length < 1, onClick: () => {
70
- commitCriteria(criteria);
70
+ const queryStringCriteriaWithoutPagination = criteria.filter((criteria) => criteria.name !== '_page');
71
+ commitCriteria(queryStringCriteriaWithoutPagination);
71
72
  } }, { children: _('Apply') }))] }))] }))] })));
72
73
  }
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { foreignKeyResolverType } from '../../entities/EntityInterface';
2
+ import EntityInterface, { foreignKeyResolverType } from '../../entities/EntityInterface';
3
3
  import { RouteMap } from '../../router/routeMapParser';
4
4
  import EntityService from '../../services/entity/EntityService';
5
- declare type ListProps = {
5
+ export declare type ListProps = EntityInterface & {
6
6
  path: string;
7
7
  routeMap: RouteMap;
8
8
  entityService: EntityService;
@@ -16,15 +16,14 @@ import useCancelToken from '../../hooks/useCancelToken';
16
16
  import useCurrentPathMatch from '../../hooks/useCurrentPathMatch';
17
17
  import useRouteChain from '../../hooks/useRouteChain';
18
18
  import findRoute from '../../router/findRoute';
19
+ import { isPropertyFk } from '../../services';
19
20
  import { useStoreActions, useStoreState } from '../../store';
20
21
  import ErrorMessage from '../shared/ErrorMessage';
21
- import { ListContent } from './Content/';
22
+ import useFirstColumn from './Content/hook/useFirstColumn';
22
23
  import { criteriaToArray, queryStringToCriteria } from './List.helpers';
23
24
  import useQueryStringParams from './useQueryStringParams';
24
- import useFirstColumn from './Content/hook/useFirstColumn';
25
- import { isPropertyFk } from '../../services';
26
25
  const List = function (props) {
27
- const { path, foreignKeyResolver, entityService, routeMap, className } = props;
26
+ const { path, foreignKeyResolver, entityService, routeMap, className, List: EntityListDecorator } = props;
28
27
  const location = useLocation();
29
28
  const match = useCurrentPathMatch();
30
29
  const params = useParams();
@@ -234,6 +233,6 @@ const List = function (props) {
234
233
  return null;
235
234
  }
236
235
  const empty = (!rows || rows.length === 0) && queryStringCriteria.length === 0;
237
- return (_jsx("div", Object.assign({ className: className }, { children: _jsxs(ErrorBoundary, { children: [_jsx(ListContent, { empty: empty, childEntities: (currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.children) || [], path: path, ignoreColumn: ignoreColumn, preloadData: preload, entityService: entityService, cancelToken: cancelToken, match: match, routeChain: routeChain, location: location }), reqError && _jsx(ErrorMessage, { message: reqError })] }) })));
236
+ return (_jsx("div", Object.assign({ className: className }, { children: _jsxs(ErrorBoundary, { children: [_jsx(EntityListDecorator, { empty: empty, childEntities: (currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.children) || [], path: path, ignoreColumn: ignoreColumn, preloadData: preload, entityService: entityService, cancelToken: cancelToken, match: match, routeChain: routeChain, location: location }), reqError && _jsx(ErrorMessage, { message: reqError })] }) })));
238
237
  };
239
238
  export default List;
@@ -1,5 +1,5 @@
1
1
  import { Theme } from '@mui/material';
2
- export declare const StyledList: import("@mui/styles").StyledComponent<Omit<{
2
+ export declare const StyledList: import("@mui/styles").StyledComponent<Omit<import("../../entities/EntityInterface").default & {
3
3
  path: string;
4
4
  routeMap: import("../..").RouteMap<import("../..").RouteMapItem>;
5
5
  entityService: import("../../services/entity/EntityService").default<import("easy-peasy").StateMapper<import("easy-peasy").FilterActionTypes<import("../..").IvozStore>>>;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { ListContentProps } from '../../components/List/Content/ListContent';
3
+ declare const List: (props: ListContentProps) => JSX.Element | null;
4
+ export default List;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ListContent } from '../../components/List/Content/';
3
+ const List = (props) => {
4
+ return (_jsx(ListContent, Object.assign({}, props)));
5
+ };
6
+ export default List;
@@ -38,6 +38,7 @@ declare const DefaultEntityBehavior: {
38
38
  properties: {};
39
39
  acl: EntityAclType;
40
40
  calculateAclByParentRow: calculateAclType;
41
+ List: (props: import("../components/List/Content/ListContent").ListContentProps) => JSX.Element | null;
41
42
  ListDecorator: import("./EntityInterface").ListDecoratorType;
42
43
  ChildDecorator: React.NamedExoticComponent<React.PropsWithChildren<ChildDecoratorProps>>;
43
44
  customActions: {};
@@ -22,6 +22,7 @@ import marshaller from './DefaultEntityBehavior/Marshaller';
22
22
  import unmarshaller from './DefaultEntityBehavior/Unmarshaller';
23
23
  import validator from './DefaultEntityBehavior/Validator';
24
24
  import View from './DefaultEntityBehavior/View';
25
+ import List from './DefaultEntityBehavior/List';
25
26
  export const initialValues = {};
26
27
  export const columns = [];
27
28
  export const properties = {};
@@ -77,6 +78,7 @@ const DefaultEntityBehavior = {
77
78
  properties,
78
79
  acl,
79
80
  calculateAclByParentRow,
81
+ List,
80
82
  ListDecorator,
81
83
  ChildDecorator: ChildDecoratorMemo,
82
84
  customActions: {},
@@ -8,6 +8,7 @@ import { PartialPropertyList, PropertySpec } from '../services/api/ParsedApiSpec
8
8
  import EntityService, { EntityValues, VisualToggleStates } from '../services/entity/EntityService';
9
9
  import { EntityFormProps, FkChoices, fetchFksType } from './DefaultEntityBehavior';
10
10
  import { IvozStoreState } from 'store';
11
+ import { ListContentProps } from '../components/List/Content/ListContent';
11
12
  export declare type ListDecoratorPropsType = {
12
13
  field: string;
13
14
  row: any;
@@ -91,6 +92,7 @@ export default interface EntityInterface {
91
92
  selectOptions?: () => Promise<SelectOptionsType>;
92
93
  Form: () => Promise<React.FunctionComponent<EntityFormProps>>;
93
94
  View: () => Promise<ViewType>;
95
+ List: React.FunctionComponent<ListContentProps>;
94
96
  ListDecorator: ListDecoratorType;
95
97
  ChildDecorator: ChildDecoratorType;
96
98
  customActions: CustomActionsType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irontec/ivoz-ui",
3
- "version": "1.4.6",
3
+ "version": "1.5.1",
4
4
  "description": "UI library used in ivozprovider",
5
5
  "license": "GPL-3.0",
6
6
  "main": "index.js",
package/store/list.d.ts CHANGED
@@ -8,6 +8,7 @@ export interface ListState {
8
8
  reloadTimestamp: number;
9
9
  parentRow: EntityValues | undefined;
10
10
  rows: Array<EntityValues>;
11
+ customData: undefined | unknown;
11
12
  headers: Record<string, string>;
12
13
  fkChoices: FkChoicesType;
13
14
  }
@@ -15,6 +16,7 @@ interface ListActions {
15
16
  reload: Action<ListState>;
16
17
  setParentRow: Action<ListState, undefined | EntityValues>;
17
18
  setRows: Action<ListState, Array<EntityValues>>;
19
+ setCustomData: Action<ListState, unknown>;
18
20
  setHeaders: Action<ListState, Record<string, string>>;
19
21
  setFkChoices: Action<ListState, FkChoicesType>;
20
22
  reset: Thunk<ListState, undefined, unknown>;
package/store/list.js CHANGED
@@ -12,6 +12,7 @@ const list = {
12
12
  reloadTimestamp: 0,
13
13
  parentRow: undefined,
14
14
  rows: [],
15
+ customData: undefined,
15
16
  headers: {},
16
17
  fkChoices: {},
17
18
  // actions
@@ -24,6 +25,9 @@ const list = {
24
25
  setRows: action((state, rows) => {
25
26
  state.rows = [...rows];
26
27
  }),
28
+ setCustomData: action((state, customData) => {
29
+ state.customData = customData;
30
+ }),
27
31
  setHeaders: action((state, headers) => {
28
32
  state.headers = Object.assign({}, headers);
29
33
  }),
@@ -33,6 +37,7 @@ const list = {
33
37
  // thunks
34
38
  reset: thunk((actions) => __awaiter(void 0, void 0, void 0, function* () {
35
39
  actions.setRows([]);
40
+ actions.setCustomData(undefined);
36
41
  actions.setHeaders({});
37
42
  actions.setFkChoices({});
38
43
  })),