@smartsoft001/crud-shell-react 0.0.0-stage → 2.193.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -3
- package/package.json +29 -4
- package/src/index.d.ts +19 -0
- package/src/index.js +23 -0
- package/src/index.js.map +1 -0
- package/src/lib/components/export/export.d.ts +7 -0
- package/src/lib/components/export/export.js +15 -0
- package/src/lib/components/export/export.js.map +1 -0
- package/src/lib/components/export/export.types.d.ts +8 -0
- package/src/lib/components/export/export.types.js +3 -0
- package/src/lib/components/export/export.types.js.map +1 -0
- package/src/lib/components/export/index.d.ts +3 -0
- package/src/lib/components/export/index.js +7 -0
- package/src/lib/components/export/index.js.map +1 -0
- package/src/lib/components/export/use-crud-export.d.ts +16 -0
- package/src/lib/components/export/use-crud-export.js +74 -0
- package/src/lib/components/export/use-crud-export.js.map +1 -0
- package/src/lib/components/filter/base/use-crud-filter.d.ts +68 -0
- package/src/lib/components/filter/base/use-crud-filter.js +248 -0
- package/src/lib/components/filter/base/use-crud-filter.js.map +1 -0
- package/src/lib/components/filter/check/filter-check.d.ts +7 -0
- package/src/lib/components/filter/check/filter-check.js +45 -0
- package/src/lib/components/filter/check/filter-check.js.map +1 -0
- package/src/lib/components/filter/date/filter-date.d.ts +7 -0
- package/src/lib/components/filter/date/filter-date.js +19 -0
- package/src/lib/components/filter/date/filter-date.js.map +1 -0
- package/src/lib/components/filter/date/use-crud-filter-date.d.ts +23 -0
- package/src/lib/components/filter/date/use-crud-filter-date.js +41 -0
- package/src/lib/components/filter/date/use-crud-filter-date.js.map +1 -0
- package/src/lib/components/filter/date/use-crud-filter-ng-model.d.ts +6 -0
- package/src/lib/components/filter/date/use-crud-filter-ng-model.js +25 -0
- package/src/lib/components/filter/date/use-crud-filter-ng-model.js.map +1 -0
- package/src/lib/components/filter/date-time/filter-date-time.d.ts +8 -0
- package/src/lib/components/filter/date-time/filter-date-time.js +27 -0
- package/src/lib/components/filter/date-time/filter-date-time.js.map +1 -0
- package/src/lib/components/filter/date-with-edit/filter-date-with-edit.d.ts +9 -0
- package/src/lib/components/filter/date-with-edit/filter-date-with-edit.js +42 -0
- package/src/lib/components/filter/date-with-edit/filter-date-with-edit.js.map +1 -0
- package/src/lib/components/filter/filter.d.ts +8 -0
- package/src/lib/components/filter/filter.js +43 -0
- package/src/lib/components/filter/filter.js.map +1 -0
- package/src/lib/components/filter/filter.types.d.ts +17 -0
- package/src/lib/components/filter/filter.types.js +3 -0
- package/src/lib/components/filter/filter.types.js.map +1 -0
- package/src/lib/components/filter/flag/filter-flag.d.ts +7 -0
- package/src/lib/components/filter/flag/filter-flag.js +20 -0
- package/src/lib/components/filter/flag/filter-flag.js.map +1 -0
- package/src/lib/components/filter/index.d.ts +13 -0
- package/src/lib/components/filter/index.js +17 -0
- package/src/lib/components/filter/index.js.map +1 -0
- package/src/lib/components/filter/int/filter-int.d.ts +12 -0
- package/src/lib/components/filter/int/filter-int.js +47 -0
- package/src/lib/components/filter/int/filter-int.js.map +1 -0
- package/src/lib/components/filter/radio/filter-radio.d.ts +7 -0
- package/src/lib/components/filter/radio/filter-radio.js +20 -0
- package/src/lib/components/filter/radio/filter-radio.js.map +1 -0
- package/src/lib/components/filter/text/filter-text.d.ts +7 -0
- package/src/lib/components/filter/text/filter-text.js +20 -0
- package/src/lib/components/filter/text/filter-text.js.map +1 -0
- package/src/lib/components/filters/filters.d.ts +10 -0
- package/src/lib/components/filters/filters.js +20 -0
- package/src/lib/components/filters/filters.js.map +1 -0
- package/src/lib/components/filters/filters.types.d.ts +5 -0
- package/src/lib/components/filters/filters.types.js +3 -0
- package/src/lib/components/filters/filters.types.js.map +1 -0
- package/src/lib/components/filters/index.d.ts +3 -0
- package/src/lib/components/filters/index.js +7 -0
- package/src/lib/components/filters/index.js.map +1 -0
- package/src/lib/components/filters/use-crud-filters.d.ts +17 -0
- package/src/lib/components/filters/use-crud-filters.js +63 -0
- package/src/lib/components/filters/use-crud-filters.js.map +1 -0
- package/src/lib/components/filters-config/filters-config.d.ts +6 -0
- package/src/lib/components/filters-config/filters-config.js +38 -0
- package/src/lib/components/filters-config/filters-config.js.map +1 -0
- package/src/lib/components/filters-config/index.d.ts +1 -0
- package/src/lib/components/filters-config/index.js +5 -0
- package/src/lib/components/filters-config/index.js.map +1 -0
- package/src/lib/components/group/group.d.ts +10 -0
- package/src/lib/components/group/group.js +19 -0
- package/src/lib/components/group/group.js.map +1 -0
- package/src/lib/components/group/group.types.d.ts +8 -0
- package/src/lib/components/group/group.types.js +3 -0
- package/src/lib/components/group/group.types.js.map +1 -0
- package/src/lib/components/group/index.d.ts +3 -0
- package/src/lib/components/group/index.js +7 -0
- package/src/lib/components/group/index.js.map +1 -0
- package/src/lib/components/group/use-crud-group.d.ts +17 -0
- package/src/lib/components/group/use-crud-group.js +50 -0
- package/src/lib/components/group/use-crud-group.js.map +1 -0
- package/src/lib/components/multiselect/index.d.ts +2 -0
- package/src/lib/components/multiselect/index.js +6 -0
- package/src/lib/components/multiselect/index.js.map +1 -0
- package/src/lib/components/multiselect/multiselect.d.ts +10 -0
- package/src/lib/components/multiselect/multiselect.js +25 -0
- package/src/lib/components/multiselect/multiselect.js.map +1 -0
- package/src/lib/components/multiselect/use-crud-multiselect.d.ts +24 -0
- package/src/lib/components/multiselect/use-crud-multiselect.js +72 -0
- package/src/lib/components/multiselect/use-crud-multiselect.js.map +1 -0
- package/src/lib/crud.config.d.ts +67 -0
- package/src/lib/crud.config.js +3 -0
- package/src/lib/crud.config.js.map +1 -0
- package/src/lib/crud.context.d.ts +23 -0
- package/src/lib/crud.context.js +25 -0
- package/src/lib/crud.context.js.map +1 -0
- package/src/lib/crud.provider.d.ts +16 -0
- package/src/lib/crud.provider.js +69 -0
- package/src/lib/crud.provider.js.map +1 -0
- package/src/lib/factories/form-options.d.ts +10 -0
- package/src/lib/factories/form-options.js +26 -0
- package/src/lib/factories/form-options.js.map +1 -0
- package/src/lib/hooks.d.ts +15 -0
- package/src/lib/hooks.js +66 -0
- package/src/lib/hooks.js.map +1 -0
- package/src/lib/models/index.d.ts +1 -0
- package/src/lib/models/index.js +5 -0
- package/src/lib/models/index.js.map +1 -0
- package/src/lib/models/interfaces.d.ts +29 -0
- package/src/lib/models/interfaces.js +3 -0
- package/src/lib/models/interfaces.js.map +1 -0
- package/src/lib/pages/crud-pages.d.ts +32 -0
- package/src/lib/pages/crud-pages.js +64 -0
- package/src/lib/pages/crud-pages.js.map +1 -0
- package/src/lib/pages/index.d.ts +12 -0
- package/src/lib/pages/index.js +16 -0
- package/src/lib/pages/index.js.map +1 -0
- package/src/lib/pages/item/item-page.d.ts +18 -0
- package/src/lib/pages/item/item-page.js +31 -0
- package/src/lib/pages/item/item-page.js.map +1 -0
- package/src/lib/pages/item/item-page.types.d.ts +47 -0
- package/src/lib/pages/item/item-page.types.js +3 -0
- package/src/lib/pages/item/item-page.types.js.map +1 -0
- package/src/lib/pages/item/standard/item-page-standard.d.ts +10 -0
- package/src/lib/pages/item/standard/item-page-standard.js +19 -0
- package/src/lib/pages/item/standard/item-page-standard.js.map +1 -0
- package/src/lib/pages/item/use-crud-item-page-base.d.ts +22 -0
- package/src/lib/pages/item/use-crud-item-page-base.js +47 -0
- package/src/lib/pages/item/use-crud-item-page-base.js.map +1 -0
- package/src/lib/pages/item/use-crud-item-page.d.ts +44 -0
- package/src/lib/pages/item/use-crud-item-page.js +297 -0
- package/src/lib/pages/item/use-crud-item-page.js.map +1 -0
- package/src/lib/pages/list/list-page.d.ts +17 -0
- package/src/lib/pages/list/list-page.js +32 -0
- package/src/lib/pages/list/list-page.js.map +1 -0
- package/src/lib/pages/list/list-page.types.d.ts +27 -0
- package/src/lib/pages/list/list-page.types.js +3 -0
- package/src/lib/pages/list/list-page.types.js.map +1 -0
- package/src/lib/pages/list/standard/list-page-standard.d.ts +13 -0
- package/src/lib/pages/list/standard/list-page-standard.js +28 -0
- package/src/lib/pages/list/standard/list-page-standard.js.map +1 -0
- package/src/lib/pages/list/use-crud-list-page.d.ts +35 -0
- package/src/lib/pages/list/use-crud-list-page.js +309 -0
- package/src/lib/pages/list/use-crud-list-page.js.map +1 -0
- package/src/lib/pages/use-crud-bound-component.d.ts +10 -0
- package/src/lib/pages/use-crud-bound-component.js +28 -0
- package/src/lib/pages/use-crud-bound-component.js.map +1 -0
- package/src/lib/pages/use-crud-page-config.d.ts +9 -0
- package/src/lib/pages/use-crud-page-config.js +19 -0
- package/src/lib/pages/use-crud-page-config.js.map +1 -0
- package/src/lib/providers/model-label.provider.d.ts +11 -0
- package/src/lib/providers/model-label.provider.js +27 -0
- package/src/lib/providers/model-label.provider.js.map +1 -0
- package/src/lib/services/crud/crud.service.d.ts +44 -0
- package/src/lib/services/crud/crud.service.js +113 -0
- package/src/lib/services/crud/crud.service.js.map +1 -0
- package/src/lib/services/list-group/list-group.service.d.ts +18 -0
- package/src/lib/services/list-group/list-group.service.js +52 -0
- package/src/lib/services/list-group/list-group.service.js.map +1 -0
- package/src/lib/services/page/page.service.d.ts +8 -0
- package/src/lib/services/page/page.service.js +33 -0
- package/src/lib/services/page/page.service.js.map +1 -0
- package/src/lib/services/search/search.service.d.ts +14 -0
- package/src/lib/services/search/search.service.js +28 -0
- package/src/lib/services/search/search.service.js.map +1 -0
- package/src/lib/state/crud.actions.d.ts +157 -0
- package/src/lib/state/crud.actions.js +257 -0
- package/src/lib/state/crud.actions.js.map +1 -0
- package/src/lib/state/crud.effects.d.ts +20 -0
- package/src/lib/state/crud.effects.js +128 -0
- package/src/lib/state/crud.effects.js.map +1 -0
- package/src/lib/state/crud.facade.d.ts +43 -0
- package/src/lib/state/crud.facade.js +93 -0
- package/src/lib/state/crud.facade.js.map +1 -0
- package/src/lib/state/crud.reducer.d.ts +20 -0
- package/src/lib/state/crud.reducer.js +218 -0
- package/src/lib/state/crud.reducer.js.map +1 -0
- package/src/lib/state/crud.selectors.d.ts +9 -0
- package/src/lib/state/crud.selectors.js +25 -0
- package/src/lib/state/crud.selectors.js.map +1 -0
- package/src/lib/state/crud.store.d.ts +17 -0
- package/src/lib/state/crud.store.js +33 -0
- package/src/lib/state/crud.store.js.map +1 -0
- package/src/lib/state/index.d.ts +6 -0
- package/src/lib/state/index.js +10 -0
- package/src/lib/state/index.js.map +1 -0
- package/styles.css +6001 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SmartCrudListPageStandard = SmartCrudListPageStandard;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@smartsoft001/react");
|
|
6
|
+
const filters_config_1 = require("../../../components/filters-config/filters-config");
|
|
7
|
+
const group_1 = require("../../../components/group/group");
|
|
8
|
+
const crud_context_1 = require("../../../crud.context");
|
|
9
|
+
const hooks_1 = require("../../../hooks");
|
|
10
|
+
/**
|
|
11
|
+
* The default list page body (`<smart-crud-list-standard-page>`, the Angular
|
|
12
|
+
* `ListStandardComponent`): the active filters (`SmartCrudFiltersConfig`)
|
|
13
|
+
* and `SmartList`; with `config.list.groups` the list is hidden behind
|
|
14
|
+
* `SmartCrudGroup` unless a text is searched. `children` are not rendered,
|
|
15
|
+
* as the Angular template had no `ng-content`.
|
|
16
|
+
*
|
|
17
|
+
* The `hidden` the Angular template set on `<smart-list>` is set on a `div`
|
|
18
|
+
* around it, rendered only when there are groups.
|
|
19
|
+
*/
|
|
20
|
+
function SmartCrudListPageStandard({ listOptions, }) {
|
|
21
|
+
const config = (0, crud_context_1.useCrudConfig)();
|
|
22
|
+
const isSearch = (0, hooks_1.useCrudState)((state) => !!state.filter?.searchText);
|
|
23
|
+
const groups = config.list?.groups;
|
|
24
|
+
const hideList = !!groups && !isSearch;
|
|
25
|
+
const list = listOptions ? (0, jsx_runtime_1.jsx)(react_1.SmartList, { options: listOptions }) : null;
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(filters_config_1.SmartCrudFiltersConfig, {}), groups ? (0, jsx_runtime_1.jsx)("div", { hidden: hideList || undefined, children: list }) : list, groups && !isSearch ? ((0, jsx_runtime_1.jsx)(group_1.SmartCrudGroup, { groups: groups, listOptions: listOptions || null })) : null] }));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=list-page-standard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-page-standard.js","sourceRoot":"","sources":["../../../../../../../../../../packages/crud/shell/react/src/lib/pages/list/standard/list-page-standard.tsx"],"names":[],"mappings":";;AAmBA,8DAqBC;;AAvCD,+CAAgD;AAEhD,sFAA2F;AAC3F,2DAAiE;AACjE,wDAAsD;AACtD,0CAA8C;AAG9C;;;;;;;;;GASG;AACH,SAAgB,yBAAyB,CAA4B,EACnE,WAAW,GACmB;IAC9B,MAAM,MAAM,GAAG,IAAA,4BAAa,GAAK,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAA,oBAAY,EAC3B,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,UAAU,CACtC,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC;IACnC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC;IAEvC,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,uBAAC,iBAAS,IAAC,OAAO,EAAE,WAAW,GAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAEtE,OAAO,CACL,6DACE,uBAAC,uCAAsB,KAAG,EACzB,MAAM,CAAC,CAAC,CAAC,gCAAK,MAAM,EAAE,QAAQ,IAAI,SAAS,YAAG,IAAI,GAAO,CAAC,CAAC,CAAC,IAAI,EAChE,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CACrB,uBAAC,sBAAc,IAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,IAAI,IAAI,GAAI,CACrE,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import { IEntity } from '@smartsoft001/domain-core';
|
|
3
|
+
import { IListOptions, IPageOptions } from '@smartsoft001/react';
|
|
4
|
+
import { SmartCrudListPageProps } from './list-page.types';
|
|
5
|
+
import { CrudFullConfig } from '../../crud.config';
|
|
6
|
+
import { ICrudFilter } from '../../models';
|
|
7
|
+
/**
|
|
8
|
+
* The logic of the list page (the Angular `ListComponent`), for
|
|
9
|
+
* `SmartCrudListPage` or a page of your own around the same feature:
|
|
10
|
+
*
|
|
11
|
+
* - `config`: the `CrudFullConfig` after the model's permissions;
|
|
12
|
+
* - the first read on mount (pagination, default sort, base query and the
|
|
13
|
+
* enabled `CrudSearchService` filter; `list.resetQuery: 'beforeInit'`
|
|
14
|
+
* starts from the defaults instead of the feature's filter);
|
|
15
|
+
* - `pageOptions`: the title, `variant`, the search (`config.search`) and the
|
|
16
|
+
* end buttons: multi edit, filters (`SmartCrudFilters` in the end menu),
|
|
17
|
+
* add (navigates to `<basePath>/add`), export (`SmartCrudExport` in a
|
|
18
|
+
* modal) and `config.buttons`;
|
|
19
|
+
* - `listOptions` for `SmartList`: the feature's items and loading, details
|
|
20
|
+
* through the facade, item links to `<basePath>/<id>`, remove through the
|
|
21
|
+
* facade (the list confirms it), the pagination of
|
|
22
|
+
* `useCrudListPagination`, sort and the multi selection (it opens
|
|
23
|
+
* `SmartCrudMultiselect` in the end menu);
|
|
24
|
+
* - `filter`: the feature's filter (the page renders once it is set);
|
|
25
|
+
* - `TopComponent`: `config.list.components.top`.
|
|
26
|
+
*
|
|
27
|
+
* A navigation closes the end menu and ends the multi selection.
|
|
28
|
+
*/
|
|
29
|
+
export declare function useCrudListPage<T extends IEntity<string>>({ basePath, }?: SmartCrudListPageProps): {
|
|
30
|
+
config: CrudFullConfig<T>;
|
|
31
|
+
filter: ICrudFilter | null | undefined;
|
|
32
|
+
pageOptions: IPageOptions;
|
|
33
|
+
listOptions: IListOptions<T>;
|
|
34
|
+
TopComponent: ComponentType | undefined;
|
|
35
|
+
};
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCrudListPage = useCrudListPage;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const models_1 = require("@smartsoft001/models");
|
|
6
|
+
const react_2 = require("@smartsoft001/react");
|
|
7
|
+
const utils_1 = require("@smartsoft001/utils");
|
|
8
|
+
const export_1 = require("../../components/export/export");
|
|
9
|
+
const filters_1 = require("../../components/filters/filters");
|
|
10
|
+
const multiselect_1 = require("../../components/multiselect/multiselect");
|
|
11
|
+
const crud_context_1 = require("../../crud.context");
|
|
12
|
+
const hooks_1 = require("../../hooks");
|
|
13
|
+
const use_crud_bound_component_1 = require("../use-crud-bound-component");
|
|
14
|
+
const use_crud_page_config_1 = require("../use-crud-page-config");
|
|
15
|
+
const NO_ITEMS = [];
|
|
16
|
+
/** `path` + `/` + `segment`, without doubling the slash. */
|
|
17
|
+
function joinPath(path, segment) {
|
|
18
|
+
return path.replace(/\/+$/, '') + '/' + segment;
|
|
19
|
+
}
|
|
20
|
+
/** The `default` / `defaultDesc` of an object `config.sort`. */
|
|
21
|
+
function sortDefaults(config) {
|
|
22
|
+
const sort = config.sort;
|
|
23
|
+
return {
|
|
24
|
+
sortBy: config.sort ? sort['default'] : undefined,
|
|
25
|
+
sortDesc: config.sort ? sort['defaultDesc'] : undefined,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The filter of the first read (the Angular `ngOnInit`): with
|
|
30
|
+
* `list.resetQuery: 'beforeInit'` the configured defaults, else the filter the
|
|
31
|
+
* feature already has, else the defaults, the enabled search filter on top.
|
|
32
|
+
*/
|
|
33
|
+
function getInitialFilter(config, current, search) {
|
|
34
|
+
if (config.list?.resetQuery === 'beforeInit') {
|
|
35
|
+
return {
|
|
36
|
+
query: config.baseQuery ? [...config.baseQuery] : [],
|
|
37
|
+
paginationMode: config.list?.paginationMode,
|
|
38
|
+
limit: config.pagination ? config.pagination.limit : undefined,
|
|
39
|
+
offset: config.pagination ? 0 : undefined,
|
|
40
|
+
...sortDefaults(config),
|
|
41
|
+
...search,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (current)
|
|
45
|
+
return current;
|
|
46
|
+
const defaults = sortDefaults(config);
|
|
47
|
+
return {
|
|
48
|
+
paginationMode: config.list?.paginationMode,
|
|
49
|
+
limit: search?.limit
|
|
50
|
+
? search.limit
|
|
51
|
+
: config.pagination
|
|
52
|
+
? config.pagination.limit
|
|
53
|
+
: undefined,
|
|
54
|
+
offset: search?.offset || search?.offset === 0
|
|
55
|
+
? search.offset
|
|
56
|
+
: config.pagination
|
|
57
|
+
? 0
|
|
58
|
+
: undefined,
|
|
59
|
+
sortBy: search?.sortBy ? search.sortBy : defaults.sortBy,
|
|
60
|
+
sortDesc: search?.sortDesc ? search.sortDesc : defaults.sortDesc,
|
|
61
|
+
query: config.baseQuery ? [...config.baseQuery] : [],
|
|
62
|
+
...search,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** The `top` / `bottom` components of an object `config.details`. */
|
|
66
|
+
function getDetailsComponents(config) {
|
|
67
|
+
return config.details && typeof config.details === 'object'
|
|
68
|
+
? config.details.components
|
|
69
|
+
: undefined;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The logic of the list page (the Angular `ListComponent`), for
|
|
73
|
+
* `SmartCrudListPage` or a page of your own around the same feature:
|
|
74
|
+
*
|
|
75
|
+
* - `config`: the `CrudFullConfig` after the model's permissions;
|
|
76
|
+
* - the first read on mount (pagination, default sort, base query and the
|
|
77
|
+
* enabled `CrudSearchService` filter; `list.resetQuery: 'beforeInit'`
|
|
78
|
+
* starts from the defaults instead of the feature's filter);
|
|
79
|
+
* - `pageOptions`: the title, `variant`, the search (`config.search`) and the
|
|
80
|
+
* end buttons: multi edit, filters (`SmartCrudFilters` in the end menu),
|
|
81
|
+
* add (navigates to `<basePath>/add`), export (`SmartCrudExport` in a
|
|
82
|
+
* modal) and `config.buttons`;
|
|
83
|
+
* - `listOptions` for `SmartList`: the feature's items and loading, details
|
|
84
|
+
* through the facade, item links to `<basePath>/<id>`, remove through the
|
|
85
|
+
* facade (the list confirms it), the pagination of
|
|
86
|
+
* `useCrudListPagination`, sort and the multi selection (it opens
|
|
87
|
+
* `SmartCrudMultiselect` in the end menu);
|
|
88
|
+
* - `filter`: the feature's filter (the page renders once it is set);
|
|
89
|
+
* - `TopComponent`: `config.list.components.top`.
|
|
90
|
+
*
|
|
91
|
+
* A navigation closes the end menu and ends the multi selection.
|
|
92
|
+
*/
|
|
93
|
+
function useCrudListPage({ basePath, } = {}) {
|
|
94
|
+
const config = (0, use_crud_page_config_1.useCrudPageConfig)();
|
|
95
|
+
const facade = (0, crud_context_1.useCrudFacade)();
|
|
96
|
+
const searchService = (0, crud_context_1.useCrudSearchService)();
|
|
97
|
+
const navigation = (0, react_2.useNavigation)();
|
|
98
|
+
const menuService = (0, react_2.useMenuService)();
|
|
99
|
+
const modalService = (0, react_2.useModalService)();
|
|
100
|
+
const filter = (0, hooks_1.useCrudState)((state) => state.filter);
|
|
101
|
+
const list = (0, hooks_1.useCrudState)((state) => state.list);
|
|
102
|
+
const loading = (0, hooks_1.useCrudState)((state) => !state.loaded);
|
|
103
|
+
const selected = (0, hooks_1.useCrudState)((state) => state.selected);
|
|
104
|
+
const [select, setSelect] = (0, react_1.useState)(undefined);
|
|
105
|
+
const [cleanMultiSelected] = (0, react_1.useState)(() => new react_2.SmartEmitter());
|
|
106
|
+
const Filters = (0, use_crud_bound_component_1.useCrudBoundComponent)(filters_1.SmartCrudFilters);
|
|
107
|
+
const Multiselect = (0, use_crud_bound_component_1.useCrudBoundComponent)(multiselect_1.SmartCrudMultiselect);
|
|
108
|
+
const Export = (0, use_crud_bound_component_1.useCrudBoundComponent)(export_1.SmartCrudExport);
|
|
109
|
+
// The Angular page used the router's current URL.
|
|
110
|
+
const path = (0, react_1.useMemo)(() => basePath ?? navigation.getCurrentUrl().split(/[?#]/)[0], [basePath, navigation]);
|
|
111
|
+
const initialized = (0, react_1.useRef)(false);
|
|
112
|
+
(0, react_1.useEffect)(() => {
|
|
113
|
+
if (initialized.current)
|
|
114
|
+
return;
|
|
115
|
+
initialized.current = true;
|
|
116
|
+
facade.read(getInitialFilter(config, facade.filter, searchService.filter));
|
|
117
|
+
}, [config, facade, searchService]);
|
|
118
|
+
// Closes the end menu and ends the multi selection (the Angular `clear()`).
|
|
119
|
+
const clear = (0, react_1.useCallback)(async () => {
|
|
120
|
+
await menuService.closeEnd();
|
|
121
|
+
setSelect(undefined);
|
|
122
|
+
facade.multiSelect([]);
|
|
123
|
+
}, [menuService, facade]);
|
|
124
|
+
(0, react_1.useEffect)(() => navigation.subscribe(() => {
|
|
125
|
+
void clear();
|
|
126
|
+
}), [navigation, clear]);
|
|
127
|
+
const type = config.type;
|
|
128
|
+
const modelOptions = (0, react_1.useMemo)(() => (0, models_1.getModelOptions)(type), [type]);
|
|
129
|
+
const fieldsWithOptions = (0, react_1.useMemo)(() => (type ? (0, models_1.getModelFieldsWithOptions)(new type()) : []), [type]);
|
|
130
|
+
const endButtons = (0, react_1.useMemo)(() => {
|
|
131
|
+
const showFilters = fieldsWithOptions.some((x) => x.options?.list?.filter) || modelOptions?.filters?.length;
|
|
132
|
+
// The Angular page also left it out on mobile devices
|
|
133
|
+
// (`HardwareService.isMobile`), which the React library does not detect.
|
|
134
|
+
const showMultiEdit = config.list?.components?.multi ||
|
|
135
|
+
(config.edit &&
|
|
136
|
+
fieldsWithOptions.some((x) => x.options?.update?.multi) &&
|
|
137
|
+
(!config.list?.mode || config.list.mode === react_2.ListMode.desktop));
|
|
138
|
+
return [
|
|
139
|
+
...(showMultiEdit
|
|
140
|
+
? [
|
|
141
|
+
{
|
|
142
|
+
icon: 'checkbox-outline',
|
|
143
|
+
text: 'multi',
|
|
144
|
+
handler: () => {
|
|
145
|
+
facade.multiSelect([]);
|
|
146
|
+
cleanMultiSelected.emit();
|
|
147
|
+
setTimeout(async () => {
|
|
148
|
+
setSelect((val) => (val === 'multi' ? undefined : 'multi'));
|
|
149
|
+
if (menuService.openedEnd)
|
|
150
|
+
await menuService.closeEnd();
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
]
|
|
155
|
+
: []),
|
|
156
|
+
...(showFilters
|
|
157
|
+
? [
|
|
158
|
+
{
|
|
159
|
+
icon: 'filter-outline',
|
|
160
|
+
text: 'filters',
|
|
161
|
+
handler: async () => {
|
|
162
|
+
await menuService.openEnd({ component: Filters });
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
]
|
|
166
|
+
: []),
|
|
167
|
+
...(config.add
|
|
168
|
+
? [
|
|
169
|
+
{
|
|
170
|
+
icon: 'add',
|
|
171
|
+
text: 'add',
|
|
172
|
+
handler: () => {
|
|
173
|
+
navigation.navigate(joinPath(path, 'add'));
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
]
|
|
177
|
+
: []),
|
|
178
|
+
...(config.export
|
|
179
|
+
? [
|
|
180
|
+
{
|
|
181
|
+
text: 'export',
|
|
182
|
+
icon: 'download-outline',
|
|
183
|
+
type: 'popover',
|
|
184
|
+
component: Export,
|
|
185
|
+
// The Angular page left showing the popover to the page
|
|
186
|
+
// (commented out there); here the component opens in a modal.
|
|
187
|
+
handler: () => {
|
|
188
|
+
void modalService.show({ component: Export });
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
]
|
|
192
|
+
: []),
|
|
193
|
+
...(config.buttons ? config.buttons : []),
|
|
194
|
+
];
|
|
195
|
+
}, [
|
|
196
|
+
config,
|
|
197
|
+
facade,
|
|
198
|
+
fieldsWithOptions,
|
|
199
|
+
modelOptions,
|
|
200
|
+
cleanMultiSelected,
|
|
201
|
+
menuService,
|
|
202
|
+
modalService,
|
|
203
|
+
navigation,
|
|
204
|
+
path,
|
|
205
|
+
Filters,
|
|
206
|
+
Export,
|
|
207
|
+
]);
|
|
208
|
+
const getFilter = (0, react_1.useCallback)(() => facade.filter, [facade]);
|
|
209
|
+
const pageOptions = (0, react_1.useMemo)(() => ({
|
|
210
|
+
title: config.title || '',
|
|
211
|
+
variant: config.variant,
|
|
212
|
+
search: config.search
|
|
213
|
+
? {
|
|
214
|
+
text: filter?.searchText ?? '',
|
|
215
|
+
set: (txt) => {
|
|
216
|
+
const current = getFilter();
|
|
217
|
+
if (txt !== current?.searchText)
|
|
218
|
+
facade.read({ ...current, searchText: txt, offset: 0 });
|
|
219
|
+
},
|
|
220
|
+
}
|
|
221
|
+
: undefined,
|
|
222
|
+
endButtons,
|
|
223
|
+
}), [config, filter, facade, getFilter, endButtons]);
|
|
224
|
+
const pagination = (0, hooks_1.useCrudListPagination)({
|
|
225
|
+
mode: config.list?.paginationMode,
|
|
226
|
+
limit: config.pagination?.limit ?? 0,
|
|
227
|
+
});
|
|
228
|
+
const listOptions = (0, react_1.useMemo)(() => {
|
|
229
|
+
const detailsComponents = getDetailsComponents(config);
|
|
230
|
+
return {
|
|
231
|
+
provider: {
|
|
232
|
+
getData: (next) => {
|
|
233
|
+
facade.read({ ...getFilter(), ...next });
|
|
234
|
+
},
|
|
235
|
+
onChangeMultiSelected: async (items) => {
|
|
236
|
+
if (items.length && !menuService.openedEnd) {
|
|
237
|
+
await menuService.openEnd({ component: Multiselect });
|
|
238
|
+
}
|
|
239
|
+
else if (!items.length && menuService.openedEnd) {
|
|
240
|
+
await menuService.closeEnd();
|
|
241
|
+
}
|
|
242
|
+
facade.multiSelect(items);
|
|
243
|
+
},
|
|
244
|
+
list: list || NO_ITEMS,
|
|
245
|
+
loading,
|
|
246
|
+
onCleanMultiSelected$: cleanMultiSelected,
|
|
247
|
+
},
|
|
248
|
+
cellPipe: config.list ? config.list.cellPipe : undefined,
|
|
249
|
+
mode: config.list?.mode,
|
|
250
|
+
type: config.type,
|
|
251
|
+
details: config.details
|
|
252
|
+
? {
|
|
253
|
+
provider: {
|
|
254
|
+
getData: (id) => {
|
|
255
|
+
facade.select(id);
|
|
256
|
+
},
|
|
257
|
+
clearData: () => {
|
|
258
|
+
facade.unselect();
|
|
259
|
+
},
|
|
260
|
+
item: selected,
|
|
261
|
+
loading,
|
|
262
|
+
},
|
|
263
|
+
componentFactories: {
|
|
264
|
+
top: detailsComponents?.top,
|
|
265
|
+
bottom: detailsComponents?.bottom,
|
|
266
|
+
},
|
|
267
|
+
}
|
|
268
|
+
: undefined,
|
|
269
|
+
item: !!config.edit || config.details
|
|
270
|
+
? {
|
|
271
|
+
options: {
|
|
272
|
+
routingPrefix: joinPath(path, ''),
|
|
273
|
+
edit: !!config.edit,
|
|
274
|
+
},
|
|
275
|
+
}
|
|
276
|
+
: undefined,
|
|
277
|
+
remove: config.remove
|
|
278
|
+
? {
|
|
279
|
+
provider: {
|
|
280
|
+
invoke: (id) => facade.delete(id),
|
|
281
|
+
check: (item) => modelOptions?.remove?.enabled
|
|
282
|
+
? utils_1.SpecificationService.valid(item, modelOptions.remove.enabled)
|
|
283
|
+
: true,
|
|
284
|
+
},
|
|
285
|
+
}
|
|
286
|
+
: undefined,
|
|
287
|
+
pagination,
|
|
288
|
+
sort: config.sort,
|
|
289
|
+
select,
|
|
290
|
+
};
|
|
291
|
+
}, [
|
|
292
|
+
config,
|
|
293
|
+
facade,
|
|
294
|
+
getFilter,
|
|
295
|
+
menuService,
|
|
296
|
+
Multiselect,
|
|
297
|
+
list,
|
|
298
|
+
loading,
|
|
299
|
+
cleanMultiSelected,
|
|
300
|
+
selected,
|
|
301
|
+
path,
|
|
302
|
+
modelOptions,
|
|
303
|
+
pagination,
|
|
304
|
+
select,
|
|
305
|
+
]);
|
|
306
|
+
const TopComponent = config.list?.components?.top;
|
|
307
|
+
return { config, filter, pageOptions, listOptions, TopComponent };
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=use-crud-list-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-crud-list-page.js","sourceRoot":"","sources":["../../../../../../../../../packages/crud/shell/react/src/lib/pages/list/use-crud-list-page.ts"],"names":[],"mappings":";;AA4HA,0CA0QC;AAtYD,iCAA0E;AAI1E,iDAK8B;AAC9B,+CAS6B;AAC7B,+CAA2D;AAG3D,2DAAiE;AACjE,8DAAoE;AACpE,0EAAgF;AAEhF,qDAAyE;AACzE,uCAAkE;AAElE,0EAAoE;AACpE,kEAA4D;AAE5D,MAAM,QAAQ,GAAY,EAAE,CAAC;AAE7B,4DAA4D;AAC5D,SAAS,QAAQ,CAAC,IAAY,EAAE,OAAe;IAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC;AAClD,CAAC;AAED,gEAAgE;AAChE,SAAS,YAAY,CAAC,MAA2B;IAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAmD,CAAC;IAExE,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;QACjD,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS;KACxD,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CACvB,MAA2B,EAC3B,OAAgC,EAChC,MAA4B;IAE5B,IAAI,MAAM,CAAC,IAAI,EAAE,UAAU,KAAK,YAAY,EAAE,CAAC;QAC7C,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE;YACpD,cAAc,EAAE,MAAM,CAAC,IAA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
|
|
2
|
+
/**
|
|
3
|
+
* `Component` bound to the CRUD feature of the caller: wherever it is
|
|
4
|
+
* rendered (the end menu of `MenuService.openEnd`, a modal of
|
|
5
|
+
* `ModalService.show`, both rendered outside the `CrudProvider`), it reads
|
|
6
|
+
* the caller's feature (`useCrud()`) and the feature's file service. This is
|
|
7
|
+
* what the Angular pages handed to `MenuService.openEnd` as the `injector`.
|
|
8
|
+
* Props are passed through, e.g. the `dismiss` of a modal.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useCrudBoundComponent<P extends object>(Component: ComponentType<P>): ComponentType<P>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCrudBoundComponent = useCrudBoundComponent;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_2 = require("@smartsoft001/react");
|
|
7
|
+
const crud_context_1 = require("../crud.context");
|
|
8
|
+
/**
|
|
9
|
+
* `Component` bound to the CRUD feature of the caller: wherever it is
|
|
10
|
+
* rendered (the end menu of `MenuService.openEnd`, a modal of
|
|
11
|
+
* `ModalService.show`, both rendered outside the `CrudProvider`), it reads
|
|
12
|
+
* the caller's feature (`useCrud()`) and the feature's file service. This is
|
|
13
|
+
* what the Angular pages handed to `MenuService.openEnd` as the `injector`.
|
|
14
|
+
* Props are passed through, e.g. the `dismiss` of a modal.
|
|
15
|
+
*/
|
|
16
|
+
function useCrudBoundComponent(Component) {
|
|
17
|
+
const crud = (0, crud_context_1.useCrud)();
|
|
18
|
+
const fileService = (0, react_2.useFileService)();
|
|
19
|
+
return (0, react_1.useMemo)(() => {
|
|
20
|
+
function CrudBoundComponent(props) {
|
|
21
|
+
const smart = (0, react_2.useSmart)();
|
|
22
|
+
const value = (0, react_1.useMemo)(() => ({ ...smart, fileService }), [smart]);
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)(react_2.SmartContext.Provider, { value: value, children: (0, jsx_runtime_1.jsx)(crud_context_1.CrudContext.Provider, { value: crud, children: (0, jsx_runtime_1.jsx)(Component, { ...props }) }) }));
|
|
24
|
+
}
|
|
25
|
+
return CrudBoundComponent;
|
|
26
|
+
}, [Component, crud, fileService]);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=use-crud-bound-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-crud-bound-component.js","sourceRoot":"","sources":["../../../../../../../../packages/crud/shell/react/src/lib/pages/use-crud-bound-component.tsx"],"names":[],"mappings":";;AAoBA,sDAyBC;;AA7CD,iCAAgC;AAGhC,+CAK6B;AAE7B,kDAAuD;AAEvD;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,SAA2B;IAE3B,MAAM,IAAI,GAAG,IAAA,sBAAO,GAAE,CAAC;IACvB,MAAM,WAAW,GAAG,IAAA,sBAAc,GAAE,CAAC;IAErC,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,SAAS,kBAAkB,CAAC,KAAQ;YAClC,MAAM,KAAK,GAAG,IAAA,gBAAQ,GAAE,CAAC;YACzB,MAAM,KAAK,GAAG,IAAA,eAAO,EACnB,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,WAAW,EAAE,CAAC,EACjC,CAAC,KAAK,CAAC,CACR,CAAC;YAEF,OAAO,CACL,uBAAC,oBAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACjC,uBAAC,0BAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,YAC/B,uBAAC,SAAS,OAAK,KAAK,GAAI,GACH,GACD,CACzB,CAAC;QACJ,CAAC;QAED,OAAO,kBAAkB,CAAC;IAC5B,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IEntity } from '@smartsoft001/domain-core';
|
|
2
|
+
import { CrudFullConfig } from '../crud.config';
|
|
3
|
+
/**
|
|
4
|
+
* The configuration of the feature's pages: the `CrudFullConfig` of the
|
|
5
|
+
* `CrudProvider` with `add`, `edit` and `remove` turned off when the model's
|
|
6
|
+
* permissions are not granted (the Angular `PageService.checkPermissions()`
|
|
7
|
+
* every page ran on init).
|
|
8
|
+
*/
|
|
9
|
+
export declare function useCrudPageConfig<T extends IEntity<string>>(): CrudFullConfig<T>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCrudPageConfig = useCrudPageConfig;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_2 = require("@smartsoft001/react");
|
|
6
|
+
const crud_context_1 = require("../crud.context");
|
|
7
|
+
const page_service_1 = require("../services/page/page.service");
|
|
8
|
+
/**
|
|
9
|
+
* The configuration of the feature's pages: the `CrudFullConfig` of the
|
|
10
|
+
* `CrudProvider` with `add`, `edit` and `remove` turned off when the model's
|
|
11
|
+
* permissions are not granted (the Angular `PageService.checkPermissions()`
|
|
12
|
+
* every page ran on init).
|
|
13
|
+
*/
|
|
14
|
+
function useCrudPageConfig() {
|
|
15
|
+
const config = (0, crud_context_1.useCrudConfig)();
|
|
16
|
+
const authService = (0, react_2.useAuthService)();
|
|
17
|
+
return (0, react_1.useMemo)(() => (0, page_service_1.applyPagePermissions)(config, authService), [config, authService]);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=use-crud-page-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-crud-page-config.js","sourceRoot":"","sources":["../../../../../../../../packages/crud/shell/react/src/lib/pages/use-crud-page-config.ts"],"names":[],"mappings":";;AAeA,8CAUC;AAzBD,iCAAgC;AAGhC,+CAAqD;AAGrD,kDAAgD;AAChD,gEAAqE;AAErE;;;;;GAKG;AACH,SAAgB,iBAAiB;IAG/B,MAAM,MAAM,GAAG,IAAA,4BAAa,GAAK,CAAC;IAClC,MAAM,WAAW,GAAG,IAAA,sBAAc,GAAE,CAAC;IAErC,OAAO,IAAA,eAAO,EACZ,GAAG,EAAE,CAAC,IAAA,mCAAoB,EAAC,MAA2B,EAAE,WAAW,CAAC,EACpE,CAAC,MAAM,EAAE,WAAW,CAAC,CACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IModelLabelOptions, IModelLabelProvider, SmartTranslateFn } from '@smartsoft001/react';
|
|
2
|
+
/**
|
|
3
|
+
* The label provider of a CRUD feature: delegates to the application's
|
|
4
|
+
* provider when there is one, otherwise translates `MODEL.<key>`.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CrudModelLabelProvider extends IModelLabelProvider {
|
|
7
|
+
private readonly translate;
|
|
8
|
+
private readonly parent;
|
|
9
|
+
constructor(translate: SmartTranslateFn, parent?: IModelLabelProvider | null);
|
|
10
|
+
get(options: IModelLabelOptions): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudModelLabelProvider = void 0;
|
|
4
|
+
const react_1 = require("@smartsoft001/react");
|
|
5
|
+
/**
|
|
6
|
+
* The label provider of a CRUD feature: delegates to the application's
|
|
7
|
+
* provider when there is one, otherwise translates `MODEL.<key>`.
|
|
8
|
+
*/
|
|
9
|
+
class CrudModelLabelProvider extends react_1.IModelLabelProvider {
|
|
10
|
+
translate;
|
|
11
|
+
parent;
|
|
12
|
+
constructor(translate, parent = null) {
|
|
13
|
+
super();
|
|
14
|
+
this.translate = translate;
|
|
15
|
+
this.parent = parent;
|
|
16
|
+
}
|
|
17
|
+
get(options) {
|
|
18
|
+
if (this.parent) {
|
|
19
|
+
const result = this.parent.get(options);
|
|
20
|
+
if (result)
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
return this.translate('MODEL.' + options.key);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.CrudModelLabelProvider = CrudModelLabelProvider;
|
|
27
|
+
//# sourceMappingURL=model-label.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-label.provider.js","sourceRoot":"","sources":["../../../../../../../../packages/crud/shell/react/src/lib/providers/model-label.provider.ts"],"names":[],"mappings":";;;AAAA,+CAI6B;AAE7B;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,2BAAmB;IAE1C;IACA;IAFnB,YACmB,SAA2B,EAC3B,SAAqC,IAAI;QAE1D,KAAK,EAAE,CAAC;QAHS,cAAS,GAAT,SAAS,CAAkB;QAC3B,WAAM,GAAN,MAAM,CAAmC;IAG5D,CAAC;IAEQ,GAAG,CAAC,OAA2B;QACtC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAExC,IAAI,MAAM;gBAAE,OAAO,MAAM,CAAC;QAC5B,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;CACF;AAjBD,wDAiBC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IEntity } from '@smartsoft001/domain-core';
|
|
2
|
+
import { SmartHttpClient } from '@smartsoft001/react';
|
|
3
|
+
import { CrudConfig } from '../../crud.config';
|
|
4
|
+
import { ICrudCreateManyOptions, ICrudFilter } from '../../models';
|
|
5
|
+
export interface ICrudListResult<T> {
|
|
6
|
+
data: T[];
|
|
7
|
+
totalCount: number;
|
|
8
|
+
links: any;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The REST client of a CRUD resource, speaking the same contract as the
|
|
12
|
+
* Angular `CrudService` and `@smartsoft001/crud-shell-nestjs`: the same URLs,
|
|
13
|
+
* the same query string (`$search`, `limit`/`offset`, `sort`, `key=value`
|
|
14
|
+
* filters) and the same CSV / XLSX export.
|
|
15
|
+
*/
|
|
16
|
+
export declare class CrudService<T extends IEntity<string>> {
|
|
17
|
+
protected readonly config: CrudConfig<T>;
|
|
18
|
+
protected readonly http: SmartHttpClient;
|
|
19
|
+
protected readonly formatMap: {
|
|
20
|
+
csv: string;
|
|
21
|
+
xlsx: string;
|
|
22
|
+
};
|
|
23
|
+
constructor(config: CrudConfig<T>, http: SmartHttpClient);
|
|
24
|
+
/**
|
|
25
|
+
* Creates `item` and resolves with the id of the new item, read from the
|
|
26
|
+
* `Location` header, or `null` when the API sends none.
|
|
27
|
+
*/
|
|
28
|
+
create(item: T): Promise<string | null>;
|
|
29
|
+
createMany(items: Array<T>, options: ICrudCreateManyOptions): Promise<void>;
|
|
30
|
+
getById(id: string): Promise<T>;
|
|
31
|
+
getList<R = T>(filter?: ICrudFilter | null): Promise<ICrudListResult<R>>;
|
|
32
|
+
/** Downloads the list matching `filter` as `data.csv` or `data.xlsx`. */
|
|
33
|
+
exportList(filter?: ICrudFilter | null, format?: 'csv' | 'xlsx'): Promise<void>;
|
|
34
|
+
update(item: T): Promise<void>;
|
|
35
|
+
updatePartial(item: Partial<T> & {
|
|
36
|
+
id: string;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
updatePartialMany(items: (Partial<T> & {
|
|
39
|
+
id: string;
|
|
40
|
+
})[]): Promise<void[]>;
|
|
41
|
+
delete(id: string): Promise<void>;
|
|
42
|
+
protected getQuery(filter: ICrudFilter | null): string;
|
|
43
|
+
private download;
|
|
44
|
+
}
|