Sha256: f0a8e741f22209aa7bcd315a2b1bfc746329b784a3549a134d8449a87cfebcef

Contents?: true

Size: 1.6 KB

Versions: 23

Compression:

Stored size: 1.6 KB

Contents

class ModelForm extends BaseForm {

  render() {
    const { modelTitle, modelName, modelUrl, modelsUrl, children, authenticityToken } = this.props;
    const errorsElement = this.getErrorsElement();

    return(
      <form action={modelUrl ? modelUrl : modelsUrl} acceptCharset="UTF-8" method="POST" data-shopify-app-submit="ea.save">
        <input type="hidden" name="utf8" value="✓"/>
        <input type="hidden" name="_method" value={modelUrl ? 'patch' : 'post'} />
        <input type="hidden" name="authenticity_token" value={authenticityToken}/>

        {errorsElement}

        {children}

        <ModelFormEmbeddedAppBar modelTitle={modelTitle} modelsUrl={modelsUrl} />
        <ModelFormPageActions modelName={modelName} modelUrl={modelUrl} modelsUrl={modelsUrl} />
      </form>
    )
  }
}

const ModelFormEmbeddedAppBar = ({ modelTitle, modelsUrl }) => {
  const buttons = {
    primary: {
      label: "Save",
      message: "ea.save"
    },
    secondary: [{
      label: "Cancel",
      href: modelsUrl
    }]
  };

  return (
    <EmbeddedAppBar title={modelTitle} buttons={buttons} />
  );
};

const ModelFormPageActions = ({ modelName, modelUrl, modelsUrl }) => {
  const primary = [
    <a href={modelsUrl} className="btn">Cancel</a>,
    <Button type="submit" primary={true}>{'Save' + (modelUrl ? '' : ' ' + modelName)}</Button>
  ];

  const secondary = modelUrl ? [
    <ModelDestroyButton
      label={'Delete ' + modelName}
      modelName={modelName}
      modelUrl={modelUrl}
      modelsUrl={modelsUrl}
    />
  ] : [];

  return (
    <UIPageActions primary={primary} secondary={secondary} />
  );
};

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/components/disco_app/forms/model-form.es6.jsx
disco_app-0.13.4 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.13.5 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.13.6 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.13.7 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.13.8 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.14.1 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.14.2 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.15.0 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.16.0 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.17.0 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.18.0 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.18.2 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.14.4 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.18.3 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.18.6 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.14.3 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.16.1 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.15.2 app/assets/components/disco_app/forms/model-form.es6.jsx
disco_app-0.18.4 app/assets/components/disco_app/forms/model-form.es6.jsx