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: 588d8ea318ba16bf4dff4610ac9ba3797e20b13833b55001175024b22f147428
4
- data.tar.gz: a2b553ef70d4a296d594da3d0b907492fb0171a1ce01e536a9b5a9674c612ba7
3
+ metadata.gz: 333b0540e47c1d1c0f35b1e10ad0b8039fae81c91a9e96648ca4e5d2abbbb526
4
+ data.tar.gz: 1749255c14c73a9c3835d4c9a1e140c9c695a97535445b16121eb9eb38e711ff
5
5
  SHA512:
6
- metadata.gz: 73cfa3f2d3dc98e0a312f1ff4827f849af6752bce0ca4b176a6ac87c2d01a67551d59a701bd0d7cb1cbb78493a03eb804fc46aba6e5cf5b4c49a05001a019363
7
- data.tar.gz: d7cadbbe26e7f65e1ce9dc980ad794689adc1c5ca19ff6b9ff31927c9f64d212c5b2707892089ff3ea735a0283820786841c00cf379956254143a8a9987ea25f
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 errors = this.renderErrors();
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
- * check if the field parameter has errors associated.
9
- * if no parameters are given, it checks if there's at least an error at all
10
- **/
11
- hasErrors(field) {
12
- if ((arguments.length === 0 && this.errorKeys().length > 0) ||
13
- (this.props.errors && this.props.errors.errors.indexOf(field) > -1)) {
14
- return true;
15
- }
16
- return false;
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
- var title = "There " + (this.errorMessages().length == 1 ? "is" : "are") + " " + this.errorMessages().length + " error" + (this.errorMessages().length > 1 ? "s" : "") + " for this " + this.errorType() + ":";
49
- var errorMessages = this.errorMessages().map(function(message) {
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
- <path d="M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.6 0 12 0zm0 4c1.4 0 2.7.4 3.9 1L12 8.8 8.8 12 5 15.9c-.6-1.1-1-2.5-1-3.9 0-4.4 3.6-8 8-8zm0 16c-1.4 0-2.7-.4-3.9-1l3.9-3.9 3.2-3.2L19 8.1c.6 1.1 1 2.5 1 3.9 0 4.4-3.6 8-8 8z"></path>
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
- {title}
32
+ There {singleError ? 'is' : 'are'} {errorCount} error{singleError ? '' : 's'} for this {errors.type}:
63
33
  </h2>
64
34
  <ul>
65
- {errorMessages}
35
+ {errors.messages.map((message, i) => {
36
+ return <li key={i}>{message}</li>;
37
+ })}
66
38
  </ul>
67
39
  </div>
68
40
  </div>
@@ -1,3 +1,3 @@
1
1
  module DiscoApp
2
- VERSION = '0.13.3'
2
+ VERSION = '0.13.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disco_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.3
4
+ version: 0.13.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Ballard