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.53.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.52.2 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.52.1 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.52.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.51.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.50.1 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.50.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.49.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.48.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.47.1 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.47.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.46.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.45.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.44.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.43.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.42.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.41.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.40.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.39.0 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js
pact_broker-2.38.1 vendor/hal-browser/js/hal/views/non_safe_request_dialog.js