Sha256: 36d18f7cf69aedf2ec1b3f402632fa3b4c88a6640d893059661fba1f199f454e

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

// eslint-disable-next-line no-unused-vars
class SelectActivityToggle extends React.Component {
  constructor(props) {
    super(props);

    this.toggle = this.toggle.bind(this);
    this.modalText = [
      this.props.preface ? this.props.preface.textContent : null,
      this.props.meta ? this.props.meta.textContent : null,
    ].filter(x => !!x).join(' ');
  }

  render() {
    return (
      <div className="o-ld-selection">
        <div className="o-ld-selection__switch" onClick={this.toggle}></div>
        <span className="o-ld-selection__label" onClick={this.toggle}>Use Activity</span>
        { this.props.item.active && <SelectActivityConfirmationModal text={this.modalText} { ...this.props } /> }
      </div>
    );
  }

  toggle() {
    const item = this.props.item;
    if (item.active && this.modalText) {
      if (item.isOptional) {
        heapTrack('Optional Activity Enabled', { id: item.id});
        this.props.callback();
      } else {
        heapTrack('Click to Deselect Activity', { id: item.id });
        $(document.getElementById(`confirm-${item.id}`)).foundation('open');
      }
    } else {
      const event = item.isOptional ? 'Optional Activity Disabled' : 'Activity Selected';
      heapTrack(event, { id: item.id });
      this.props.callback();
    }
  }
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lcms-engine-0.1.4 app/assets/javascripts/lcms/engine/components/select-activity/SelectActivityToggle.js.jsx
lcms-engine-0.1.3 app/assets/javascripts/lcms/engine/components/select-activity/SelectActivityToggle.js.jsx
lcms-engine-0.2.0 app/assets/javascripts/lcms/engine/components/select-activity/SelectActivityToggle.js.jsx
lcms-engine-0.1.2 app/assets/javascripts/lcms/engine/components/select-activity/SelectActivityToggle.js.jsx
lcms-engine-0.1.0 app/assets/javascripts/lcms/engine/components/select-activity/SelectActivityToggle.js.jsx