studiokit-scaffolding-js 4.5.1-next.1.3 → 4.5.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.
@@ -61,15 +61,14 @@ export declare const configureActivityRequiredComponent: <TOwnProps extends {}>(
61
61
  };
62
62
  /**
63
63
  * Return `mapStateToProps` function. Add a `hasAccess` boolean property to the component's props
64
- * checking whether the user has the passed `requiredActivity`
64
+ * checking whether the user has the passed `requiredActivity`.
65
65
  *
66
- * @param {function} accessPredicate A predicate accepting a required activity and an optional entity and/or
67
- * userInfo object
68
- * @param {string} requiredActivity The required activity which is passed to the predicate for evaluation
69
- * @param {string} modelsProperty The property used to locate the entity or entities needed for entity-level
70
- * activity grants
66
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
67
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
68
+ * @param modelsProperty (Optional) The property used to locate the entity or entities needed for entity-level activity grants
69
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
71
70
  */
72
- export declare const configureMapStateToProps: <TOwnProps extends {}>(accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, modelsProperty?: string | undefined, redirectPredicate?: ((options: ActivityOptions) => string | undefined) | undefined) => (state: BaseReduxState, ownProps?: TOwnProps | undefined) => ActivityRequiredStateProps;
71
+ export declare const configureMapStateToProps: <TOwnProps extends {}>(accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, modelsProperty?: string | undefined, redirectPath?: string | ((options: ActivityOptions) => string | undefined) | undefined) => (state: BaseReduxState, ownProps?: TOwnProps | undefined) => ActivityRequiredStateProps;
73
72
  /**
74
73
  * This HOC ensures that the wrapped component is only rendered if the predicate provided is satisfied.
75
74
  *
@@ -79,15 +78,14 @@ export declare const configureMapStateToProps: <TOwnProps extends {}>(accessPred
79
78
  * If a lambda is passed as the predicate, it is passed (but may or may not opt to utilize) the `requiredActivity`
80
79
  * parameter. It can be ignored if not needed by the lambda.
81
80
  *
82
- * @param {Component} WrappedComponent The component which requires activity/activities in order to render
83
- * @param {function} accessPredicate A predicate accepting a required activity and an optional entity and/or
84
- * userInfo object
85
- * @param {string} requiredActivity The required activity which is passed to the predicate for evaluation
86
- *
81
+ * @param WrappedComponent The component which requires activity/activities in order to render
82
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
83
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
84
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
87
85
  */
88
- export default function activityRequiredComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps>, accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, redirectPredicate?: (options: ActivityOptions) => string | undefined): ComponentClass<TOwnProps>;
86
+ export default function activityRequiredComponent<TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps>, accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, redirectPath?: string | ((options: ActivityOptions) => string | undefined) | undefined): ComponentClass<TOwnProps>;
89
87
  /**
90
- * This HOC ensures that the wrapped component is rendered iff the predicate provided is satisfied.
88
+ * This HOC ensures that the wrapped component is rendered if the predicate provided is satisfied.
91
89
  *
92
90
  * Typically this component is used by passing one of the functions in utils/activities as the
93
91
  * `accessPredicate` and a constant from "constants/activities" as the `requiredActivity`.
@@ -95,12 +93,10 @@ export default function activityRequiredComponent<TOwnProps extends {}>(WrappedC
95
93
  * If a lambda is passed as the predicate, it is passed (but may or may not opt to utilize) the `requiredActivity`
96
94
  * and `modelsProperty` parameters. They can be ignored if not needed by the lambda.
97
95
  *
98
- * @param {Component} WrappedComponent The component which requires activity/activities in order to render
99
- * @param {function} accessPredicate A predicate accepting a required activity and an optional entity and/or
100
- * userInfo object
101
- * @param {string} requiredActivity The required activity which is passed to the predicate for evaluation
102
- * @param {string} modelsProperty The property used to locate the entity or entities needed for entity-level
103
- * activity grants
104
- *
96
+ * @param WrappedComponent The component which requires activity/activities in order to render
97
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
98
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
99
+ * @param modelsProperty The property used to locate the entity or entities needed for entity-level activity grants
100
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
105
101
  */
106
- export default function activityRequiredComponent<TOwnProps extends {}, TPropName extends string>(WrappedComponent: ComponentType<TOwnProps>, accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, modelsProperty: TPropName, redirectPredicate?: (options: ActivityOptions) => string): ComponentClass<TOwnProps & OptionalRecord<TPropName, Model>>;
102
+ export default function activityRequiredComponent<TOwnProps extends {}, TPropName extends string>(WrappedComponent: ComponentType<TOwnProps>, accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, modelsProperty: TPropName, redirectPath?: string | ((options: ActivityOptions) => string | undefined) | undefined): ComponentClass<TOwnProps & OptionalRecord<TPropName, Model>>;
@@ -78,26 +78,39 @@ var configureActivityRequiredComponent = function (WrappedComponent) {
78
78
  exports.configureActivityRequiredComponent = configureActivityRequiredComponent;
79
79
  /**
80
80
  * Return `mapStateToProps` function. Add a `hasAccess` boolean property to the component's props
81
- * checking whether the user has the passed `requiredActivity`
81
+ * checking whether the user has the passed `requiredActivity`.
82
82
  *
83
- * @param {function} accessPredicate A predicate accepting a required activity and an optional entity and/or
84
- * userInfo object
85
- * @param {string} requiredActivity The required activity which is passed to the predicate for evaluation
86
- * @param {string} modelsProperty The property used to locate the entity or entities needed for entity-level
87
- * activity grants
83
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
84
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
85
+ * @param modelsProperty (Optional) The property used to locate the entity or entities needed for entity-level activity grants
86
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
88
87
  */
89
- var configureMapStateToProps = function (accessPredicate, requiredActivity, modelsProperty, redirectPredicate) { return function (state, ownProps) {
90
- var _a;
88
+ var configureMapStateToProps = function (accessPredicate, requiredActivity, modelsProperty, redirectPath) { return function (state, ownProps) {
91
89
  var options = baseActivity_1.defaultOptions(state, ownProps, modelsProperty);
92
90
  return {
93
91
  hasAccess: accessPredicate(requiredActivity, options),
94
- redirectPath: redirectPredicate ? (_a = redirectPredicate(options)) !== null && _a !== void 0 ? _a : '/' : '/'
92
+ redirectPath: (typeof redirectPath === 'function' ? redirectPath(options) : redirectPath) || '/'
95
93
  };
96
94
  }; };
97
95
  exports.configureMapStateToProps = configureMapStateToProps;
98
- function activityRequiredComponent(WrappedComponent, accessPredicate, requiredActivity, modelsProperty, redirectPredicate) {
96
+ /**
97
+ * This HOC ensures that the wrapped component is rendered if the predicate provided is satisfied.
98
+ *
99
+ * Typically this component is used by passing one of the functions in utils/activities as the
100
+ * `accessPredicate` and a constant from "constants/activities" as the `requiredActivity`.
101
+ *
102
+ * If a lambda is passed as the predicate, it is passed (but may or may not opt to utilize) the `requiredActivity`
103
+ * and `modelsProperty` parameters. They can be ignored if not needed by the lambda.
104
+ *
105
+ * @param WrappedComponent The component which requires activity/activities in order to render
106
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
107
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
108
+ * @param modelsProperty The property used to locate the entity or entities needed for entity-level activity grants
109
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
110
+ */
111
+ function activityRequiredComponent(WrappedComponent, accessPredicate, requiredActivity, modelsProperty, redirectPath) {
99
112
  var ActivityRequiredComponent = exports.configureActivityRequiredComponent(WrappedComponent);
100
- var mapStateToProps = exports.configureMapStateToProps(accessPredicate, requiredActivity, modelsProperty, redirectPredicate);
113
+ var mapStateToProps = exports.configureMapStateToProps(accessPredicate, requiredActivity, modelsProperty, redirectPath);
101
114
  // @ts-ignore: could not match inferred type from the `connect` HOC
102
115
  return react_redux_1.connect(mapStateToProps)(ActivityRequiredComponent);
103
116
  }
@@ -123,11 +123,11 @@ function configureCollectionComponent(WrappedComponent, LoaderComponent) {
123
123
  collection_1.initializeCollection(model, this.load, this.getCollectionMethodConfig());
124
124
  };
125
125
  CollectionComponent.prototype.componentDidUpdate = function (prevProps) {
126
- var prevModel = prevProps.model, prevPathParams = prevProps.pathParams, prevQueryParams = prevProps.queryParams;
127
- var _a = this.props, model = _a.model, pathParams = _a.pathParams, queryParams = _a.queryParams;
126
+ var prevModel = prevProps.model, prevModelName = prevProps.modelName, prevPathParams = prevProps.pathParams, prevQueryParams = prevProps.queryParams;
127
+ var _a = this.props, model = _a.model, modelName = _a.modelName, pathParams = _a.pathParams, queryParams = _a.queryParams;
128
128
  var fetchingId = this.state.fetchingId;
129
129
  model_1.handleModelFetchFinish(model, prevModel, fetchingId, this.changeModelStatus);
130
- collection_1.handleCollectionParamsChange(pathParams, prevPathParams, queryParams, prevQueryParams, this.load);
130
+ collection_1.handleCollectionParamsChange(modelName, prevModelName, pathParams, prevPathParams, queryParams, prevQueryParams, this.load);
131
131
  };
132
132
  CollectionComponent.prototype.componentWillUnmount = function () {
133
133
  var model = this.props.model;
@@ -125,10 +125,10 @@ function configureCollectionItemComponent(WrappedComponent, LoaderComponent) {
125
125
  collection_1.initializeCollectionItem(model, this.load, this.getCollectionMethodConfig());
126
126
  };
127
127
  CollectionItemComponent.prototype.componentDidUpdate = function (prevProps) {
128
- var prevModel = prevProps.model, prevPathParams = prevProps.pathParams, prevQueryParams = prevProps.queryParams;
128
+ var prevModel = prevProps.model, prevModelName = prevProps.modelName, prevPathParams = prevProps.pathParams, prevQueryParams = prevProps.queryParams;
129
129
  var _a = this.props, modelName = _a.modelName, model = _a.model, pathParams = _a.pathParams, queryParams = _a.queryParams;
130
130
  model_1.handleModelFetchFinish(model, prevModel, undefined, this.setModelStatus);
131
- collection_1.handleCollectionItemParamsChange(modelName, pathParams, prevPathParams, queryParams, prevQueryParams, this.load);
131
+ collection_1.handleCollectionItemParamsChange(modelName, prevModelName, pathParams, prevPathParams, queryParams, prevQueryParams, this.load);
132
132
  };
133
133
  CollectionItemComponent.prototype.render = function () {
134
134
  var _a = this.props, history = _a.history, match = _a.match, location = _a.location, staticContext = _a.staticContext, otherProps = __rest(_a, ["history", "match", "location", "staticContext"]);
@@ -15,15 +15,18 @@ export interface GroupRelatedEntity extends Model {
15
15
  * checking whether the user has the passed `requiredActivity` for the group referenced by
16
16
  * `ownProps.model.groupId`, if any.
17
17
  *
18
- * @param {function} accessPredicate A predicate accepting a required activity and an optional entity and/or
19
- * userInfo object
20
- * @param {string} requiredActivity The required activity which is passed to the predicate for evaluation
18
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
19
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
20
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
21
21
  */
22
- export declare const configureMapStateToProps: <TOwnProps extends CollectionItemComponentWrappedProps<GroupRelatedEntity>>(accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, redirectPredicate?: ((options: ActivityOptions) => string | undefined) | undefined) => (state: BaseReduxState, ownProps?: TOwnProps | undefined) => ActivityRequiredStateProps;
22
+ export declare const configureMapStateToProps: <TOwnProps extends CollectionItemComponentWrappedProps<GroupRelatedEntity>>(accessPredicate: (requiredActivity: string, options: ActivityOptions) => boolean, requiredActivity: string, redirectPath?: string | ((options: ActivityOptions) => string | undefined) | undefined) => (state: BaseReduxState, ownProps?: TOwnProps | undefined) => ActivityRequiredStateProps;
23
23
  /**
24
24
  * This HOC ensures that the wrapped component is only rendered if the group referenced by
25
25
  * `props.model.groupId`, if any, satisfies the `accessPredicate` for the `requiredActivity`.
26
26
  *
27
- * @see ActivityRequiredComponent
27
+ * @param WrappedComponent The component which requires activity/activities in order to render
28
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
29
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
30
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
28
31
  */
29
- export default function groupActivityRequiredComponent<TOwnProps extends CollectionItemComponentWrappedProps<GroupRelatedEntity>>(WrappedComponent: ComponentType<TOwnProps>, accessPredicate: (requiredActivity: string, options: any) => boolean, requiredActivity: string, redirectPredicate?: (options: ActivityOptions) => string | undefined): ComponentClass<TOwnProps>;
32
+ export default function groupActivityRequiredComponent<TOwnProps extends CollectionItemComponentWrappedProps<GroupRelatedEntity>>(WrappedComponent: ComponentType<TOwnProps>, accessPredicate: (requiredActivity: string, options: any) => boolean, requiredActivity: string, redirectPath?: string | undefined | ((options: ActivityOptions) => string | undefined)): ComponentClass<TOwnProps>;
@@ -20,19 +20,18 @@ var ActivityRequiredComponent_1 = require("./ActivityRequiredComponent");
20
20
  * checking whether the user has the passed `requiredActivity` for the group referenced by
21
21
  * `ownProps.model.groupId`, if any.
22
22
  *
23
- * @param {function} accessPredicate A predicate accepting a required activity and an optional entity and/or
24
- * userInfo object
25
- * @param {string} requiredActivity The required activity which is passed to the predicate for evaluation
23
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
24
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
25
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
26
26
  */
27
- var configureMapStateToProps = function (accessPredicate, requiredActivity, redirectPredicate) { return function (state, ownProps) {
28
- var _a;
27
+ var configureMapStateToProps = function (accessPredicate, requiredActivity, redirectPath) { return function (state, ownProps) {
29
28
  var entity = ownProps && ownProps.model && state.models && state.models.groups
30
29
  ? state.models.groups[ownProps.model.groupId]
31
30
  : undefined;
32
31
  var options = __assign(__assign({}, baseActivity_1.defaultOptions(state, ownProps)), { entity: entity });
33
32
  return {
34
33
  hasAccess: accessPredicate(requiredActivity, options),
35
- redirectPath: redirectPredicate ? (_a = redirectPredicate(options)) !== null && _a !== void 0 ? _a : '/' : '/'
34
+ redirectPath: (typeof redirectPath === 'function' ? redirectPath(options) : redirectPath) || '/'
36
35
  };
37
36
  }; };
38
37
  exports.configureMapStateToProps = configureMapStateToProps;
@@ -40,11 +39,14 @@ exports.configureMapStateToProps = configureMapStateToProps;
40
39
  * This HOC ensures that the wrapped component is only rendered if the group referenced by
41
40
  * `props.model.groupId`, if any, satisfies the `accessPredicate` for the `requiredActivity`.
42
41
  *
43
- * @see ActivityRequiredComponent
42
+ * @param WrappedComponent The component which requires activity/activities in order to render
43
+ * @param accessPredicate A predicate accepting a required activity and an optional entity and/or userInfo object
44
+ * @param requiredActivity The required activity which is passed to the predicate for evaluation
45
+ * @param redirectPath (Optional) A string or function that provides the redirect path for when `accessPredicate` is false. Defaults to '/'.
44
46
  */
45
- function groupActivityRequiredComponent(WrappedComponent, accessPredicate, requiredActivity, redirectPredicate) {
47
+ function groupActivityRequiredComponent(WrappedComponent, accessPredicate, requiredActivity, redirectPath) {
46
48
  var ActivityRequiredComponent = ActivityRequiredComponent_1.configureActivityRequiredComponent(WrappedComponent);
47
- var mapStateToProps = exports.configureMapStateToProps(accessPredicate, requiredActivity, redirectPredicate);
49
+ var mapStateToProps = exports.configureMapStateToProps(accessPredicate, requiredActivity, redirectPath);
48
50
  // @ts-ignore: could not match inferred type from the `connect` HOC
49
51
  return react_redux_1.connect(mapStateToProps)(ActivityRequiredComponent);
50
52
  }
@@ -8,7 +8,7 @@ function useCollection(props) {
8
8
  var modelName = props.modelName;
9
9
  // state, route, and redux
10
10
  var config = useCollectionConfiguration_1.useCollectionConfiguration(props, collection_1.selectCollectionFromState);
11
- var 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;
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;
12
12
  // decorated methods
13
13
  var load = react_1.useCallback(function (params) {
14
14
  if (params === void 0) { params = {}; }
@@ -35,8 +35,8 @@ function useCollection(props) {
35
35
  }, [isInitialized, load, methodConfig, model, setIsInitialized]);
36
36
  // re-load if `pathParams` or `queryParams` change
37
37
  react_1.useEffect(function () {
38
- collection_1.handleCollectionParamsChange(pathParams, previousPathParams, queryParams, previousQueryParams, load);
39
- }, [load, modelName, pathParams, previousPathParams, previousQueryParams, queryParams]);
38
+ collection_1.handleCollectionParamsChange(modelName, previousModelName, pathParams, previousPathParams, queryParams, previousQueryParams, load);
39
+ }, [load, modelName, pathParams, previousModelName, previousPathParams, previousQueryParams, queryParams]);
40
40
  // cleanup on unmount
41
41
  react_1.useEffect(function () {
42
42
  return function cleanup() {
@@ -4,6 +4,7 @@ import { Model, ModelCollection } from 'studiokit-net-js';
4
4
  import { CollectionCommonProps, CollectionCommonState, CollectionMethodConfiguration, CollectionSelectorMethod } from '../types/Collection';
5
5
  /** Configuration returned by `useCollectionConfiguration` for use in `useCollection` and `useCollectionItem` */
6
6
  export interface CollectionConfiguration<TModel extends Model> extends CollectionCommonState {
7
+ previousModelName: string;
7
8
  guid: string;
8
9
  model: TModel | ModelCollection<TModel>;
9
10
  modelArray?: TModel[];
@@ -26,6 +26,7 @@ function useCollectionConfiguration(props, selectorFunction) {
26
26
  var _d = react_redux_1.useSelector(function (state) {
27
27
  return selectorFunction({ guid: guid, modelName: modelName, pathParams: propPathParams, routeMatchParams: routeMatchParams, state: state });
28
28
  }), pathParams = _d.pathParams, model = _d.model, modelArray = _d.modelArray, modelMinusRelations = _d.modelMinusRelations;
29
+ var previousModelName = usePrevious_1.usePrevious(modelName);
29
30
  var previousModel = usePrevious_1.usePrevious(model);
30
31
  var previousPathParams = usePrevious_1.usePrevious(pathParams);
31
32
  var previousQueryParams = usePrevious_1.usePrevious(queryParams);
@@ -47,6 +48,7 @@ function useCollectionConfiguration(props, selectorFunction) {
47
48
  model_1.handleModelFetchFinish(model, previousModel, fetchingId, changeModelStatus);
48
49
  }, [fetchingId, model, previousModel]);
49
50
  return {
51
+ previousModelName: previousModelName,
50
52
  guid: guid,
51
53
  model: model,
52
54
  modelArray: modelArray,
@@ -8,7 +8,7 @@ function useCollectionItem(props) {
8
8
  var modelName = props.modelName;
9
9
  // state, route, and redux
10
10
  var config = useCollectionConfiguration_1.useCollectionConfiguration(props, collection_1.selectCollectionItemFromState);
11
- var 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;
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;
12
12
  // decorated methods
13
13
  var load = react_1.useCallback(function (params) {
14
14
  if (params === void 0) { params = {}; }
@@ -36,8 +36,8 @@ function useCollectionItem(props) {
36
36
  }, [isInitialized, load, methodConfig, model, setIsInitialized]);
37
37
  // re-load if `pathParams` or `queryParams` change
38
38
  react_1.useEffect(function () {
39
- collection_1.handleCollectionItemParamsChange(modelName, pathParams, previousPathParams, queryParams, previousQueryParams, load);
40
- }, [load, modelName, pathParams, previousPathParams, previousQueryParams, queryParams]);
39
+ collection_1.handleCollectionItemParamsChange(modelName, previousModelName, pathParams, previousPathParams, queryParams, previousQueryParams, load);
40
+ }, [load, modelName, pathParams, previousModelName, previousPathParams, previousQueryParams, queryParams]);
41
41
  return {
42
42
  guid: guid,
43
43
  model: model,
@@ -32,11 +32,11 @@ export declare function initializeCollection(model: Model, load: (params?: Colle
32
32
  /**
33
33
  * When `pathParams` or `queryParams` change, call `load`
34
34
  */
35
- export declare function handleCollectionItemParamsChange(modelName: string, pathParams: string[], prevPathParams: string[] | undefined, queryParams: Dictionary<string> | undefined, prevQueryParams: Dictionary<string> | undefined, load: (params?: CollectionItemLoadParams) => void): void;
35
+ export declare function handleCollectionItemParamsChange(modelName: string, prevModelName: string, pathParams: string[], prevPathParams: string[] | undefined, queryParams: Dictionary<string> | undefined, prevQueryParams: Dictionary<string> | undefined, load: (params?: CollectionItemLoadParams) => void): void;
36
36
  /**
37
37
  * When `pathParams` or `queryParams` change, call `load`
38
38
  */
39
- export declare function handleCollectionParamsChange(pathParams: string[], prevPathParams: string[] | undefined, queryParams: Dictionary<string> | undefined, prevQueryParams: Dictionary<string> | undefined, load: (params?: CollectionLoadParams) => void): void;
39
+ export declare function handleCollectionParamsChange(modelName: string, prevModelName: string, pathParams: string[], prevPathParams: string[] | undefined, queryParams: Dictionary<string> | undefined, prevQueryParams: Dictionary<string> | undefined, load: (params?: CollectionLoadParams) => void): void;
40
40
  /**
41
41
  * Delete the guid in the model
42
42
  */
@@ -291,8 +291,9 @@ exports.initializeCollection = initializeCollection;
291
291
  /**
292
292
  * When `pathParams` or `queryParams` change, call `load`
293
293
  */
294
- function handleCollectionItemParamsChange(modelName, pathParams, prevPathParams, queryParams, prevQueryParams, load) {
295
- if ((pathParams.length === route_1.getMinRequiredPathParamsCount(modelName) + 1 && !lodash_1.isEqual(prevPathParams, pathParams)) ||
294
+ function handleCollectionItemParamsChange(modelName, prevModelName, pathParams, prevPathParams, queryParams, prevQueryParams, load) {
295
+ if (modelName !== prevModelName ||
296
+ (pathParams.length === route_1.getMinRequiredPathParamsCount(modelName) + 1 && !lodash_1.isEqual(prevPathParams, pathParams)) ||
296
297
  !lodash_1.isEqual(prevQueryParams, queryParams)) {
297
298
  load({ pathParams: pathParams, queryParams: queryParams });
298
299
  }
@@ -301,8 +302,10 @@ exports.handleCollectionItemParamsChange = handleCollectionItemParamsChange;
301
302
  /**
302
303
  * When `pathParams` or `queryParams` change, call `load`
303
304
  */
304
- function handleCollectionParamsChange(pathParams, prevPathParams, queryParams, prevQueryParams, load) {
305
- if ((pathParams.length > 0 && !lodash_1.isEqual(prevPathParams, pathParams)) || !lodash_1.isEqual(prevQueryParams, queryParams)) {
305
+ function handleCollectionParamsChange(modelName, prevModelName, pathParams, prevPathParams, queryParams, prevQueryParams, load) {
306
+ if (modelName !== prevModelName ||
307
+ (pathParams.length > 0 && !lodash_1.isEqual(prevPathParams, pathParams)) ||
308
+ !lodash_1.isEqual(prevQueryParams, queryParams)) {
306
309
  load({ pathParams: pathParams, queryParams: queryParams });
307
310
  }
308
311
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "studiokit-scaffolding-js",
3
- "version": "4.5.1-next.1.3",
3
+ "version": "4.5.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",