Sha256: 7fd09d734207078cae6ddfd9d22a290519a7ef29eb959fdac8fa4da1aaf7703d

Contents?: true

Size: 1.53 KB

Versions: 137

Compression:

Stored size: 1.53 KB

Contents

Spree.Views.Order.ShippingMethod = Backbone.View.extend({
  tagName: 'tr',
  className: 'edit-shipping-method',

  events: {
    "click .js-edit":   "onEdit",
    "click .js-save":   "onSave",
    "submit form":      "onSave",
    "click .js-cancel": "onCancel"
  },

  initialize: function(options) {
    this.shippingMethodId = this.model.get('selected_shipping_rate').get('shipping_method_id');
    this.shippingRates = new Backbone.Collection();
    this.render();
  },

  onEdit: function(event) {
    this.editing = true;
    this.shippingRates = this.model.estimatedRates();
    this.listenTo(this.shippingRates, "sync", this.render);
    this.render();
  },

  onSave: function(event) {
    this.editing = false;
    this.shippingMethodId = this.$('select').val();
    this.shippingRates = new Backbone.Collection();
    this.model.selectShippingMethodId(this.shippingMethodId, {
      success: function() {
        window.location.reload();
      }
    });
    this.render();

    return false;
  },

  onCancel: function(event) {
    this.editing = false;
    this.shippingRates = new Backbone.Collection();
    this.render();
  },

  render: function() {
    var html = HandlebarsTemplates['orders/shipping_method']({
      editing: this.editing,
      order: this.model.collection.parent.toJSON(),
      shipment: this.model.toJSON(),
      selected_shipping_rate: this.model.get("selected_shipping_rate").toJSON(),
      shipping_rates: this.shippingRates.toJSON()
    });

    this.$el.html(html);
    this.$('select').val(this.shippingMethodId);
  }
})

Version data entries

137 entries across 137 versions & 2 rubygems

Version Path
solidus_backend-4.4.1 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.4.0 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.3.4 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.2.4 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.1.5 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.3.3 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.3.2 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.1.4 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.3.1 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.3.0 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.2.3 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.1.3 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.0.4 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-3.4.6 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.0.3 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.1.2 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.2.2 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-3.4.5 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.2.1 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-4.2.0 app/assets/javascripts/spree/backend/views/order/shipping_method.js