@kaspernj/api-maker 1.0.305 → 1.0.306
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
|
@@ -19,7 +19,7 @@ const EditPage = ({modelClass}) => {
|
|
|
19
19
|
const modelVarName = inflection.camelize(modelClass.modelClassData().name, true)
|
|
20
20
|
const extraContent = configReader.modelConfig?.edit?.extraContentconst
|
|
21
21
|
const attributes = configReader.modelConfig?.edit?.attributes
|
|
22
|
-
const selectedModelAttributes = []
|
|
22
|
+
const selectedModelAttributes = ["id"]
|
|
23
23
|
const selectedAttributes = {}
|
|
24
24
|
|
|
25
25
|
selectedAttributes[modelClassName] = selectedModelAttributes
|
|
@@ -37,7 +37,8 @@ const EditPage = ({modelClass}) => {
|
|
|
37
37
|
const useModelResult = useModel(modelClass, {
|
|
38
38
|
cacheArgs: [currentUser?.id()],
|
|
39
39
|
loadByQueryParam: (props) => props.queryParams.model_id,
|
|
40
|
-
newIfNoId: true
|
|
40
|
+
newIfNoId: true,
|
|
41
|
+
select: selectedAttributes
|
|
41
42
|
})
|
|
42
43
|
|
|
43
44
|
const model = digg(useModelResult, modelVarName)
|
|
@@ -68,7 +69,7 @@ const EditPage = ({modelClass}) => {
|
|
|
68
69
|
{attribute.translated && availableLocales.map((locale) =>
|
|
69
70
|
<div key={locale}>
|
|
70
71
|
<Input
|
|
71
|
-
attribute={attribute.attribute}
|
|
72
|
+
attribute={`${attribute.attribute}${inflection.camelize(locale)}`}
|
|
72
73
|
id={`${camelizedLower}_${inflection.underscore(attribute.attribute)}_${locale}`}
|
|
73
74
|
label={`${modelClass.humanAttributeName(attribute.attribute)} (${locale})`}
|
|
74
75
|
model={model}
|
|
@@ -17,6 +17,8 @@ const ApiMakerSuperAdmin = () => {
|
|
|
17
17
|
|
|
18
18
|
if (queryParams.model && queryParams.model_id && queryParams.model_reflection) {
|
|
19
19
|
pageToShow = "show_reflection"
|
|
20
|
+
} else if (queryParams.model && queryParams.model_id && queryParams.mode == "edit") {
|
|
21
|
+
pageToShow = "edit"
|
|
20
22
|
} else if (queryParams.model && queryParams.model_id) {
|
|
21
23
|
pageToShow = "show"
|
|
22
24
|
} else if (queryParams.model && queryParams.mode == "new") {
|
|
@@ -34,6 +36,11 @@ const ApiMakerSuperAdmin = () => {
|
|
|
34
36
|
Create new
|
|
35
37
|
</Link>
|
|
36
38
|
}
|
|
39
|
+
{modelClass && pageToShow == "show" &&
|
|
40
|
+
<Link to={Params.withParams({model: modelClass.modelClassData().name, model_id: queryParams.model_id, mode: "edit"})}>
|
|
41
|
+
Edit
|
|
42
|
+
</Link>
|
|
43
|
+
}
|
|
37
44
|
</>,
|
|
38
45
|
[modelClass, pageToShow]
|
|
39
46
|
)
|
|
@@ -16,6 +16,17 @@ const ApiMakerSuperAdminModelClassTable = ({modelClass, ...restProps}) => {
|
|
|
16
16
|
return configReader.tableColumns()
|
|
17
17
|
}, [modelClass])
|
|
18
18
|
|
|
19
|
+
const editModelPath = useCallback((args) => {
|
|
20
|
+
const argName = inflection.camelize(digg(modelClass.modelClassData(), "name"), true)
|
|
21
|
+
const model = digg(args, argName)
|
|
22
|
+
|
|
23
|
+
return Params.withParams({
|
|
24
|
+
model: modelClass.modelClassData().name,
|
|
25
|
+
model_id: model.primaryKey(),
|
|
26
|
+
mode: "edit"
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
19
30
|
const viewModelPath = useCallback((args) => {
|
|
20
31
|
const argName = inflection.camelize(digg(modelClass.modelClassData(), "name"), true)
|
|
21
32
|
const model = digg(args, argName)
|
|
@@ -30,6 +41,7 @@ const ApiMakerSuperAdminModelClassTable = ({modelClass, ...restProps}) => {
|
|
|
30
41
|
<Table
|
|
31
42
|
columns={columns}
|
|
32
43
|
currentUser={currentUser}
|
|
44
|
+
editModelPath={editModelPath}
|
|
33
45
|
modelClass={modelClass}
|
|
34
46
|
viewModelPath={viewModelPath}
|
|
35
47
|
{...restProps}
|
|
@@ -3,6 +3,7 @@ import BelongsToAttributeRow from "./belongs-to-attribute-row"
|
|
|
3
3
|
import ConfigReader from "../config-reader"
|
|
4
4
|
import {digg} from "diggerize"
|
|
5
5
|
import * as inflection from "inflection"
|
|
6
|
+
import Link from "../../link"
|
|
6
7
|
import PropTypes from "prop-types"
|
|
7
8
|
import {memo} from "react"
|
|
8
9
|
import ShowNav from "../show-nav"
|