Sha256: 771571c09e6b6b6044104601a18c637c0842739e2e9d6338f0e3f32e03958e14

Contents?: true

Size: 1.75 KB

Versions: 45

Compression:

Stored size: 1.75 KB

Contents

import CollectionUtilities from 'hyrax/collections_utils';

export default class CollectionsV2 {
  constructor() {
    this.collectionUtilities = new CollectionUtilities();
    this.setupAddSharingHandler();
    this.sharingAddButtonDisabler();
  }

  /**
   * Set up the handler for adding groups or users via AJAX POSTS at the following location:
   * Collection > Edit > Sharing tab; or
   * Collection Types > Edit > Participants tab
   * @return {void}
   */
  setupAddSharingHandler() {
    const { addParticipants } = this.collectionUtilities;
    const wrapEl = '.form-add-sharing-wrapper';

    $('#participants')
      .find('.edit-collection-add-sharing-button')
      .on('click', {
        wrapEl,
        urlFn: (e) => {
          const $wrapEl = $(e.target).parents(wrapEl);
          return '/dashboard/collections/' + $wrapEl.data('id') + '/permission_template?locale=en';
        }
      },
      addParticipants.handleAddParticipants.bind(addParticipants));
  }

  /**
   * Set up enabling/disabling "Add" button for adding groups and/or users in
   * Edit Collection > Sharing tab
   * @return {void}
   */
  sharingAddButtonDisabler() {
    const { addParticipantsInputValidator } = this.collectionUtilities;
    // Selector for the button to enable/disable
    const buttonSelector = '.edit-collection-add-sharing-button';
    const inputsWrapper = '.form-add-sharing-wrapper';

    $('#participants')
      .find(inputsWrapper)
      .on(
        'change',
        // custom data we need passed into the event handler
        {
          buttonSelector: '.edit-collection-add-sharing-button',
          inputsWrapper
        },
        addParticipantsInputValidator.handleWrapperContentsChange.bind(
          addParticipantsInputValidator
        )
      );
  }
}

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
hyrax-3.4.1 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-3.4.0 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-3.3.0 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-3.2.0 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-2.9.6 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-3.1.0 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-2.9.5 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-3.0.2 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-3.0.1 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-3.0.0 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-3.0.0.pre.rc4 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-2.9.4 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-3.0.0.pre.rc3 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-2.9.3 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-2.9.2 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-2.9.1 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-2.9.0 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-3.0.0.pre.rc2 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-2.8.0 app/assets/javascripts/hyrax/collections_v2.es6
hyrax-2.7.2 app/assets/javascripts/hyrax/collections_v2.es6