Sha256: f037ed7b3531f4b16a9085d898564fa205d48b00a929b0ad5ecdf2333c5d5f12

Contents?: true

Size: 1.14 KB

Versions: 82

Compression:

Stored size: 1.14 KB

Contents

export class DepositAgreement {
  // Monitors the form and runs the callback if any files are added
  constructor(form, callback) {
    this.agreementCheckbox = form.find('input#agreement')

    // If true, require the accept checkbox to be checked.
    // Tracks whether the user needs to accept again to the depositor
    // agreement. Once the user has manually agreed once she does not
    // need to agree again regardless on how many files are being added.
    this.isActiveAgreement = this.agreementCheckbox.length > 0
    if (this.isActiveAgreement) {
      this.setupActiveAgreement(callback)
      this.mustAgreeAgain = this.isAccepted
    }
    else {
      this.mustAgreeAgain = false
    }
  }

  setupActiveAgreement(callback) {
    this.agreementCheckbox.on('change', callback)
  }

  setNotAccepted() {
    this.agreementCheckbox.prop("checked", false)
    this.mustAgreeAgain = false
  }

  setAccepted() {
    this.agreementCheckbox.prop("checked", true)
  }

  /**
   * return true if it's a passive agreement or if the checkbox has been checked
   */
  get isAccepted() {
    return !this.isActiveAgreement || this.agreementCheckbox[0].checked
  }
}

Version data entries

82 entries across 82 versions & 1 rubygems

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