Sha256: 2a97e5652e54791bc13577fe2a5b441eaa6a84d01a6c7324c75e0213c2b71053

Contents?: true

Size: 1.27 KB

Versions: 62

Compression:

Stored size: 1.27 KB

Contents

export default class SelectCollectionType {
  /**
   * Initializes the class in the context of an individual table element
   * @param {jQuery} element the table element that this class represents
   */
  constructor(element) {
      this.$element = element;
      this.target = element.data('target')
      this.modal = $(this.target)
      this.form = this.modal.find('form.new-collection-select')

      // launch the modal.
      element.on('click', (e) => {
          e.preventDefault()
          this.form.on('submit', this.routingLogic.bind(this))
      });

      // remove the routing logic when the modal is hidden
      this.modal.on('hide.bs.modal', (e) => {
          this.form.unbind('submit')
      });
  }

  // when the form is submitted route to the correct location
  routingLogic(e) {
      e.preventDefault()
      if (this.destination() === undefined)
        return false
      // get the destination from the data attribute of the selected radio button
      window.location.href = this.destination()
  }

  // Each input has two attributes that contain paths, one for the batch and one
  // for a single work.  So, given the value of 'this.type', return the appropriate
  // path.
  destination() {
      return this.form.find('input[type="radio"]:checked').data("path")
  }
}

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
hyrax-5.0.2 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-5.0.1 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-5.0.0 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-5.0.0.rc3 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-5.0.0.rc2 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-5.0.0.rc1 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-3.6.0 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-4.0.0 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-4.0.0.rc3 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-4.0.0.rc2 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-4.0.0.rc1 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-3.5.0 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-4.0.0.beta2 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-3.4.2 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-4.0.0.beta1 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-3.4.1 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-3.4.0 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-3.3.0 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-3.2.0 app/assets/javascripts/hyrax/select_collection_type.es6
hyrax-2.9.6 app/assets/javascripts/hyrax/select_collection_type.es6