state_machine_buttons 1.0 → 2.0

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
  SHA256:
3
- metadata.gz: e206b3b24ecaf6cb6f1fbec6db2f2debf227bfe064b617a9dfb2c2b26a6000d8
4
- data.tar.gz: 738ee01d490c946fcba23691beef5f5b5a07828280f264ed70af153f9192fe81
3
+ metadata.gz: f3dd4faca018028bd67f43b11c29cc9ff4ca7fd85c7259075cad6e9a2157771c
4
+ data.tar.gz: 652cf144d705d79f9c85db969cbb1b1968f7e095bc4cfc948ebe79c42ba50e56
5
5
  SHA512:
6
- metadata.gz: 9fd75826686bf059d220d16de4a38c2d2ec5bba6b90ff879e01c818bef6a74449d2642096afb1519ec90339d0620b621bde4269f509c1d393215582f683d1c79
7
- data.tar.gz: 3393703bffa24ba26d39dcf27c48db0b391553aa7053afca84f268885b67d5d8aa342d714866bc32863d273d2cfa89c7fa9a47b7e5df7901936287f24bd200a8
6
+ metadata.gz: 7bf8ce226badcb97849e3bf3ac9acf008e824164f7da69231011f8f5fd43cf7070365e541cadb745f374f4ff6975330468b1cdf10d3a938167211a6734da6c65
7
+ data.tar.gz: 6c69c3c9cd0225abafd76ec15086dc4975c789e0d68eabd2bcc947e3109283cecd03cf8ad249f170288ec8620db978f13ac301b23658efbd8efa74cdc84e354f
@@ -6,13 +6,13 @@ module StateMachineButtons
6
6
  model_name = object.model.model_name.name.underscore
7
7
  model_param_name ||= model_name
8
8
  excepted_actions = without.is_a?(Array) ? without.map(&:to_sym) : [without.to_sym] if without
9
- transitions = object.model.send("#{state_method}_transitions").reject do |t|
10
- excepted_actions.present? && excepted_actions.include?(t.event)
9
+ transitions = object.model.aasm(state_method).permitted_transitions.reject do |t|
10
+ excepted_actions.present? && excepted_actions.include?(t[:event])
11
11
  end
12
12
  content_tag(:div, class: 'btn-group-vertical') do
13
13
  transitions.each do |event|
14
14
  button(
15
- event: event.event,
15
+ event: event[:event],
16
16
  model_name: model_name,
17
17
  object: object,
18
18
  state_method: state_method,
@@ -30,7 +30,7 @@ module StateMachineButtons
30
30
  private
31
31
 
32
32
  def button(event:, model_name:, object:, state_method:, controller:, action:, namespace:, parameters:, model_param_name:, form_options:)
33
- attributes = { "#{state_method}_event" => event }
33
+ attributes = { aasm_event: event }
34
34
  concat(
35
35
  patch_button(
36
36
  record: object.model,
@@ -42,7 +42,7 @@ module StateMachineButtons
42
42
  button_options: { class: "btn btn-sm btn-xs btn-#{object.send("#{state_method}_button_color", event)}" },
43
43
  form_options: form_options
44
44
  ) do
45
- object.class.send "human_#{state_method}_event_name", event
45
+ I18n.t("state_machines.#{object.model.class.name.underscore}.#{state_method}.events.#{object.model.aasm(state_method).events.select { |ev| ev.name == event }.first.name}")
46
46
  end
47
47
  )
48
48
  end
@@ -1,3 +1,3 @@
1
1
  module StateMachineButtons
2
- VERSION = '1.0'
2
+ VERSION = '2.0'
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: '1.0'
4
+ version: '2.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-25 00:00:00.000000000 Z
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  requirements: []
105
- rubygems_version: 3.0.3
105
+ rubygems_version: 3.1.2
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: State Machines events buttons renderer