@kaspernj/api-maker 1.0.258 → 1.0.260
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.260",
|
|
20
20
|
"type": "module",
|
|
21
21
|
"description": "",
|
|
22
22
|
"main": "index.js",
|
|
@@ -75,6 +75,6 @@
|
|
|
75
75
|
"eslint-plugin-react": "^7.23.2",
|
|
76
76
|
"i18n-on-steroids": "^1.0.5",
|
|
77
77
|
"jest": "^29.0.1",
|
|
78
|
-
"jsdom": "^
|
|
78
|
+
"jsdom": "^21.0.0"
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -127,6 +127,7 @@ export default class ApiMakerBootstrapLiveTable extends React.PureComponent {
|
|
|
127
127
|
noRecordsAvailableContent={noRecordsAvailableContent}
|
|
128
128
|
noRecordsFoundContent={noRecordsFoundContent}
|
|
129
129
|
onModelsLoaded={onModelsLoaded}
|
|
130
|
+
pagination
|
|
130
131
|
preloads={preloads}
|
|
131
132
|
select={select}
|
|
132
133
|
selectColumns={selectColumns}
|
|
@@ -14,6 +14,7 @@ class CollectionLoader extends React.PureComponent {
|
|
|
14
14
|
groupBy: ["id"],
|
|
15
15
|
noRecordsAvailableContent: undefined,
|
|
16
16
|
noRecordsFoundContent: undefined,
|
|
17
|
+
pagination: false,
|
|
17
18
|
preloads: [],
|
|
18
19
|
select: {}
|
|
19
20
|
}
|
|
@@ -30,6 +31,7 @@ class CollectionLoader extends React.PureComponent {
|
|
|
30
31
|
noRecordsAvailableContent: PropTypes.func,
|
|
31
32
|
noRecordsFoundContent: PropTypes.func,
|
|
32
33
|
onModelsLoaded: PropTypes.func,
|
|
34
|
+
pagination: PropTypes.bool.isRequired,
|
|
33
35
|
paginateContent: PropTypes.func,
|
|
34
36
|
preloads: PropTypes.array.isRequired,
|
|
35
37
|
queryName: PropTypes.string,
|
|
@@ -140,7 +142,7 @@ class CollectionLoader extends React.PureComponent {
|
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
loadModels = async () => {
|
|
143
|
-
const {queryParams} = digs(this.props, "queryParams")
|
|
145
|
+
const {pagination, queryParams} = digs(this.props, "pagination", "queryParams")
|
|
144
146
|
const {abilities, collection, groupBy, modelClass, onModelsLoaded, preloads, select, selectColumns} = this.props
|
|
145
147
|
const {
|
|
146
148
|
qParams,
|
|
@@ -156,26 +158,29 @@ class CollectionLoader extends React.PureComponent {
|
|
|
156
158
|
"queryQName",
|
|
157
159
|
"searchParams"
|
|
158
160
|
)
|
|
159
|
-
const page = queryParams[queryPageName] || 1
|
|
160
|
-
let per = queryParams[queryPerKey] || 30
|
|
161
|
-
|
|
162
|
-
if (per == "all") {
|
|
163
|
-
per = 999_999_999
|
|
164
|
-
} else {
|
|
165
|
-
per = Number(per)
|
|
166
|
-
}
|
|
167
161
|
|
|
168
162
|
let query = collection?.clone() || modelClass.ransack()
|
|
169
163
|
|
|
164
|
+
if (pagination) {
|
|
165
|
+
const page = queryParams[queryPageName] || 1
|
|
166
|
+
let per = queryParams[queryPerKey] || 30
|
|
167
|
+
|
|
168
|
+
if (per == "all") {
|
|
169
|
+
per = 999_999_999
|
|
170
|
+
} else {
|
|
171
|
+
per = Number(per)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
query.page(page).per(per)
|
|
175
|
+
}
|
|
176
|
+
|
|
170
177
|
if (groupBy) query = query.groupBy(...groupBy)
|
|
171
178
|
|
|
172
179
|
query = query
|
|
173
180
|
.ransack(qParams)
|
|
174
181
|
.search(searchParams)
|
|
175
182
|
.searchKey(queryQName)
|
|
176
|
-
.page(page)
|
|
177
183
|
.pageKey(queryPageName)
|
|
178
|
-
.per(per)
|
|
179
184
|
.perKey(queryPerKey)
|
|
180
185
|
.preload(preloads)
|
|
181
186
|
.select(select)
|
package/src/table/model-row.jsx
CHANGED
|
@@ -98,7 +98,7 @@ export default class ApiMakerBootStrapLiveTableModelRow extends React.PureCompon
|
|
|
98
98
|
const {attribute} = digs(column, "attribute")
|
|
99
99
|
const currentModelClass = this.props.modelClass
|
|
100
100
|
const path = column.path || []
|
|
101
|
-
|
|
101
|
+
let value
|
|
102
102
|
let currentModel = model
|
|
103
103
|
|
|
104
104
|
if (path.length > 0) {
|
|
@@ -109,8 +109,7 @@ export default class ApiMakerBootStrapLiveTableModelRow extends React.PureCompon
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
if (!(attribute in currentModel)) throw new Error(`${currentModelClass.modelName().name} doesn't respond to ${attribute}`)
|
|
112
|
-
|
|
113
|
-
const value = currentModel[attribute]()
|
|
112
|
+
if (currentModel.isAttributeLoaded(attribute)) value = currentModel[attribute]()
|
|
114
113
|
|
|
115
114
|
return this.presentColumnValue(value)
|
|
116
115
|
}
|
package/src/table/table.jsx
CHANGED
|
@@ -177,6 +177,7 @@ class ApiMakerTable extends React.PureComponent {
|
|
|
177
177
|
onModelsLoaded={onModelsLoaded}
|
|
178
178
|
noRecordsAvailableContent={noRecordsAvailableContent}
|
|
179
179
|
noRecordsFoundContent={noRecordsFoundContent}
|
|
180
|
+
pagination
|
|
180
181
|
preloads={preload}
|
|
181
182
|
select={selectCalculator({table: this})}
|
|
182
183
|
selectColumns={selectColumns}
|