state_machine_buttons 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2281ef49c3ce8b2c1716385e0d87972aa5ba44e8
4
- data.tar.gz: 9a317f931fbd0885a74731f9f36ebebbc0c1fb44
3
+ metadata.gz: 7d9fec7fe4d84069ba585f236674733697823b8d
4
+ data.tar.gz: 98067277e8ded820f95b59f87a110622fd5f7efb
5
5
  SHA512:
6
- metadata.gz: 8c7d5cec1df817b6ac7b00fd01ecf16e8e79e0b0331b6d61406c3bd51cf7cd44911df25879dbcd8d328f13ece75400cd8cc372ac6c898745e9065c683a9ae0e8
7
- data.tar.gz: a2df6c70d123ae8d302b2600face18bb963f26f0240ea2005c62c8009294e47710545f27d06ccc73b5535a8567a2a20928fc0c3c091382f0ec0cc58b81c05c7f
6
+ metadata.gz: 392dcb7900aaaa6b920731285cc09203444bddf63cb3419de1febe233e163ba9dbdaa0c3a2c887ca06b752edafd0c15eb5cf71990f84cc04e68e7cad069bbf79
7
+ data.tar.gz: 19ead81dadb3e5d8eba5e840266e179d5a410f96e0d40c1fefd272cd47c66772301b0d69b4408f619655024b25ebe7f2e4902eeb96ef5cb401a84299c9b11be3
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
@@ -2,7 +2,7 @@
2
2
 
3
3
  module StateMachineButtons
4
4
  module Renderer
5
- def state_events_buttons(object, state_method: :state, url: nil, without: nil, namespace: nil)
5
+ def state_events_buttons(object, state_method: :state, route_method: nil, parameters: {}, without: nil, namespace: nil)
6
6
  model_name = object.model.model_name.name.underscore
7
7
  excepted_actions = without.is_a?(Array) ? without.map(&:to_sym) : [without.to_sym] if without
8
8
  transitions = object.model.send("#{state_method}_transitions").reject do |t|
@@ -10,20 +10,21 @@ module StateMachineButtons
10
10
  end
11
11
  content_tag(:div, class: 'btn-group-vertical') do
12
12
  transitions.each do |event|
13
- button event: event, model_name: model_name, object: object, state_method: state_method, url: url, namespace: namespace
13
+ button event: event, model_name: model_name, object: object, state_method: state_method, route_method: route_method, namespace: namespace, parameters: parameters
14
14
  end
15
15
  end
16
16
  end
17
17
 
18
18
  private
19
19
 
20
- def button(event:, model_name:, object:, state_method:, url:, namespace:)
21
- route_method_name = "#{namespace.present? ? "#{namespace}_": ""}#{model_name.gsub('/', '_')}_path"
22
- href = url || send(route_method_name, object.model, model_name => { state_method => event.to })
20
+ def button(event:, model_name:, object:, state_method:, route_method:, namespace:, parameters:)
21
+ route_method ||= "#{namespace.present? ? "#{namespace}_": ""}#{model_name.gsub('/', '_')}_path"
22
+ href = send route_method, object.model, parameters.merge(model_name => { state_method => event.to })
23
23
  concat(
24
24
  link_to(
25
25
  href,
26
- class: "btn btn-sm btn-xs btn-#{object.send("#{state_method}_button_color", event.event)}",
26
+ #class: "btn btn-sm btn-xs btn-#{object.send("#{state_method}_button_color", event.event)}",
27
+ class: "btn btn-sm btn-xs",
27
28
  method: :patch
28
29
  ) do
29
30
  t("state_machines.#{model_name}.#{state_method}.events.#{event.event}")
@@ -1,3 +1,3 @@
1
1
  module StateMachineButtons
2
- VERSION = '0.2'
2
+ VERSION = '0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_machine_buttons
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov