@kaspernj/api-maker 1.0.387 → 1.0.389
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 +1 -1
- package/src/super-admin/config-reader.jsx +13 -5
- package/src/super-admin/index-page.jsx +3 -2
- package/src/super-admin/layout/header/index.jsx +79 -11
- package/src/super-admin/layout/header/style.scss +3 -54
- package/src/super-admin/layout/index.jsx +32 -25
- package/src/super-admin/layout/menu/index.jsx +14 -6
- package/src/super-admin/layout/menu/style.scss +1 -1
- package/src/super-admin/layout/no-access.jsx +10 -5
- package/src/super-admin/layout/style.scss +2 -2
- package/src/super-admin/model-class-table.jsx +4 -1
- package/src/super-admin/show-nav.jsx +10 -7
- package/src/super-admin/show-page/index.jsx +6 -3
- package/src/super-admin/show-reflection-page.jsx +5 -3
- package/src/table/table.jsx +4 -2
- package/src/table/with-breakpoint.jsx +0 -9
- /package/src/{table/use-breakpoint.mjs → use-breakpoint.mjs} +0 -0
package/package.json
CHANGED
|
@@ -36,8 +36,9 @@ export default class ApiMakerSuperAdminConfigReader {
|
|
|
36
36
|
|
|
37
37
|
defaultAttributesToShow() {
|
|
38
38
|
const attributesToShow = []
|
|
39
|
+
const {columns} = this.defaultTableColumns()
|
|
39
40
|
|
|
40
|
-
for (const column of
|
|
41
|
+
for (const column of columns) {
|
|
41
42
|
attributesToShow.push(digg(column, "attribute"))
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -48,16 +49,22 @@ export default class ApiMakerSuperAdminConfigReader {
|
|
|
48
49
|
const {modelConfig} = digs(this, "modelConfig")
|
|
49
50
|
|
|
50
51
|
if (modelConfig?.table?.columns) {
|
|
51
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
columns: modelConfig.table.columns()
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
return this.defaultTableColumns()
|
|
52
57
|
}
|
|
53
|
-
|
|
54
|
-
return this.defaultTableColumns()
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
defaultTableColumns() {
|
|
58
61
|
const {modelClass} = digs(this, "modelClass")
|
|
59
62
|
const attributes = modelClass.attributes()
|
|
60
63
|
const columns = []
|
|
64
|
+
const select = {}
|
|
65
|
+
const modelClassSelect = []
|
|
66
|
+
|
|
67
|
+
select[modelClass.modelClassData().name] = modelClassSelect
|
|
61
68
|
|
|
62
69
|
for (const attribute of attributes) {
|
|
63
70
|
if (!attribute.isSelectedByDefault() && attribute.name() != "name") {
|
|
@@ -75,9 +82,10 @@ export default class ApiMakerSuperAdminConfigReader {
|
|
|
75
82
|
column.sortKey = `currentTranslation${camelizedName}`
|
|
76
83
|
}
|
|
77
84
|
|
|
85
|
+
modelClassSelect.push(camelizedName)
|
|
78
86
|
columns.push(column)
|
|
79
87
|
}
|
|
80
88
|
|
|
81
|
-
return columns
|
|
89
|
+
return {columns, select}
|
|
82
90
|
}
|
|
83
91
|
}
|
|
@@ -3,6 +3,7 @@ import {memo} from "react"
|
|
|
3
3
|
import ModelClassTable from "./model-class-table"
|
|
4
4
|
import PropTypes from "prop-types"
|
|
5
5
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
6
|
+
import {View} from "react-native"
|
|
6
7
|
|
|
7
8
|
export default memo(shapeComponent(class ApiMakerSuperAdminIndexPage extends BaseComponent {
|
|
8
9
|
static propTypes = {
|
|
@@ -13,9 +14,9 @@ export default memo(shapeComponent(class ApiMakerSuperAdminIndexPage extends Bas
|
|
|
13
14
|
const {modelClass} = this.props
|
|
14
15
|
|
|
15
16
|
return (
|
|
16
|
-
<
|
|
17
|
+
<View dataSet={{component: "super-admin--index-page"}}>
|
|
17
18
|
<ModelClassTable modelClass={modelClass} />
|
|
18
|
-
</
|
|
19
|
+
</View>
|
|
19
20
|
)
|
|
20
21
|
}
|
|
21
22
|
}))
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import "./style"
|
|
2
2
|
import BaseComponent from "../../../base-component"
|
|
3
|
-
import EventListener from "../../../event-listener"
|
|
4
3
|
import {memo, useRef} from "react"
|
|
5
4
|
import PropTypes from "prop-types"
|
|
6
5
|
import PropTypesExact from "prop-types-exact"
|
|
7
6
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
7
|
+
import {Text, View} from "react-native"
|
|
8
|
+
import useBreakpoint from "../../../use-breakpoint"
|
|
9
|
+
import useEventListener from "../../../use-event-listener"
|
|
8
10
|
|
|
9
11
|
export default memo(shapeComponent(class ApiMakerSuperAdminLayoutHeader extends BaseComponent {
|
|
10
12
|
static propTypes = PropTypesExact({
|
|
@@ -14,27 +16,93 @@ export default memo(shapeComponent(class ApiMakerSuperAdminLayoutHeader extends
|
|
|
14
16
|
})
|
|
15
17
|
|
|
16
18
|
setup() {
|
|
19
|
+
const {breakpoint} = useBreakpoint()
|
|
20
|
+
|
|
17
21
|
this.headerActionsRef = useRef()
|
|
22
|
+
this.setInstance({breakpoint})
|
|
18
23
|
this.useStates({
|
|
19
24
|
headerActionsActive: false
|
|
20
25
|
})
|
|
26
|
+
|
|
27
|
+
useEventListener(window, "mouseup", this.tt.onWindowMouseUp)
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
render() {
|
|
31
|
+
const {breakpoint} = this.tt
|
|
24
32
|
const {actions, onTriggerMenu, title} = this.props
|
|
25
33
|
|
|
34
|
+
const headerStyle = {
|
|
35
|
+
display: "flex",
|
|
36
|
+
flexDirection: "row",
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
zIndex: 9,
|
|
39
|
+
height: 100,
|
|
40
|
+
paddingRight: 30,
|
|
41
|
+
paddingLeft: 30,
|
|
42
|
+
backgroundColor: "#fff"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const headerActionsContainerStyle = {}
|
|
46
|
+
const headerActionsStyle = {}
|
|
47
|
+
|
|
48
|
+
if (breakpoint == "xs" || breakpoint == "sm") {
|
|
49
|
+
headerStyle.position = "absolute"
|
|
50
|
+
headerStyle.width = "100%"
|
|
51
|
+
|
|
52
|
+
Object.assign(headerActionsContainerStyle, {
|
|
53
|
+
position: "fixed",
|
|
54
|
+
top: 0,
|
|
55
|
+
left: 0,
|
|
56
|
+
|
|
57
|
+
display: "flex",
|
|
58
|
+
width: "100vw",
|
|
59
|
+
height: "100vh",
|
|
60
|
+
alignItems: "center",
|
|
61
|
+
justifyContent: "center",
|
|
62
|
+
|
|
63
|
+
background: "rgba(#000, .8)"
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
if (!this.s.headerActionsActive) {
|
|
67
|
+
headerActionsContainerStyle.display = "none"
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
Object.assign(headerActionsStyle, {
|
|
71
|
+
minWidth: "80vw",
|
|
72
|
+
maxWidth: "100vw",
|
|
73
|
+
backgroundColor: "#fff"
|
|
74
|
+
})
|
|
75
|
+
} else if (breakpoint == "md") {
|
|
76
|
+
headerStyle.position = "fixed"
|
|
77
|
+
headerStyle.left = 250
|
|
78
|
+
headerStyle.width = "calc(100% - 250px)"
|
|
79
|
+
} else if (breakpoint == "lg" || breakpoint == "xl" || breakpoint == "xxl") {
|
|
80
|
+
headerStyle.position = "fixed"
|
|
81
|
+
headerStyle.left = 290
|
|
82
|
+
headerStyle.width = "calc(100% - 290px)"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (breakpoint == "md" || breakpoint == "lg" || breakpoint == "xl" || breakpoint == "xxl") {
|
|
86
|
+
headerActionsContainerStyle.marginLeft = "auto"
|
|
87
|
+
}
|
|
88
|
+
|
|
26
89
|
return (
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
90
|
+
<View dataSet={{component: "super-admin--layout--header"}} style={headerStyle}>
|
|
91
|
+
<View dataSet={{class: "header-title-container"}}>
|
|
92
|
+
<Text style={{color: "#282a33", fontSize: 22}}>
|
|
93
|
+
{title}
|
|
94
|
+
</Text>
|
|
95
|
+
</View>
|
|
32
96
|
{actions &&
|
|
33
|
-
<
|
|
34
|
-
<
|
|
97
|
+
<View dataSet={{active: this.s.headerActionsActive, class: "header-actions-container"}} style={headerActionsContainerStyle}>
|
|
98
|
+
<View
|
|
99
|
+
dataSet={{class: "header-actions"}}
|
|
100
|
+
ref={this.tt.headerActionsRef}
|
|
101
|
+
style={headerActionsStyle}
|
|
102
|
+
>
|
|
35
103
|
{actions}
|
|
36
|
-
</
|
|
37
|
-
</
|
|
104
|
+
</View>
|
|
105
|
+
</View>
|
|
38
106
|
}
|
|
39
107
|
<div className="burger-menu-container">
|
|
40
108
|
{actions &&
|
|
@@ -46,7 +114,7 @@ export default memo(shapeComponent(class ApiMakerSuperAdminLayoutHeader extends
|
|
|
46
114
|
<i className="fa fa-bars" />
|
|
47
115
|
</a>
|
|
48
116
|
</div>
|
|
49
|
-
</
|
|
117
|
+
</View>
|
|
50
118
|
)
|
|
51
119
|
}
|
|
52
120
|
|
|
@@ -1,42 +1,8 @@
|
|
|
1
1
|
@import "@kaspernj/api-maker/src/super-admin/stylesheets/variables";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
top: 0;
|
|
5
|
-
display: flex;
|
|
6
|
-
height: 100px;
|
|
7
|
-
align-items: center;
|
|
8
|
-
padding-right: 30px;
|
|
9
|
-
padding-left: 30px;
|
|
10
|
-
background: #fff;
|
|
11
|
-
color: #282a33;
|
|
12
|
-
|
|
3
|
+
[data-component="super-admin--layout--header"] {
|
|
13
4
|
@media (max-width: $sm-to) {
|
|
14
|
-
|
|
15
|
-
width: 100%;
|
|
16
|
-
|
|
17
|
-
.header-actions-container {
|
|
18
|
-
position: fixed;
|
|
19
|
-
top: 0;
|
|
20
|
-
left: 0;
|
|
21
|
-
|
|
22
|
-
display: flex;
|
|
23
|
-
width: 100vw;
|
|
24
|
-
height: 100vh;
|
|
25
|
-
align-items: center;
|
|
26
|
-
justify-content: center;
|
|
27
|
-
|
|
28
|
-
background: rgba(#000, .8);
|
|
29
|
-
|
|
30
|
-
&[data-active="false"] {
|
|
31
|
-
display: none;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.header-actions {
|
|
36
|
-
min-width: 80vw;
|
|
37
|
-
max-width: 100vw;
|
|
38
|
-
background: #fff;
|
|
39
|
-
|
|
5
|
+
[data-class="header-actions"] {
|
|
40
6
|
.action-button {
|
|
41
7
|
display: block;
|
|
42
8
|
padding: 11px;
|
|
@@ -63,15 +29,7 @@
|
|
|
63
29
|
}
|
|
64
30
|
|
|
65
31
|
@media (min-width: $md-from) {
|
|
66
|
-
|
|
67
|
-
left: 250px;
|
|
68
|
-
width: calc(100% - 250px);
|
|
69
|
-
|
|
70
|
-
.header-actions-container {
|
|
71
|
-
margin-left: auto;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.header-actions {
|
|
32
|
+
[data-class="header-actions"] {
|
|
75
33
|
.action-button {
|
|
76
34
|
display: inline-block;
|
|
77
35
|
padding: 7px 10px;
|
|
@@ -89,11 +47,6 @@
|
|
|
89
47
|
}
|
|
90
48
|
}
|
|
91
49
|
|
|
92
|
-
@media (min-width: $lg-from) {
|
|
93
|
-
left: 290px;
|
|
94
|
-
width: calc(100% - 290px);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
50
|
.burger-menu-container {
|
|
98
51
|
@media (max-width: $sm-to) {
|
|
99
52
|
margin-left: auto;
|
|
@@ -117,8 +70,4 @@
|
|
|
117
70
|
color: #1b1c1e;
|
|
118
71
|
}
|
|
119
72
|
}
|
|
120
|
-
|
|
121
|
-
.header-title-container {
|
|
122
|
-
font-size: 22px;
|
|
123
|
-
}
|
|
124
73
|
}
|
|
@@ -7,10 +7,11 @@ import Header from "./header"
|
|
|
7
7
|
import Menu from "./menu"
|
|
8
8
|
import PropTypes from "prop-types"
|
|
9
9
|
import PropTypesExact from "prop-types-exact"
|
|
10
|
-
import {memo,
|
|
10
|
+
import {memo, useMemo} from "react"
|
|
11
11
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
12
12
|
import useCurrentUser from "../../use-current-user"
|
|
13
|
-
import
|
|
13
|
+
import useI18n from "i18n-on-steroids/src/use-i18n.mjs"
|
|
14
|
+
import {View} from "react-native"
|
|
14
15
|
|
|
15
16
|
const NoAccess = React.lazy(() => import("./no-access"))
|
|
16
17
|
|
|
@@ -27,7 +28,21 @@ export default memo(shapeComponent(class ApiMakerSuperAdminLayout extends BaseCo
|
|
|
27
28
|
headerTitle: PropTypes.string
|
|
28
29
|
})
|
|
29
30
|
|
|
31
|
+
setup() {
|
|
32
|
+
const currentUser = useCurrentUser()
|
|
33
|
+
const {locale, t} = useI18n({namespace: "js.api_maker.super_admin.layout"})
|
|
34
|
+
|
|
35
|
+
this.useStates({menuTriggered: false})
|
|
36
|
+
this.setInstance({currentUser, t})
|
|
37
|
+
|
|
38
|
+
useMemo(() => {
|
|
39
|
+
CommandsPool.current().globalRequestData.layout = "admin"
|
|
40
|
+
CommandsPool.current().globalRequestData.locale = locale
|
|
41
|
+
}, [I18n.locale])
|
|
42
|
+
}
|
|
43
|
+
|
|
30
44
|
render() {
|
|
45
|
+
const {currentUser, t} = this.tt
|
|
31
46
|
const {
|
|
32
47
|
actions,
|
|
33
48
|
active,
|
|
@@ -39,14 +54,6 @@ export default memo(shapeComponent(class ApiMakerSuperAdminLayout extends BaseCo
|
|
|
39
54
|
menu,
|
|
40
55
|
...restProps
|
|
41
56
|
} = this.props
|
|
42
|
-
const s = useShape()
|
|
43
|
-
const currentUser = useCurrentUser()
|
|
44
|
-
|
|
45
|
-
useMemo(() => {
|
|
46
|
-
CommandsPool.current().globalRequestData.layout = "admin"
|
|
47
|
-
CommandsPool.current().globalRequestData.locale = I18n.locale
|
|
48
|
-
}, [I18n.locale])
|
|
49
|
-
|
|
50
57
|
const headTitle = headTitle || headerTitle
|
|
51
58
|
|
|
52
59
|
if (headTitle) {
|
|
@@ -55,38 +62,32 @@ export default memo(shapeComponent(class ApiMakerSuperAdminLayout extends BaseCo
|
|
|
55
62
|
document.title = "Wooftech"
|
|
56
63
|
}
|
|
57
64
|
|
|
58
|
-
const setMenuTriggered = s.useState("menuTriggered", false)
|
|
59
65
|
const noAccess = !currentUser
|
|
60
|
-
const onRequestMenuClose = useCallback(() => setMenuTriggered(false), [])
|
|
61
|
-
const onTriggerMenu = useCallback((e) => {
|
|
62
|
-
e.preventDefault()
|
|
63
|
-
setMenuTriggered(!s.state.menuTriggered)
|
|
64
|
-
}, [])
|
|
65
66
|
|
|
66
67
|
return (
|
|
67
|
-
<
|
|
68
|
+
<View dataSet={{component: "super-admin--layout", class: className, menuTriggered: this.s.menuTriggered}} {...restProps}>
|
|
68
69
|
<Menu
|
|
69
70
|
active={active}
|
|
70
71
|
noAccess={noAccess}
|
|
71
|
-
onRequestMenuClose={onRequestMenuClose}
|
|
72
|
-
triggered={s.
|
|
72
|
+
onRequestMenuClose={this.tt.onRequestMenuClose}
|
|
73
|
+
triggered={this.s.menuTriggered}
|
|
73
74
|
/>
|
|
74
|
-
<Header actions={actions} onTriggerMenu={onTriggerMenu} title={headerTitle} />
|
|
75
|
-
<
|
|
75
|
+
<Header actions={actions} onTriggerMenu={this.tt.onTriggerMenu} title={headerTitle} />
|
|
76
|
+
<View dataSet={{class: "app-layout-content-container"}}>
|
|
76
77
|
{noAccess &&
|
|
77
78
|
<>
|
|
78
79
|
<NoAccess />
|
|
79
80
|
{currentUser &&
|
|
80
81
|
<>
|
|
81
82
|
<div className="mb-4">
|
|
82
|
-
{
|
|
83
|
+
{t(".try_signing_out_and_in_with_a_different_user", {defaultValue: "Try signing in with a different user."})}
|
|
83
84
|
</div>
|
|
84
85
|
</>
|
|
85
86
|
}
|
|
86
87
|
{!currentUser &&
|
|
87
88
|
<>
|
|
88
89
|
<div className="mb-4">
|
|
89
|
-
{
|
|
90
|
+
{t(".try_signing_in", {defaultValue: "Try signing in."})}
|
|
90
91
|
</div>
|
|
91
92
|
{config.signInContent()}
|
|
92
93
|
</>
|
|
@@ -94,8 +95,14 @@ export default memo(shapeComponent(class ApiMakerSuperAdminLayout extends BaseCo
|
|
|
94
95
|
</>
|
|
95
96
|
}
|
|
96
97
|
{!noAccess && children}
|
|
97
|
-
</
|
|
98
|
-
</
|
|
98
|
+
</View>
|
|
99
|
+
</View>
|
|
99
100
|
)
|
|
100
101
|
}
|
|
102
|
+
|
|
103
|
+
onRequestMenuClose = () => this.setState({menuTriggered: false})
|
|
104
|
+
onTriggerMenu = (e) => {
|
|
105
|
+
e.preventDefault()
|
|
106
|
+
setMenuTriggered(!this.s.menuTriggered)
|
|
107
|
+
}
|
|
101
108
|
}))
|
|
@@ -8,6 +8,8 @@ import PropTypes from "prop-types"
|
|
|
8
8
|
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
|
+
import useI18n from "i18n-on-steroids/src/use-i18n.mjs"
|
|
12
|
+
import {View} from "react-native"
|
|
11
13
|
|
|
12
14
|
export default memo(shapeComponent(class ComponentsAdminLayoutMenu extends BaseComponent {
|
|
13
15
|
static propTypes = PropTypesExact({
|
|
@@ -17,13 +19,19 @@ export default memo(shapeComponent(class ComponentsAdminLayoutMenu extends BaseC
|
|
|
17
19
|
triggered: PropTypes.bool.isRequired
|
|
18
20
|
})
|
|
19
21
|
|
|
22
|
+
setup() {
|
|
23
|
+
const {t} = useI18n({namespace: "js.api_maker.super_admin.layout.menu"})
|
|
24
|
+
const currentUser = useCurrentUser()
|
|
25
|
+
|
|
26
|
+
this.setInstance({currentUser, t})
|
|
27
|
+
}
|
|
28
|
+
|
|
20
29
|
render() {
|
|
30
|
+
const {currentUser, t} = this.tt
|
|
21
31
|
const {active, noAccess, triggered} = this.props
|
|
22
|
-
const currentUser = useCurrentUser()
|
|
23
|
-
const rootRef = useRef()
|
|
24
32
|
|
|
25
33
|
return (
|
|
26
|
-
<
|
|
34
|
+
<View dataSet={{component: "super-admin--layout--menu", triggered}}>
|
|
27
35
|
<div className="menu-logo">
|
|
28
36
|
<Link className="menu-logo-link" to={Params.withParams({})}>
|
|
29
37
|
Admin
|
|
@@ -52,12 +60,12 @@ export default memo(shapeComponent(class ComponentsAdminLayoutMenu extends BaseC
|
|
|
52
60
|
active
|
|
53
61
|
className="sign-out-menu-item"
|
|
54
62
|
icon="sign-out-alt"
|
|
55
|
-
label={
|
|
63
|
+
label={t(".sign_out", {defaultValue: "Sign out"})}
|
|
56
64
|
onClick={this.tt.onSignOutClicked}
|
|
57
65
|
/>
|
|
58
66
|
}
|
|
59
67
|
</div>
|
|
60
|
-
</
|
|
68
|
+
</View>
|
|
61
69
|
)
|
|
62
70
|
}
|
|
63
71
|
|
|
@@ -66,7 +74,7 @@ export default memo(shapeComponent(class ComponentsAdminLayoutMenu extends BaseC
|
|
|
66
74
|
|
|
67
75
|
try {
|
|
68
76
|
await Devise.signOut()
|
|
69
|
-
FlashMessage.success(
|
|
77
|
+
FlashMessage.success(this.t(".you_have_been_signed_out", {defaultValue: "You have been signed out"}))
|
|
70
78
|
} catch (error) {
|
|
71
79
|
FlashMessage.errorResponse(error)
|
|
72
80
|
}
|
|
@@ -2,18 +2,23 @@ import BaseComponent from "../../base-component"
|
|
|
2
2
|
import {memo} from "react"
|
|
3
3
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
4
4
|
import useCurrentUser from "../../use-current-user"
|
|
5
|
+
import useI18n from "i18n-on-steroids/src/use-i18n.mjs"
|
|
6
|
+
import {View} from "react-native"
|
|
5
7
|
|
|
6
8
|
export default memo(shapeComponent(class ComponentsAdminLayoutNoAccess extends BaseComponent {
|
|
7
9
|
render() {
|
|
8
10
|
const currentUser = useCurrentUser()
|
|
11
|
+
const {t} = useI18n({namespace: "js.api_maker.super_admin.layout.no_access"})
|
|
9
12
|
|
|
10
13
|
return (
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
<View
|
|
15
|
+
dataSet={{
|
|
16
|
+
component: "super-admin--layout--no-access",
|
|
17
|
+
userRoles: currentUser?.userRoles()?.loaded()?.map((userRole) => userRole.role()?.identifier()).join(", ")
|
|
18
|
+
}}
|
|
14
19
|
>
|
|
15
|
-
{
|
|
16
|
-
</
|
|
20
|
+
{t(".you_dont_have_no_access_to_this_page", {defaultValue: "You don't have access to this page."})}
|
|
21
|
+
</View>
|
|
17
22
|
)
|
|
18
23
|
}
|
|
19
24
|
}))
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
@import "@kaspernj/api-maker/src/super-admin/stylesheets/variables";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[data-component="super-admin--layout"] {
|
|
4
4
|
width: 100%;
|
|
5
5
|
min-height: 100vh;
|
|
6
6
|
background: #fff;
|
|
7
7
|
color: #000;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
[data-class="app-layout-content-container"] {
|
|
10
10
|
min-height: 100vh;
|
|
11
11
|
background: #f7f7f7;
|
|
12
12
|
|
|
@@ -19,10 +19,12 @@ export default memo(shapeComponent(class ApiMakerSuperAdminModelClassTable exten
|
|
|
19
19
|
const {modelClass, ...restProps} = this.props
|
|
20
20
|
const currentUser = useCurrentUser()
|
|
21
21
|
const configReader = useMemo(() => ConfigReader.forModel(modelClass), [modelClass])
|
|
22
|
-
const columns = useMemo(() => configReader.tableColumns(), [modelClass])
|
|
22
|
+
const {columns, select} = useMemo(() => configReader.tableColumns(), [modelClass])
|
|
23
23
|
const tableConfig = configReader.modelConfig?.table
|
|
24
24
|
const tableProps = {}
|
|
25
25
|
|
|
26
|
+
if (!columns) throw new Error("No columns given")
|
|
27
|
+
|
|
26
28
|
if (tableConfig?.query) tableProps.collection = tableConfig.query
|
|
27
29
|
|
|
28
30
|
return (
|
|
@@ -31,6 +33,7 @@ export default memo(shapeComponent(class ApiMakerSuperAdminModelClassTable exten
|
|
|
31
33
|
currentUser={currentUser}
|
|
32
34
|
editModelPath={hasEditConfig(modelClass) ? this.tt.editModelPath : undefined}
|
|
33
35
|
modelClass={modelClass}
|
|
36
|
+
select={select}
|
|
34
37
|
viewModelPath={this.tt.viewModelPath}
|
|
35
38
|
workplace
|
|
36
39
|
{...tableProps}
|
|
@@ -5,7 +5,9 @@ import PropTypesExact from "prop-types-exact"
|
|
|
5
5
|
import {memo} from "react"
|
|
6
6
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
7
7
|
import ShowReflectionLink from "./show-reflection-link"
|
|
8
|
+
import useI18n from "i18n-on-steroids/src/use-i18n.mjs"
|
|
8
9
|
import useQueryParams from "on-location-changed/src/use-query-params"
|
|
10
|
+
import {View} from "react-native"
|
|
9
11
|
|
|
10
12
|
export default memo(shapeComponent(class ApiMakerSuperAdminShowNav extends BaseComponent {
|
|
11
13
|
static propTypes = PropTypesExact({
|
|
@@ -14,23 +16,24 @@ export default memo(shapeComponent(class ApiMakerSuperAdminShowNav extends BaseC
|
|
|
14
16
|
})
|
|
15
17
|
|
|
16
18
|
render() {
|
|
19
|
+
const {t} = useI18n({namespace: "js.api_maker.suprt_admin.show_reflection_page"})
|
|
17
20
|
const {model, modelClass} = this.props
|
|
18
21
|
const queryParams = useQueryParams()
|
|
19
22
|
const reflections = modelClass.reflections()
|
|
20
23
|
|
|
21
24
|
return (
|
|
22
|
-
<
|
|
23
|
-
<
|
|
25
|
+
<View dataSet={{component: "super-admin--show-nav"}}>
|
|
26
|
+
<View>
|
|
24
27
|
<Link to={Params.withParams({model: modelClass.modelClassData().name, model_id: queryParams.model_id})}>
|
|
25
|
-
{
|
|
28
|
+
{t(".general", {defaultValue: "General"})}
|
|
26
29
|
</Link>
|
|
27
|
-
</
|
|
30
|
+
</View>
|
|
28
31
|
{model && reflections.filter((reflection) => reflection.macro() == "has_many").map((reflection) =>
|
|
29
|
-
<
|
|
32
|
+
<View key={reflection.name()}>
|
|
30
33
|
<ShowReflectionLink model={model} modelClass={modelClass} reflection={reflection} />
|
|
31
|
-
</
|
|
34
|
+
</View>
|
|
32
35
|
)}
|
|
33
|
-
</
|
|
36
|
+
</View>
|
|
34
37
|
)
|
|
35
38
|
}
|
|
36
39
|
}))
|
|
@@ -9,6 +9,7 @@ import {memo, useMemo} from "react"
|
|
|
9
9
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
10
10
|
import ShowNav from "../show-nav"
|
|
11
11
|
import useModel from "../../use-model"
|
|
12
|
+
import {View} from "react-native"
|
|
12
13
|
|
|
13
14
|
const AttributePresenter = memo(({attribute, model, modelArgs}) => {
|
|
14
15
|
const attributeRowProps = {
|
|
@@ -63,7 +64,9 @@ export default memo(shapeComponent(class ApiMakerSuperAdminShowPage extends Base
|
|
|
63
64
|
|
|
64
65
|
// Select all attributes selected by default because they will be shown by default
|
|
65
66
|
for (const attribute of modelClass.attributes()) {
|
|
66
|
-
if (attribute.isSelectedByDefault()
|
|
67
|
+
if ((attribute.isSelectedByDefault() || attribute.name() == "name") && !modelClassSelect.includes(attribute.name())) {
|
|
68
|
+
modelClassSelect.push(attribute.name())
|
|
69
|
+
}
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
for (const reflection of modelClass.reflections()) {
|
|
@@ -112,7 +115,7 @@ export default memo(shapeComponent(class ApiMakerSuperAdminShowPage extends Base
|
|
|
112
115
|
modelArgs[inflection.camelize(modelClass.modelClassData().name, true)] = model
|
|
113
116
|
|
|
114
117
|
return (
|
|
115
|
-
<
|
|
118
|
+
<View dataSet={{component: "super-admin--show-page"}}>
|
|
116
119
|
{model &&
|
|
117
120
|
<ShowNav model={model} modelClass={modelClass} />
|
|
118
121
|
}
|
|
@@ -123,7 +126,7 @@ export default memo(shapeComponent(class ApiMakerSuperAdminShowPage extends Base
|
|
|
123
126
|
<BelongsToAttributeRow key={reflection.name()} model={model} modelClass={modelClass} reflection={reflection} />
|
|
124
127
|
)}
|
|
125
128
|
{model && extraContent && extraContent(modelArgs)}
|
|
126
|
-
</
|
|
129
|
+
</View>
|
|
127
130
|
)
|
|
128
131
|
}
|
|
129
132
|
}))
|
|
@@ -7,10 +7,12 @@ import ModelClassTable from "./model-class-table"
|
|
|
7
7
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
8
8
|
import ShowNav from "./show-nav"
|
|
9
9
|
import useQueryParams from "on-location-changed/src/use-query-params"
|
|
10
|
+
import {View} from "react-native"
|
|
10
11
|
|
|
11
12
|
export default memo(shapeComponent(class ApiMakerSuperAdminShowReflectionPage extends BaseComponent {
|
|
12
13
|
static propTypes = propTypesExact({
|
|
13
|
-
modelClass: PropTypes.func.isRequired
|
|
14
|
+
modelClass: PropTypes.func.isRequired,
|
|
15
|
+
modelId: PropTypes.string.isRequired
|
|
14
16
|
})
|
|
15
17
|
|
|
16
18
|
render() {
|
|
@@ -27,7 +29,7 @@ export default memo(shapeComponent(class ApiMakerSuperAdminShowReflectionPage ex
|
|
|
27
29
|
if (model) collection = model[reflection.name()]()
|
|
28
30
|
|
|
29
31
|
return (
|
|
30
|
-
<
|
|
32
|
+
<View dataSet={{component: "super-admin--show-page"}}>
|
|
31
33
|
{model &&
|
|
32
34
|
<ShowNav model={model} modelClass={modelClass} />
|
|
33
35
|
}
|
|
@@ -38,7 +40,7 @@ export default memo(shapeComponent(class ApiMakerSuperAdminShowReflectionPage ex
|
|
|
38
40
|
modelClass={reflectionModelClass}
|
|
39
41
|
/>
|
|
40
42
|
}
|
|
41
|
-
</
|
|
43
|
+
</View>
|
|
42
44
|
)
|
|
43
45
|
}
|
|
44
46
|
}))
|
package/src/table/table.jsx
CHANGED
|
@@ -21,7 +21,7 @@ import Settings from "./settings"
|
|
|
21
21
|
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
22
22
|
import TableSettings from "./table-settings"
|
|
23
23
|
import uniqunize from "uniqunize"
|
|
24
|
-
import useBreakpoint from "
|
|
24
|
+
import useBreakpoint from "../use-breakpoint"
|
|
25
25
|
import useCollection from "../use-collection"
|
|
26
26
|
import useQueryParams from "on-location-changed/src/use-query-params.js"
|
|
27
27
|
|
|
@@ -175,7 +175,9 @@ export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
|
175
175
|
updateSettingsFullCacheKey = () => this.setState({tableSettingFullCacheKey: this.state.tableSetting.fullCacheKey()})
|
|
176
176
|
|
|
177
177
|
columnsAsArray = () => {
|
|
178
|
-
if (typeof this.props.columns == "function")
|
|
178
|
+
if (typeof this.props.columns == "function") {
|
|
179
|
+
return this.props.columns()
|
|
180
|
+
}
|
|
179
181
|
|
|
180
182
|
return this.props.columns
|
|
181
183
|
}
|
|
File without changes
|