@kaspernj/api-maker 1.0.434 → 1.0.435
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/base-component.jsx +1 -4
- package/src/bootstrap/attribute-row/index.jsx +2 -1
- package/src/bootstrap/attribute-rows.jsx +1 -1
- package/src/bootstrap/card.jsx +2 -1
- package/src/bootstrap/input.jsx +1 -1
- package/src/bootstrap/paginate.jsx +2 -1
- package/src/bootstrap/sort-link.jsx +29 -44
- package/src/collection-loader.jsx +2 -1
- package/src/event-created.jsx +1 -1
- package/src/event-destroyed.jsx +1 -1
- package/src/event-emitter-listener.jsx +1 -1
- package/src/event-listener.jsx +1 -1
- package/src/event-updated.jsx +4 -3
- package/src/form.jsx +2 -1
- package/src/inputs/attachment.jsx +1 -1
- package/src/inputs/checkbox.jsx +1 -1
- package/src/inputs/checkboxes.jsx +1 -1
- package/src/inputs/input.jsx +2 -1
- package/src/inputs/money.jsx +2 -1
- package/src/inputs/select.jsx +1 -1
- package/src/link.jsx +12 -7
- package/src/modal.jsx +1 -1
- package/src/resize-observer.jsx +1 -1
- package/src/super-admin/edit-page/edit-attribute-checkbox.jsx +2 -1
- package/src/super-admin/edit-page/edit-attribute-content.jsx +1 -1
- package/src/super-admin/edit-page/edit-attribute-input.jsx +2 -1
- package/src/super-admin/edit-page/edit-attribute.jsx +1 -1
- package/src/super-admin/edit-page.jsx +1 -1
- package/src/super-admin/index-page.jsx +1 -1
- package/src/super-admin/index.jsx +2 -1
- package/src/super-admin/layout/header/index.jsx +2 -1
- package/src/super-admin/layout/index.jsx +2 -2
- package/src/super-admin/layout/menu/index.jsx +1 -1
- package/src/super-admin/layout/menu/menu-content.jsx +2 -1
- package/src/super-admin/layout/menu/menu-item/index.jsx +1 -1
- package/src/super-admin/layout/no-access.jsx +1 -1
- package/src/super-admin/model-class-table.jsx +2 -1
- package/src/super-admin/show-nav.jsx +1 -1
- package/src/super-admin/show-page/belongs-to-attribute-row.jsx +1 -1
- package/src/super-admin/show-page/index.jsx +2 -1
- package/src/super-admin/show-reflection-actions.jsx +2 -1
- package/src/super-admin/show-reflection-link.jsx +1 -1
- package/src/super-admin/show-reflection-page.jsx +1 -1
- package/src/table/components/column.jsx +1 -1
- package/src/table/components/flat-list.jsx +1 -1
- package/src/table/components/header.jsx +10 -2
- package/src/table/components/row.jsx +1 -1
- package/src/table/filters/attribute-element.jsx +1 -1
- package/src/table/filters/filter-form.jsx +2 -1
- package/src/table/filters/filter.jsx +1 -1
- package/src/table/filters/index.jsx +1 -1
- package/src/table/filters/load-search-modal.jsx +2 -1
- package/src/table/filters/reflection-element.jsx +1 -1
- package/src/table/filters/save-search-modal.jsx +1 -1
- package/src/table/filters/scope-element.jsx +1 -1
- package/src/table/header-column-content.jsx +54 -0
- package/src/table/header-column.jsx +3 -18
- package/src/table/header-select.jsx +72 -0
- package/src/table/model-column.jsx +3 -4
- package/src/table/model-row.jsx +2 -4
- package/src/table/settings/column-row.jsx +2 -1
- package/src/table/settings/download-action.jsx +1 -1
- package/src/table/settings/index.jsx +2 -1
- package/src/table/table.jsx +65 -41
- package/src/table/use-sorting.mjs +30 -0
- package/src/table/worker-plugins-check-all-checkbox.jsx +2 -1
- package/src/table/worker-plugins-checkbox.jsx +2 -1
- package/src/utils/card.jsx +49 -0
- package/src/utils/checkbox.jsx +1 -1
- package/src/utils/modal.jsx +59 -0
- package/src/with-can-can.jsx +1 -1
- package/src/with-collection.jsx +1 -1
- package/src/with-model.jsx +1 -1
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import BaseComponent from "../../base-component"
|
|
2
|
-
import
|
|
2
|
+
import classNames from "classnames"
|
|
3
|
+
import memo from "set-state-compare/src/memo"
|
|
3
4
|
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
4
5
|
import {View} from "react-native"
|
|
5
6
|
|
|
6
7
|
export default memo(shapeComponent(class SharedTableHeader extends BaseComponent {
|
|
7
8
|
render() {
|
|
9
|
+
const {dataSet, ...restProps} = this.props
|
|
10
|
+
const {component, ...restDataSet} = dataSet || {}
|
|
11
|
+
const actualDataSet = Object.assign(
|
|
12
|
+
{component: classNames("api-maker/table/header", component)},
|
|
13
|
+
restDataSet
|
|
14
|
+
)
|
|
15
|
+
|
|
8
16
|
return (
|
|
9
|
-
<View {...
|
|
17
|
+
<View dataSet={actualDataSet} {...restProps} />
|
|
10
18
|
)
|
|
11
19
|
}
|
|
12
20
|
}))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BaseComponent from "../../base-component"
|
|
2
|
-
import
|
|
2
|
+
import memo from "set-state-compare/src/memo"
|
|
3
3
|
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
4
4
|
import useBreakpoint from "../../use-breakpoint"
|
|
5
5
|
import {View} from "react-native"
|
|
@@ -2,7 +2,7 @@ import BaseComponent from "../../base-component"
|
|
|
2
2
|
import {digg} from "diggerize"
|
|
3
3
|
import PropTypes from "prop-types"
|
|
4
4
|
import PropTypesExact from "prop-types-exact"
|
|
5
|
-
import
|
|
5
|
+
import memo from "set-state-compare/src/memo"
|
|
6
6
|
import {Pressable} from "react-native"
|
|
7
7
|
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
8
8
|
import Text from "../../utils/text"
|
|
@@ -4,9 +4,10 @@ import {digg, digs} from "diggerize"
|
|
|
4
4
|
import * as inflection from "inflection"
|
|
5
5
|
import {Form} from "../../form"
|
|
6
6
|
import Input from "../../inputs/input"
|
|
7
|
+
import memo from "set-state-compare/src/memo"
|
|
7
8
|
import PropTypes from "prop-types"
|
|
8
9
|
import PropTypesExact from "prop-types-exact"
|
|
9
|
-
import {
|
|
10
|
+
import {useMemo, useRef} from "react"
|
|
10
11
|
import {ActivityIndicator, View} from "react-native"
|
|
11
12
|
import ReflectionElement from "./reflection-element"
|
|
12
13
|
import ScopeElement from "./scope-element"
|
|
@@ -3,7 +3,7 @@ import BaseComponent from "../../base-component"
|
|
|
3
3
|
import FontAwesomeIcon from "react-native-vector-icons/FontAwesome"
|
|
4
4
|
import PropTypes from "prop-types"
|
|
5
5
|
import PropTypesExact from "prop-types-exact"
|
|
6
|
-
import
|
|
6
|
+
import memo from "set-state-compare/src/memo"
|
|
7
7
|
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
8
8
|
import Text from "../../utils/text"
|
|
9
9
|
|
|
@@ -5,7 +5,7 @@ import FilterForm from "./filter-form"
|
|
|
5
5
|
import LoadSearchModal from "./load-search-modal"
|
|
6
6
|
import SaveSearchModal from "./save-search-modal"
|
|
7
7
|
import PropTypes from "prop-types"
|
|
8
|
-
import
|
|
8
|
+
import memo from "set-state-compare/src/memo"
|
|
9
9
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
10
10
|
import {TableSearch} from "../../models.mjs.erb"
|
|
11
11
|
import useI18n from "i18n-on-steroids/src/use-i18n.mjs"
|
|
@@ -2,7 +2,8 @@ import apiMakerConfig from "@kaspernj/api-maker/src/config.mjs"
|
|
|
2
2
|
import BaseComponent from "../../base-component"
|
|
3
3
|
import classNames from "classnames"
|
|
4
4
|
import {digg} from "diggerize"
|
|
5
|
-
import
|
|
5
|
+
import memo from "set-state-compare/src/memo"
|
|
6
|
+
import {useMemo} from "react"
|
|
6
7
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
7
8
|
import {TableSearch} from "../../models.mjs.erb"
|
|
8
9
|
import {Pressable, View} from "react-native"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BaseComponent from "../../base-component"
|
|
2
2
|
import PropTypes from "prop-types"
|
|
3
3
|
import PropTypesExact from "prop-types-exact"
|
|
4
|
-
import
|
|
4
|
+
import memo from "set-state-compare/src/memo"
|
|
5
5
|
import {Pressable} from "react-native"
|
|
6
6
|
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
7
7
|
import Text from "../../utils/text"
|
|
@@ -6,7 +6,7 @@ import {Form} from "../../form"
|
|
|
6
6
|
import Input from "../../bootstrap/input"
|
|
7
7
|
import modelClassRequire from "../../model-class-require.mjs"
|
|
8
8
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
9
|
-
import
|
|
9
|
+
import memo from "set-state-compare/src/memo"
|
|
10
10
|
import useI18n from "i18n-on-steroids/src/use-i18n.mjs"
|
|
11
11
|
|
|
12
12
|
const TableSearch = modelClassRequire("TableSearch")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseComponent from "../../base-component"
|
|
2
2
|
import PropTypes from "prop-types"
|
|
3
|
-
import
|
|
3
|
+
import memo from "set-state-compare/src/memo"
|
|
4
4
|
import {Pressable} from "react-native"
|
|
5
5
|
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
6
6
|
import Text from "../../utils/text"
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import BaseComponent from "../base-component"
|
|
2
|
+
import {digs} from "diggerize"
|
|
3
|
+
import memo from "set-state-compare/src/memo"
|
|
4
|
+
import {View} from "react-native"
|
|
5
|
+
import PropTypes from "prop-types"
|
|
6
|
+
import propTypesExact from "prop-types-exact"
|
|
7
|
+
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
8
|
+
import SortLink from "../bootstrap/sort-link"
|
|
9
|
+
import Text from "../utils/text"
|
|
10
|
+
|
|
11
|
+
export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseComponent {
|
|
12
|
+
static propTypes = propTypesExact({
|
|
13
|
+
column: PropTypes.object.isRequired,
|
|
14
|
+
sortLinkProps: PropTypes.object,
|
|
15
|
+
table: PropTypes.object.isRequired,
|
|
16
|
+
tableSettingColumn: PropTypes.object.isRequired
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
render() {
|
|
20
|
+
const {column, table, tableSettingColumn} = this.p
|
|
21
|
+
const {defaultParams} = table.props
|
|
22
|
+
const {styleForHeaderText} = table.tt
|
|
23
|
+
const {query} = digs(table.collection, "query")
|
|
24
|
+
const columnProps = table.columnProps(column)
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<View
|
|
28
|
+
dataSet={{
|
|
29
|
+
component: "api-maker/table/header-column-content",
|
|
30
|
+
identifier: tableSettingColumn.identifier()
|
|
31
|
+
}}
|
|
32
|
+
style={{display: "flex", flexDirection: "row", alignItems: "center"}}
|
|
33
|
+
{...columnProps}
|
|
34
|
+
>
|
|
35
|
+
{tableSettingColumn.hasSortKey() && query &&
|
|
36
|
+
<SortLink
|
|
37
|
+
attribute={tableSettingColumn.sortKey()}
|
|
38
|
+
defaultParams={defaultParams}
|
|
39
|
+
query={query}
|
|
40
|
+
style={{whiteSpace: "nowrap", overflow: "hidden"}}
|
|
41
|
+
textProps={{ellipsizeMode: "clip", numberOfLines: 1, style: styleForHeaderText()}}
|
|
42
|
+
title={table.headerLabelForColumn(column)}
|
|
43
|
+
{...this.props.sortLinkProps}
|
|
44
|
+
/>
|
|
45
|
+
}
|
|
46
|
+
{(!tableSettingColumn.hasSortKey() || !query) &&
|
|
47
|
+
<Text ellipsizeMode="clip" numberOfLines={1}>
|
|
48
|
+
{table.headerLabelForColumn(column)}
|
|
49
|
+
</Text>
|
|
50
|
+
}
|
|
51
|
+
</View>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
}))
|
|
@@ -2,7 +2,8 @@ import BaseComponent from "../base-component"
|
|
|
2
2
|
import classNames from "classnames"
|
|
3
3
|
import {digs} from "diggerize"
|
|
4
4
|
import Header from "./components/header"
|
|
5
|
-
import
|
|
5
|
+
import HeaderColumnContent from "./header-column-content"
|
|
6
|
+
import memo from "set-state-compare/src/memo"
|
|
6
7
|
import {Platform, Pressable, View} from "react-native"
|
|
7
8
|
import PropTypes from "prop-types"
|
|
8
9
|
import propTypesExact from "prop-types-exact"
|
|
@@ -64,23 +65,7 @@ export default memo(shapeComponent(class ApiMakerTableHeaderColumn extends BaseC
|
|
|
64
65
|
style={styleForHeader({style: actualStyle})}
|
|
65
66
|
{...restColumnProps}
|
|
66
67
|
>
|
|
67
|
-
<
|
|
68
|
-
{tableSettingColumn.hasSortKey() && query &&
|
|
69
|
-
<SortLink
|
|
70
|
-
attribute={tableSettingColumn.sortKey()}
|
|
71
|
-
defaultParams={defaultParams}
|
|
72
|
-
query={query}
|
|
73
|
-
style={{whiteSpace: "nowrap", overflow: "hidden"}}
|
|
74
|
-
textProps={{ellipsizeMode: "clip", numberOfLines: 1, style: styleForHeaderText()}}
|
|
75
|
-
title={table.headerLabelForColumn(column)}
|
|
76
|
-
/>
|
|
77
|
-
}
|
|
78
|
-
{(!tableSettingColumn.hasSortKey() || !query) &&
|
|
79
|
-
<Text ellipsizeMode="clip" numberOfLines={1}>
|
|
80
|
-
{table.headerLabelForColumn(column)}
|
|
81
|
-
</Text>
|
|
82
|
-
}
|
|
83
|
-
</View>
|
|
68
|
+
<HeaderColumnContent column={column} table={table} tableSettingColumn={tableSettingColumn} />
|
|
84
69
|
{mdUp &&
|
|
85
70
|
<Pressable
|
|
86
71
|
onMouseDown={Platform.OS == "web" ? this.tt.onResizeMouseDown : undefined}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {Pressable, View} from "react-native"
|
|
2
|
+
import BaseComponent from "../base-component"
|
|
3
|
+
import Collection from "../collection"
|
|
4
|
+
import HeaderColumnContent from "./header-column-content"
|
|
5
|
+
import memo from "set-state-compare/src/memo"
|
|
6
|
+
import Modal from "../utils/modal"
|
|
7
|
+
import PropTypes from "prop-types"
|
|
8
|
+
import propTypesExact from "prop-types-exact"
|
|
9
|
+
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
10
|
+
import Text from "../utils/text"
|
|
11
|
+
import useI18n from "i18n-on-steroids/src/use-i18n.mjs"
|
|
12
|
+
import useSorting from "./use-sorting"
|
|
13
|
+
|
|
14
|
+
export default memo(shapeComponent(class ApiMakerTableHeaderSelect extends BaseComponent {
|
|
15
|
+
static propTypes = propTypesExact({
|
|
16
|
+
preparedColumns: PropTypes.array.isRequired,
|
|
17
|
+
query: PropTypes.instanceOf(Collection).isRequired,
|
|
18
|
+
table: PropTypes.object
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
setup() {
|
|
22
|
+
const {t} = useI18n({namespace: "js.api_maker.table.header_select"})
|
|
23
|
+
const {preparedColumns, query} = this.p
|
|
24
|
+
const {qParams, searchKey, sortAttribute, sortMode} = useSorting({query})
|
|
25
|
+
|
|
26
|
+
this.useStates({
|
|
27
|
+
modalOpen: false
|
|
28
|
+
})
|
|
29
|
+
this.setInstance({qParams, searchKey, sortAttribute, sortMode, t})
|
|
30
|
+
this.sortedByPreparedColumn = preparedColumns.find((preparedColumn) => preparedColumn.tableSettingColumn.sortKey() == sortAttribute)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
render() {
|
|
34
|
+
const {sortedByPreparedColumn, sortMode, t} = this.tt
|
|
35
|
+
const {table} = this.p
|
|
36
|
+
const column = sortedByPreparedColumn?.column
|
|
37
|
+
const columnLabel = column && table.headerLabelForColumn(column)
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<View dataSet={{component: "api-maker/table/header-select"}}>
|
|
41
|
+
{this.s.modalOpen &&
|
|
42
|
+
<Modal dataSet={{class: "table-header-select-modal"}} onRequestClose={this.tt.onModalRequestClose} transparent>
|
|
43
|
+
{this.p.preparedColumns.map(({column, tableSettingColumn}) =>
|
|
44
|
+
<View
|
|
45
|
+
key={tableSettingColumn.identifier()}
|
|
46
|
+
style={{marginVertical: 5}}
|
|
47
|
+
>
|
|
48
|
+
<HeaderColumnContent column={column} table={table} tableSettingColumn={tableSettingColumn} sortLinkProps={{usePressable: true}} />
|
|
49
|
+
</View>
|
|
50
|
+
)}
|
|
51
|
+
</Modal>
|
|
52
|
+
}
|
|
53
|
+
<Pressable onPress={this.tt.onSortedByPress}>
|
|
54
|
+
<Text>
|
|
55
|
+
{sortedByPreparedColumn && sortMode == "asc" &&
|
|
56
|
+
t(".sorted_by_column", {column: columnLabel, defaultValue: "Sorted by %{column}"})
|
|
57
|
+
}
|
|
58
|
+
{sortedByPreparedColumn && sortMode == "desc" &&
|
|
59
|
+
t(".sorted_by_column_reversed", {column: columnLabel, defaultValue: "Sorted by %{column} reversed"})
|
|
60
|
+
}
|
|
61
|
+
{!sortedByPreparedColumn &&
|
|
62
|
+
t(".not_sorted", {defaultValue: "Not sorted"})
|
|
63
|
+
}
|
|
64
|
+
</Text>
|
|
65
|
+
</Pressable>
|
|
66
|
+
</View>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
onModalRequestClose = () => this.setState({modalOpen: false})
|
|
71
|
+
onSortedByPress = () => this.setState({modalOpen: true})
|
|
72
|
+
}))
|
|
@@ -6,7 +6,7 @@ import ColumnContent from "./column-content"
|
|
|
6
6
|
import columnIdentifier from "./column-identifier.mjs"
|
|
7
7
|
import PropTypes from "prop-types"
|
|
8
8
|
import propTypesExact from "prop-types-exact"
|
|
9
|
-
import
|
|
9
|
+
import memo from "set-state-compare/src/memo"
|
|
10
10
|
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
11
11
|
import Text from "../utils/text"
|
|
12
12
|
import useBreakpoint from "../use-breakpoint"
|
|
@@ -16,7 +16,6 @@ export default memo(shapeComponent(class ApiMakerTableModelColumn extends BaseCo
|
|
|
16
16
|
column: PropTypes.object.isRequired,
|
|
17
17
|
columnIndex: PropTypes.number.isRequired,
|
|
18
18
|
even: PropTypes.bool.isRequired,
|
|
19
|
-
isSmallScreen: PropTypes.bool.isRequired,
|
|
20
19
|
model: PropTypes.object.isRequired,
|
|
21
20
|
table: PropTypes.object.isRequired,
|
|
22
21
|
tableSettingColumn: PropTypes.object.isRequired,
|
|
@@ -25,7 +24,7 @@ export default memo(shapeComponent(class ApiMakerTableModelColumn extends BaseCo
|
|
|
25
24
|
|
|
26
25
|
render() {
|
|
27
26
|
const {mdUp} = useBreakpoint()
|
|
28
|
-
const {column, columnIndex, even,
|
|
27
|
+
const {column, columnIndex, even, model, table, width} = this.props
|
|
29
28
|
const columnProps = table.columnProps(column)
|
|
30
29
|
const {style, ...restColumnProps} = columnProps
|
|
31
30
|
const actualStyle = Object.assign(
|
|
@@ -49,7 +48,7 @@ export default memo(shapeComponent(class ApiMakerTableModelColumn extends BaseCo
|
|
|
49
48
|
style={actualStyle}
|
|
50
49
|
{...restColumnProps}
|
|
51
50
|
>
|
|
52
|
-
{
|
|
51
|
+
{!mdUp &&
|
|
53
52
|
<View dataSet={{class: "table--column-label"}}>
|
|
54
53
|
<Text style={{fontWeight: "bold"}}>
|
|
55
54
|
{table.headerLabelForColumn(column)}
|
package/src/table/model-row.jsx
CHANGED
|
@@ -11,7 +11,7 @@ import ModelColumn from "./model-column"
|
|
|
11
11
|
import PropTypes from "prop-types"
|
|
12
12
|
import propTypesExact from "prop-types-exact"
|
|
13
13
|
import Row from "./components/row"
|
|
14
|
-
import
|
|
14
|
+
import memo from "set-state-compare/src/memo"
|
|
15
15
|
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
16
16
|
|
|
17
17
|
const WorkerPluginsCheckbox = React.lazy(() => import("./worker-plugins-checkbox"))
|
|
@@ -21,7 +21,6 @@ export default memo(shapeComponent(class ApiMakerBootStrapLiveTableModelRow exte
|
|
|
21
21
|
cacheKey: PropTypes.string.isRequired,
|
|
22
22
|
columnWidths: PropTypes.object.isRequired,
|
|
23
23
|
index: PropTypes.number.isRequired,
|
|
24
|
-
isSmallScreen: PropTypes.bool.isRequired,
|
|
25
24
|
model: PropTypes.object.isRequired,
|
|
26
25
|
table: PropTypes.object.isRequired,
|
|
27
26
|
preparedColumns: PropTypes.array,
|
|
@@ -86,14 +85,13 @@ export default memo(shapeComponent(class ApiMakerBootStrapLiveTableModelRow exte
|
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
columnsContentFromColumns(model, even) {
|
|
89
|
-
const {
|
|
88
|
+
const {table, preparedColumns} = this.p
|
|
90
89
|
|
|
91
90
|
return preparedColumns?.map(({column, tableSettingColumn, width}, columnIndex) => columnVisible(column, tableSettingColumn) &&
|
|
92
91
|
<ModelColumn
|
|
93
92
|
column={column}
|
|
94
93
|
columnIndex={columnIndex}
|
|
95
94
|
even={even}
|
|
96
|
-
isSmallScreen={isSmallScreen}
|
|
97
95
|
key={columnIdentifier(column)}
|
|
98
96
|
model={model}
|
|
99
97
|
table={table}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import BaseComponent from "../../base-component"
|
|
2
2
|
import columnIdentifier from "../column-identifier.mjs"
|
|
3
|
+
import memo from "set-state-compare/src/memo"
|
|
3
4
|
import PropTypes from "prop-types"
|
|
4
5
|
import propTypesExact from "prop-types-exact"
|
|
5
|
-
import {
|
|
6
|
+
import {useEffect, useRef} from "react"
|
|
6
7
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
7
8
|
import Text from "../../utils/text"
|
|
8
9
|
import {View} from "react-native"
|
|
@@ -4,7 +4,7 @@ import columnIdentifier from "../column-identifier.mjs"
|
|
|
4
4
|
import columnVisible from "../column-visible.mjs"
|
|
5
5
|
import {saveAs} from "file-saver"
|
|
6
6
|
import FontAwesomeIcon from "react-native-vector-icons/FontAwesome"
|
|
7
|
-
import
|
|
7
|
+
import memo from "set-state-compare/src/memo"
|
|
8
8
|
import PropTypes from "prop-types"
|
|
9
9
|
import propTypesExact from "prop-types-exact"
|
|
10
10
|
import {renderToString} from "react-dom/server"
|
|
@@ -2,7 +2,8 @@ import BaseComponent from "../../base-component"
|
|
|
2
2
|
import columnIdentifier from "../column-identifier.mjs"
|
|
3
3
|
import ColumnRow from "./column-row"
|
|
4
4
|
import DownloadAction from "./download-action"
|
|
5
|
-
import {
|
|
5
|
+
import {useRef} from "react"
|
|
6
|
+
import memo from "set-state-compare/src/memo"
|
|
6
7
|
import Modal from "../../modal"
|
|
7
8
|
import PropTypes from "prop-types"
|
|
8
9
|
import propTypesExact from "prop-types-exact"
|
package/src/table/table.jsx
CHANGED
|
@@ -11,13 +11,15 @@ import FlatList from "./components/flat-list"
|
|
|
11
11
|
import FontAwesomeIcon from "react-native-vector-icons/FontAwesome"
|
|
12
12
|
import Header from "./components/header"
|
|
13
13
|
import HeaderColumn from "./header-column"
|
|
14
|
+
import HeaderSelect from "./header-select"
|
|
14
15
|
import * as inflection from "inflection"
|
|
16
|
+
import memo from "set-state-compare/src/memo"
|
|
15
17
|
import modelClassRequire from "../model-class-require.mjs"
|
|
16
18
|
import ModelRow from "./model-row"
|
|
17
19
|
import Paginate from "../bootstrap/paginate"
|
|
18
20
|
import Params from "../params"
|
|
19
21
|
import PropTypes from "prop-types"
|
|
20
|
-
import React, {
|
|
22
|
+
import React, {createContext, useContext, useMemo, useRef} from "react"
|
|
21
23
|
import Row from "./components/row"
|
|
22
24
|
import selectCalculator from "./select-calculator"
|
|
23
25
|
import Select from "../inputs/select"
|
|
@@ -42,6 +44,45 @@ const styleSheet = StyleSheet.create({
|
|
|
42
44
|
overflowX: "auto"
|
|
43
45
|
}
|
|
44
46
|
})
|
|
47
|
+
const TableContext = createContext()
|
|
48
|
+
|
|
49
|
+
const ListHeaderComponent = memo(() => {
|
|
50
|
+
const {mdUp} = useBreakpoint()
|
|
51
|
+
const tableContextValue = useContext(TableContext)
|
|
52
|
+
const table = tableContextValue.table
|
|
53
|
+
const {collection, queryWithoutPagination, t} = table.tt
|
|
54
|
+
const {query} = digs(collection, "query")
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Row dataSet={{class: "api-maker/table/header-row"}} style={table.styleForRowHeader()}>
|
|
58
|
+
{table.p.workplace && table.s.currentWorkplace &&
|
|
59
|
+
<Header style={table.styleForHeader({style: {width: mdUp ? 41 : undefined}})}>
|
|
60
|
+
<WorkerPluginsCheckAllCheckbox
|
|
61
|
+
currentWorkplace={table.s.currentWorkplace}
|
|
62
|
+
query={queryWithoutPagination}
|
|
63
|
+
style={{marginHorizontal: "auto"}}
|
|
64
|
+
/>
|
|
65
|
+
{!mdUp &&
|
|
66
|
+
<Text style={{marginLeft: 3}}>
|
|
67
|
+
{t(".select_all_found", {defaultValue: "Select all found"})}
|
|
68
|
+
</Text>
|
|
69
|
+
}
|
|
70
|
+
</Header>
|
|
71
|
+
}
|
|
72
|
+
{!mdUp &&
|
|
73
|
+
<Header style={table.styleForHeader({style: {}})}>
|
|
74
|
+
<HeaderSelect preparedColumns={table.s.preparedColumns} query={query} table={table} />
|
|
75
|
+
</Header>
|
|
76
|
+
}
|
|
77
|
+
{mdUp &&
|
|
78
|
+
<>
|
|
79
|
+
{table.headersContentFromColumns()}
|
|
80
|
+
<Header style={table.styleForHeader({style: {}, type: "actions"})} />
|
|
81
|
+
</>
|
|
82
|
+
}
|
|
83
|
+
</Row>
|
|
84
|
+
)
|
|
85
|
+
})
|
|
45
86
|
|
|
46
87
|
export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
47
88
|
static defaultProps = {
|
|
@@ -105,7 +146,6 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
105
146
|
this.setInstance({
|
|
106
147
|
breakpoint,
|
|
107
148
|
filterFormRef: useRef(),
|
|
108
|
-
isSmallScreen: breakpoint == "xs" || breakpoint == "sm",
|
|
109
149
|
mdUp,
|
|
110
150
|
t
|
|
111
151
|
})
|
|
@@ -140,6 +180,8 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
140
180
|
widths: null
|
|
141
181
|
})
|
|
142
182
|
|
|
183
|
+
this.tableContextValue = useMemo(() => ({cacheKey: this.s.tableSettingFullCacheKey, table: this}), [this.s.tableSettingFullCacheKey])
|
|
184
|
+
|
|
143
185
|
useMemo(() => {
|
|
144
186
|
if (this.props.workplace) {
|
|
145
187
|
this.loadCurrentWorkplace().then(() => {
|
|
@@ -391,17 +433,19 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
391
433
|
}
|
|
392
434
|
|
|
393
435
|
const flatList = (
|
|
394
|
-
<
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
436
|
+
<TableContext.Provider value={this.tt.tableContextValue}>
|
|
437
|
+
<FlatList
|
|
438
|
+
data={models}
|
|
439
|
+
dataSet={{class: classNames("api-maker--table", className), cacheKey: this.s.tableSettingFullCacheKey}}
|
|
440
|
+
extraData={this.s.lastUpdate}
|
|
441
|
+
keyExtractor={this.tt.keyExtrator}
|
|
442
|
+
ListHeaderComponent={ListHeaderComponent}
|
|
443
|
+
renderItem={this.tt.renderItem}
|
|
444
|
+
showsHorizontalScrollIndicator
|
|
445
|
+
style={styleSheet.flatList}
|
|
446
|
+
{...restProps}
|
|
447
|
+
/>
|
|
448
|
+
</TableContext.Provider>
|
|
405
449
|
)
|
|
406
450
|
|
|
407
451
|
return (
|
|
@@ -468,7 +512,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
468
512
|
}
|
|
469
513
|
}
|
|
470
514
|
|
|
471
|
-
keyExtrator = (model) => model.id()
|
|
515
|
+
keyExtrator = (model) => `${this.s.tableSettingFullCacheKey}-${model.id()}`
|
|
472
516
|
|
|
473
517
|
filterForm = () => {
|
|
474
518
|
const {filterFormRef, submitFilter, submitFilterDebounce} = this.tt
|
|
@@ -514,26 +558,6 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
514
558
|
Params.changeParams(paramsChange)
|
|
515
559
|
}
|
|
516
560
|
|
|
517
|
-
listHeaderComponent = () => {
|
|
518
|
-
const {queryWithoutPagination} = this.tt
|
|
519
|
-
|
|
520
|
-
return (
|
|
521
|
-
<Row dataSet={{class: "api-maker/table/header-row"}} style={this.styleForRowHeader()}>
|
|
522
|
-
{this.p.workplace && this.s.currentWorkplace &&
|
|
523
|
-
<Header style={this.styleForHeader({style: {width: 41}})}>
|
|
524
|
-
<WorkerPluginsCheckAllCheckbox
|
|
525
|
-
currentWorkplace={this.s.currentWorkplace}
|
|
526
|
-
query={queryWithoutPagination}
|
|
527
|
-
style={{marginHorizontal: "auto"}}
|
|
528
|
-
/>
|
|
529
|
-
</Header>
|
|
530
|
-
}
|
|
531
|
-
{this.headersContentFromColumns()}
|
|
532
|
-
<Header style={this.styleForHeader({style: {}, type: "actions"})} />
|
|
533
|
-
</Row>
|
|
534
|
-
)
|
|
535
|
-
}
|
|
536
|
-
|
|
537
561
|
renderItem = ({index, item: model}) => {
|
|
538
562
|
const {preparedColumns, tableSettingFullCacheKey} = this.s
|
|
539
563
|
|
|
@@ -541,7 +565,7 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
541
565
|
return (
|
|
542
566
|
<View>
|
|
543
567
|
<Text>
|
|
544
|
-
Loading...
|
|
568
|
+
{this.t(".loading_dot_dot_dot", {defaultValue: "Loading..."})}
|
|
545
569
|
</Text>
|
|
546
570
|
</View>
|
|
547
571
|
)
|
|
@@ -552,7 +576,6 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
552
576
|
cacheKey={model.cacheKey()}
|
|
553
577
|
columnWidths={this.columnWidths()}
|
|
554
578
|
index={index}
|
|
555
|
-
isSmallScreen={this.tt.isSmallScreen}
|
|
556
579
|
key={model.id()}
|
|
557
580
|
model={model}
|
|
558
581
|
preparedColumns={preparedColumns}
|
|
@@ -563,7 +586,6 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
563
586
|
}
|
|
564
587
|
|
|
565
588
|
styleForColumn = ({column, columnIndex, even, style, type}) => {
|
|
566
|
-
const {mdUp} = this.tt
|
|
567
589
|
const defaultStyle = {
|
|
568
590
|
justifyContent: "center",
|
|
569
591
|
padding: 8,
|
|
@@ -575,12 +597,12 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
575
597
|
defaultStyle.flexDirection = "row"
|
|
576
598
|
defaultStyle.alignItems = "center"
|
|
577
599
|
|
|
578
|
-
if (mdUp) {
|
|
600
|
+
if (this.tt.mdUp) {
|
|
579
601
|
defaultStyle.marginLeft = "auto"
|
|
580
602
|
} else {
|
|
581
603
|
defaultStyle.marginRight = "auto"
|
|
582
604
|
}
|
|
583
|
-
} else {
|
|
605
|
+
} else if (this.tt.mdUp) {
|
|
584
606
|
defaultStyle.borderRight = "1px solid #dbdbdb"
|
|
585
607
|
}
|
|
586
608
|
|
|
@@ -592,12 +614,14 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
592
614
|
return actualStyle
|
|
593
615
|
}
|
|
594
616
|
|
|
595
|
-
styleForHeader({column, columnIndex, style, type}) {
|
|
617
|
+
styleForHeader = ({column, columnIndex, style, type}) => {
|
|
596
618
|
const defaultStyle = {
|
|
619
|
+
flexDirection: "row",
|
|
620
|
+
alignItems: "center",
|
|
597
621
|
padding: 8
|
|
598
622
|
}
|
|
599
623
|
|
|
600
|
-
if (type != "actions") {
|
|
624
|
+
if (type != "actions" && this.tt.mdUp) {
|
|
601
625
|
defaultStyle.borderRight = "1px solid #dbdbdb"
|
|
602
626
|
}
|
|
603
627
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {camelize} from "inflection"
|
|
2
|
+
import useQueryParams from "on-location-changed/src/use-query-params.js"
|
|
3
|
+
|
|
4
|
+
const calculateQParams = (defaultParams, queryParams, searchKey) => {
|
|
5
|
+
if (searchKey in queryParams) {
|
|
6
|
+
return JSON.parse(queryParams[searchKey])
|
|
7
|
+
} else if (defaultParams) {
|
|
8
|
+
return {...defaultParams}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return {}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const useSorting = ({defaultParams, query}) => {
|
|
15
|
+
const queryParams = useQueryParams()
|
|
16
|
+
const searchKey = query.queryArgs.searchKey || "q"
|
|
17
|
+
const qParams = calculateQParams(defaultParams, queryParams, searchKey)
|
|
18
|
+
const matchSortParam = qParams.s?.match(/^(.+?)( asc| desc|)$/)
|
|
19
|
+
const sortAttribute = matchSortParam ? camelize(matchSortParam[1], true) : null
|
|
20
|
+
const sortMode = matchSortParam ? matchSortParam[2].trim() : null
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
qParams,
|
|
24
|
+
searchKey,
|
|
25
|
+
sortAttribute,
|
|
26
|
+
sortMode
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default useSorting
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {useEffect, useMemo, useRef} from "react"
|
|
2
2
|
import BaseComponent from "../base-component"
|
|
3
3
|
import classNames from "classnames"
|
|
4
4
|
import Collection from "../collection.mjs"
|
|
5
|
+
import memo from "set-state-compare/src/memo"
|
|
5
6
|
import PropTypes from "prop-types"
|
|
6
7
|
import propTypesExact from "prop-types-exact"
|
|
7
8
|
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import BaseComponent from "../base-component"
|
|
2
2
|
import classNames from "classnames"
|
|
3
3
|
import {digg} from "diggerize"
|
|
4
|
+
import memo from "set-state-compare/src/memo"
|
|
4
5
|
import modelClassRequire from "../model-class-require.mjs"
|
|
5
6
|
import PropTypes from "prop-types"
|
|
6
7
|
import PropTypesExact from "prop-types-exact"
|
|
7
|
-
import {
|
|
8
|
+
import {useMemo} from "react"
|
|
8
9
|
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
9
10
|
import useModelEvent from "../use-model-event.js"
|
|
10
11
|
|