nimbleshop_cod 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,21 +4,26 @@ module NimbleshopCod
4
4
 
5
5
  before_filter :load_payment_method
6
6
 
7
- def destroy
7
+ def update
8
+ alert_msg = if @payment_method.update_attributes(post_params[:cod])
9
+ msg = "Record has been updated"
10
+ %Q[alert("#{msg}")]
11
+ else
12
+ msg = @payment_method.errors.full_messages.first
13
+ %Q[alert("#{msg}")]
14
+ end
15
+
8
16
  respond_to do |format|
9
- if @payment_method.destroy
10
- format.js {
11
- flash[:notice] = 'Cash on delivery record was successfully deleted'
12
- render js: "window.location = '/admin/payment_methods'"
13
- }
14
- else
15
- format.js { render js: 'Cash on delivery record could not be deleted. Please try again later.' }
16
- end
17
+ format.js { render js: alert_msg }
17
18
  end
18
19
  end
19
20
 
20
21
  private
21
22
 
23
+ def post_params
24
+ params.permit(cod: [:name])
25
+ end
26
+
22
27
  def load_payment_method
23
28
  @payment_method = NimbleshopCod::Cod.first
24
29
  end
@@ -2,7 +2,7 @@ module NimbleshopCod
2
2
  class PaymentsController < ::ActionController::Base
3
3
 
4
4
  def create
5
- order = Order.find_by_id(session[:order_id])
5
+ order = Order.find_by_id! session[:order_id]
6
6
  order.update_attributes(payment_method: NimbleshopCod::Cod.first)
7
7
  order.pending
8
8
 
@@ -1,4 +1,5 @@
1
1
  module NimbleshopCod
2
2
  class Cod < PaymentMethod
3
+ validates_presence_of :name
3
4
  end
4
5
  end
@@ -1,29 +1,26 @@
1
- <div class='payment-method-engine-well'>
1
+ <% payment_method = NimbleshopCod::Cod.first %>
2
2
 
3
- <div>
4
- <h2> Cash on delivery </h2>
3
+ <%= content_tag :div, style: 'display:none', data: { behavior: "payment-method-form-#{payment_method.permalink}" } do %>
5
4
 
6
- <div class='edit_link'>
7
- <%= link_to nimbleshop_cod.cod_path, confirm: 'Do you really want to delete Cash on delivery payment method',
8
- class: 'nimbleshop-payment-method-delete',
9
- method: :delete,
10
- remote: true do %>
11
- <i class='icon-remove icon-white'></i>
12
- <% end %>
13
- </div>
14
- <div class='clear'></div>
15
- </div>
5
+ <%= form_for payment_method, url: '/nimbleshop_cod/cod',
6
+ remote: true,
7
+ html: { method: 'put',
8
+ id: 'nimbleshop-cod-form',
9
+ class: 'nimbleshop-payment-method-form form-horizontal'} do |f| %>
16
10
 
17
- </div>
11
+ <fieldset>
12
+ <div class="control-group">
13
+ <%= f.label :name, nil, class: 'control-label' %>
14
+ <div class="controls">
15
+ <%= f.text_field :name, class: 'span6' %>
16
+ </div>
17
+ </div>
18
+ </fieldset>
18
19
 
19
- <script>
20
- $(function(){
21
-
22
- $('#nimbleshop-cod-payment-method-edit').toggle(function(){
23
- $('#nimbleshop-cod-form-well').show();
24
- }, function(){
25
- $('#nimbleshop-cod-form-well').hide();
26
- });
27
-
28
- })
29
- </script>
20
+ <div class="form-actions">
21
+ <%= f.submit('Submit', class: 'btn btn-primary') %>
22
+ &nbsp;
23
+ <%= link_to 'Disable', main_app.disable_admin_payment_method_path(payment_method), class: 'disable-payment-method-link', method: :put %>
24
+ </div>
25
+ <% end %>
26
+ <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nimbleshop_cod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-23 00:00:00.000000000 Z
13
+ date: 2012-11-12 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Provides Cash on delivery support to nimbleShop
16
16
  email:
@@ -25,7 +25,6 @@ files:
25
25
  - app/helpers/nimbleshop_cod/exposed_helper.rb
26
26
  - app/models/nimbleshop_cod/cod.rb
27
27
  - app/views/nimbleshop_cod/cods/_edit.html.erb
28
- - app/views/nimbleshop_cod/cods/_form.html.erb
29
28
  - app/views/nimbleshop_cod/payments/_new.html.erb
30
29
  - config/routes.rb
31
30
  - lib/nimbleshop_cod/engine.rb
@@ -48,7 +47,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
47
  version: '0'
49
48
  segments:
50
49
  - 0
51
- hash: -315151620456155521
50
+ hash: -630379733786449362
52
51
  required_rubygems_version: !ruby/object:Gem::Requirement
53
52
  none: false
54
53
  requirements:
@@ -57,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
56
  version: '0'
58
57
  segments:
59
58
  - 0
60
- hash: -315151620456155521
59
+ hash: -630379733786449362
61
60
  requirements: []
62
61
  rubyforge_project:
63
62
  rubygems_version: 1.8.24
@@ -1,26 +0,0 @@
1
- <div class='well nimbleshop-payment-method-form-well' id='nimbleshop-cod-form-well' style='display:none;'>
2
-
3
- <%= form_for NimbleshopSplitable::Splitable.first, url: '/nimbleshop_cod/cod',
4
- remote: true,
5
- html: { method: 'put',
6
- id: 'nimbleshop-cod-form',
7
- class: 'nimbleshop-payment-method-form form-horizontal'} do |f| %>
8
-
9
- <fieldset>
10
- <div class="control-group">
11
- <div class="controls">
12
- <label class='checkbox'>
13
- <%= f.check_box :mode, {}, 'test', 'production' %> Enable test mode
14
- </label>
15
- </div>
16
- </div>
17
-
18
- </fieldset>
19
-
20
- <div class="form-actions">
21
- <%= f.submit('Submit', class: 'btn btn-primary') %>
22
- &nbsp;
23
- <%= link_to t(:cancel), nimbleshop_splitable.splitable_path, class: 'cancel btn' %>
24
- </div>
25
- <% end %>
26
- </div>