studiokit-scaffolding-js 5.1.1 → 5.1.2-next.1.2
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/lib/components/HOC/CollectionComponent.d.ts +1 -1
- package/lib/components/HOC/CollectionComponent.js +4 -2
- package/lib/components/HOC/CollectionItemComponent.d.ts +1 -1
- package/lib/components/HOC/CollectionItemComponent.js +4 -2
- package/lib/components/HOC/SearchPersistorComponent.d.ts +8 -4
- package/lib/components/HOC/SearchPersistorComponent.js +12 -8
- package/lib/components/ManageTable.js +19 -22
- package/lib/components/ManageTableNoDataComponent.d.ts +11 -0
- package/lib/components/ManageTableNoDataComponent.js +26 -0
- package/lib/components/PaginationNextButton.d.ts +3 -0
- package/lib/components/PaginationNextButton.js +24 -0
- package/lib/components/PaginationPreviousButton.d.ts +3 -0
- package/lib/components/PaginationPreviousButton.js +24 -0
- package/lib/components/SearchControls.d.ts +2 -0
- package/lib/components/SearchControls.js +2 -2
- package/lib/components/UserRoles/index.d.ts +1 -1
- package/lib/css/components/_tables.css +108 -37
- package/lib/hooks/useCollection.js +15 -4
- package/lib/hooks/useCollectionItem.js +15 -4
- package/lib/types/Collection.d.ts +3 -1
- package/lib/utils/table.d.ts +7 -0
- package/lib/utils/{manageTable.js → table.js} +15 -1
- package/package.json +1 -1
- package/lib/utils/manageTable.d.ts +0 -2
|
@@ -46,7 +46,7 @@ export declare function configureCollectionComponent<TModel extends Model, TOwnP
|
|
|
46
46
|
};
|
|
47
47
|
contextType?: React.Context<any> | undefined;
|
|
48
48
|
};
|
|
49
|
-
export declare const configureMapStateToProps: <TModel extends Model, TOwnProps extends Pick<CollectionComponentProps<TModel>, "match" | "queryParams" | "modelName" | "guid" | "location" | "history" | "staticContext" | "pathParams" | "disableAutoLoad">>(modelName: string) => (state: BaseReduxState, ownProps: TOwnProps & Partial<CollectionComponentProps<TModel>>) => import("../../types").CollectionSelectorMethodResponse<Model>;
|
|
49
|
+
export declare const configureMapStateToProps: <TModel extends Model, TOwnProps extends Pick<CollectionComponentProps<TModel>, "match" | "queryParams" | "modelName" | "guid" | "location" | "history" | "staticContext" | "pathParams" | "disableAutoLoad" | "disableAutoLoadOnParamsChange">>(modelName: string) => (state: BaseReduxState, ownProps: TOwnProps & Partial<CollectionComponentProps<TModel>>) => import("../../types").CollectionSelectorMethodResponse<Model>;
|
|
50
50
|
/**
|
|
51
51
|
* HOC that provides "collection" related functionality, using redux `connect()`, react-router-dom `withRouter()`, and `GuidComponent`.
|
|
52
52
|
*
|
|
@@ -126,10 +126,12 @@ function configureCollectionComponent(WrappedComponent, LoaderComponent) {
|
|
|
126
126
|
};
|
|
127
127
|
CollectionComponent.prototype.componentDidUpdate = function (prevProps) {
|
|
128
128
|
var prevModel = prevProps.model, prevModelName = prevProps.modelName, prevPathParams = prevProps.pathParams, prevQueryParams = prevProps.queryParams;
|
|
129
|
-
var _a = this.props, model = _a.model, modelName = _a.modelName, pathParams = _a.pathParams, queryParams = _a.queryParams;
|
|
129
|
+
var _a = this.props, model = _a.model, modelName = _a.modelName, pathParams = _a.pathParams, queryParams = _a.queryParams, disableAutoLoadOnParamsChange = _a.disableAutoLoadOnParamsChange;
|
|
130
130
|
var fetchingId = this.state.fetchingId;
|
|
131
131
|
model_1.handleModelFetchFinish(model, prevModel, fetchingId, this.changeModelStatus);
|
|
132
|
-
|
|
132
|
+
if (!disableAutoLoadOnParamsChange) {
|
|
133
|
+
collection_1.handleCollectionParamsChange(modelName, prevModelName, pathParams, prevPathParams, queryParams, prevQueryParams, this.load);
|
|
134
|
+
}
|
|
133
135
|
};
|
|
134
136
|
CollectionComponent.prototype.componentWillUnmount = function () {
|
|
135
137
|
var model = this.props.model;
|
|
@@ -45,7 +45,7 @@ export declare function configureCollectionItemComponent<TModel extends Model, T
|
|
|
45
45
|
};
|
|
46
46
|
contextType?: React.Context<any> | undefined;
|
|
47
47
|
};
|
|
48
|
-
export declare const configureMapStateToProps: <TModel extends Model, TOwnProps extends Pick<CollectionItemComponentProps<TModel>, "match" | "queryParams" | "modelName" | "guid" | "location" | "history" | "staticContext" | "pathParams" | "disableAutoLoad">>(modelName: string) => (state: BaseReduxState, ownProps: TOwnProps) => import("../../types").CollectionSelectorMethodResponse<Model>;
|
|
48
|
+
export declare const configureMapStateToProps: <TModel extends Model, TOwnProps extends Pick<CollectionItemComponentProps<TModel>, "match" | "queryParams" | "modelName" | "guid" | "location" | "history" | "staticContext" | "pathParams" | "disableAutoLoad" | "disableAutoLoadOnParamsChange">>(modelName: string) => (state: BaseReduxState, ownProps: TOwnProps) => import("../../types").CollectionSelectorMethodResponse<Model>;
|
|
49
49
|
/**
|
|
50
50
|
* HOC that provides "collection" related functionality for a single item in a collection, using redux `connect()`, react-router-dom `withRouter()`, and `GuidComponent`.
|
|
51
51
|
*
|
|
@@ -128,9 +128,11 @@ function configureCollectionItemComponent(WrappedComponent, LoaderComponent) {
|
|
|
128
128
|
};
|
|
129
129
|
CollectionItemComponent.prototype.componentDidUpdate = function (prevProps) {
|
|
130
130
|
var prevModel = prevProps.model, prevModelName = prevProps.modelName, prevPathParams = prevProps.pathParams, prevQueryParams = prevProps.queryParams;
|
|
131
|
-
var _a = this.props, modelName = _a.modelName, model = _a.model, pathParams = _a.pathParams, queryParams = _a.queryParams;
|
|
131
|
+
var _a = this.props, modelName = _a.modelName, model = _a.model, pathParams = _a.pathParams, queryParams = _a.queryParams, disableAutoLoadOnParamsChange = _a.disableAutoLoadOnParamsChange;
|
|
132
132
|
model_1.handleModelFetchFinish(model, prevModel, undefined, this.setModelStatus);
|
|
133
|
-
|
|
133
|
+
if (!disableAutoLoadOnParamsChange) {
|
|
134
|
+
collection_1.handleCollectionItemParamsChange(modelName, prevModelName, pathParams, prevPathParams, queryParams, prevQueryParams, this.load);
|
|
135
|
+
}
|
|
134
136
|
};
|
|
135
137
|
CollectionItemComponent.prototype.render = function () {
|
|
136
138
|
var _a = this.props, history = _a.history, match = _a.match, location = _a.location, staticContext = _a.staticContext, otherProps = __rest(_a, ["history", "match", "location", "staticContext"]);
|
|
@@ -22,8 +22,8 @@ export interface SearchPersistorMethods<T extends Search = Search> {
|
|
|
22
22
|
export interface SearchPersistorWrappedProps<T extends Search = Search> extends SearchPersistorProps<T>, SearchPersistorMethods<T> {
|
|
23
23
|
search?: T;
|
|
24
24
|
}
|
|
25
|
-
export declare function configureSearchPersistorComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & SearchPersistorWrappedProps
|
|
26
|
-
export declare function configureSearchPersistorComponent<TOwnProps extends {}, TSearchType extends Search>(WrappedComponent: ComponentType<TOwnProps & SearchPersistorWrappedProps<TSearchType
|
|
25
|
+
export declare function configureSearchPersistorComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & SearchPersistorWrappedProps>, disableLocalSearch?: boolean): ComponentType<TOwnProps & SearchPersistorProps>;
|
|
26
|
+
export declare function configureSearchPersistorComponent<TOwnProps extends {}, TSearchType extends Search>(WrappedComponent: ComponentType<TOwnProps & SearchPersistorWrappedProps<TSearchType>>, disableLocalSearch?: boolean): ComponentType<TOwnProps & SearchPersistorProps<TSearchType>>;
|
|
27
27
|
export declare const configureMapStateToProps: <TSearchType extends Search>(key: string) => (state: BaseReduxState) => SearchPersistorProps<TSearchType>;
|
|
28
28
|
export declare const configureMapDispatchToProps: <TSearchType extends Search>(key: string) => (dispatch: Dispatch) => SearchPersistorProps<TSearchType>;
|
|
29
29
|
/**
|
|
@@ -44,9 +44,11 @@ export declare const configureMapDispatchToProps: <TSearchType extends Search>(k
|
|
|
44
44
|
*
|
|
45
45
|
* @param WrappedComponent The component to wrap
|
|
46
46
|
* @param key The key under "search" in redux where the component’s search params will be stored
|
|
47
|
+
* @param disableLocalSearch By default, `doSearch` is only called at initialization and when `queryAll` is `true`, and searching happens locally (see ManageTable).
|
|
48
|
+
* If `disableLocalSearch` is `true` then the legacy logic is used, where `doSearch` is always called for all searches.
|
|
47
49
|
* @returns The wrapped component, passing down `search` and `persistSearch` as props
|
|
48
50
|
*/
|
|
49
|
-
export default function searchPersistorComponent<TOwnProps extends SearchPersistorWrappedProps>(WrappedComponent: ComponentType<TOwnProps>, key: string): ComponentClass<Omit<TOwnProps, keyof SearchPersistorWrappedProps>>;
|
|
51
|
+
export default function searchPersistorComponent<TOwnProps extends SearchPersistorWrappedProps>(WrappedComponent: ComponentType<TOwnProps>, key: string, disableLocalSearch?: boolean): ComponentClass<Omit<TOwnProps, keyof SearchPersistorWrappedProps>>;
|
|
50
52
|
/**
|
|
51
53
|
* HOC to handle persistence and restoration of "Manage" components search parameters.
|
|
52
54
|
* Note: if you store a search date in a child component, make sure it’s called `date`.
|
|
@@ -65,6 +67,8 @@ export default function searchPersistorComponent<TOwnProps extends SearchPersist
|
|
|
65
67
|
*
|
|
66
68
|
* @param WrappedComponent The component to wrap
|
|
67
69
|
* @param key The key under "search" in redux where the component’s search params will be stored
|
|
70
|
+
* @param disableLocalSearch By default, `doSearch` is only called at initialization and when `queryAll` is `true`, and searching happens locally (see ManageTable).
|
|
71
|
+
* If `disableLocalSearch` is `true` then the legacy logic is used, where `doSearch` is always called for all searches.
|
|
68
72
|
* @returns The wrapped component, passing down `search` and `persistSearch` as props
|
|
69
73
|
*/
|
|
70
|
-
export default function searchPersistorComponent<TOwnProps extends SearchPersistorWrappedProps<TSearchType>, TSearchType extends Search>(WrappedComponent: ComponentType<TOwnProps>, key: string): ComponentClass<Omit<TOwnProps, keyof SearchPersistorWrappedProps<TSearchType>>>;
|
|
74
|
+
export default function searchPersistorComponent<TOwnProps extends SearchPersistorWrappedProps<TSearchType>, TSearchType extends Search>(WrappedComponent: ComponentType<TOwnProps>, key: string, disableLocalSearch?: boolean): ComponentClass<Omit<TOwnProps, keyof SearchPersistorWrappedProps<TSearchType>>>;
|
|
@@ -48,7 +48,7 @@ var lodash_1 = require("lodash");
|
|
|
48
48
|
var react_1 = __importStar(require("react"));
|
|
49
49
|
var react_redux_1 = require("react-redux");
|
|
50
50
|
var actions_1 = require("../../redux/actions");
|
|
51
|
-
function configureSearchPersistorComponent(WrappedComponent) {
|
|
51
|
+
function configureSearchPersistorComponent(WrappedComponent, disableLocalSearch) {
|
|
52
52
|
return /** @class */ (function (_super) {
|
|
53
53
|
__extends(SearchPersistorComponent, _super);
|
|
54
54
|
function SearchPersistorComponent(props) {
|
|
@@ -105,8 +105,8 @@ function configureSearchPersistorComponent(WrappedComponent) {
|
|
|
105
105
|
pageSize: search.pageSize,
|
|
106
106
|
pageByTab: search.pageByTab
|
|
107
107
|
}),
|
|
108
|
-
// do not trigger a re-load unless queryAll is true
|
|
109
|
-
search.queryAll ? _this.doSearch : undefined);
|
|
108
|
+
// do not trigger a re-load unless queryAll is true, or local search is disabled
|
|
109
|
+
disableLocalSearch || search.queryAll ? _this.doSearch : undefined);
|
|
110
110
|
};
|
|
111
111
|
_this.setSelectedTab = function (selectedTab) {
|
|
112
112
|
var _a, _b;
|
|
@@ -126,16 +126,20 @@ function configureSearchPersistorComponent(WrappedComponent) {
|
|
|
126
126
|
};
|
|
127
127
|
_this.handleKeywordsKeyDown = function (event) {
|
|
128
128
|
var _a;
|
|
129
|
-
if (event.key === 'Enter' && ((_a = _this.state.search) === null || _a === void 0 ? void 0 : _a.queryAll)) {
|
|
129
|
+
if (event.key === 'Enter' && (disableLocalSearch || ((_a = _this.state.search) === null || _a === void 0 ? void 0 : _a.queryAll))) {
|
|
130
130
|
_this.handleSearchClick();
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
133
|
_this.setQueryAll = function (event) {
|
|
134
|
+
var _a;
|
|
134
135
|
var queryAll = event.target.checked;
|
|
135
136
|
_this.updateAndPersistSearch({
|
|
136
137
|
queryAll: queryAll,
|
|
137
|
-
requiredMessage
|
|
138
|
-
|
|
138
|
+
// clear the `requiredMessage` when turning off `queryAll` and local search is enabled
|
|
139
|
+
requiredMessage: !queryAll && !disableLocalSearch ? null : (_a = _this.state.search) === null || _a === void 0 ? void 0 : _a.requiredMessage
|
|
140
|
+
},
|
|
141
|
+
// only automatically trigger re-load when local search is enabled
|
|
142
|
+
!disableLocalSearch ? _this.doSearch : undefined);
|
|
139
143
|
};
|
|
140
144
|
_this.setSortingRules = function (newSortingRules) {
|
|
141
145
|
_this.updateAndPersistSearch({
|
|
@@ -213,8 +217,8 @@ var configureMapDispatchToProps = function (key) { return function (dispatch) {
|
|
|
213
217
|
};
|
|
214
218
|
}; };
|
|
215
219
|
exports.configureMapDispatchToProps = configureMapDispatchToProps;
|
|
216
|
-
function searchPersistorComponent(WrappedComponent, key) {
|
|
217
|
-
var SearchPersistorComponent = configureSearchPersistorComponent(WrappedComponent);
|
|
220
|
+
function searchPersistorComponent(WrappedComponent, key, disableLocalSearch) {
|
|
221
|
+
var SearchPersistorComponent = configureSearchPersistorComponent(WrappedComponent, disableLocalSearch);
|
|
218
222
|
var mapStateToProps = exports.configureMapStateToProps(key);
|
|
219
223
|
var mapDispatchToProps = exports.configureMapDispatchToProps(key);
|
|
220
224
|
// @ts-ignore: could not match inferred type from the `connect` HOC
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
@@ -10,6 +21,10 @@ var react_2 = __importDefault(require("react"));
|
|
|
10
21
|
var react_bootstrap_1 = require("react-bootstrap");
|
|
11
22
|
var react_table_1 = __importDefault(require("react-table"));
|
|
12
23
|
var table_1 = require("../constants/table");
|
|
24
|
+
var table_2 = require("../utils/table");
|
|
25
|
+
var ManageTableNoDataComponent_1 = require("./ManageTableNoDataComponent");
|
|
26
|
+
var PaginationNextButton_1 = require("./PaginationNextButton");
|
|
27
|
+
var PaginationPreviousButton_1 = require("./PaginationPreviousButton");
|
|
13
28
|
var RefreshIndicator_1 = require("./RefreshIndicator");
|
|
14
29
|
var ManageTable = function (_a) {
|
|
15
30
|
//#region Data
|
|
@@ -62,33 +77,15 @@ var ManageTable = function (_a) {
|
|
|
62
77
|
var SearchTabs = react_1.useMemo(function () { return (react_2.default.createElement(react_bootstrap_1.Tabs, { activeKey: selectedTab, id: "search-tabs", onSelect: onTabSelect }, tabs.map(function (tab) { return (react_2.default.createElement(react_bootstrap_1.Tab, { key: tab, eventKey: tab.toString(), title: getTabName(tab) + " (" + dataLengthByTab[tab] + ")", disabled: noResultsFound })); }))); }, [dataLengthByTab, getTabName, noResultsFound, onTabSelect, selectedTab, tabs]);
|
|
63
78
|
//#endregion Tabs
|
|
64
79
|
//#region Table
|
|
65
|
-
var NoDataComponent = react_1.useMemo(function () {
|
|
66
|
-
return hasSearched ? (react_2.default.createElement("p", { className: "pt4 tc" },
|
|
67
|
-
"No ",
|
|
68
|
-
entityName.toLocaleLowerCase(),
|
|
69
|
-
" matched your search.",
|
|
70
|
-
canQueryAll && !queryAll && (react_2.default.createElement(react_2.default.Fragment, null,
|
|
71
|
-
" You might want to try again with \"Search All ",
|
|
72
|
-
entityName,
|
|
73
|
-
"\" checked.")))) : (react_2.default.createElement("p", { className: "pt4 tc" },
|
|
74
|
-
"No ",
|
|
75
|
-
getTabName(selectedTab).toLowerCase(),
|
|
76
|
-
" ",
|
|
77
|
-
entityName.toLocaleLowerCase(),
|
|
78
|
-
' ',
|
|
79
|
-
isFiltered ? 'matched your search' : 'found',
|
|
80
|
-
"."));
|
|
81
|
-
}, [canQueryAll, entityName, getTabName, hasSearched, isFiltered, queryAll, selectedTab]);
|
|
80
|
+
var NoDataComponent = react_1.useMemo(function () { return (react_2.default.createElement(ManageTableNoDataComponent_1.ManageTableNoDataComponent, __assign({}, { canQueryAll: canQueryAll, entityName: entityName, getTabName: getTabName, hasSearched: hasSearched, isFiltered: isFiltered, queryAll: queryAll, selectedTab: selectedTab }))); }, [canQueryAll, entityName, getTabName, hasSearched, isFiltered, queryAll, selectedTab]);
|
|
82
81
|
var NoDataComponentCallback = react_1.useCallback(function () { return NoDataComponent; }, [NoDataComponent]);
|
|
83
82
|
var Table = react_1.useMemo(function () {
|
|
84
|
-
|
|
83
|
+
// show pagination if there are more rows than the default page size
|
|
85
84
|
var showPagination = !!data && data.length > table_1.TABLE_DEFAULT_PAGE_SIZE;
|
|
86
85
|
// if pagination is not enabled, or page is not set, ensure page is 0, the first page
|
|
87
86
|
var pageForTab = showPagination && pageByTab && selectedTab ? pageByTab[selectedTab] : 0;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
var pageSizeOptions = table_1.TABLE_PAGE_SIZE_OPTIONS.filter(function (s) { return !(data === null || data === void 0 ? void 0 : data.length) || s <= (data === null || data === void 0 ? void 0 : data.length); });
|
|
91
|
-
return (react_2.default.createElement(react_table_1.default, { "aria-describedby": "search-results-label", className: "manage-table -striped cb" + ((data === null || data === void 0 ? void 0 : data.length) === 1 ? ' single-row-action-button' : ''), data: data, showPagination: showPagination, showPaginationTop: true, sorted: sortingRules, pageSize: currentPageSize, page: pageForTab, pageSizeOptions: pageSizeOptions, columns: columns, onSortedChange: setSortingRules, onPageSizeChange: setPageSize, onPageChange: setPage, NoDataComponent: NoDataComponentCallback }));
|
|
87
|
+
var pageSizeOptions = table_2.getPageSizeOptions(data === null || data === void 0 ? void 0 : data.length);
|
|
88
|
+
return (react_2.default.createElement(react_table_1.default, { "aria-describedby": "search-results-label", className: "manage-table -striped cb" + ((data === null || data === void 0 ? void 0 : data.length) === 1 ? ' single-row-action-button' : ''), data: data, showPagination: showPagination, showPaginationTop: true, sorted: sortingRules, pageSize: pageSize, page: pageForTab, pageSizeOptions: pageSizeOptions, minRows: 0, columns: columns, onSortedChange: setSortingRules, onPageSizeChange: setPageSize, onPageChange: setPage, NextComponent: PaginationNextButton_1.PaginationNextButton, PreviousComponent: PaginationPreviousButton_1.PaginationPreviousButton, NoDataComponent: NoDataComponentCallback }));
|
|
92
89
|
}, [
|
|
93
90
|
NoDataComponentCallback,
|
|
94
91
|
columns,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
export interface ManageTableNoDataComponentProps {
|
|
3
|
+
entityName: string;
|
|
4
|
+
selectedTab?: number;
|
|
5
|
+
getTabName: (tab?: number) => string;
|
|
6
|
+
queryAll?: boolean;
|
|
7
|
+
canQueryAll?: boolean;
|
|
8
|
+
isFiltered?: boolean;
|
|
9
|
+
hasSearched?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const ManageTableNoDataComponent: FunctionComponent<ManageTableNoDataComponentProps>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ManageTableNoDataComponent = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var ManageTableNoDataComponent = function (_a) {
|
|
9
|
+
var entityName = _a.entityName, selectedTab = _a.selectedTab, getTabName = _a.getTabName, queryAll = _a.queryAll, canQueryAll = _a.canQueryAll, isFiltered = _a.isFiltered, hasSearched = _a.hasSearched;
|
|
10
|
+
return (react_1.default.createElement("p", { className: "pt4 tc" }, hasSearched ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
11
|
+
"No ",
|
|
12
|
+
entityName.toLocaleLowerCase(),
|
|
13
|
+
" matched your search.",
|
|
14
|
+
canQueryAll && !queryAll && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
15
|
+
" You might want to try again with \"Search All ",
|
|
16
|
+
entityName,
|
|
17
|
+
"\" checked.")))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
18
|
+
"No ",
|
|
19
|
+
getTabName(selectedTab).toLowerCase(),
|
|
20
|
+
" ",
|
|
21
|
+
entityName.toLocaleLowerCase(),
|
|
22
|
+
' ',
|
|
23
|
+
isFiltered ? 'matched your search' : 'found',
|
|
24
|
+
"."))));
|
|
25
|
+
};
|
|
26
|
+
exports.ManageTableNoDataComponent = ManageTableNoDataComponent;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.PaginationNextButton = void 0;
|
|
18
|
+
var core_1 = require("@material-ui/core");
|
|
19
|
+
var KeyboardArrowRight_1 = __importDefault(require("@material-ui/icons/KeyboardArrowRight"));
|
|
20
|
+
var react_1 = __importDefault(require("react"));
|
|
21
|
+
var PaginationNextButton = function (props) { return (react_1.default.createElement(core_1.Button, __assign({ className: "btn-text color-primary w-100" }, props),
|
|
22
|
+
"Next ",
|
|
23
|
+
react_1.default.createElement(KeyboardArrowRight_1.default, null))); };
|
|
24
|
+
exports.PaginationNextButton = PaginationNextButton;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.PaginationPreviousButton = void 0;
|
|
18
|
+
var core_1 = require("@material-ui/core");
|
|
19
|
+
var KeyboardArrowLeft_1 = __importDefault(require("@material-ui/icons/KeyboardArrowLeft"));
|
|
20
|
+
var react_1 = __importDefault(require("react"));
|
|
21
|
+
var PaginationPreviousButton = function (props) { return (react_1.default.createElement(core_1.Button, __assign({ className: "btn-text color-primary w-100" }, props),
|
|
22
|
+
react_1.default.createElement(KeyboardArrowLeft_1.default, null),
|
|
23
|
+
" Previous")); };
|
|
24
|
+
exports.PaginationPreviousButton = PaginationPreviousButton;
|
|
@@ -9,6 +9,8 @@ export interface SearchControlsProps extends Search, SearchControlsMethods {
|
|
|
9
9
|
handleDateChange?: (dateString: string, date?: Date) => void;
|
|
10
10
|
canReadAnyGlobally?: boolean;
|
|
11
11
|
canReadSome?: boolean;
|
|
12
|
+
/** force Search button to be visible. otherwise only shows when `queryAll` is `true`. */
|
|
13
|
+
showSearchButton?: boolean;
|
|
12
14
|
}
|
|
13
15
|
export declare const SearchControls: FunctionComponent<SearchControlsProps>;
|
|
14
16
|
export {};
|
|
@@ -12,7 +12,7 @@ var react_bootstrap_1 = require("react-bootstrap");
|
|
|
12
12
|
var AlertWithIcon_1 = require("./AlertWithIcon");
|
|
13
13
|
var DateField_1 = require("./Forms/DateField");
|
|
14
14
|
var SearchControls = function (_a) {
|
|
15
|
-
var keywords = _a.keywords, invalidKeywords = _a.invalidKeywords, dateString = _a.dateString, queryAll = _a.queryAll, requiredMessage = _a.requiredMessage, setKeywords = _a.setKeywords, handleKeywordsKeyDown = _a.handleKeywordsKeyDown, handleSearchClick = _a.handleSearchClick, resetSearch = _a.resetSearch, setQueryAll = _a.setQueryAll, keywordPlaceholder = _a.keywordPlaceholder, handleDateChange = _a.handleDateChange, queryAllText = _a.queryAllText, canReadAnyGlobally = _a.canReadAnyGlobally, canReadSome = _a.canReadSome;
|
|
15
|
+
var keywords = _a.keywords, invalidKeywords = _a.invalidKeywords, dateString = _a.dateString, queryAll = _a.queryAll, requiredMessage = _a.requiredMessage, setKeywords = _a.setKeywords, handleKeywordsKeyDown = _a.handleKeywordsKeyDown, handleSearchClick = _a.handleSearchClick, resetSearch = _a.resetSearch, setQueryAll = _a.setQueryAll, keywordPlaceholder = _a.keywordPlaceholder, handleDateChange = _a.handleDateChange, queryAllText = _a.queryAllText, canReadAnyGlobally = _a.canReadAnyGlobally, canReadSome = _a.canReadSome, showSearchButton = _a.showSearchButton;
|
|
16
16
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
17
17
|
!!requiredMessage && (react_1.default.createElement(AlertWithIcon_1.AlertWithIcon, { variant: "danger", className: "mb0", id: "requiredMessageAlert" },
|
|
18
18
|
react_1.default.createElement("p", null, requiredMessage))),
|
|
@@ -25,7 +25,7 @@ var SearchControls = function (_a) {
|
|
|
25
25
|
react_1.default.createElement(DateField_1.DateField, { id: "date", onChange: handleDateChange, label: "Date", "aria-label": "Active date", className: "fl-ns mw5-ns mr3-ns mb3 mb0-ns w-100-lt-xs date-align", value: dateString }))),
|
|
26
26
|
react_1.default.createElement("div", { className: "fl-ns mt3-ns pt3-ns w-100-lt-xs" },
|
|
27
27
|
canReadAnyGlobally && !!setQueryAll && (react_1.default.createElement(react_bootstrap_1.FormCheck, { name: "queryAll", id: "queryAll", checked: queryAll, disabled: canReadAnyGlobally && !canReadSome, onChange: setQueryAll, className: "fl-ns f6 mr2-ns mb3 mt2 w-100-lt-xs", label: react_1.default.createElement("span", { className: "b black" }, queryAllText || 'Search All') })),
|
|
28
|
-
canReadAnyGlobally && queryAll && (react_1.default.createElement(Button_1.default, { className: "btn-primary fr-ns ml2-ns mb3 w-100-lt-xs search-button", onClick: handleSearchClick, color: "primary", disabled: !keywords || keywords.length < 3 || !!invalidKeywords },
|
|
28
|
+
(showSearchButton || (canReadAnyGlobally && queryAll)) && (react_1.default.createElement(Button_1.default, { className: "btn-primary fr-ns ml2-ns mb3 w-100-lt-xs search-button", onClick: handleSearchClick, color: "primary", disabled: (!keywords || keywords.length < 3 || !!invalidKeywords) && !dateString },
|
|
29
29
|
react_1.default.createElement(Search_1.default, null),
|
|
30
30
|
"Search")),
|
|
31
31
|
react_1.default.createElement(Button_1.default, { className: "btn-text color-pink fr-ns mb3 w-100-lt-xs", onClick: resetSearch },
|
|
@@ -107,5 +107,5 @@ export declare class UserRoles extends Component<UserRolesProps, UserRolesState>
|
|
|
107
107
|
render(): JSX.Element;
|
|
108
108
|
}
|
|
109
109
|
export declare const mapStateToProps: (state: BaseReduxState, ownProps: UserRolesOwnProps) => UserRolesReduxProps;
|
|
110
|
-
declare const _default: import("react-redux").ConnectedComponent<typeof UserRoles, Pick<React.ClassAttributes<UserRoles> & UserRolesProps, "ref" | "queryParams" | "modelName" | "externalProviders" | "model" | "key" | "readOnly" | "guid" | "entityName" | "load" | "pathParams" | "modelStatus" | "disableAutoLoad" | "modelArray" | "stopPeriodicLoad" | "create" | "update" | "delete" | "previousModelStatus" | "fetchingId" | "textForRole" | "defaultRole" | "roleDescriptions" | "renderAddDescription" | "isUpdateDisabled" | "isDeleteDisabled" | "allowMultipleRoles" | "requiredRole" | "isAddDisabled" | "modifyUserRoleActivityName" | "deleteOwnUserRoleActivityName" | "addRoleExcludeList" | "entity" | "filterUsers" | "onAdd" | "onUpdate" | "onRemove" | "renderTableDescription" | "lowercaseTextForRole" | "singularArticleForRole"> & UserRolesOwnProps>;
|
|
110
|
+
declare const _default: import("react-redux").ConnectedComponent<typeof UserRoles, Pick<React.ClassAttributes<UserRoles> & UserRolesProps, "ref" | "queryParams" | "modelName" | "externalProviders" | "model" | "key" | "readOnly" | "guid" | "entityName" | "load" | "pathParams" | "modelStatus" | "disableAutoLoad" | "disableAutoLoadOnParamsChange" | "modelArray" | "stopPeriodicLoad" | "create" | "update" | "delete" | "previousModelStatus" | "fetchingId" | "textForRole" | "defaultRole" | "roleDescriptions" | "renderAddDescription" | "isUpdateDisabled" | "isDeleteDisabled" | "allowMultipleRoles" | "requiredRole" | "isAddDisabled" | "modifyUserRoleActivityName" | "deleteOwnUserRoleActivityName" | "addRoleExcludeList" | "entity" | "filterUsers" | "onAdd" | "onUpdate" | "onRemove" | "renderTableDescription" | "lowercaseTextForRole" | "singularArticleForRole"> & UserRolesOwnProps>;
|
|
111
111
|
export default _default;
|
|
@@ -62,6 +62,39 @@ th,
|
|
|
62
62
|
* react table
|
|
63
63
|
*/
|
|
64
64
|
|
|
65
|
+
.table-container {
|
|
66
|
+
width: 100%;
|
|
67
|
+
overflow-x: auto;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.table-search-container {
|
|
71
|
+
padding: 0 !important;
|
|
72
|
+
text-align: left;
|
|
73
|
+
background: white;
|
|
74
|
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
|
75
|
+
border-radius: 3px;
|
|
76
|
+
width: 100%;
|
|
77
|
+
|
|
78
|
+
& .MuiSvgIcon-root {
|
|
79
|
+
margin-top: 0.55rem;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
& .table-search-input {
|
|
83
|
+
text-align: left;
|
|
84
|
+
outline: none !important;
|
|
85
|
+
border: none !important;
|
|
86
|
+
width: 100%;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
& input[type=search] {
|
|
90
|
+
-webkit-appearance: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
& input[type=search]::-webkit-search-cancel-button {
|
|
94
|
+
-webkit-appearance: searchfield-cancel-button;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
65
98
|
.ReactTable {
|
|
66
99
|
& .rt-thead .rt-tr {
|
|
67
100
|
background-color: var(--color-off-white);
|
|
@@ -88,10 +121,81 @@ th,
|
|
|
88
121
|
overflow: visible;
|
|
89
122
|
}
|
|
90
123
|
|
|
91
|
-
&
|
|
92
|
-
|
|
93
|
-
background-color: var(--color-
|
|
94
|
-
|
|
124
|
+
& .pagination-top,
|
|
125
|
+
& .pagination-bottom {
|
|
126
|
+
background-color: var(--color-off-white);
|
|
127
|
+
|
|
128
|
+
& .-pagination {
|
|
129
|
+
padding: 0.5rem 0.6rem;
|
|
130
|
+
border-top: none;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
& .pagination-top .-pagination {
|
|
135
|
+
border-bottom: 1px solid var(--color-light-grey);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
& .pagination-bottom .-pagination {
|
|
139
|
+
border-top: 1px solid var(--color-light-grey);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
& .-pagination .-previous,
|
|
143
|
+
& .-pagination .-next {
|
|
144
|
+
& .MuiButton-text {
|
|
145
|
+
background-color: var(--color-white);
|
|
146
|
+
border: 1px solid var(--color-light-grey);
|
|
147
|
+
|
|
148
|
+
&[disabled] {
|
|
149
|
+
background-color: var(--color-light-grey);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
& .MuiButton-label .MuiSvgIcon-root {
|
|
153
|
+
margin: 0;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* duplicate .form-control styles */
|
|
159
|
+
& .-pagination input,
|
|
160
|
+
.-pagination select {
|
|
161
|
+
display: block;
|
|
162
|
+
width: 100%;
|
|
163
|
+
height: calc(1.5em + 0.75rem + 2px);
|
|
164
|
+
font-size: 1rem;
|
|
165
|
+
font-weight: 400;
|
|
166
|
+
line-height: 1.5;
|
|
167
|
+
color: #495057;
|
|
168
|
+
background-color: #fff;
|
|
169
|
+
background-clip: padding-box;
|
|
170
|
+
border: 1px solid #ced4da;
|
|
171
|
+
border-radius: 0.25rem;
|
|
172
|
+
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
173
|
+
font-family: var(--text-font-stack);
|
|
174
|
+
padding: 0.5rem;
|
|
175
|
+
border-color: var(--color-light-grey);
|
|
176
|
+
box-shadow: none;
|
|
177
|
+
|
|
178
|
+
&:focus {
|
|
179
|
+
border-color: #80bdff;
|
|
180
|
+
outline: 0;
|
|
181
|
+
-webkit-box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
|
|
182
|
+
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&::placeholder {
|
|
186
|
+
color: #6c757d;
|
|
187
|
+
opacity: 1;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
& .-pagination .-pageSizeOptions.select {
|
|
192
|
+
padding: 0.375rem 0.75rem;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
&.single-row-action-button {
|
|
196
|
+
& .rt-tbody {
|
|
197
|
+
padding-bottom: 108px;
|
|
198
|
+
}
|
|
95
199
|
}
|
|
96
200
|
|
|
97
201
|
& .rt-noData {
|
|
@@ -113,39 +217,6 @@ th,
|
|
|
113
217
|
}
|
|
114
218
|
}
|
|
115
219
|
|
|
116
|
-
.table-container {
|
|
117
|
-
width: 100%;
|
|
118
|
-
overflow-x: auto;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.table-search-container {
|
|
122
|
-
padding: 0 !important;
|
|
123
|
-
text-align: left;
|
|
124
|
-
background: white;
|
|
125
|
-
border: 1px solid rgba(0, 0, 0, 0.1);
|
|
126
|
-
border-radius: 3px;
|
|
127
|
-
width: 100%;
|
|
128
|
-
|
|
129
|
-
& .MuiSvgIcon-root {
|
|
130
|
-
margin-top: 0.55rem;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
& .table-search-input {
|
|
134
|
-
text-align: left;
|
|
135
|
-
outline: none !important;
|
|
136
|
-
border: none !important;
|
|
137
|
-
width: 100%;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
& input[type=search] {
|
|
141
|
-
-webkit-appearance: none;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
& input[type=search]::-webkit-search-cancel-button {
|
|
145
|
-
-webkit-appearance: searchfield-cancel-button;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
220
|
.striped-table tr:nth-child(even) {
|
|
150
221
|
background-color: var(--color-light-blue) !important;
|
|
151
222
|
}
|
|
@@ -5,7 +5,7 @@ var react_1 = require("react");
|
|
|
5
5
|
var collection_1 = require("../utils/collection");
|
|
6
6
|
var useCollectionConfiguration_1 = require("./useCollectionConfiguration");
|
|
7
7
|
function useCollection(props) {
|
|
8
|
-
var modelName = props.modelName;
|
|
8
|
+
var modelName = props.modelName, disableAutoLoadOnParamsChange = props.disableAutoLoadOnParamsChange;
|
|
9
9
|
// state, route, and redux
|
|
10
10
|
var config = useCollectionConfiguration_1.useCollectionConfiguration(props, collection_1.selectCollectionFromState);
|
|
11
11
|
var previousModelName = config.previousModelName, guid = config.guid, model = config.model, pathParams = config.pathParams, previousPathParams = config.previousPathParams, queryParams = config.queryParams, previousQueryParams = config.previousQueryParams, fetchingId = config.fetchingId, modelStatus = config.modelStatus, previousModelStatus = config.previousModelStatus, isInitialized = config.isInitialized, setIsInitialized = config.setIsInitialized, methodConfig = config.methodConfig, modelArray = config.modelArray;
|
|
@@ -33,10 +33,21 @@ function useCollection(props) {
|
|
|
33
33
|
setIsInitialized(true);
|
|
34
34
|
}
|
|
35
35
|
}, [isInitialized, load, methodConfig, model, setIsInitialized]);
|
|
36
|
-
// re-load if `pathParams` or `queryParams` change
|
|
36
|
+
// re-load if `pathParams` or `queryParams` change, unless `disableAutoLoadOnParamsChange` is true
|
|
37
37
|
react_1.useEffect(function () {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if (!disableAutoLoadOnParamsChange) {
|
|
39
|
+
collection_1.handleCollectionParamsChange(modelName, previousModelName, pathParams, previousPathParams, queryParams, previousQueryParams, load);
|
|
40
|
+
}
|
|
41
|
+
}, [
|
|
42
|
+
disableAutoLoadOnParamsChange,
|
|
43
|
+
load,
|
|
44
|
+
modelName,
|
|
45
|
+
pathParams,
|
|
46
|
+
previousModelName,
|
|
47
|
+
previousPathParams,
|
|
48
|
+
previousQueryParams,
|
|
49
|
+
queryParams
|
|
50
|
+
]);
|
|
40
51
|
// cleanup on unmount
|
|
41
52
|
react_1.useEffect(function () {
|
|
42
53
|
return function cleanup() {
|
|
@@ -5,7 +5,7 @@ var react_1 = require("react");
|
|
|
5
5
|
var collection_1 = require("../utils/collection");
|
|
6
6
|
var useCollectionConfiguration_1 = require("./useCollectionConfiguration");
|
|
7
7
|
function useCollectionItem(props) {
|
|
8
|
-
var modelName = props.modelName;
|
|
8
|
+
var modelName = props.modelName, disableAutoLoadOnParamsChange = props.disableAutoLoadOnParamsChange;
|
|
9
9
|
// state, route, and redux
|
|
10
10
|
var config = useCollectionConfiguration_1.useCollectionConfiguration(props, collection_1.selectCollectionItemFromState);
|
|
11
11
|
var previousModelName = config.previousModelName, guid = config.guid, model = config.model, pathParams = config.pathParams, previousPathParams = config.previousPathParams, queryParams = config.queryParams, previousQueryParams = config.previousQueryParams, modelStatus = config.modelStatus, previousModelStatus = config.previousModelStatus, isInitialized = config.isInitialized, setIsInitialized = config.setIsInitialized, methodConfig = config.methodConfig, modelMinusRelations = config.modelMinusRelations;
|
|
@@ -34,10 +34,21 @@ function useCollectionItem(props) {
|
|
|
34
34
|
setIsInitialized(true);
|
|
35
35
|
}
|
|
36
36
|
}, [isInitialized, load, methodConfig, model, setIsInitialized]);
|
|
37
|
-
// re-load if `pathParams` or `queryParams` change
|
|
37
|
+
// re-load if `pathParams` or `queryParams` change, unless `disableAutoLoadOnParamsChange` is true
|
|
38
38
|
react_1.useEffect(function () {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
if (!disableAutoLoadOnParamsChange) {
|
|
40
|
+
collection_1.handleCollectionItemParamsChange(modelName, previousModelName, pathParams, previousPathParams, queryParams, previousQueryParams, load);
|
|
41
|
+
}
|
|
42
|
+
}, [
|
|
43
|
+
disableAutoLoadOnParamsChange,
|
|
44
|
+
load,
|
|
45
|
+
modelName,
|
|
46
|
+
pathParams,
|
|
47
|
+
previousModelName,
|
|
48
|
+
previousPathParams,
|
|
49
|
+
previousQueryParams,
|
|
50
|
+
queryParams
|
|
51
|
+
]);
|
|
41
52
|
return {
|
|
42
53
|
guid: guid,
|
|
43
54
|
model: model,
|
|
@@ -14,8 +14,10 @@ export interface CollectionCommonProps {
|
|
|
14
14
|
pathParams: string[];
|
|
15
15
|
/** Custom queryParams for use in all requests. */
|
|
16
16
|
queryParams?: Dictionary<string>;
|
|
17
|
-
/** Whether
|
|
17
|
+
/** Whether to disable triggering `load()` after mounting. Default is `false`. */
|
|
18
18
|
disableAutoLoad?: boolean;
|
|
19
|
+
/** Whether to disable triggering `load()` when `pathParams` or `queryParams` change. Default is `false`. */
|
|
20
|
+
disableAutoLoadOnParamsChange?: boolean;
|
|
19
21
|
}
|
|
20
22
|
/** See `CollectionSelectorMethod` */
|
|
21
23
|
export interface CollectionSelectorMethodParams {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const getManageTableTabName: (selectedTab?: number | undefined) => "" | "Available" | "Deleted";
|
|
2
|
+
export declare const getGroupManageTableTabName: (selectedTab?: number | undefined) => "" | "Deleted" | "Current" | "Past";
|
|
3
|
+
/**
|
|
4
|
+
* return page size options that are less than or equal to the total data length,
|
|
5
|
+
* and one that is greater (if it exists) to allow viewing all data on one page.
|
|
6
|
+
* */
|
|
7
|
+
export declare const getPageSizeOptions: (dataLength?: number | undefined) => number[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGroupManageTableTabName = exports.getManageTableTabName = void 0;
|
|
3
|
+
exports.getPageSizeOptions = exports.getGroupManageTableTabName = exports.getManageTableTabName = void 0;
|
|
4
4
|
var table_1 = require("../constants/table");
|
|
5
5
|
var getManageTableTabName = function (selectedTab) {
|
|
6
6
|
switch (selectedTab) {
|
|
@@ -26,3 +26,17 @@ var getGroupManageTableTabName = function (selectedTab) {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
exports.getGroupManageTableTabName = getGroupManageTableTabName;
|
|
29
|
+
/**
|
|
30
|
+
* return page size options that are less than or equal to the total data length,
|
|
31
|
+
* and one that is greater (if it exists) to allow viewing all data on one page.
|
|
32
|
+
* */
|
|
33
|
+
var getPageSizeOptions = function (dataLength) {
|
|
34
|
+
return table_1.TABLE_PAGE_SIZE_OPTIONS.reduce(function (options, option, currentIndex) {
|
|
35
|
+
var prevOption = currentIndex > 0 ? options[currentIndex - 1] : undefined;
|
|
36
|
+
if (!dataLength || option < dataLength || (prevOption && prevOption < dataLength)) {
|
|
37
|
+
options.push(option);
|
|
38
|
+
}
|
|
39
|
+
return options;
|
|
40
|
+
}, []);
|
|
41
|
+
};
|
|
42
|
+
exports.getPageSizeOptions = getPageSizeOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "studiokit-scaffolding-js",
|
|
3
|
-
"version": "5.1.1",
|
|
3
|
+
"version": "5.1.2-next.1.2",
|
|
4
4
|
"description": "Common scaffolding for Studio apps at Purdue",
|
|
5
5
|
"repository": "https://gitlab.com/purdue-informatics/studiokit/studiokit-scaffolding-js",
|
|
6
6
|
"license": "MIT",
|