@kaspernj/api-maker 1.0.286 → 1.0.288

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/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  ]
17
17
  },
18
18
  "name": "@kaspernj/api-maker",
19
- "version": "1.0.286",
19
+ "version": "1.0.288",
20
20
  "type": "module",
21
21
  "description": "",
22
22
  "main": "index.js",
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "@rails/actioncable": ">= 6.1.0",
40
40
  "clone-deep": ">= 4.0.1",
41
- "debounce": ">= 1.2.1",
41
+ "debounce": ">= 2.0.0",
42
42
  "diggerize": ">= 1.0.5",
43
43
  "epic-locks": ">= 1.0.2",
44
44
  "form-data-objectizer": ">= 1.0.0",
@@ -76,6 +76,6 @@
76
76
  "eslint-plugin-react": "^7.23.2",
77
77
  "i18n-on-steroids": "^1.0.7",
78
78
  "jest": "^29.0.1",
79
- "jsdom": "^22.0.0"
79
+ "jsdom": "^23.0.0"
80
80
  }
81
81
  }
@@ -2,7 +2,7 @@ import Card from "./card"
2
2
  import classNames from "classnames"
3
3
  import Collection from "../collection"
4
4
  import CollectionLoader from "../collection-loader"
5
- import {debounce} from "debounce"
5
+ import debounce from "debounce"
6
6
  import {digg, digs} from "diggerize"
7
7
  import instanceOfClassName from "../instance-of-class-name"
8
8
  import ModelRow from "./live-table/model-row"
@@ -39,13 +39,24 @@ export default class CacheKeyGenerator {
39
39
  for (const relationshipType in model.relationships) {
40
40
  this.recordModelType(relationshipType)
41
41
 
42
- for (const anotherModel of model.relationships[relationshipType]) {
43
- if (this.isModelRecorded(relationshipType, anotherModel)) {
42
+ const loadedRelationship = model.relationships[relationshipType]
43
+
44
+ if (Array.isArray(loadedRelationship)) { // has_many
45
+ for (const anotherModel of loadedRelationship) {
46
+ if (this.isModelRecorded(relationshipType, anotherModel)) {
47
+ continue
48
+ }
49
+
50
+ this.recordModel(relationshipType, anotherModel)
51
+ this.fillModels(anotherModel)
52
+ }
53
+ } else if (loadedRelationship) { // belongs_to, has_one
54
+ if (this.isModelRecorded(relationshipType, loadedRelationship)) {
44
55
  continue
45
56
  }
46
57
 
47
- this.recordModel(relationshipType, anotherModel)
48
- this.fillModels(anotherModel)
58
+ this.recordModel(relationshipType, loadedRelationship)
59
+ this.fillModels(loadedRelationship)
49
60
  }
50
61
  }
51
62
 
@@ -1,5 +1,5 @@
1
1
  import Collection from "./collection"
2
- import {debounce} from "debounce"
2
+ import debounce from "debounce"
3
3
  import {digg, digs} from "diggerize"
4
4
  import EventCreated from "./event-created"
5
5
  import EventDestroyed from "./event-destroyed"
@@ -87,6 +87,8 @@ class CollectionLoader extends React.PureComponent {
87
87
  changed = true
88
88
  } else if (prevProps.queryParams[querySName] != this.props.queryParams[querySName]) {
89
89
  changed = true
90
+ } else if (prevProps.collection != this.props.collection) {
91
+ changed = true
90
92
  }
91
93
 
92
94
  if (changed) {
package/src/devise.mjs CHANGED
@@ -12,8 +12,9 @@ export default class ApiMakerDevise {
12
12
  }
13
13
 
14
14
  static current () {
15
- if (!globalThis.currentApiMakerDevise)
16
- globalThis.currentApiMakerDevise = new ApiMakerDevise()
15
+ if (!globalThis.currentApiMakerDevise) {
16
+ globalThis.currentApiMakerDevise = new ApiMakerDevise()
17
+ }
17
18
 
18
19
  return globalThis.currentApiMakerDevise
19
20
  }
@@ -151,7 +151,7 @@ const inputWrapper = (WrapperComponentClass, wrapperOptions = {}) => {
151
151
  label() {
152
152
  if ("label" in this.props) {
153
153
  return this.props.label
154
- } else if (this.props.model) {
154
+ } else if (this.props.attribute && this.props.model) {
155
155
  return this.props.model.modelClass().humanAttributeName(this.props.attribute)
156
156
  }
157
157
  }
@@ -4,7 +4,7 @@ import classNames from "classnames"
4
4
  import Collection from "../collection"
5
5
  import CollectionLoader from "../collection-loader"
6
6
  import columnVisible from "./column-visible.mjs"
7
- import {debounce} from "debounce"
7
+ import debounce from "debounce"
8
8
  import {digg, digs} from "diggerize"
9
9
  import Filters from "./filters"
10
10
  import * as inflection from "inflection"
@@ -1,4 +1,4 @@
1
- import {debounce} from "debounce"
1
+ import debounce from "debounce"
2
2
  import {digg, digs} from "diggerize"
3
3
  import EventCreated from "./event-created"
4
4
  import EventDestroyed from "./event-destroyed"