@kaspernj/api-maker 1.0.400 → 1.0.402
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/paginate.jsx +15 -14
- package/src/bootstrap/sort-link.jsx +10 -12
- package/src/data-set-to-attributes.mjs +13 -0
- package/src/link.jsx +44 -10
- package/src/router/route.jsx +32 -13
- package/src/super-admin/index.jsx +15 -10
- package/src/super-admin/layout/menu/index.jsx +5 -3
- package/src/super-admin/layout/menu/menu-item/index.jsx +42 -5
- package/src/super-admin/layout/menu/menu-item/style.scss +1 -21
- package/src/super-admin/show-nav.jsx +4 -2
- package/src/super-admin/show-page/belongs-to-attribute-row.jsx +5 -2
- package/src/super-admin/show-reflection-actions.jsx +1 -1
- package/src/super-admin/show-reflection-link.jsx +4 -1
- package/src/table/components/column.jsx +12 -0
- package/src/table/components/flat-list.jsx +18 -0
- package/src/table/components/header.jsx +12 -0
- package/src/table/components/row.jsx +20 -0
- package/src/table/header-column.jsx +36 -38
- package/src/table/model-row.jsx +76 -51
- package/src/table/settings/column-row.jsx +1 -1
- package/src/table/settings/index.jsx +0 -12
- package/src/table/style.scss +0 -4
- package/src/table/table.jsx +99 -82
- package/src/table/widths.mjs +77 -0
- package/src/table/worker-plugins-check-all-checkbox.jsx +6 -4
- package/src/table/worker-plugins-checkbox.jsx +5 -3
- package/src/use-model.mjs +25 -23
- package/src/use-screen-layout.mjs +2 -2
- package/src/bootstrap/live-table/model-row.jsx +0 -149
- package/src/bootstrap/live-table.jsx +0 -399
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaspernj/api-maker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.402",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
@@ -53,6 +53,6 @@
|
|
|
53
53
|
"eslint-plugin-react": "^7.23.2",
|
|
54
54
|
"i18n-on-steroids": "^1.0.15",
|
|
55
55
|
"jest": "^29.0.1",
|
|
56
|
-
"jsdom": "^
|
|
56
|
+
"jsdom": "^25.0.0"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -5,6 +5,7 @@ import PropTypes from "prop-types"
|
|
|
5
5
|
import propTypesExact from "prop-types-exact"
|
|
6
6
|
import qs from "qs"
|
|
7
7
|
import {memo, useMemo} from "react"
|
|
8
|
+
import {Text} from "react-native"
|
|
8
9
|
import Result from "../result"
|
|
9
10
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
10
11
|
import urlEncode from "../url-encode.mjs"
|
|
@@ -113,21 +114,21 @@ export default memo(shapeComponent(class ApiMakerBootstrapPaginate extends BaseC
|
|
|
113
114
|
<ul className="pagination" data-pages-length={pages.length}>
|
|
114
115
|
<li className={`page-item ${!showPreviousPage ? "disabled" : ""}`} key="page-first">
|
|
115
116
|
{!showPreviousPage &&
|
|
116
|
-
|
|
117
|
+
<Text>⇤</Text>
|
|
117
118
|
}
|
|
118
119
|
{showPreviousPage &&
|
|
119
|
-
<Link
|
|
120
|
-
|
|
120
|
+
<Link dataSet={{class: "page-link"}} to={this.pagePath(1)}>
|
|
121
|
+
<Text>⇤</Text>
|
|
121
122
|
</Link>
|
|
122
123
|
}
|
|
123
124
|
</li>
|
|
124
125
|
<li className={`page-item ${!showFirstPage ? "disabled" : ""}`} key="page-previous">
|
|
125
126
|
{!showFirstPage &&
|
|
126
|
-
|
|
127
|
+
<Text>←</Text>
|
|
127
128
|
}
|
|
128
129
|
{showFirstPage &&
|
|
129
|
-
<Link
|
|
130
|
-
|
|
130
|
+
<Link dataSet={{class: "page-link"}} to={this.previousPagePath()}>
|
|
131
|
+
<Text>←</Text>
|
|
131
132
|
</Link>
|
|
132
133
|
}
|
|
133
134
|
</li>
|
|
@@ -147,8 +148,8 @@ export default memo(shapeComponent(class ApiMakerBootstrapPaginate extends BaseC
|
|
|
147
148
|
page
|
|
148
149
|
}
|
|
149
150
|
{this.isPageActiveClass(page) == "not-active" &&
|
|
150
|
-
<Link
|
|
151
|
-
{page}
|
|
151
|
+
<Link dataSet={{class: "page-link"}} to={this.pagePath(page)}>
|
|
152
|
+
<Text>{page}</Text>
|
|
152
153
|
</Link>
|
|
153
154
|
}
|
|
154
155
|
</li>
|
|
@@ -160,21 +161,21 @@ export default memo(shapeComponent(class ApiMakerBootstrapPaginate extends BaseC
|
|
|
160
161
|
}
|
|
161
162
|
<li className={`page-item ${!showNextPage ? "disabled" : ""}`} key="page-next">
|
|
162
163
|
{!showNextPage &&
|
|
163
|
-
|
|
164
|
+
<Text>→</Text>
|
|
164
165
|
}
|
|
165
166
|
{showNextPage &&
|
|
166
|
-
<Link
|
|
167
|
-
|
|
167
|
+
<Link dataSet={{class: "page-link"}} to={this.nextPagePath()}>
|
|
168
|
+
<Text>→</Text>
|
|
168
169
|
</Link>
|
|
169
170
|
}
|
|
170
171
|
</li>
|
|
171
172
|
<li className={`page-item ${!showLastPage ? "disabled" : ""}`} key="page-last">
|
|
172
173
|
{!showLastPage &&
|
|
173
|
-
|
|
174
|
+
<Text>⇥</Text>
|
|
174
175
|
}
|
|
175
176
|
{showLastPage &&
|
|
176
|
-
<Link
|
|
177
|
-
|
|
177
|
+
<Link dataSet={{class: "page-link"}} to={this.pagePath(totalPages)}>
|
|
178
|
+
<Text>⇥</Text>
|
|
178
179
|
</Link>
|
|
179
180
|
}
|
|
180
181
|
</li>
|
|
@@ -3,6 +3,7 @@ import * as inflection from "inflection"
|
|
|
3
3
|
import PropTypes from "prop-types"
|
|
4
4
|
import qs from "qs"
|
|
5
5
|
import {memo} from "react"
|
|
6
|
+
import {Text} from "react-native"
|
|
6
7
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
7
8
|
import urlEncode from "../url-encode.mjs"
|
|
8
9
|
|
|
@@ -57,25 +58,22 @@ export default memo(shapeComponent(class ApiMakerBootstrapSortLink extends BaseC
|
|
|
57
58
|
|
|
58
59
|
return (
|
|
59
60
|
<LinkComponent
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
dataSet={{
|
|
62
|
+
attribute,
|
|
63
|
+
class: className,
|
|
64
|
+
component: "api-maker--bootstrap--sort-link",
|
|
65
|
+
sortMode: this.sortMode()
|
|
66
|
+
}}
|
|
63
67
|
to={this.href()}
|
|
64
68
|
{...restProps}
|
|
65
69
|
>
|
|
66
|
-
|
|
70
|
+
<Text>
|
|
71
|
+
{this.title()}
|
|
72
|
+
</Text>
|
|
67
73
|
</LinkComponent>
|
|
68
74
|
)
|
|
69
75
|
}
|
|
70
76
|
|
|
71
|
-
className () {
|
|
72
|
-
const classNames = ["component-api-maker-bootstrap-sort-link"]
|
|
73
|
-
|
|
74
|
-
if (this.props.className) classNames.push(this.props.className)
|
|
75
|
-
|
|
76
|
-
return classNames.join(" ")
|
|
77
|
-
}
|
|
78
|
-
|
|
79
77
|
linkComponent = () => this.props.linkComponent || Link
|
|
80
78
|
|
|
81
79
|
qParams() {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as inflection from "inflection"
|
|
2
|
+
|
|
3
|
+
export default function dataSetToAttributes(dataSet) {
|
|
4
|
+
const result = {}
|
|
5
|
+
|
|
6
|
+
for (const key in dataSet) {
|
|
7
|
+
const dasherizedKey = `data-${inflection.dasherize(inflection.underscore(key))}`
|
|
8
|
+
|
|
9
|
+
result[dasherizedKey] = dataSet[key]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return result
|
|
13
|
+
}
|
package/src/link.jsx
CHANGED
|
@@ -1,27 +1,61 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BaseComponent from "./base-component"
|
|
2
|
+
import dataSetToAttributes from "./data-set-to-attributes.mjs"
|
|
3
|
+
import {memo} from "react"
|
|
4
|
+
import {Platform, Pressable} from "react-native"
|
|
5
|
+
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
2
6
|
|
|
3
|
-
export default class Link extends
|
|
7
|
+
export default memo(shapeComponent(class Link extends BaseComponent {
|
|
4
8
|
render() {
|
|
5
|
-
const {to, onClick, ...restProps} = this.props
|
|
9
|
+
const {dataSet, to, onClick, onPress, ...restProps} = this.props
|
|
10
|
+
|
|
11
|
+
if (Platform.OS == "web") {
|
|
12
|
+
return (
|
|
13
|
+
<a {...dataSetToAttributes(dataSet)} href={to} {...restProps} onClick={this.tt.onLinkClicked} />
|
|
14
|
+
)
|
|
15
|
+
}
|
|
6
16
|
|
|
7
17
|
return (
|
|
8
|
-
<
|
|
18
|
+
<Pressable dataSet={dataSet} onPress={this.tt.onPress} {...restProps} />
|
|
9
19
|
)
|
|
10
20
|
}
|
|
11
21
|
|
|
12
22
|
onLinkClicked = (e, ...restArgs) => {
|
|
13
|
-
const {onClick} = this.props
|
|
23
|
+
const {onClick, onPress} = this.props
|
|
14
24
|
|
|
15
|
-
if (onClick)
|
|
25
|
+
if (onClick) {
|
|
26
|
+
onClick(e, ...restArgs)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (onPress) {
|
|
30
|
+
onPress(e, ...restArgs)
|
|
31
|
+
}
|
|
16
32
|
|
|
17
33
|
if (!e.defaultPrevented && !e.ctrlKey && !e.metaKey) {
|
|
18
34
|
e.preventDefault()
|
|
19
35
|
|
|
20
|
-
|
|
36
|
+
this.redirect()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
onPress() {
|
|
41
|
+
const {onClick, onPress} = this.props
|
|
21
42
|
|
|
22
|
-
|
|
43
|
+
if (onClick) {
|
|
44
|
+
onClick(e, ...restArgs)
|
|
45
|
+
}
|
|
23
46
|
|
|
24
|
-
|
|
47
|
+
if (onPress) {
|
|
48
|
+
onPress(e, ...restArgs)
|
|
25
49
|
}
|
|
50
|
+
|
|
51
|
+
this.redirect()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
redirect() {
|
|
55
|
+
const history = globalThis.apiMakerConfigGlobal?.history
|
|
56
|
+
|
|
57
|
+
if (!history) throw new Error("History hasn't been set in the API maker configuration")
|
|
58
|
+
|
|
59
|
+
history.push(this.props.to)
|
|
26
60
|
}
|
|
27
|
-
}
|
|
61
|
+
}))
|
package/src/router/route.jsx
CHANGED
|
@@ -20,13 +20,14 @@ const Route = memo(shapeComponent(class Route extends BaseComponent {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
static propTypes = propTypesExact({
|
|
23
|
+
children: PropTypes.node,
|
|
23
24
|
component: PropTypes.string,
|
|
24
25
|
componentPath: PropTypes.string,
|
|
25
26
|
exact: PropTypes.bool.isRequired,
|
|
26
27
|
fallback: PropTypes.bool.isRequired,
|
|
27
28
|
includeInPath: PropTypes.bool.isRequired,
|
|
28
29
|
onMatch: PropTypes.func,
|
|
29
|
-
path: PropTypes.string
|
|
30
|
+
path: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(RegExp)])
|
|
30
31
|
})
|
|
31
32
|
|
|
32
33
|
match = null
|
|
@@ -39,17 +40,14 @@ const Route = memo(shapeComponent(class Route extends BaseComponent {
|
|
|
39
40
|
const givenRoute = useContext(RouteContext)
|
|
40
41
|
const {pathShown} = switchGroup.s
|
|
41
42
|
|
|
43
|
+
this.debug = false
|
|
44
|
+
this.log(() => ({givenRoute}))
|
|
45
|
+
|
|
42
46
|
this.requireComponent = useContext(RequireComponentContext)
|
|
43
47
|
this.currentParams = useContext(ParamsContext)
|
|
44
48
|
this.currentPath = useContext(CurrentPathContext)
|
|
45
49
|
this.switchGroup = switchGroup
|
|
46
|
-
|
|
47
|
-
this.routeParts = useMemo(() => {
|
|
48
|
-
let routeParts = givenRoute?.split("/")
|
|
49
|
-
|
|
50
|
-
return routeParts
|
|
51
|
-
}, [path, givenRoute])
|
|
52
|
-
|
|
50
|
+
this.routeParts = useMemo(() => givenRoute?.split("/"), [path, givenRoute])
|
|
53
51
|
this.pathParts = useMemo(() => path?.split("/"), [path])
|
|
54
52
|
|
|
55
53
|
this.newRouteParts = useMemo(
|
|
@@ -79,7 +77,9 @@ const Route = memo(shapeComponent(class Route extends BaseComponent {
|
|
|
79
77
|
this.props.onMatch()
|
|
80
78
|
}
|
|
81
79
|
|
|
82
|
-
this.
|
|
80
|
+
if ((!this.props.children && this.props.path) || this.props.component || this.props.componentPath) {
|
|
81
|
+
this.loadComponent()
|
|
82
|
+
}
|
|
83
83
|
}
|
|
84
84
|
}, [path, pathShown, this.s.matches])
|
|
85
85
|
}
|
|
@@ -111,11 +111,14 @@ const Route = memo(shapeComponent(class Route extends BaseComponent {
|
|
|
111
111
|
const params = {}
|
|
112
112
|
const componentPathParts = [...this.currentPath]
|
|
113
113
|
|
|
114
|
+
this.log(() => [this.props.path, "Start generating component paths", JSON.stringify(componentPathParts)])
|
|
115
|
+
|
|
114
116
|
for (const pathPartIndex in this.pathParts) {
|
|
115
117
|
const pathPart = this.pathParts[pathPartIndex]
|
|
116
118
|
const translatedPathPart = I18n.t(`routes.${pathPart}`, {defaultValue: pathPart})
|
|
117
119
|
|
|
118
120
|
if (!(pathPartIndex in this.routeParts)) {
|
|
121
|
+
this.log(() => `No match for: ${pathPartIndex}`)
|
|
119
122
|
matches = false
|
|
120
123
|
break
|
|
121
124
|
}
|
|
@@ -135,6 +138,7 @@ const Route = memo(shapeComponent(class Route extends BaseComponent {
|
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
if (exact && newRouteParts.length > 0) {
|
|
141
|
+
this.log(() => ["Exact and more route parts", {newRouteParts, pathParts: this.pathParts, routeParts: this.routeParts}])
|
|
138
142
|
matches = false
|
|
139
143
|
} else if (matches && path) {
|
|
140
144
|
matches = true
|
|
@@ -148,6 +152,8 @@ const Route = memo(shapeComponent(class Route extends BaseComponent {
|
|
|
148
152
|
matches = true
|
|
149
153
|
}
|
|
150
154
|
|
|
155
|
+
this.log(() => [this.props.path, "End generating component paths", JSON.stringify(componentPathParts), {matches}])
|
|
156
|
+
|
|
151
157
|
if (matches) {
|
|
152
158
|
if (component && includeInPath) {
|
|
153
159
|
componentPathParts.push(component)
|
|
@@ -169,6 +175,8 @@ const Route = memo(shapeComponent(class Route extends BaseComponent {
|
|
|
169
175
|
const actualComponentPath = this.props.componentPath || this.tt.componentPathParts.join("/")
|
|
170
176
|
let Component
|
|
171
177
|
|
|
178
|
+
this.log(() => ["loadComponent", {componentPath: this.props.componentPath, componentPathParts: this.componentPathParts, actualComponentPath}])
|
|
179
|
+
|
|
172
180
|
try {
|
|
173
181
|
const componentImport = await this.tt.requireComponent({routeDefinition: {component: actualComponentPath}})
|
|
174
182
|
|
|
@@ -182,9 +190,19 @@ const Route = memo(shapeComponent(class Route extends BaseComponent {
|
|
|
182
190
|
this.setState({Component, componentNotFound: !Component})
|
|
183
191
|
}
|
|
184
192
|
|
|
193
|
+
log(callbackArgs) {
|
|
194
|
+
if (this.debug) {
|
|
195
|
+
let args = callbackArgs()
|
|
196
|
+
|
|
197
|
+
if (!Array.isArray(args)) args = [args]
|
|
198
|
+
|
|
199
|
+
console.log(...args)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
185
203
|
render() {
|
|
186
204
|
const {componentPathParts, match, newParams, newRouteParts} = this.tt
|
|
187
|
-
const {component, path} = this.props
|
|
205
|
+
const {children, component, path} = this.props
|
|
188
206
|
const {Component, componentNotFound, matches} = this.s
|
|
189
207
|
|
|
190
208
|
if (!matches || !this.hasSwitchMatch()) {
|
|
@@ -192,7 +210,7 @@ const Route = memo(shapeComponent(class Route extends BaseComponent {
|
|
|
192
210
|
return null
|
|
193
211
|
}
|
|
194
212
|
|
|
195
|
-
if (!Component && !componentNotFound) {
|
|
213
|
+
if (!Component && !children && !componentNotFound) {
|
|
196
214
|
// Route is matching but hasn't been loaded yet.
|
|
197
215
|
return (
|
|
198
216
|
<div>
|
|
@@ -201,7 +219,7 @@ const Route = memo(shapeComponent(class Route extends BaseComponent {
|
|
|
201
219
|
)
|
|
202
220
|
}
|
|
203
221
|
|
|
204
|
-
if (!Component && componentNotFound) {
|
|
222
|
+
if (!Component && !children && componentNotFound) {
|
|
205
223
|
// Don't render anything if the component couldn't be found.
|
|
206
224
|
return null
|
|
207
225
|
}
|
|
@@ -211,7 +229,8 @@ const Route = memo(shapeComponent(class Route extends BaseComponent {
|
|
|
211
229
|
<RouteContext.Provider value={newRouteParts.join("/")}>
|
|
212
230
|
<ParamsContext.Provider value={newParams}>
|
|
213
231
|
<Switch name={`route-group-${path}`} single={false}>
|
|
214
|
-
<Component match={match} />
|
|
232
|
+
{Component && <Component match={match} />}
|
|
233
|
+
{children}
|
|
215
234
|
</Switch>
|
|
216
235
|
</ParamsContext.Provider>
|
|
217
236
|
</RouteContext.Provider>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {Pressable, Text} from "react-native"
|
|
1
2
|
import BaseComponent from "../base-component"
|
|
2
3
|
import EditPage from "./edit-page"
|
|
3
4
|
import hasEditConfig from "./has-edit-config.js"
|
|
@@ -92,8 +93,10 @@ export default memo(shapeComponent(class ApiMakerSuperAdmin extends BaseComponen
|
|
|
92
93
|
{modelClass && pageToShow == "index" &&
|
|
93
94
|
<>
|
|
94
95
|
{canCan?.can("new", modelClass) && hasEditConfig(modelClass) &&
|
|
95
|
-
<Link
|
|
96
|
-
|
|
96
|
+
<Link dataSet={{class: "create-new-model-link"}} to={Params.withParams({model: modelName, mode: "new"})}>
|
|
97
|
+
<Text>
|
|
98
|
+
Create new
|
|
99
|
+
</Text>
|
|
97
100
|
</Link>
|
|
98
101
|
}
|
|
99
102
|
</>
|
|
@@ -101,14 +104,18 @@ export default memo(shapeComponent(class ApiMakerSuperAdmin extends BaseComponen
|
|
|
101
104
|
{model && pageToShow == "show" &&
|
|
102
105
|
<>
|
|
103
106
|
{model.can("edit") && hasEditConfig(modelClass) &&
|
|
104
|
-
<Link
|
|
105
|
-
|
|
107
|
+
<Link dataSet={{class: "edit-model-link"}} to={Params.withParams({model: modelName, model_id: modelId, mode: "edit"})}>
|
|
108
|
+
<Text>
|
|
109
|
+
Edit
|
|
110
|
+
</Text>
|
|
106
111
|
</Link>
|
|
107
112
|
}
|
|
108
113
|
{model.can("destroy") &&
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
114
|
+
<Pressable dataSet={{class: "destroy-model-link"}} onPress={this.tt.onDestroyClicked}>
|
|
115
|
+
<Text>
|
|
116
|
+
Delete
|
|
117
|
+
</Text>
|
|
118
|
+
</Pressable>
|
|
112
119
|
}
|
|
113
120
|
</>
|
|
114
121
|
}
|
|
@@ -151,9 +158,7 @@ export default memo(shapeComponent(class ApiMakerSuperAdmin extends BaseComponen
|
|
|
151
158
|
)
|
|
152
159
|
}
|
|
153
160
|
|
|
154
|
-
onDestroyClicked = async (
|
|
155
|
-
e.preventDefault()
|
|
156
|
-
|
|
161
|
+
onDestroyClicked = async () => {
|
|
157
162
|
if (!confirm("Are you sure?")) {
|
|
158
163
|
return
|
|
159
164
|
}
|
|
@@ -9,7 +9,7 @@ import PropTypesExact from "prop-types-exact"
|
|
|
9
9
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
10
10
|
import useCurrentUser from "../../../use-current-user"
|
|
11
11
|
import useI18n from "i18n-on-steroids/src/use-i18n.mjs"
|
|
12
|
-
import {View} from "react-native"
|
|
12
|
+
import {Text, View} from "react-native"
|
|
13
13
|
|
|
14
14
|
export default memo(shapeComponent(class ComponentsAdminLayoutMenu extends BaseComponent {
|
|
15
15
|
static propTypes = PropTypesExact({
|
|
@@ -33,8 +33,10 @@ export default memo(shapeComponent(class ComponentsAdminLayoutMenu extends BaseC
|
|
|
33
33
|
return (
|
|
34
34
|
<View dataSet={{component: "super-admin--layout--menu", triggered}}>
|
|
35
35
|
<div className="menu-logo">
|
|
36
|
-
<Link
|
|
37
|
-
|
|
36
|
+
<Link dataSet={{class: "menu-logo-link"}} to={Params.withParams({})}>
|
|
37
|
+
<Text>
|
|
38
|
+
Admin
|
|
39
|
+
</Text>
|
|
38
40
|
</Link>
|
|
39
41
|
</div>
|
|
40
42
|
<div className="menu-items-center">
|
|
@@ -5,6 +5,7 @@ import Link from "../../../../link"
|
|
|
5
5
|
import {memo} from "react"
|
|
6
6
|
import PropTypes from "prop-types"
|
|
7
7
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
8
|
+
import {Text} from "react-native"
|
|
8
9
|
|
|
9
10
|
export default memo(shapeComponent(class ComponentsAdminLayoutMenuMenuItem extends BaseComponent {
|
|
10
11
|
static propTypes = {
|
|
@@ -14,20 +15,56 @@ export default memo(shapeComponent(class ComponentsAdminLayoutMenuMenuItem exten
|
|
|
14
15
|
label: PropTypes.node
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
setup() {
|
|
19
|
+
this.useStates({
|
|
20
|
+
hover: false
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
17
24
|
render() {
|
|
18
25
|
const {active, children, className, icon, identifier, label, to, ...restProps} = this.props
|
|
26
|
+
const {hover} = this.s
|
|
27
|
+
const textStyle = {}
|
|
28
|
+
const style = {
|
|
29
|
+
display: "flex",
|
|
30
|
+
width: "80%",
|
|
31
|
+
alignItems: "center",
|
|
32
|
+
paddingTop: 10,
|
|
33
|
+
paddingRight: 14,
|
|
34
|
+
paddingBottom: 10,
|
|
35
|
+
paddingLeft: 14,
|
|
36
|
+
marginLeft: "auto",
|
|
37
|
+
marginRight: "auto"
|
|
38
|
+
}
|
|
39
|
+
const isActive = active === true || active == identifier
|
|
40
|
+
|
|
41
|
+
if (isActive || hover) {
|
|
42
|
+
style.background = "#323435"
|
|
43
|
+
style.borderRadius = 7
|
|
44
|
+
textStyle.color = "#b9b9bb"
|
|
45
|
+
} else {
|
|
46
|
+
textStyle.color = "#6f6f71"
|
|
47
|
+
}
|
|
19
48
|
|
|
20
49
|
return (
|
|
21
50
|
<Link
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
51
|
+
dataSet={{
|
|
52
|
+
active: isActive,
|
|
53
|
+
class: classNames("components--admin--layout--menu--menu-item", className),
|
|
54
|
+
identifier
|
|
55
|
+
}}
|
|
56
|
+
onPointerEnter={this.tt.onPointerEnter}
|
|
57
|
+
onPointerLeave={this.tt.onPointerLeave}
|
|
58
|
+
style={style}
|
|
25
59
|
to={to || "#"}
|
|
26
60
|
{...restProps}
|
|
27
61
|
>
|
|
28
|
-
<i className={`fa fa-fw fa-${icon} menu-item-icon`} />
|
|
29
|
-
{children || label}
|
|
62
|
+
<i className={`fa fa-fw fa-${icon} menu-item-icon`} style={{color: textStyle.color}} />
|
|
63
|
+
{children || <Text style={textStyle}>{label}</Text>}
|
|
30
64
|
</Link>
|
|
31
65
|
)
|
|
32
66
|
}
|
|
67
|
+
|
|
68
|
+
onPointerEnter = () => this.setState({hover: true})
|
|
69
|
+
onPointerLeave = () => this.setState({hover: false})
|
|
33
70
|
}))
|
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
display: flex;
|
|
3
|
-
width: 80%;
|
|
4
|
-
align-items: center;
|
|
5
|
-
padding: 10px 14px;
|
|
6
|
-
margin-right: auto;
|
|
7
|
-
margin-left: auto;
|
|
8
|
-
text-decoration: none;
|
|
9
|
-
|
|
10
|
-
&:link,
|
|
11
|
-
&:visited {
|
|
12
|
-
color: #6f6f71;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
&[data-active="true"],
|
|
16
|
-
&:hover {
|
|
17
|
-
background: #323435;
|
|
18
|
-
border-radius: 7px;
|
|
19
|
-
color: #b9b9bb;
|
|
20
|
-
}
|
|
21
|
-
|
|
1
|
+
[data-class="components--admin--layout--menu--menu-item"] {
|
|
22
2
|
.menu-item-icon {
|
|
23
3
|
margin-right: 4px;
|
|
24
4
|
font-size: 12px;
|
|
@@ -7,7 +7,7 @@ import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
|
7
7
|
import ShowReflectionLink from "./show-reflection-link"
|
|
8
8
|
import useI18n from "i18n-on-steroids/src/use-i18n.mjs"
|
|
9
9
|
import useQueryParams from "on-location-changed/src/use-query-params"
|
|
10
|
-
import {View} from "react-native"
|
|
10
|
+
import {Text, View} from "react-native"
|
|
11
11
|
|
|
12
12
|
export default memo(shapeComponent(class ApiMakerSuperAdminShowNav extends BaseComponent {
|
|
13
13
|
static propTypes = PropTypesExact({
|
|
@@ -25,7 +25,9 @@ export default memo(shapeComponent(class ApiMakerSuperAdminShowNav extends BaseC
|
|
|
25
25
|
<View dataSet={{component: "super-admin--show-nav"}}>
|
|
26
26
|
<View>
|
|
27
27
|
<Link to={Params.withParams({model: modelClass.modelClassData().name, model_id: queryParams.model_id})}>
|
|
28
|
-
|
|
28
|
+
<Text>
|
|
29
|
+
{t(".general", {defaultValue: "General"})}
|
|
30
|
+
</Text>
|
|
29
31
|
</Link>
|
|
30
32
|
</View>
|
|
31
33
|
{model && reflections.filter((reflection) => reflection.macro() == "has_many").map((reflection) =>
|
|
@@ -5,6 +5,7 @@ import Link from "../../link"
|
|
|
5
5
|
import {memo} from "react"
|
|
6
6
|
import Params from "../../params"
|
|
7
7
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
8
|
+
import {Text} from "react-native"
|
|
8
9
|
|
|
9
10
|
export default memo(shapeComponent(class ApiMakerSuperAdminShowPageBelongsToAttributeRow extends BaseComponent {
|
|
10
11
|
render() {
|
|
@@ -16,8 +17,10 @@ export default memo(shapeComponent(class ApiMakerSuperAdminShowPageBelongsToAttr
|
|
|
16
17
|
<AttributeRow label={modelClass.humanAttributeName(inflection.camelize(reflection.name(), true))}>
|
|
17
18
|
{subModel &&
|
|
18
19
|
<Link to={Params.withParams({model: subModel.modelClassData().name, model_id: subModel.primaryKey()})}>
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
<Text>
|
|
21
|
+
{subModel && "name" in subModel && subModel.name()}
|
|
22
|
+
{subModel && !("name" in subModel) && subModel?.id()}
|
|
23
|
+
</Text>
|
|
21
24
|
</Link>
|
|
22
25
|
}
|
|
23
26
|
</AttributeRow>
|
|
@@ -38,7 +38,7 @@ export default memo(shapeComponent(class SuperAdminShowReflectionActions extends
|
|
|
38
38
|
return (
|
|
39
39
|
<>
|
|
40
40
|
{canCan?.can("new", reflection.modelClass()) &&
|
|
41
|
-
<Link
|
|
41
|
+
<Link dataSet={{class: "create-new-model-link"}} to={Params.withParams(linkParams)}>
|
|
42
42
|
Create new
|
|
43
43
|
</Link>
|
|
44
44
|
}
|
|
@@ -3,6 +3,7 @@ import {digg} from "diggerize"
|
|
|
3
3
|
import Link from "../link"
|
|
4
4
|
import {memo} from "react"
|
|
5
5
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
6
|
+
import {Text} from "react-native"
|
|
6
7
|
import {useMemo} from "react"
|
|
7
8
|
|
|
8
9
|
export default memo(shapeComponent(class ApiMakerSuperAdminShowReflectionLink extends BaseComponent {
|
|
@@ -28,7 +29,9 @@ export default memo(shapeComponent(class ApiMakerSuperAdminShowReflectionLink ex
|
|
|
28
29
|
|
|
29
30
|
return (
|
|
30
31
|
<Link to={Params.withParams({model: digg(modelClass.modelClassData(), "name"), model_id: model.primaryKey(), model_reflection: reflection.name()})}>
|
|
31
|
-
|
|
32
|
+
<Text>
|
|
33
|
+
{modelClass.humanAttributeName(reflection.name())} ({count})
|
|
34
|
+
</Text>
|
|
32
35
|
</Link>
|
|
33
36
|
)
|
|
34
37
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BaseComponent from "../../base-component"
|
|
2
|
+
import {memo} from "react"
|
|
3
|
+
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
4
|
+
import {View} from "react-native"
|
|
5
|
+
|
|
6
|
+
export default memo(shapeComponent(class SharedTableColumn extends BaseComponent {
|
|
7
|
+
render() {
|
|
8
|
+
return (
|
|
9
|
+
<View {...this.props} />
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
}))
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import BaseComponent from "../../base-component"
|
|
2
|
+
import {FlatList} from "react-native"
|
|
3
|
+
import {memo} from "react"
|
|
4
|
+
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
5
|
+
|
|
6
|
+
export default memo(shapeComponent(class SharedTagble extends BaseComponent {
|
|
7
|
+
render() {
|
|
8
|
+
const {style, ...restProps} = this.props
|
|
9
|
+
const actualStyle = Object.assign(
|
|
10
|
+
{width: "100%"},
|
|
11
|
+
style
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<FlatList style={actualStyle} {...restProps} />
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
}))
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BaseComponent from "../../base-component"
|
|
2
|
+
import {memo} from "react"
|
|
3
|
+
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
4
|
+
import {View} from "react-native"
|
|
5
|
+
|
|
6
|
+
export default memo(shapeComponent(class SharedTableHeader extends BaseComponent {
|
|
7
|
+
render() {
|
|
8
|
+
return (
|
|
9
|
+
<View {...this.props} />
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
}))
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import BaseComponent from "../../base-component"
|
|
2
|
+
import {memo} from "react"
|
|
3
|
+
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
4
|
+
import {View} from "react-native"
|
|
5
|
+
|
|
6
|
+
export default memo(shapeComponent(class SharedTableRow extends BaseComponent {
|
|
7
|
+
render() {
|
|
8
|
+
const {style, ...restProps} = this.props
|
|
9
|
+
const actualStyle = Object.assign(
|
|
10
|
+
{
|
|
11
|
+
flexDirection: "row"
|
|
12
|
+
},
|
|
13
|
+
style
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<View style={actualStyle} {...restProps} />
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
}))
|