goblin-gadgets 4.0.14 → 4.0.16
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goblin-gadgets",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.16",
|
|
4
4
|
"description": "Gadgets library",
|
|
5
5
|
"main": "./builders/builders.js",
|
|
6
6
|
"scripts": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"scroll-into-view-if-needed": "^1.4.0",
|
|
45
45
|
"xcraft-core-shredder": "^5.0.0",
|
|
46
46
|
"xcraft-dev-prettier": "^2.0.0",
|
|
47
|
-
"xcraft-dev-rules": "^4.
|
|
47
|
+
"xcraft-dev-rules": "^4.3.0"
|
|
48
48
|
},
|
|
49
49
|
"prettier": "xcraft-dev-prettier"
|
|
50
50
|
}
|
|
@@ -17,6 +17,8 @@ import NabuTextField from './text-field';
|
|
|
17
17
|
import ToNabuObject from 'goblin-nabu/widgets/helpers/t.js';
|
|
18
18
|
import T from 't';
|
|
19
19
|
import SchemaHelpers from 'goblin-toolbox/lib/schema-helpers';
|
|
20
|
+
import ModelContext from 'goblin-laboratory/widgets/with-model/context.js';
|
|
21
|
+
import joinModels from 'goblin-laboratory/widgets/connect-helpers/join-models';
|
|
20
22
|
|
|
21
23
|
/******************************************************************************/
|
|
22
24
|
|
|
@@ -76,19 +78,14 @@ class TranslatableTextField extends Widget {
|
|
|
76
78
|
static get contextTypes() {
|
|
77
79
|
return {
|
|
78
80
|
...Widget.contextTypes,
|
|
79
|
-
entityId: PropTypes.string,
|
|
80
81
|
id: PropTypes.string,
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
componentDidMount() {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
path: this.props.model.startsWith('.')
|
|
89
|
-
? this.props.model.slice(1)
|
|
90
|
-
: this.props.model,
|
|
91
|
-
newValue: WrapT(nabuId, null, null, null, true),
|
|
86
|
+
this.doFor(this.props.entityId, 'change', {
|
|
87
|
+
path: this.props.modelPath,
|
|
88
|
+
newValue: WrapT(this.props.nabuId, null, null, null, true),
|
|
92
89
|
});
|
|
93
90
|
}
|
|
94
91
|
|
|
@@ -176,7 +173,7 @@ class TranslatableTextField extends Widget {
|
|
|
176
173
|
//#endregion
|
|
177
174
|
|
|
178
175
|
getEntitySchema() {
|
|
179
|
-
const entityId = this.
|
|
176
|
+
const entityId = this.props.entityId; // by example "portfolio@e564950b-cd9f-4d35-abd0-b85bf93017f1"
|
|
180
177
|
if (entityId) {
|
|
181
178
|
const entityType = entityId.split('@', 2)[0]; // by example "portfolio"
|
|
182
179
|
return this.getSchema(entityType);
|
|
@@ -336,7 +333,7 @@ class TranslatableTextField extends Widget {
|
|
|
336
333
|
rounded: 'left-rounded',
|
|
337
334
|
};
|
|
338
335
|
const textFieldShape = textFieldShapes[s];
|
|
339
|
-
const nabuId =
|
|
336
|
+
const nabuId = this.props.nabuId;
|
|
340
337
|
|
|
341
338
|
if (this.props.readonly && this.props.rows && this.props.rows > 1) {
|
|
342
339
|
return (
|
|
@@ -512,7 +509,7 @@ class TranslatableTextField extends Widget {
|
|
|
512
509
|
return null;
|
|
513
510
|
}
|
|
514
511
|
|
|
515
|
-
const nabuId =
|
|
512
|
+
const nabuId = this.props.nabuId;
|
|
516
513
|
|
|
517
514
|
return (
|
|
518
515
|
<div className={this.styles.classNames.editLocale}>
|
|
@@ -552,7 +549,7 @@ class TranslatableTextField extends Widget {
|
|
|
552
549
|
return null;
|
|
553
550
|
}
|
|
554
551
|
|
|
555
|
-
const nabuId =
|
|
552
|
+
const nabuId = this.props.nabuId;
|
|
556
553
|
|
|
557
554
|
return (
|
|
558
555
|
<div className={this.styles.classNames.editLocale}>
|
|
@@ -666,4 +663,22 @@ export default Widget.connect((state, props) => {
|
|
|
666
663
|
list: locales,
|
|
667
664
|
defaultValue: defaultLocale.get('name'),
|
|
668
665
|
};
|
|
669
|
-
})(
|
|
666
|
+
})((props) => (
|
|
667
|
+
<ModelContext.Consumer>
|
|
668
|
+
{(model) => {
|
|
669
|
+
// backend.entityId.xyz
|
|
670
|
+
const fullModel = joinModels(model, props.model);
|
|
671
|
+
let [_, entityId, ...modelPath] = fullModel.split('.');
|
|
672
|
+
modelPath = modelPath.join('.');
|
|
673
|
+
const nabuId = `${entityId}.${modelPath}`;
|
|
674
|
+
return (
|
|
675
|
+
<TranslatableTextField
|
|
676
|
+
{...props}
|
|
677
|
+
nabuId={nabuId}
|
|
678
|
+
entityId={entityId}
|
|
679
|
+
modelPath={modelPath}
|
|
680
|
+
/>
|
|
681
|
+
);
|
|
682
|
+
}}
|
|
683
|
+
</ModelContext.Consumer>
|
|
684
|
+
));
|