@kaspernj/api-maker 1.0.439 → 1.0.441
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
|
@@ -184,7 +184,7 @@ export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends
|
|
|
184
184
|
</View>
|
|
185
185
|
<View style={{flexDirection: "row"}}>
|
|
186
186
|
<View>
|
|
187
|
-
{this.s.associations
|
|
187
|
+
{this.s.associations && this.sortedReflectionsByName(this.s.associations).map((reflection) =>
|
|
188
188
|
<ReflectionElement
|
|
189
189
|
key={reflection.reflectionName}
|
|
190
190
|
modelClassName={this.s.modelClassName}
|
|
@@ -194,7 +194,7 @@ export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends
|
|
|
194
194
|
)}
|
|
195
195
|
</View>
|
|
196
196
|
<View>
|
|
197
|
-
{this.s.ransackableAttributes?.map((attribute) =>
|
|
197
|
+
{this.s.ransackableAttributes && this.sortedAttributesByName(this.s.ransackableAttributes)?.map((attribute) =>
|
|
198
198
|
<AttributeElement
|
|
199
199
|
active={attribute.attributeName == this.s.attribute?.attributeName}
|
|
200
200
|
attribute={attribute}
|
|
@@ -377,9 +377,23 @@ export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends
|
|
|
377
377
|
})
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
-
|
|
380
|
+
sortedAttributesByName(attributes) {
|
|
381
|
+
return attributes.sort((a, b) =>
|
|
382
|
+
digg(a, "humanName")
|
|
383
|
+
.toLowerCase()
|
|
384
|
+
.localeCompare(
|
|
385
|
+
digg(b, "humanName").toLowerCase()
|
|
386
|
+
)
|
|
387
|
+
)
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
sortedReflectionsByName(reflections) {
|
|
381
391
|
return reflections.sort((a, b) =>
|
|
382
|
-
|
|
392
|
+
digg(a, "humanName")
|
|
393
|
+
.toLowerCase()
|
|
394
|
+
.localeCompare(
|
|
395
|
+
digg(b, "humanName").toLowerCase()
|
|
396
|
+
)
|
|
383
397
|
)
|
|
384
398
|
}
|
|
385
399
|
}))
|
|
@@ -44,7 +44,7 @@ export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseC
|
|
|
44
44
|
/>
|
|
45
45
|
}
|
|
46
46
|
{(!tableSettingColumn.hasSortKey() || !query) &&
|
|
47
|
-
<Text ellipsizeMode="clip" numberOfLines={1}>
|
|
47
|
+
<Text ellipsizeMode="clip" numberOfLines={1} style={{fontWeight: "bold"}}>
|
|
48
48
|
{table.headerLabelForColumn(column)}
|
|
49
49
|
</Text>
|
|
50
50
|
}
|
package/src/table/table.jsx
CHANGED
|
@@ -9,6 +9,7 @@ import debounce from "debounce"
|
|
|
9
9
|
import Filters from "./filters"
|
|
10
10
|
import FlatList from "./components/flat-list"
|
|
11
11
|
import FontAwesomeIcon from "react-native-vector-icons/FontAwesome"
|
|
12
|
+
import {Form} from "../form"
|
|
12
13
|
import Header from "./components/header"
|
|
13
14
|
import HeaderColumn from "./header-column"
|
|
14
15
|
import HeaderSelect from "./header-select"
|
|
@@ -157,6 +158,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
157
158
|
columns: columnsAsArray,
|
|
158
159
|
currentWorkplace: undefined,
|
|
159
160
|
currentWorkplaceCount: null,
|
|
161
|
+
filterForm: null,
|
|
160
162
|
identifier: () => this.props.identifier || `${collectionKey}-default`,
|
|
161
163
|
lastUpdate: () => new Date(),
|
|
162
164
|
preload: undefined,
|
|
@@ -529,18 +531,20 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
529
531
|
filterForm = () => {
|
|
530
532
|
const {filterFormRef, submitFilter, submitFilterDebounce} = this.tt
|
|
531
533
|
const {filterContent, filterSubmitButton} = this.p
|
|
534
|
+
const {queryQName} = this.s
|
|
532
535
|
const {filterSubmitLabel} = this.props
|
|
533
536
|
const {qParams} = digs(this.collection, "qParams")
|
|
534
537
|
|
|
535
538
|
return (
|
|
536
|
-
<
|
|
539
|
+
<Form className="live-table--filter-form" formRef={filterFormRef} onSubmit={this.onFilterFormSubmit} setForm={this.setStates.filterForm}>
|
|
537
540
|
{"s" in qParams &&
|
|
538
541
|
<input name="s" type="hidden" value={qParams.s} />
|
|
539
542
|
}
|
|
540
543
|
{filterContent({
|
|
541
544
|
onFilterChanged: submitFilter,
|
|
542
545
|
onFilterChangedWithDelay: submitFilterDebounce,
|
|
543
|
-
qParams
|
|
546
|
+
qParams,
|
|
547
|
+
queryQName
|
|
544
548
|
})}
|
|
545
549
|
{filterSubmitButton &&
|
|
546
550
|
<input
|
|
@@ -550,7 +554,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
550
554
|
value={filterSubmitLabel || this.t(".filter", {defaultValue: "Filter"})}
|
|
551
555
|
/>
|
|
552
556
|
}
|
|
553
|
-
</
|
|
557
|
+
</Form>
|
|
554
558
|
)
|
|
555
559
|
}
|
|
556
560
|
|
|
@@ -843,11 +847,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
843
847
|
throw new Error("No 'label' or 'attribute' was given")
|
|
844
848
|
}
|
|
845
849
|
|
|
846
|
-
onFilterFormSubmit = (
|
|
847
|
-
e.preventDefault()
|
|
848
|
-
this.submitFilter()
|
|
849
|
-
}
|
|
850
|
-
|
|
850
|
+
onFilterFormSubmit = () => this.submitFilter()
|
|
851
851
|
onRequestCloseSettings = () => this.setState({showSettings: false})
|
|
852
852
|
|
|
853
853
|
onSettingsClicked = (e) => {
|
package/src/use-input.mjs
CHANGED
|
@@ -63,7 +63,7 @@ const useInput = ({props, wrapperOptions}) => {
|
|
|
63
63
|
const inputDefaultValue = useCallback(() => {
|
|
64
64
|
if ("defaultValue" in s.props) {
|
|
65
65
|
return formatValue(s.props.defaultValue)
|
|
66
|
-
} else if (s.props.model) {
|
|
66
|
+
} else if (s.props.model && s.props.attribute) {
|
|
67
67
|
if (!s.props.model[s.props.attribute]) {
|
|
68
68
|
throw new Error(`No such attribute defined on resource: ${digg(s.props.model.modelClassData(), "name")}#${s.props.attribute}`)
|
|
69
69
|
}
|