@imposium-hub/components 1.30.0 → 1.31.1
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/components/assets/AssetField.tsx +32 -11
- package/dist/components.js +1 -1
- package/dist/components.js.map +1 -1
- package/package.json +1 -1
|
@@ -52,21 +52,42 @@ class AssetField extends React.PureComponent<IAssetFieldProps, IAssetFieldState>
|
|
|
52
52
|
|
|
53
53
|
// get the asset name from the API
|
|
54
54
|
if (assetId && !this.state.assetName) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
this.loadAsset();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public componentDidUpdate(prevProps, prevState) {
|
|
60
|
+
|
|
61
|
+
const {assetId} = this.props;
|
|
62
|
+
|
|
63
|
+
if (assetId && assetId !== prevProps.assetId) {
|
|
64
|
+
this.loadAsset();
|
|
65
|
+
} else if (!assetId) {
|
|
66
|
+
this.setState({
|
|
67
|
+
error: false,
|
|
68
|
+
assetName: ''
|
|
66
69
|
});
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
|
|
73
|
+
private loadAsset() {
|
|
74
|
+
|
|
75
|
+
const {assetId, api} = this.props;
|
|
76
|
+
|
|
77
|
+
api.getAssetItem(assetId).then((data : any) => {
|
|
78
|
+
this.setState({
|
|
79
|
+
error: false,
|
|
80
|
+
assetName: data.name
|
|
81
|
+
});
|
|
82
|
+
})
|
|
83
|
+
.catch((e : Error) => {
|
|
84
|
+
this.setState({
|
|
85
|
+
error: true,
|
|
86
|
+
assetName: `Cound not find asset: ${assetId}`
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
70
91
|
public setFilter(e) {
|
|
71
92
|
|
|
72
93
|
const {accepts} = this.props;
|