state_machine_buttons 0.3 → 0.4

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: 7d9fec7fe4d84069ba585f236674733697823b8d
4
- data.tar.gz: 98067277e8ded820f95b59f87a110622fd5f7efb
3
+ metadata.gz: ef89473af1ebcc8e04611cea16c599851dbfad64
4
+ data.tar.gz: 0dc344776c9fc577d3b026969373646fec2db86e
5
5
  SHA512:
6
- metadata.gz: 392dcb7900aaaa6b920731285cc09203444bddf63cb3419de1febe233e163ba9dbdaa0c3a2c887ca06b752edafd0c15eb5cf71990f84cc04e68e7cad069bbf79
7
- data.tar.gz: 19ead81dadb3e5d8eba5e840266e179d5a410f96e0d40c1fefd272cd47c66772301b0d69b4408f619655024b25ebe7f2e4902eeb96ef5cb401a84299c9b11be3
6
+ metadata.gz: b9ae8dd74b32b9e52d3046abc3d4dc454600e9be8f928dd325d77e8341bdbd8abd23fac6108e0bdc900e1654667ea7474fe776155c85c33b9e991d95136b7d49
7
+ data.tar.gz: de51605c9467dd1bed27c3ea94acaf4f7802b75ca2c7cc3abc1d5ff43dfe966bcbf39b254e4ec8e40a96f774c9f3e3c1b96d0cbdbbc54984c61011da0a84f0ba
@@ -2,29 +2,29 @@
2
2
 
3
3
  module StateMachineButtons
4
4
  module Renderer
5
- def state_events_buttons(object, state_method: :state, route_method: nil, parameters: {}, without: nil, namespace: nil)
5
+ def state_events_buttons(object, state_method: :state, route_method: nil, parameters: {}, without: nil, namespace: nil, model_param_name: nil)
6
6
  model_name = object.model.model_name.name.underscore
7
+ model_param_name ||= model_name
7
8
  excepted_actions = without.is_a?(Array) ? without.map(&:to_sym) : [without.to_sym] if without
8
9
  transitions = object.model.send("#{state_method}_transitions").reject do |t|
9
10
  excepted_actions.present? && excepted_actions.include?(t.event)
10
11
  end
11
12
  content_tag(:div, class: 'btn-group-vertical') do
12
13
  transitions.each do |event|
13
- button event: event, model_name: model_name, object: object, state_method: state_method, route_method: route_method, namespace: namespace, parameters: parameters
14
+ button event: event, model_name: model_name, object: object, state_method: state_method, route_method: route_method, namespace: namespace, parameters: parameters, model_param_name: model_param_name
14
15
  end
15
16
  end
16
17
  end
17
18
 
18
19
  private
19
20
 
20
- def button(event:, model_name:, object:, state_method:, route_method:, namespace:, parameters:)
21
+ def button(event:, model_name:, object:, state_method:, route_method:, namespace:, parameters:, model_param_name:)
21
22
  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
+ href = send route_method, object.model, parameters.merge(model_param_name => { state_method => event.to })
23
24
  concat(
24
25
  link_to(
25
26
  href,
26
- #class: "btn btn-sm btn-xs btn-#{object.send("#{state_method}_button_color", event.event)}",
27
- class: "btn btn-sm btn-xs",
27
+ class: "btn btn-sm btn-xs btn-#{object.send("#{state_method}_button_color", event.event)}",
28
28
  method: :patch
29
29
  ) do
30
30
  t("state_machines.#{model_name}.#{state_method}.events.#{event.event}")
@@ -1,3 +1,3 @@
1
1
  module StateMachineButtons
2
- VERSION = '0.3'
2
+ VERSION = '0.4'
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.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov