state_machine_buttons 0.4.1 → 1.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
- SHA1:
3
- metadata.gz: 7bedd196ac1f212d5b7cb8806fb8b1afebbb1142
4
- data.tar.gz: 8e32676f146b789fb79454c448de25bfdfabdc51
2
+ SHA256:
3
+ metadata.gz: e206b3b24ecaf6cb6f1fbec6db2f2debf227bfe064b617a9dfb2c2b26a6000d8
4
+ data.tar.gz: 738ee01d490c946fcba23691beef5f5b5a07828280f264ed70af153f9192fe81
5
5
  SHA512:
6
- metadata.gz: '02846ce9cabde9b250a4d7a59cbc29b54434694ba227d441d99b2a62b7a5dce2dbfccdeabae45356872306736e751aa36afbf125a0f55f129c1d66905ff60865'
7
- data.tar.gz: edbe3876f04fbe5e469a66055e501e4b5954474710116a0de98e7220f0db83a94cd64a8f061386ed540f1e48c826820ca4954f757f3f53170775f91523131161
6
+ metadata.gz: 9fd75826686bf059d220d16de4a38c2d2ec5bba6b90ff879e01c818bef6a74449d2642096afb1519ec90339d0620b621bde4269f509c1d393215582f683d1c79
7
+ data.tar.gz: 3393703bffa24ba26d39dcf27c48db0b391553aa7053afca84f268885b67d5d8aa342d714866bc32863d273d2cfa89c7fa9a47b7e5df7901936287f24bd200a8
@@ -2,7 +2,7 @@
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, model_param_name: nil)
5
+ def state_events_buttons(object, state_method: :state, controller:, action:, parameters: {}, without: nil, namespace: nil, model_param_name: nil, button_options: {})
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
@@ -11,23 +11,38 @@ module StateMachineButtons
11
11
  end
12
12
  content_tag(:div, class: 'btn-group-vertical') do
13
13
  transitions.each do |event|
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
+ button(
15
+ event: event.event,
16
+ model_name: model_name,
17
+ object: object,
18
+ state_method: state_method,
19
+ controller: controller,
20
+ action: action,
21
+ namespace: namespace,
22
+ parameters: parameters,
23
+ model_param_name: model_param_name,
24
+ form_options: button_options
25
+ )
15
26
  end
16
27
  end
17
28
  end
18
29
 
19
30
  private
20
31
 
21
- def button(event:, model_name:, object:, state_method:, route_method:, namespace:, parameters:, model_param_name:)
22
- route_method ||= "#{namespace.present? ? "#{namespace}_": ""}#{model_name.gsub('/', '_')}_path"
23
- href = send route_method, object.model, parameters.merge(model_param_name => { state_method => event.to })
32
+ def button(event:, model_name:, object:, state_method:, controller:, action:, namespace:, parameters:, model_param_name:, form_options:)
33
+ attributes = { "#{state_method}_event" => event }
24
34
  concat(
25
- link_to(
26
- href,
27
- class: "btn btn-sm btn-xs btn-#{object.send("#{state_method}_button_color", event.event)}",
28
- method: :patch
35
+ patch_button(
36
+ record: object.model,
37
+ controller: controller,
38
+ action: action,
39
+ parameters: parameters,
40
+ attributes: attributes,
41
+ model_name: model_param_name,
42
+ button_options: { class: "btn btn-sm btn-xs btn-#{object.send("#{state_method}_button_color", event)}" },
43
+ form_options: form_options
29
44
  ) do
30
- object.class.send "human_#{state_method}_event_name", event.event
45
+ object.class.send "human_#{state_method}_event_name", event
31
46
  end
32
47
  )
33
48
  end
@@ -1,3 +1,3 @@
1
1
  module StateMachineButtons
2
- VERSION = '0.4.1'
2
+ VERSION = '1.0'
3
3
  end
@@ -22,4 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.16"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "minitest", "~> 5.0"
25
+
26
+ spec.add_dependency 'smart_buttons'
25
27
  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.4.1
4
+ version: '1.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: 2018-01-08 00:00:00.000000000 Z
11
+ date: 2020-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: smart_buttons
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: State Machines events buttons renderer
56
70
  email:
57
71
  - kalashnikovisme@gmail.com
@@ -88,8 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.6.13
105
+ rubygems_version: 3.0.3
93
106
  signing_key:
94
107
  specification_version: 4
95
108
  summary: State Machines events buttons renderer