state_machine_buttons 0.1.0 → 0.2

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: 030fec9e6125ae8fc0fac331d0d6d5f3d3a0b9c2
4
- data.tar.gz: 87db0bc8b4e658d26efb23b6a3855fcb9692293f
3
+ metadata.gz: 2281ef49c3ce8b2c1716385e0d87972aa5ba44e8
4
+ data.tar.gz: 9a317f931fbd0885a74731f9f36ebebbc0c1fb44
5
5
  SHA512:
6
- metadata.gz: cf0d4b91ffb824ef21e0ef9cce4a4a0a4586656018b79ddfbf30e49a3382e9f945f6d18baa73dd3dd880115453cdf6863241f2132b838454f398243c4569f98a
7
- data.tar.gz: 0e69a459e1fd10208a759d9dc6bcb86bbe8151408a4459ec56b4a91968859c21e579502a6d9d8d845b00691aa47d08d3892ddb6fa1cfee16c02d4c519f747915
6
+ metadata.gz: 8c7d5cec1df817b6ac7b00fd01ecf16e8e79e0b0331b6d61406c3bd51cf7cd44911df25879dbcd8d328f13ece75400cd8cc372ac6c898745e9065c683a9ae0e8
7
+ data.tar.gz: a2df6c70d123ae8d302b2600face18bb963f26f0240ea2005c62c8009294e47710545f27d06ccc73b5535a8567a2a20928fc0c3c091382f0ec0cc58b81c05c7f
@@ -2,23 +2,24 @@
2
2
 
3
3
  module StateMachineButtons
4
4
  module Renderer
5
- def state_events_buttons(object, state_method: :state, url: nil, without: nil)
5
+ def state_events_buttons(object, state_method: :state, url: nil, without: nil, namespace: nil)
6
6
  model_name = object.model.model_name.name.underscore
7
- excepted_actions = without.is_a?(Array) ? without.map(&:to_sym) : [without.to_sym]
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|
9
- excepted_actions.include? t.event
9
+ excepted_actions.present? && excepted_actions.include?(t.event)
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
13
+ button event: event, model_name: model_name, object: object, state_method: state_method, url: url, namespace: namespace
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:)
21
- href = url || send("admin_#{model_name}_path", object.model, model_name => { state_method => event.to })
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 })
22
23
  concat(
23
24
  link_to(
24
25
  href,
@@ -1,3 +1,3 @@
1
1
  module StateMachineButtons
2
- VERSION = "0.1.0"
2
+ VERSION = '0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_machine_buttons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-23 00:00:00.000000000 Z
11
+ date: 2017-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler