Skip to content
Browse files

general improvements. updated Versionfile to prepare for new spree-0-…

…70-stable branch (and 1.0 upgrade)
  • Loading branch information...
1 parent 0787eac commit 5b1b5a46e9da3ac642bc735a3f54cbbc072f3b9f @jsqu99 jsqu99 committed
View
3 Versionfile
@@ -1,4 +1,5 @@
-"0.70.x" => { :branch => "master"}
+"1.0.x" => { :branch => "master"}
+"0.70.x" => { :branch => "spree-0-70-stable"}
# This file is used to designate compatibilty with different versions of Spree
# Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
View
16 app/assets/javascripts/store/spree_reuse_credit_card.js
@@ -1,2 +1,16 @@
//= require store/spree_core
-//= require jquery.alerts/jquery.alerts
+//= require jquery.alerts/jquery.alerts
+//= require_self
+
+function displayCreditCardDeleteStatus(notice) {
+ notice_div = $('.flash.notice');
+
+ if notice {
+ if (notice_div.length > 0) {
+ notice_div.html(notice);
+ notice_div.show();
+ } else {
+ $("#card_notice").html('<div class="flash notice">' + notice + '</div>');
+ }
+ }
+}
View
10 app/controllers/creditcards_controller.rb
@@ -1,6 +1,6 @@
class CreditcardsController < Spree::BaseController
- respond_to :js
+ respond_to :json
def destroy
@creditcard = Spree::Creditcard.find(params["id"])
@@ -10,11 +10,13 @@ def destroy
# I'm thinking we want to always leave them alone
if @creditcard.update_attribute(:deleted_at, Time.now)
- flash[:notice] = I18n.t(:creditcard_successfully_removed)
respond_with(@creditcard) do |format|
- format.js { render :partial => "/shared/card_destroy" }
+ format.json { render :status => 200 }
+ end
+ else
+ respond_with(@creditcard) do |format|
+ format.json { render :status => 500 }
end
end
-
end
end
View
12 app/helpers/creditcards_helper.rb
@@ -0,0 +1,12 @@
+module CreditcardsHelper
+ def link_to_delete_credit_card(card)
+ # <%# passing in an explicit 'url' here let's us make use of this 'admin' helper and bypass the object_url %>
+ # <%# (from resourcec_ontroller) that is embedded in the helper %>
+
+ %(link_to_delete card, {
+ :url => main_app.creditcard_url(card),
+ :dataType => 'json',
+ :success => "function(r){ jQuery('##{dom_id card}').fadeOut('hide'); displayCreditCardDeleteStatus(#{t(:creditcard_successfully_removed)}); }",
+ :failure => "function(r){ displayCreditCardDeleteStatus(#{t(:creditcard_not_removed)}); }"} )
+ end
+end
View
5 app/views/users/_card_admin.html.erb
@@ -26,10 +26,7 @@
<td><%= card.last_digits %></td>
<td><%= card.month %></td>
<td><%= card.year %></td>
-
- <%# passing in an explicit 'url' here let's us make use of this 'admin' helper and bypass the object_url %>
- <%# (from resource_controller) that is embedded in the helper %>
- <td><%= link_to_delete card, {:url => main_app.creditcard_url(card)} %></td>
+ <td><%= link_to_delete_credit_card(card) %></td>
</tr>
<% end %>
</tbody>
View
2 config/locales/en.yml
@@ -1,4 +1,4 @@
---
en:
creditcard_successfully_removed: "Credit Card Successfully Removed"
- creditcard_not_removed: "Credit card could not be deleted"
+ creditcard_not_removed: "There Was a Problem Removing the Credit Card"

0 comments on commit 5b1b5a4

Please sign in to comment.
Something went wrong with that request. Please try again.