Sha256: 7247efe719d8ea0f90ef8a01fb9a0a56fb70f8eeb3f0aab2d0b21c823b19aca6

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

export class UploadedFiles {
  // Monitors the form and runs the callback when files are added
  constructor(form, callback) {
    this.form = form
    this.element = $('#fileupload')
    this.uploadsInProgress = 0
    this.element.on('fileuploadadded', (e, data) => {
      this.uploadsInProgress += 1
      callback(e, data)
    })
    this.element.on('fileuploadcompleted', (e, data) => {
      this.uploadsInProgress -= 1
      callback(e, data)
    })
    this.element.on('fileuploaddestroyed', callback)
  }

  get hasFileRequirement() {
    let fileRequirement = this.form.find('li#required-files')
    return fileRequirement.length > 0
  }

  get inProgress() {
    return this.uploadsInProgress > 0;
  }

  get hasFiles() {
    let fileField = this.form.find('input[name="uploaded_files[]"]')
    return fileField.length > 0
  }

  get hasNewFiles() {
    // In a future release hasFiles will include files already on the work plus new files,
    // but hasNewFiles() will include only the files added in this browser window.
    return this.hasFiles
  }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/assets/javascripts/hyrax/save_work/uploaded_files.es6
hyrax-5.0.0 app/assets/javascripts/hyrax/save_work/uploaded_files.es6
hyrax-5.0.0.rc3 app/assets/javascripts/hyrax/save_work/uploaded_files.es6