Sha256: ee5d663f688fbc36149eefd31eb965e8834005bda11cb178388462e620e16920

Contents?: true

Size: 1.65 KB

Versions: 50

Compression:

Stored size: 1.65 KB

Contents

import ConfirmRemoveDialog from 'hyrax/relationships/confirm_remove_dialog'

export default class RegistryEntry {
    /**
     * Initialize the registry entry
     * @param {Resource} resource the resource to display on the form
     * @param {Registry} registry the registry that holds this registry entry.
     * @param {String} template identifer of the new row template.
     */
    constructor(resource, registry, template) {
        this.resource = resource
        this.registry = registry
        this.view = this.createView(resource, template);
        this.destroyed = false
        //this.view.effect("highlight", {}, 3000);
    }

    export() {
      return { 'id': this.resource.id, '_destroy': this.destroyed }
    }

    // Add a row that has not been persisted
    createView(resource, templateId) {
        let row = $(tmpl(templateId, resource))
        let removeButton = row.find('[data-behavior="remove-relationship"]')
        removeButton.click((e) => {
          e.preventDefault()
          var dialog = new ConfirmRemoveDialog(removeButton.data('confirmText'),
                                               removeButton.data('confirmCancel'),
                                               removeButton.data('confirmRemove'),
                                               () => this.removeResource(e));
          dialog.launch();
        });
        return row;
    }

    // Hides the row and adds a _destroy=true field to the form
    removeResource(evt) {
       evt.preventDefault();
       let button = $(evt.target);
       this.view.addClass('hidden'); // do not show the block
       this.destroyed = true
       this.registry.showSaveNote();
    }
}

Version data entries

50 entries across 50 versions & 1 rubygems

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