Sha256: c9f332fa8778e17000eee54bb98c5e7d6879f49e9c3a4ea9c5afc80437443058

Contents?: true

Size: 776 Bytes

Versions: 1

Compression:

Stored size: 776 Bytes

Contents

Sprangular.directive 'shippingRateSelection', ->
  restrict: 'E'
  templateUrl: 'shipping/rates.html'
  scope:
    order: '='
    disabled: '='

  controller: ($scope, Checkout, Env, _) ->
    $scope.loading = false
    $scope.address = {}
    $scope.currencySymbol = Env.currency.symbol

    $scope.$watch 'order.shippingRate', (rate, oldRate) ->
      return if !oldRate || !rate || (rate.shippingMethodId == oldRate.shippingMethodId && rate.cost == oldRate.cost)

      order = $scope.order
      order.shipTotal = rate.cost

      order.updateTotals()

      Checkout.setDelivery()

    $scope.$watch('order.shippingAddress', ->
      $scope.address = $scope.order.shippingAddress
    , true)

  link: (element, attrs) ->
    attrs.disabled = false unless attrs.disabled?

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sprangular-0.1.0 app/assets/javascripts/sprangular/directives/shippingRatesSelection.coffee