disco_app 0.13.3 → 0.13.4
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 333b0540e47c1d1c0f35b1e10ad0b8039fae81c91a9e96648ca4e5d2abbbb526
|
4
|
+
data.tar.gz: 1749255c14c73a9c3835d4c9a1e140c9c695a97535445b16121eb9eb38e711ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0367c1f61d48894dcc70a8f08d8bfe2f00fe4c7ba589a0969ff28e2043f538c8f413f9417b02268940b9b9ba9281fc12d0278402406128dee20a7ea14fa45308
|
7
|
+
data.tar.gz: 2da5c048070836eebd7fd577f01240cc70c8f4671d57d5f5be70143e23ab55029d5cecc514eb2b021129f626ef9703806c621dbd4c7610a3b05d7adeeb3a5553
|
@@ -2,7 +2,7 @@ class ModelForm extends BaseForm {
|
|
2
2
|
|
3
3
|
render() {
|
4
4
|
const { modelTitle, modelName, modelUrl, modelsUrl, children, authenticityToken } = this.props;
|
5
|
-
const
|
5
|
+
const errorsElement = this.getErrorsElement();
|
6
6
|
|
7
7
|
return(
|
8
8
|
<form action={modelUrl ? modelUrl : modelsUrl} acceptCharset="UTF-8" method="POST" data-shopify-app-submit="ea.save">
|
@@ -10,12 +10,7 @@ class ModelForm extends BaseForm {
|
|
10
10
|
<input type="hidden" name="_method" value={modelUrl ? 'patch' : 'post'} />
|
11
11
|
<input type="hidden" name="authenticity_token" value={authenticityToken}/>
|
12
12
|
|
13
|
-
{
|
14
|
-
if (!errors) return false;
|
15
|
-
return (
|
16
|
-
{errors}
|
17
|
-
);
|
18
|
-
})()}
|
13
|
+
{errorsElement}
|
19
14
|
|
20
15
|
{children}
|
21
16
|
|
@@ -5,64 +5,36 @@
|
|
5
5
|
class BaseForm extends React.Component {
|
6
6
|
|
7
7
|
/**
|
8
|
-
*
|
9
|
-
*
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
}
|
18
|
-
|
19
|
-
/**
|
20
|
-
* returns a list of fields that contain errors
|
21
|
-
**/
|
22
|
-
errorKeys() {
|
23
|
-
return this.props.errors.errors;
|
24
|
-
}
|
25
|
-
|
26
|
-
/**
|
27
|
-
* returns the type of resource associate with this error
|
28
|
-
**/
|
29
|
-
errorType() {
|
30
|
-
return this.props.errors.type;
|
31
|
-
}
|
32
|
-
|
33
|
-
/**
|
34
|
-
* returns the error messages
|
35
|
-
**/
|
36
|
-
errorMessages() {
|
37
|
-
return this.props.errors.messages;
|
38
|
-
}
|
39
|
-
|
40
|
-
/**
|
41
|
-
* renders basic form errors
|
42
|
-
**/
|
43
|
-
renderErrors() {
|
44
|
-
if (!this.hasErrors()) {
|
8
|
+
* Returns the JSX required to render a list of errors.
|
9
|
+
*
|
10
|
+
* @returns {*}
|
11
|
+
*/
|
12
|
+
getErrorsElement() {
|
13
|
+
const { errors } = this.props;
|
14
|
+
|
15
|
+
// Don't render anything if no errors present.
|
16
|
+
if(!errors || !errors.errors || (errors.errors.length == 0)) {
|
45
17
|
return null;
|
46
18
|
}
|
47
19
|
|
48
|
-
|
49
|
-
|
50
|
-
return <li>{message}</li>;
|
51
|
-
});
|
20
|
+
const errorCount = errors.errors.length;
|
21
|
+
const singleError = (errorCount == 1);
|
52
22
|
|
53
23
|
return (
|
54
24
|
<div className="ui-banner ui-banner--status-error ui-banner--default-vertical-spacing ui-banner--default-horizontal-spacing">
|
55
25
|
<div className="ui-banner__ribbon">
|
56
26
|
<svg className="next-icon next-icon--24" viewBox="0 0 24 24">
|
57
|
-
<
|
27
|
+
<use xmlns="http://www.w3.org/1999/xlink" xlinkHref="#next-error" />
|
58
28
|
</svg>
|
59
29
|
</div>
|
60
30
|
<div className="ui-banner__content">
|
61
31
|
<h2 className="ui-banner__title">
|
62
|
-
{
|
32
|
+
There {singleError ? 'is' : 'are'} {errorCount} error{singleError ? '' : 's'} for this {errors.type}:
|
63
33
|
</h2>
|
64
34
|
<ul>
|
65
|
-
{
|
35
|
+
{errors.messages.map((message, i) => {
|
36
|
+
return <li key={i}>{message}</li>;
|
37
|
+
})}
|
66
38
|
</ul>
|
67
39
|
</div>
|
68
40
|
</div>
|
data/lib/disco_app/version.rb
CHANGED