@kaspernj/api-maker 1.0.430 → 1.0.431
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
|
@@ -34,13 +34,20 @@ export default memo(shapeComponent(class EditAttributeContent extends BaseCompon
|
|
|
34
34
|
id,
|
|
35
35
|
model
|
|
36
36
|
},
|
|
37
|
-
onChangeValue: this.tt.onChangeValue
|
|
38
|
-
|
|
37
|
+
onChangeValue: this.tt.onChangeValue,
|
|
38
|
+
value: this.s.value
|
|
39
|
+
}), [attribute.attribute, id, model, this.s.value])
|
|
39
40
|
|
|
40
41
|
return attribute.content(contentArgs)
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
defaultValue = () =>
|
|
44
|
+
defaultValue = () => {
|
|
45
|
+
if (!(this.p.attribute.attribute in this.p.model)) {
|
|
46
|
+
throw new Error(`No attribute called ${this.p.attribute.attribute} in model ${this.p.model.modelClassData().name}`)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return this.p.model[this.p.attribute.attribute]() || ""
|
|
50
|
+
}
|
|
44
51
|
|
|
45
52
|
onChangeValue = (newValue) => {
|
|
46
53
|
this.setState({value: newValue})
|
|
@@ -42,7 +42,7 @@ export default memo(shapeComponent(class EditAttributeInput extends BaseComponen
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
|
-
<View
|
|
45
|
+
<View dataSet={{component: "api-maker/super-admin/edit-page/edit-attribute-input"}}>
|
|
46
46
|
<Text>{label}</Text>
|
|
47
47
|
<View>
|
|
48
48
|
<TextInput
|
|
@@ -7,6 +7,7 @@ import Locales from "shared/locales"
|
|
|
7
7
|
import {memo} from "react"
|
|
8
8
|
import PropTypes from "prop-types"
|
|
9
9
|
import propTypesExact from "prop-types-exact"
|
|
10
|
+
import {View} from "react-native"
|
|
10
11
|
import {shapeComponent} from "set-state-compare/src/shape-component.js"
|
|
11
12
|
|
|
12
13
|
export default memo(shapeComponent(class EditAttribute extends BaseComponent {
|
|
@@ -22,7 +23,7 @@ export default memo(shapeComponent(class EditAttribute extends BaseComponent {
|
|
|
22
23
|
const camelizedLower = digg(modelClass.modelClassData(), "camelizedLower")
|
|
23
24
|
|
|
24
25
|
return (
|
|
25
|
-
|
|
26
|
+
<View dataSet={{component: "api-maker/super-admin/edit-page/edit-attribute"}} style={{marginBottom: attribute.translated ? undefined : 12}}>
|
|
26
27
|
{attribute.content &&
|
|
27
28
|
<EditAttributeContent
|
|
28
29
|
attribute={attribute}
|
|
@@ -32,14 +33,15 @@ export default memo(shapeComponent(class EditAttribute extends BaseComponent {
|
|
|
32
33
|
/>
|
|
33
34
|
}
|
|
34
35
|
{!attribute.content && attribute.translated && availableLocales.map((locale) =>
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
<View key={locale} style={{marginBottom: 12}}>
|
|
37
|
+
<EditAttributeInput
|
|
38
|
+
attributeName={`${attribute.attribute}${inflection.camelize(locale)}`}
|
|
39
|
+
id={`${inflection.underscore(camelizedLower)}_${inflection.underscore(attribute.attribute)}_${locale}`}
|
|
40
|
+
label={`${modelClass.humanAttributeName(attribute.attribute)} (${locale})`}
|
|
41
|
+
model={model}
|
|
42
|
+
name={`${inflection.underscore(attribute.attribute)}_${locale}`}
|
|
43
|
+
/>
|
|
44
|
+
</View>
|
|
43
45
|
)}
|
|
44
46
|
{!attribute.content && !attribute.translated &&
|
|
45
47
|
<EditAttributeInput
|
|
@@ -50,7 +52,7 @@ export default memo(shapeComponent(class EditAttribute extends BaseComponent {
|
|
|
50
52
|
name={inflection.underscore(attribute.attribute)}
|
|
51
53
|
/>
|
|
52
54
|
}
|
|
53
|
-
|
|
55
|
+
</View>
|
|
54
56
|
)
|
|
55
57
|
}
|
|
56
58
|
}))
|