Sha256: d17b9ae9e25254308c23300b0fb5048e29f5bef0f751d06cba6aa5eaf38c203b

Contents?: true

Size: 1.4 KB

Versions: 82

Compression:

Stored size: 1.4 KB

Contents

HAL.Views.NonSafeRequestDialog = Backbone.View.extend({
  initialize: function(opts) {
    this.href = opts.href;
    this.vent = opts.vent;
    this.uriTemplate = uritemplate(this.href);
    _.bindAll(this, 'submitQuery');
  },

  events: {
    'submit form': 'submitQuery'
  },

  className: 'modal fade',

  submitQuery: function(e) {
    e.preventDefault();

    var self = this,
        opts = {
          url: this.$('.url').val(),
          headers: HAL.parseHeaders(this.$('.headers').val()),
          method:  this.$('.method').val(),
          data: this.$('.body').val()
        };

    var request = HAL.client.request(opts);
    request.done(function(response) {
      self.vent.trigger('response', { resource: response, jqxhr: jqxhr });
    }).fail(function(response) {
      self.vent.trigger('fail-response', { jqxhr: jqxhr });
    }).always(function() {
      self.vent.trigger('response-headers', { jqxhr: jqxhr });
      window.location.hash = 'NON-GET:' + opts.url;
    });

    this.$el.modal('hide');
  },

  render: function(opts) {
    var headers = HAL.client.getHeaders(),
        headersString = '';

    _.each(headers, function(value, name) {
      headersString += name + ': ' + value + '\n';
    });

    this.$el.html(this.template({ href: this.href, user_defined_headers: headersString }));
    this.$el.modal();
    return this;
  },

  template: _.template($('#non-safe-request-template').html())
});

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
pact_broker-2.112.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.111.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.109.1 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.109.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.108.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.107.1 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.107.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.107.0.beta.1 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.106.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.105.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.104.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.103.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.102.2 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.102.1 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.102.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.101.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.100.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.99.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.98.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.97.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js