nimbleshop_splitable 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,30 +19,16 @@ module NimbleshopSplitable
19
19
  end
20
20
 
21
21
  def update
22
- respond_to do |format|
23
- if @payment_method.update_attributes(post_params[:splitable])
24
- format.js {
25
- flash[:notice] = "Splitable record was successfully updated"
26
- render js: "window.location = '/admin/payment_methods'"
27
- }
28
- else
29
- msg = @payment_method.errors.full_messages.first
30
- error = %Q[alert("#{msg}")]
31
- format.js { render js: error }
32
- end
33
- end
34
- end
22
+ alert_msg = if @payment_method.update_attributes(post_params[:splitable])
23
+ msg = "Record has been updated"
24
+ %Q[alert("#{msg}")]
25
+ else
26
+ msg = @payment_method.errors.full_messages.first
27
+ %Q[alert("#{msg}")]
28
+ end
35
29
 
36
- def destroy
37
30
  respond_to do |format|
38
- if @payment_method.destroy
39
- format.js {
40
- flash[:notice] = "Splitable record was successfully deleted"
41
- render js: "window.location = '/admin/payment_methods'" #TODO hardcoded url
42
- }
43
- else
44
- format.js { render js: 'Splitable record could not be deleted. Please try again later.' }
45
- end
31
+ format.js { render js: alert_msg }
46
32
  end
47
33
  end
48
34
 
@@ -1,35 +1,53 @@
1
- <div class='payment-method-engine-well'>
2
-
3
- <div>
4
- <h2> Splitable </h2>
5
-
6
- <div class="edit_link">
7
- <%= link_to 'Edit', '#', class: "nimbleshop-payment-method-edit", id: "nimbleshop-splitable-payment-method-edit" %>
8
- <%= link_to nimbleshop_splitable.splitable_path, confirm: 'Do you really want to delete Authorize.net payment method',
9
- class: 'nimbleshop-payment-method-delete',
10
- method: :delete,
11
- remote: true do %>
12
- <i class='icon-remove icon-white'></i>
13
- <% end %>
14
- </div>
15
-
16
- <%= nimbleshop_splitable_picture_on_admin_payment_methods %>
17
-
18
- <div class='clear'></div>
19
- </div>
20
-
21
- <%= render partial: '/nimbleshop_splitable/splitables/form' %>
22
-
23
- </div>
24
-
25
- <script>
26
- $(function(){
27
-
28
- $('#nimbleshop-splitable-payment-method-edit').toggle(function(){
29
- $('#nimbleshop-splitable-form-well').show();
30
- }, function(){
31
- $('#nimbleshop-splitable-form-well').hide();
32
- });
33
-
34
- })
35
- </script>
1
+ <% payment_method = NimbleshopSplitable::Splitable.first %>
2
+
3
+ <%= content_tag :div, style: 'display:none', data: { behavior: "payment-method-form-#{payment_method.permalink}" } do %>
4
+
5
+ <div style="width:100px;margin-left:90px;"><%= nimbleshop_splitable_picture_on_admin_payment_methods %></div>
6
+ <br />
7
+
8
+
9
+ <%= form_for NimbleshopSplitable::Splitable.first, url: '/nimbleshop_splitable/splitable',
10
+ remote: true,
11
+ html: { method: 'put',
12
+ id: 'nimbleshop-splitable-form',
13
+ class: 'nimbleshop-payment-method-form form-horizontal'} do |f| %>
14
+
15
+ <fieldset>
16
+ <div class="control-group">
17
+ <%= f.label :api_key, nil, class: 'control-label' %>
18
+ <div class="controls">
19
+ <%= f.text_field :api_key, class: 'span6' %>
20
+ </div>
21
+ </div>
22
+
23
+ <div class="control-group">
24
+ <%= f.label :api_secret, nil, class: 'control-label' %>
25
+ <div class="controls">
26
+ <%= f.text_field :api_secret, class: 'span6' %>
27
+ </div>
28
+ </div>
29
+
30
+ <div class="control-group">
31
+ <%= f.label :expires_in, nil, class: 'control-label' %>
32
+ <div class="controls">
33
+ <%= f.text_field :expires_in, class: 'span6' %>
34
+ </div>
35
+ </div>
36
+
37
+ <div class="control-group">
38
+ <div class="controls">
39
+ <label class='checkbox'>
40
+ <%= f.check_box :mode, {}, 'test', 'production' %> Enable test mode
41
+ </label>
42
+ </div>
43
+ </div>
44
+
45
+ </fieldset>
46
+
47
+ <div class="form-actions">
48
+ <%= link_to 'Disable', main_app.disable_admin_payment_method_path(payment_method), class: 'disable-payment-method-link', method: :put %>
49
+ &nbsp;
50
+ <%= f.submit('Submit', class: 'btn btn-primary') %>
51
+ </div>
52
+ <% end %>
53
+ <% end %>
@@ -71,7 +71,7 @@ module NimbleshopSplitable
71
71
  end
72
72
 
73
73
  def do_purchase(options = {})
74
- add_to_order(options, 'purchased')
74
+ record_transaction(options, 'purchased')
75
75
  order.update_attributes(payment_method: payment_method)
76
76
  order.purchase!
77
77
 
@@ -79,16 +79,15 @@ module NimbleshopSplitable
79
79
  end
80
80
 
81
81
  def do_void(options = {})
82
- add_to_order(options, 'voided')
82
+ record_transaction(options, 'voided')
83
83
  order.update_attributes(payment_method: payment_method)
84
84
  order.void!
85
85
 
86
86
  true
87
87
  end
88
88
 
89
- def add_to_order(params, operation)
89
+ def record_transaction(params, operation)
90
90
  order.payment_transactions.create(operation: operation,
91
- success: true,
92
91
  transaction_gid: params[:transaction_id],
93
92
  params: params)
94
93
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nimbleshop_splitable
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
  - !ruby/object:Gem::Dependency
16
16
  name: activemerchant
@@ -44,7 +44,6 @@ files:
44
44
  - app/models/nimbleshop_splitable/splitable.rb
45
45
  - app/views/nimbleshop_splitable/payments/_new.html.erb
46
46
  - app/views/nimbleshop_splitable/splitables/_edit.html.erb
47
- - app/views/nimbleshop_splitable/splitables/_form.html.erb
48
47
  - config/routes.rb
49
48
  - lib/nimbleshop_splitable/engine.rb
50
49
  - lib/nimbleshop_splitable/gateway.rb
@@ -74,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
73
  version: '0'
75
74
  segments:
76
75
  - 0
77
- hash: -1909870227371927329
76
+ hash: -2530981225204108230
78
77
  required_rubygems_version: !ruby/object:Gem::Requirement
79
78
  none: false
80
79
  requirements:
@@ -83,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
82
  version: '0'
84
83
  segments:
85
84
  - 0
86
- hash: -1909870227371927329
85
+ hash: -2530981225204108230
87
86
  requirements: []
88
87
  rubyforge_project:
89
88
  rubygems_version: 1.8.24
@@ -1,47 +0,0 @@
1
- <div class='well nimbleshop-payment-method-form-well' id='nimbleshop-splitable-form-well' style='display:none;'>
2
-
3
- <%= form_for NimbleshopSplitable::Splitable.first, url: '/nimbleshop_splitable/splitable',
4
- remote: true,
5
- html: { method: 'put',
6
- id: 'nimbleshop-splitable-form',
7
- class: 'nimbleshop-payment-method-form form-horizontal'} do |f| %>
8
-
9
- <fieldset>
10
- <div class="control-group">
11
- <%= f.label :api_key, nil, class: 'control-label' %>
12
- <div class="controls">
13
- <%= f.text_field :api_key, class: 'span6' %>
14
- </div>
15
- </div>
16
-
17
- <div class="control-group">
18
- <%= f.label :api_secret, nil, class: 'control-label' %>
19
- <div class="controls">
20
- <%= f.text_field :api_secret, class: 'span6' %>
21
- </div>
22
- </div>
23
-
24
- <div class="control-group">
25
- <%= f.label :expires_in, nil, class: 'control-label' %>
26
- <div class="controls">
27
- <%= f.text_field :expires_in, class: 'span6' %>
28
- </div>
29
- </div>
30
-
31
- <div class="control-group">
32
- <div class="controls">
33
- <label class='checkbox'>
34
- <%= f.check_box :mode, {}, 'test', 'production' %> Enable test mode
35
- </label>
36
- </div>
37
- </div>
38
-
39
- </fieldset>
40
-
41
- <div class="form-actions">
42
- <%= f.submit('Submit', class: 'btn btn-primary') %>
43
- &nbsp;
44
- <%= link_to t(:cancel), nimbleshop_splitable.splitable_path, class: 'cancel btn' %>
45
- </div>
46
- <% end %>
47
- </div>