@kaspernj/api-maker 1.0.229 → 1.0.230
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 +2 -2
- package/src/bootstrap/card.jsx +8 -1
- package/src/collection.mjs +3 -5
- package/src/super-admin/index.jsx +1 -1
- package/src/table/table.jsx +20 -3
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.230",
|
|
20
20
|
"type": "module",
|
|
21
21
|
"description": "",
|
|
22
22
|
"main": "index.js",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"eslint-find-rules": "^4.0.0",
|
|
74
74
|
"eslint-plugin-jest": "^27.0.1",
|
|
75
75
|
"eslint-plugin-react": "^7.23.2",
|
|
76
|
-
"i18n-on-steroids": "^1.0.
|
|
76
|
+
"i18n-on-steroids": "^1.0.5",
|
|
77
77
|
"jest": "^29.0.1",
|
|
78
78
|
"jsdom": "^20.0.0"
|
|
79
79
|
}
|
package/src/bootstrap/card.jsx
CHANGED
|
@@ -18,6 +18,7 @@ export default class ApiMakerBootstrapCard extends React.PureComponent {
|
|
|
18
18
|
defaultExpanded: PropTypes.bool.isRequired,
|
|
19
19
|
expandable: PropTypes.bool.isRequired,
|
|
20
20
|
expandableHide: PropTypes.bool.isRequired,
|
|
21
|
+
footer: PropTypes.node,
|
|
21
22
|
header: PropTypes.node,
|
|
22
23
|
striped: PropTypes.bool,
|
|
23
24
|
responsiveTable: PropTypes.bool.isRequired,
|
|
@@ -39,6 +40,7 @@ export default class ApiMakerBootstrapCard extends React.PureComponent {
|
|
|
39
40
|
defaultExpanded,
|
|
40
41
|
expandable,
|
|
41
42
|
expandableHide,
|
|
43
|
+
footer,
|
|
42
44
|
header,
|
|
43
45
|
responsiveTable,
|
|
44
46
|
striped,
|
|
@@ -48,7 +50,7 @@ export default class ApiMakerBootstrapCard extends React.PureComponent {
|
|
|
48
50
|
const {expanded} = digs(this.state, "expanded")
|
|
49
51
|
|
|
50
52
|
return (
|
|
51
|
-
<div className={this.classNames()} ref="card" {...restProps}>
|
|
53
|
+
<div className={this.classNames()} data-has-footer={Boolean(footer)} ref="card" {...restProps}>
|
|
52
54
|
{(controls || expandable || header) &&
|
|
53
55
|
<div className={`card-header d-flex ${!expanded && "border-bottom-0"}`}>
|
|
54
56
|
<div style={{alignSelf: "center", marginRight: "auto"}}>
|
|
@@ -81,6 +83,11 @@ export default class ApiMakerBootstrapCard extends React.PureComponent {
|
|
|
81
83
|
{!table && children}
|
|
82
84
|
</div>
|
|
83
85
|
}
|
|
86
|
+
{footer &&
|
|
87
|
+
<div className="card-footer">
|
|
88
|
+
{footer}
|
|
89
|
+
</div>
|
|
90
|
+
}
|
|
84
91
|
</div>
|
|
85
92
|
)
|
|
86
93
|
}
|
package/src/collection.mjs
CHANGED
|
@@ -6,7 +6,9 @@ import {incorporate} from "incorporator"
|
|
|
6
6
|
import modelClassRequire from "./model-class-require.mjs"
|
|
7
7
|
import Result from "./result.mjs"
|
|
8
8
|
|
|
9
|
-
class ApiMakerCollection {
|
|
9
|
+
export default class ApiMakerCollection {
|
|
10
|
+
static apiMakerType = "Collection"
|
|
11
|
+
|
|
10
12
|
constructor (args, queryArgs = {}) {
|
|
11
13
|
this.queryArgs = queryArgs
|
|
12
14
|
this.args = args
|
|
@@ -249,7 +251,3 @@ class ApiMakerCollection {
|
|
|
249
251
|
)
|
|
250
252
|
}
|
|
251
253
|
}
|
|
252
|
-
|
|
253
|
-
ApiMakerCollection.apiMakerType = "Collection"
|
|
254
|
-
|
|
255
|
-
export default ApiMakerCollection
|
|
@@ -22,7 +22,7 @@ class ApiMakerSuperAdmin extends React.PureComponent {
|
|
|
22
22
|
if (queryParams.model) modelClass = modelsModule[queryParams.model]
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
|
-
<Layout headerTitle={modelClass?.modelName()?.human({count: 2})}>
|
|
25
|
+
<Layout active={queryParams.model} headerTitle={modelClass?.modelName()?.human({count: 2})}>
|
|
26
26
|
{pageToShow == "index" &&
|
|
27
27
|
<IndexPage
|
|
28
28
|
currentUser={currentUser}
|
package/src/table/table.jsx
CHANGED
|
@@ -7,7 +7,6 @@ import columnVisible from "./column-visible.mjs"
|
|
|
7
7
|
import {debounce} from "debounce"
|
|
8
8
|
import {digg, digs} from "diggerize"
|
|
9
9
|
import inflection from "inflection"
|
|
10
|
-
import instanceOfClassName from "../instance-of-class-name"
|
|
11
10
|
import modelClassRequire from "../model-class-require.mjs"
|
|
12
11
|
import ModelRow from "./model-row"
|
|
13
12
|
import Paginate from "../bootstrap/paginate"
|
|
@@ -300,7 +299,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
300
299
|
this.filterForm()
|
|
301
300
|
}
|
|
302
301
|
{card &&
|
|
303
|
-
<Card className={classNames("mb-4", className)} controls={controlsContent} header={headerContent} table={!this.isSmallScreen()} {...restProps}>
|
|
302
|
+
<Card className={classNames("mb-4", className)} controls={controlsContent} header={headerContent} footer={this.tableFooter()} table={!this.isSmallScreen()} {...restProps}>
|
|
304
303
|
{this.tableContent()}
|
|
305
304
|
</Card>
|
|
306
305
|
}
|
|
@@ -384,7 +383,25 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
384
383
|
)
|
|
385
384
|
}
|
|
386
385
|
|
|
387
|
-
|
|
386
|
+
tableFooter() {
|
|
387
|
+
const {result} = digs(this.shape, "result")
|
|
388
|
+
const currentPage = result.currentPage()
|
|
389
|
+
const totalCount = result.totalCount()
|
|
390
|
+
const perPage = result.perPage()
|
|
391
|
+
const to = Math.min(currentPage * perPage, totalCount)
|
|
392
|
+
const defaultValue = "Showing %{from} to %{to} out of %{total_count} total"
|
|
393
|
+
let from = ((currentPage - 1) * perPage) + 1
|
|
394
|
+
|
|
395
|
+
if (to === 0) from = 0
|
|
396
|
+
|
|
397
|
+
return (
|
|
398
|
+
<div style={{marginTop: "10px"}}>
|
|
399
|
+
{I18n.t("js.api_maker.table.showing_from_to_out_of_total", {defaultValue, from, to, total_count: totalCount})}
|
|
400
|
+
</div>
|
|
401
|
+
)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
className() {
|
|
388
405
|
const classNames = ["component-api-maker-live-table"]
|
|
389
406
|
|
|
390
407
|
if (this.props.className)
|