Sha256: 7be0561eb4f7707e93634fabe24defe6b00536300cf6b6209bfe4df2b7aca82f

Contents?: true

Size: 707 Bytes

Versions: 75

Compression:

Stored size: 707 Bytes

Contents

export class RequiredFields {
  // Monitors the form and runs the callback if any of the required fields change
  constructor(form, callback) {
    this.form = form
    this.callback = callback
    this.reload()
  }

  get areComplete() {
    return this.requiredFields.filter((n, elem) => { return this.isValuePresent(elem) } ).length === 0
  }

  isValuePresent(elem) {
    return ($(elem).val() === null) || ($(elem).val().length < 1)
  }

  // Reassign requiredFields because fields may have been added or removed.
  reload() {
    // ":input" matches all input, select or textarea fields.
    this.requiredFields = this.form.find(':input[required]')
    this.requiredFields.change(this.callback)
  }
}

Version data entries

75 entries across 75 versions & 2 rubygems

Version Path
hyrax-3.6.0 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-3.5.0 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-3.4.2 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-3.4.1 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-3.4.0 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-3.3.0 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-3.2.0 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-2.9.6 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-3.1.0 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-2.9.5 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-3.0.2 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-3.0.1 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-3.0.0 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-3.0.0.pre.rc4 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-2.9.4 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-3.0.0.pre.rc3 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-2.9.3 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-2.9.2 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-2.9.1 app/assets/javascripts/hyrax/save_work/required_fields.es6
hyrax-2.9.0 app/assets/javascripts/hyrax/save_work/required_fields.es6