-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert payments row backbone view into JS
Per our definition newly introduced files should be JS instead of Coffeescript.
- Loading branch information
Showing
2 changed files
with
35 additions
and
24 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
backend/app/assets/javascripts/spree/backend/views/payment/payment_row.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Spree.Views.Payment.PaymentRow = Backbone.View.extend({ | ||
events: { | ||
"click .js-edit": "onEdit", | ||
"click .js-save": "onSave", | ||
"click .js-cancel": "onCancel" | ||
}, | ||
|
||
onEdit: function(e) { | ||
e.preventDefault(); | ||
this.$el.addClass("editing"); | ||
}, | ||
|
||
onCancel: function(e) { | ||
e.preventDefault(); | ||
this.$el.removeClass("editing"); | ||
}, | ||
|
||
onSave: function(e) { | ||
var view = this; | ||
var amount = this.$(".js-edit-amount").val(); | ||
var options = { | ||
success: function(model, response, options) { | ||
view.$(".js-display-amount").text(model.attributes.display_amount); | ||
view.$el.removeClass("editing"); | ||
}, | ||
error: function(model, response, options) { | ||
show_flash('error', response.responseJSON.error); | ||
} | ||
}; | ||
e.preventDefault(); | ||
this.model.save({ | ||
amount: amount | ||
}, options); | ||
} | ||
}); |
24 changes: 0 additions & 24 deletions
24
backend/app/assets/javascripts/spree/backend/views/payment/payment_row.js.coffee
This file was deleted.
Oops, something went wrong.