@kaspernj/api-maker 1.0.292 → 1.0.294
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
|
@@ -5,6 +5,7 @@ import EventCreated from "./event-created"
|
|
|
5
5
|
import EventDestroyed from "./event-destroyed"
|
|
6
6
|
import EventUpdated from "./event-updated"
|
|
7
7
|
import PropTypes from "prop-types"
|
|
8
|
+
import PropTypesExact from "prop-types-exact"
|
|
8
9
|
import React from "react"
|
|
9
10
|
import withQueryParams from "on-location-changed/src/with-query-params"
|
|
10
11
|
|
|
@@ -19,13 +20,14 @@ class CollectionLoader extends React.PureComponent {
|
|
|
19
20
|
select: {}
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
static propTypes = {
|
|
23
|
+
static propTypes = PropTypesExact({
|
|
23
24
|
abilities: PropTypes.object,
|
|
24
25
|
appHistory: PropTypes.object,
|
|
25
26
|
className: PropTypes.string,
|
|
26
27
|
collection: PropTypes.instanceOf(Collection),
|
|
27
28
|
component: PropTypes.object,
|
|
28
29
|
defaultParams: PropTypes.object,
|
|
30
|
+
destroyEnabled: PropTypes.bool.isRequired,
|
|
29
31
|
groupBy: PropTypes.array,
|
|
30
32
|
modelClass: PropTypes.func.isRequired,
|
|
31
33
|
noRecordsAvailableContent: PropTypes.func,
|
|
@@ -34,10 +36,12 @@ class CollectionLoader extends React.PureComponent {
|
|
|
34
36
|
pagination: PropTypes.bool.isRequired,
|
|
35
37
|
paginateContent: PropTypes.func,
|
|
36
38
|
preloads: PropTypes.array.isRequired,
|
|
39
|
+
queryMethod: PropTypes.func,
|
|
37
40
|
queryName: PropTypes.string,
|
|
41
|
+
queryParams: PropTypes.object,
|
|
38
42
|
select: PropTypes.object,
|
|
39
43
|
selectColumns: PropTypes.object
|
|
40
|
-
}
|
|
44
|
+
})
|
|
41
45
|
|
|
42
46
|
shape = digg(this, "props", "component", "shape")
|
|
43
47
|
|
|
@@ -145,7 +149,7 @@ class CollectionLoader extends React.PureComponent {
|
|
|
145
149
|
|
|
146
150
|
loadModels = async () => {
|
|
147
151
|
const {pagination, queryParams} = digs(this.props, "pagination", "queryParams")
|
|
148
|
-
const {abilities, collection, groupBy, modelClass, onModelsLoaded, preloads, select, selectColumns} = this.props
|
|
152
|
+
const {abilities, collection, groupBy, modelClass, onModelsLoaded, preloads, queryMethod, select, selectColumns} = this.props
|
|
149
153
|
const {
|
|
150
154
|
qParams,
|
|
151
155
|
queryPageName,
|
|
@@ -190,7 +194,14 @@ class CollectionLoader extends React.PureComponent {
|
|
|
190
194
|
if (abilities) query = query.abilities(abilities)
|
|
191
195
|
if (selectColumns) query = query.selectColumns(selectColumns)
|
|
192
196
|
|
|
193
|
-
|
|
197
|
+
let result
|
|
198
|
+
|
|
199
|
+
if (queryMethod) {
|
|
200
|
+
result = await queryMethod({query})
|
|
201
|
+
} else {
|
|
202
|
+
result = await query.result()
|
|
203
|
+
}
|
|
204
|
+
|
|
194
205
|
const models = result.models()
|
|
195
206
|
|
|
196
207
|
if (onModelsLoaded) {
|
|
@@ -46,7 +46,7 @@ class SelectCalculator {
|
|
|
46
46
|
|
|
47
47
|
if (!relationship) throw new Error(`No such relationship: ${currentModelClass.modelClassData().name}#${pathPart}`)
|
|
48
48
|
|
|
49
|
-
currentModelClass = modelClassRequire(digg(relationship, "
|
|
49
|
+
currentModelClass = modelClassRequire(digg(relationship, "resource_name"))
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
package/src/table/table.jsx
CHANGED
|
@@ -69,6 +69,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
69
69
|
paginateContent: PropTypes.func,
|
|
70
70
|
paginationComponent: PropTypes.func,
|
|
71
71
|
preloads: PropTypes.array.isRequired,
|
|
72
|
+
queryMethod: PropTypes.func,
|
|
72
73
|
queryName: PropTypes.string,
|
|
73
74
|
select: PropTypes.object,
|
|
74
75
|
selectColumns: PropTypes.object,
|
|
@@ -157,7 +158,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
157
158
|
|
|
158
159
|
render () {
|
|
159
160
|
const {modelClass, noRecordsAvailableContent, noRecordsFoundContent} = digs(this.props, "modelClass", "noRecordsAvailableContent", "noRecordsFoundContent")
|
|
160
|
-
const {collection, currentUser, defaultParams, onModelsLoaded, selectColumns} = this.props
|
|
161
|
+
const {collection, currentUser, defaultParams, onModelsLoaded, queryMethod, selectColumns} = this.props
|
|
161
162
|
const {
|
|
162
163
|
overallCount,
|
|
163
164
|
preload,
|
|
@@ -206,6 +207,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
206
207
|
noRecordsFoundContent={noRecordsFoundContent}
|
|
207
208
|
pagination
|
|
208
209
|
preloads={preload}
|
|
210
|
+
queryMethod={queryMethod}
|
|
209
211
|
select={selectCalculator({table: this})}
|
|
210
212
|
selectColumns={selectColumns}
|
|
211
213
|
/>
|
|
@@ -293,6 +295,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
293
295
|
paginateContent,
|
|
294
296
|
paginationComponent,
|
|
295
297
|
preloads,
|
|
298
|
+
queryMethod,
|
|
296
299
|
queryName,
|
|
297
300
|
select,
|
|
298
301
|
selectColumns,
|
|
@@ -585,7 +588,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
585
588
|
const relationships = digg(currentModelClass.modelClassData(), "relationships")
|
|
586
589
|
const relationship = relationships.find((relationshipInArray) => relationshipInArray.name == inflection.underscore(pathPart))
|
|
587
590
|
|
|
588
|
-
currentModelClass = modelClassRequire(digg(relationship, "
|
|
591
|
+
currentModelClass = modelClassRequire(digg(relationship, "resource_name"))
|
|
589
592
|
}
|
|
590
593
|
}
|
|
591
594
|
|