@kaspernj/api-maker 1.0.255 → 1.0.257
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}
|
|
@@ -328,8 +329,13 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
328
329
|
const {filterSubmitLabel} = this.props
|
|
329
330
|
const {qParams} = digs(this.shape, "qParams")
|
|
330
331
|
|
|
332
|
+
console.log({qParams})
|
|
333
|
+
|
|
331
334
|
return (
|
|
332
335
|
<form className="live-table--filter-form" onSubmit={this.onFilterFormSubmit} ref={filterFormRef}>
|
|
336
|
+
{"s" in qParams &&
|
|
337
|
+
<input name="s" type="hidden" value={qParams.s} />
|
|
338
|
+
}
|
|
333
339
|
{filterContent({
|
|
334
340
|
onFilterChanged: submitFilter,
|
|
335
341
|
onFilterChangedWithDelay: submitFilterDebounce,
|
|
@@ -404,6 +410,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
404
410
|
{models.map((model) =>
|
|
405
411
|
<ModelRow
|
|
406
412
|
breakPoint={breakPoint}
|
|
413
|
+
cacheKey={model.cacheKey()}
|
|
407
414
|
columnComponent={this.columnComponent()}
|
|
408
415
|
key={model.id()}
|
|
409
416
|
liveTable={this}
|