Sha256: 5e526c531ae1fe7142b674aa72082e46ec2e3c793b54c2570dec83c4946a76dc

Contents?: true

Size: 1.41 KB

Versions: 129

Compression:

Stored size: 1.41 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.getDefaultHeaders(),
        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

129 entries across 129 versions & 1 rubygems

Version Path
pact_broker-2.1.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.5 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.4 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.3 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.2 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.1 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.0.beta.8 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.0.beta.7 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.0.beta.6 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-1.18.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.0.beta.5 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-1.18.0.beta.1 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-1.17.2 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-1.17.1 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.0.beta.4 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.0.beta.3 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.0.beta.2 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.0.0.beta.1 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-1.17.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js