Sha256: fdcc83465c8a72bd67318c43fe64c8a92f4c4050e53d45e72791f5752c57b46b

Contents?: true

Size: 1.3 KB

Versions: 23

Compression:

Stored size: 1.3 KB

Contents

/**
 * Base class for form components that provides helper methods
 * for rendering errors associated with the form
 **/
class BaseForm extends React.Component {

  /**
   * Returns the JSX required to render a list of errors.
   *
   * @returns {*}
   */
  getErrorsElement() {
    const { errors } = this.props;

    // Don't render anything if no errors present.
    if(!errors || !errors.errors || (errors.errors.length == 0)) {
      return null;
    }

    const errorCount = errors.errors.length;
    const singleError = (errorCount == 1);

    return (
      <div className="ui-banner ui-banner--status-error ui-banner--default-vertical-spacing ui-banner--default-horizontal-spacing">
        <div className="ui-banner__ribbon">
          <svg className="next-icon next-icon--24" viewBox="0 0 24 24">
            <use xmlns="http://www.w3.org/1999/xlink" xlinkHref="#next-error" />
          </svg>
        </div>
        <div className="ui-banner__content">
          <h2 className="ui-banner__title">
            There {singleError ? 'is' : 'are'} {errorCount} error{singleError ? '' : 's'} for this {errors.type}:
          </h2>
          <ul>
            {errors.messages.map((message, i) => {
              return <li key={i}>{message}</li>;
            })}
          </ul>
        </div>
      </div>
    )
  }

}

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.13.4 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.13.5 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.13.6 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.13.7 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.13.8 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.14.1 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.14.2 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.15.0 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.16.0 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.17.0 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.18.0 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.18.2 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.14.4 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.18.3 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.18.6 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.14.3 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.16.1 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.15.2 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx
disco_app-0.18.4 app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx