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-3.0.4 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-3.1.4 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-2.11.12 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-3.0.3 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-3.1.3 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-3.1.2 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-3.1.1 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-3.1.0 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-2.11.11 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-3.0.2 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-2.10.5 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-2.11.10 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-3.0.1 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-3.0.0 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-2.11.9 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-2.11.8 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-2.11.7 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-2.11.6 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-3.0.0.rc2 app/assets/javascripts/spree/backend/views/order/shipping_method.js
solidus_backend-2.11.5 app/assets/javascripts/spree/backend/views/order/shipping_method.js