@kaspernj/api-maker 1.0.254 → 1.0.256
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
package/src/base-model.mjs
CHANGED
|
@@ -33,6 +33,15 @@ export default class BaseModel {
|
|
|
33
33
|
return result
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
static hasAttribute(attributeName) {
|
|
37
|
+
const attributes = digg(this.modelClassData(), "attributes")
|
|
38
|
+
const lowerCaseAttributeName = inflection.underscore(attributeName)
|
|
39
|
+
|
|
40
|
+
if (lowerCaseAttributeName in attributes) return true
|
|
41
|
+
|
|
42
|
+
return false
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
static modelClassData() {
|
|
37
46
|
throw new Error("modelClassData should be overriden by child")
|
|
38
47
|
}
|
package/src/table/model-row.jsx
CHANGED
|
@@ -9,19 +9,20 @@ import PropTypes from "prop-types"
|
|
|
9
9
|
|
|
10
10
|
export default class ApiMakerBootStrapLiveTableModelRow extends React.PureComponent {
|
|
11
11
|
static propTypes = {
|
|
12
|
+
cacheKey: PropTypes.string.isRequired,
|
|
12
13
|
model: PropTypes.object.isRequired,
|
|
13
14
|
liveTable: PropTypes.object.isRequired,
|
|
14
15
|
preparedColumns: PropTypes.array
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
modelCallbackArgs = this._modelCallbackArgs()
|
|
18
|
-
|
|
19
18
|
render() {
|
|
20
|
-
const {model} = digs(this.props, "model")
|
|
19
|
+
const {cacheKey, model} = digs(this.props, "cacheKey", "model")
|
|
21
20
|
const {modelClass} = digs(this.props.liveTable.props, "modelClass")
|
|
22
21
|
const {actionsContent, columnsContent, destroyEnabled, editModelPath, viewModelPath} = digg(this, "props", "liveTable", "props")
|
|
23
22
|
const {columns} = digg(this, "props", "liveTable", "shape")
|
|
24
23
|
|
|
24
|
+
this.modelCallbackArgs = this._modelCallbackArgs() // 'model' can change so this needs to be re-cached for every render
|
|
25
|
+
|
|
25
26
|
let editPath, viewPath
|
|
26
27
|
|
|
27
28
|
if (editModelPath && model.can("edit")) editPath = editModelPath(this.modelCallbackArgs)
|
|
@@ -21,6 +21,13 @@ class SelectCalculator {
|
|
|
21
21
|
if (!select[className].includes(primaryKeyColumnName)) select[className].push(primaryKeyColumnName)
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
// Ensure 'updatedAt' is selected if defined as an attribute, because it is used for cacheKey and updates in the table
|
|
25
|
+
if (modelClass.hasAttribute("updatedAt")) {
|
|
26
|
+
if (!(className in select)) select[className] = []
|
|
27
|
+
if (!select[className].includes("updatedAt")) select[className].push("updatedAt")
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
24
31
|
// Ensure columns used for columns are loaded
|
|
25
32
|
for (const preparedColumn of preparedColumns) {
|
|
26
33
|
const {column} = digs(preparedColumn, "column")
|
package/src/table/table.jsx
CHANGED
|
@@ -137,7 +137,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
137
137
|
|
|
138
138
|
render () {
|
|
139
139
|
const {modelClass, noRecordsAvailableContent, noRecordsFoundContent} = digs(this.props, "modelClass", "noRecordsAvailableContent", "noRecordsFoundContent")
|
|
140
|
-
const {collection, defaultParams, selectColumns} = this.props
|
|
140
|
+
const {collection, defaultParams, onModelsLoaded, selectColumns} = this.props
|
|
141
141
|
const {
|
|
142
142
|
overallCount,
|
|
143
143
|
preload,
|
|
@@ -174,6 +174,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
174
174
|
collection={collection}
|
|
175
175
|
component={this}
|
|
176
176
|
modelClass={modelClass}
|
|
177
|
+
onModelsLoaded={onModelsLoaded}
|
|
177
178
|
noRecordsAvailableContent={noRecordsAvailableContent}
|
|
178
179
|
noRecordsFoundContent={noRecordsFoundContent}
|
|
179
180
|
preloads={preload}
|
|
@@ -364,6 +365,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
364
365
|
|
|
365
366
|
tableControls() {
|
|
366
367
|
const {controls} = this.props
|
|
368
|
+
const {models, qParams, query, result} = digs(this.shape, "models", "qParams", "query", "result")
|
|
367
369
|
|
|
368
370
|
return (
|
|
369
371
|
<>
|
|
@@ -403,6 +405,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
403
405
|
{models.map((model) =>
|
|
404
406
|
<ModelRow
|
|
405
407
|
breakPoint={breakPoint}
|
|
408
|
+
cacheKey={model.cacheKey()}
|
|
406
409
|
columnComponent={this.columnComponent()}
|
|
407
410
|
key={model.id()}
|
|
408
411
|
liveTable={this}
|