@kaspernj/api-maker 1.0.423 → 1.0.425

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaspernj/api-maker",
3
- "version": "1.0.423",
3
+ "version": "1.0.425",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "index.js",
@@ -1,4 +1,4 @@
1
- @import "@kaspernj/api-maker/src/super-admin/stylesheets/variables";
1
+ @use "@kaspernj/api-maker/src/super-admin/stylesheets/variables" as *;
2
2
 
3
3
  [data-component="super-admin--layout--header"] {
4
4
  @media (max-width: $sm-to) {
@@ -1,4 +1,4 @@
1
- @import "@kaspernj/api-maker/src/super-admin/stylesheets/variables";
1
+ @use "@kaspernj/api-maker/src/super-admin/stylesheets/variables" as *;
2
2
 
3
3
  [data-component="super-admin--layout--menu"] {
4
4
  position: fixed;
@@ -1,4 +1,4 @@
1
- @import "@kaspernj/api-maker/src/super-admin/stylesheets/variables";
1
+ @use "@kaspernj/api-maker/src/super-admin/stylesheets/variables" as *;
2
2
 
3
3
  [data-component="super-admin--layout"] {
4
4
  width: 100%;
@@ -74,6 +74,8 @@ export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends
74
74
  this.increaseLoading()
75
75
 
76
76
  try {
77
+ if (!this.s.modelClassName) throw new Error("'modelClassName' not set in state")
78
+
77
79
  const result = await Services.current().sendRequest("Models::Associations", {model_class_name: this.s.modelClassName})
78
80
  const {associations, ransackableAttributes, ransackableScopes} = this.parseAssociationData(result)
79
81
 
@@ -96,9 +98,11 @@ export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends
96
98
  }
97
99
 
98
100
  async loadInitialValues() {
101
+ if (!this.s.modelClassName) throw new Error("'modelClassName' not set in state")
102
+
99
103
  let result = await Services.current().sendRequest("Models::Associations", {model_class_name: this.s.modelClassName})
100
104
  let data = this.parseAssociationData(result)
101
- let modelClassName
105
+ let modelClassName = this.s.modelClassName
102
106
  const path = []
103
107
 
104
108
  for (const pathPart of this.props.filter.p) {
@@ -108,6 +112,12 @@ export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends
108
112
 
109
113
  modelClassName = digg(reflection, "modelClassName")
110
114
 
115
+ if (!modelClassName) {
116
+ const pathNames = path.map((pathPart) => pathPart.name()).join(".")
117
+
118
+ throw new Error(`No model class name from ${pathNames}.${reflection.name()}`)
119
+ }
120
+
111
121
  result = await Services.current().sendRequest("Models::Associations", {model_class_name: modelClassName})
112
122
  data = this.parseAssociationData(result)
113
123
 
@@ -201,7 +211,7 @@ export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends
201
211
  )}
202
212
  </View>
203
213
  <View>
204
- {predicates && !this.state.scope &&
214
+ {predicates && !this.s.scope &&
205
215
  <Select
206
216
  className="predicate-select"
207
217
  defaultValue={predicate?.name}
@@ -289,7 +299,6 @@ export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends
289
299
  onAttributeClicked = ({attribute}) => {
290
300
  this.setState({
291
301
  attribute,
292
- predicate: undefined,
293
302
  scope: undefined
294
303
  })
295
304
  }
@@ -317,6 +326,7 @@ export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends
317
326
  onScopeClicked = ({scope}) => {
318
327
  this.setState({
319
328
  attribute: undefined,
329
+ predicate: undefined,
320
330
  scope
321
331
  })
322
332
  }
@@ -29,7 +29,13 @@ export default memo(shapeComponent(class ApiMakerTableFilter extends BaseCompone
29
29
 
30
30
  return (
31
31
  <View style={{alignItems: "center", flexDirection: "row", backgroundColor: "grey", paddingVertical: 10, paddingHorizontal: 6}}>
32
- <Pressable dataSet={{class: "filter-label"}} onPress={this.tt.onFilterPressed}>
32
+ <Pressable
33
+ dataSet={{
34
+ attribute: a,
35
+ class: "filter-label"
36
+ }}
37
+ onPress={this.tt.onFilterPressed}
38
+ >
33
39
  <Text>
34
40
  {p.length > 0 &&
35
41
  `${p.join(".")}.`