Sha256: 7fbf925351e04dc55a55936ce58a9c07b071deab9d6e799d123b43637b909159

Contents?: true

Size: 985 Bytes

Versions: 21

Compression:

Stored size: 985 Bytes

Contents

PaymentRowView = Backbone.View.extend
  events:
    "click .js-edit": "onEdit"
    "click .js-save": "onSave"
    "click .js-cancel": "onCancel"
    "click .js-display-amount": "onEdit"

  onEdit: (e) ->
    e.preventDefault()
    @$el.addClass("editing")

  onCancel: (e) ->
    e.preventDefault()
    @$el.removeClass("editing")

  onSave: (e) ->
    e.preventDefault()
    amount = @$(".js-edit-amount").val()
    options =
      success: (model, response, options) =>
        @$(".js-display-amount").text(model.attributes.display_amount)
        @$el.removeClass("editing")
      error: (model, response, options) =>
        show_flash 'error', response.responseJSON.error
    @model.save({ amount: amount }, options)

$ ->
  order_id = $('#payments').data('order-id')
  Payment = Backbone.Model.extend
    urlRoot: Spree.routes.payments_api(order_id)

  $('tr.payment').each ->
    model = new Payment({id: $(@).data('payment-id')})
    new PaymentRowView({el: @, model: model})

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
solidus_backend-2.1.1 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-2.0.3 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-1.4.2 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-1.3.2 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-2.0.2 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-1.4.1 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-2.1.0 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-2.1.0.rc1 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-2.0.1 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-2.1.0.beta1 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-2.0.0 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-1.4.0 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-2.0.0.rc1 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-1.4.0.rc1 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-2.0.0.beta1 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-1.4.0.beta1 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-1.3.1 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-1.3.0 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-1.3.0.rc2 app/assets/javascripts/spree/backend/payments/edit.js.coffee
solidus_backend-1.3.0.rc1 app/assets/javascripts/spree/backend/payments/edit.js.coffee