@kaspernj/api-maker 1.0.294 → 1.0.296
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.
|
|
19
|
+
"version": "1.0.296",
|
|
20
20
|
"type": "module",
|
|
21
21
|
"description": "",
|
|
22
22
|
"main": "index.js",
|
|
@@ -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": "^
|
|
79
|
+
"jsdom": "^24.0.0"
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -12,6 +12,7 @@ class ApiMakerBootstrapSortLink extends PureComponent {
|
|
|
12
12
|
static propTypes = {
|
|
13
13
|
attribute: PropTypes.string.isRequired,
|
|
14
14
|
className: PropTypes.string,
|
|
15
|
+
defaultParams: PropTypes.object,
|
|
15
16
|
linkComponent: PropTypes.object,
|
|
16
17
|
onChanged: PropTypes.func,
|
|
17
18
|
query: PropTypes.object.isRequired,
|
|
@@ -51,7 +52,7 @@ class ApiMakerBootstrapSortLink extends PureComponent {
|
|
|
51
52
|
|
|
52
53
|
render () {
|
|
53
54
|
const LinkComponent = this.linkComponent()
|
|
54
|
-
const {attribute, className, linkComponent, onChanged, query, queryParams, title, ...restProps} = this.props
|
|
55
|
+
const {attribute, className, defaultParams, linkComponent, onChanged, query, queryParams, title, ...restProps} = this.props
|
|
55
56
|
|
|
56
57
|
return (
|
|
57
58
|
<>
|
|
@@ -83,10 +84,15 @@ class ApiMakerBootstrapSortLink extends PureComponent {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
qParams() {
|
|
87
|
+
const {defaultParams} = this.props
|
|
86
88
|
const {queryParams} = digs(this.props, "queryParams")
|
|
87
89
|
const {searchKey} = digs(this, "searchKey")
|
|
88
90
|
|
|
89
|
-
if (searchKey in queryParams)
|
|
91
|
+
if (searchKey in queryParams) {
|
|
92
|
+
return JSON.parse(queryParams[searchKey])
|
|
93
|
+
} else if (defaultParams) {
|
|
94
|
+
return {...defaultParams}
|
|
95
|
+
}
|
|
90
96
|
|
|
91
97
|
return {}
|
|
92
98
|
}
|
|
@@ -10,7 +10,7 @@ export default class ApiMakerSuperAdminConfigReader {
|
|
|
10
10
|
modelConfig = require(`super-admin/model-configs/${modelNameCamelized}`).default
|
|
11
11
|
} catch (error) {
|
|
12
12
|
if (error.message.includes("Cannot find module")) {
|
|
13
|
-
console.
|
|
13
|
+
console.debug(`No model-config for ${modelClass.modelClassData().name}`)
|
|
14
14
|
} else {
|
|
15
15
|
throw error
|
|
16
16
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ConfigReader from "./config-reader"
|
|
2
2
|
import {digg, digs} from "diggerize"
|
|
3
|
+
import * as inflection from "inflection"
|
|
3
4
|
import Params from "../params"
|
|
4
5
|
import PropTypes from "prop-types"
|
|
5
6
|
import React from "react"
|
|
@@ -34,7 +35,7 @@ export default class ApiMakerSuperAdminModelClassTable extends React.PureCompone
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
viewModelPath = (args) => {
|
|
37
|
-
const argName = digg(this.props.modelClass.modelClassData(), "
|
|
38
|
+
const argName = inflection.camelize(digg(this.props.modelClass.modelClassData(), "name"), true)
|
|
38
39
|
const model = digg(args, argName)
|
|
39
40
|
|
|
40
41
|
return Params.withParams({
|
|
@@ -14,7 +14,7 @@ class SelectCalculator {
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
// Ensure the primary key column is loader for the primary model class
|
|
17
|
-
const className = digg(modelClass.modelClassData(), "
|
|
17
|
+
const className = digg(modelClass.modelClassData(), "name")
|
|
18
18
|
const primaryKeyColumnName = modelClass.primaryKey()
|
|
19
19
|
|
|
20
20
|
if (!(className in select)) select[className] = []
|
package/src/table/table.jsx
CHANGED
|
@@ -195,6 +195,9 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
195
195
|
|
|
196
196
|
return (
|
|
197
197
|
<div className={this.className()}>
|
|
198
|
+
<div>
|
|
199
|
+
queryQName: {this.shape.queryQName}
|
|
200
|
+
</div>
|
|
198
201
|
{preload !== undefined &&
|
|
199
202
|
<CollectionLoader
|
|
200
203
|
abilities={this.abilitiesToLoad()}
|
|
@@ -540,6 +543,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
540
543
|
rowComponent = () => this.responsiveComponent("tr")
|
|
541
544
|
|
|
542
545
|
headersContentFromColumns () {
|
|
546
|
+
const {defaultParams} = this.props
|
|
543
547
|
const {preparedColumns, query} = digs(this.shape, "preparedColumns", "query")
|
|
544
548
|
const ColumnInHeadComponent = this.columnInHeadComponent()
|
|
545
549
|
|
|
@@ -551,7 +555,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
551
555
|
{...this.columnProps(column)}
|
|
552
556
|
>
|
|
553
557
|
{tableSettingColumn.hasSortKey() && query &&
|
|
554
|
-
<SortLink attribute={tableSettingColumn.sortKey()} query={query} title={this.headerLabelForColumn(column)} />
|
|
558
|
+
<SortLink attribute={tableSettingColumn.sortKey()} defaultParams={defaultParams} query={query} title={this.headerLabelForColumn(column)} />
|
|
555
559
|
}
|
|
556
560
|
{(!tableSettingColumn.hasSortKey() || !query) &&
|
|
557
561
|
this.headerLabelForColumn(column)
|