Sha256: 9d15e341111b90a87a2f4460468a0c2eb9bdcaa14ef5db5e1f9600eb00cee4cf

Contents?: true

Size: 1.41 KB

Versions: 14

Compression:

Stored size: 1.41 KB

Contents

export default class ConfirmRemoveDialog {
  /**
   * The function to perform when the dialog is accepted.
   *
   * @callback requestCallback
   */

  /**
   * Initialize the dialog
   * @param {String} text the text for the body of the dialog
   * @param {String} cancel the text for the cancel button
   * @param {String} remove the text for the remove button
   * @param {requestCallback} fn the function to perform if the remove button is pressed
   */
  constructor(text, cancel, remove, fn) {
      this.text = text
      this.cancel = cancel
      this.remove = remove
      this.fn = fn
  }

  template() {
      return `<div class="modal confirm-remove-dialog" tabindex="-1" role="dialog">
              <div class="modal-dialog modal-md" role="document">
              <div class="modal-content">
              <div class="modal-body">${this.text}</div>
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">${this.cancel}</button>
                <button type="button" class="btn btn-danger" data-behavior="submit">${this.remove}</button>
              </div>
              </div>
              </div>
              </div>`
  }

  launch() {
      let dialog = $(this.template())
      dialog.find('[data-behavior="submit"]').click(() => {
          dialog.modal('hide');
          dialog.remove();
          this.fn();
      })
      dialog.modal('show')
  }
}

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
hyrax-5.0.4 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-5.0.3 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-5.0.2 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-5.0.1 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-5.0.0 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-5.0.0.rc3 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-5.0.0.rc2 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-5.0.0.rc1 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-4.0.0 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-4.0.0.rc3 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-4.0.0.rc2 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-4.0.0.rc1 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-4.0.0.beta2 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6
hyrax-4.0.0.beta1 app/assets/javascripts/hyrax/relationships/confirm_remove_dialog.es6