administrate-field-state_machine 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +12 -5
- data/administrate-field-state_machine.gemspec +1 -1
- data/app/views/fields/state_machine/_form.html.erb +7 -10
- data/lib/administrate/field/state_machine.rb +3 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc1b91185f4fbb162b1a19f60caa253da4955243
|
4
|
+
data.tar.gz: 8c2e3f0d3249ec9d97dc5b1f1673e54463c0ca95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cea98a35ceea7bddaa5f2f0d92ce50170b6a84d0bd418821c3704f4448f12a6db0e1c158e841b1de8ff98bebd998d330a837cd87a4a9e8e81098f838d8918ae
|
7
|
+
data.tar.gz: ef5766e2136a32c1940d31bd48640ec7b3f45ebead7ebacfec7aae70ae3ba37ae72ac63c011ac13fb08139c145c3ef32bc9a1edfc02099ee94befb8ea0a9ec86
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.0.2](https://github.com/z-productions/administrate-field-state_machine/tree/v0.0.2) (2016-11-25)
|
4
|
+
[Full Changelog](https://github.com/z-productions/administrate-field-state_machine/compare/v0.0.1...v0.0.2)
|
5
|
+
|
6
|
+
* Switch to selecting transitions rather than states
|
7
|
+
|
3
8
|
## [v0.0.1](https://github.com/z-productions/administrate-field-state_machine/tree/v0.0.1) (2016-11-16)
|
4
9
|
First release
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,10 +4,7 @@
|
|
4
4
|
|
5
5
|
A plugin to handle [state machine] attributes in [Administrate].
|
6
6
|
|
7
|
-
|
8
|
-
otherwise it will be disabled.
|
9
|
-
|
10
|
-
**IMPORTANT**
|
7
|
+
## IMPORTANT NOTICE
|
11
8
|
This gem relies on the original resource being passed to the field.
|
12
9
|
This functionality is not yet merged in Administrate
|
13
10
|
([a PR has been in review for a while](thoughtbot/administrate#381)),
|
@@ -18,7 +15,7 @@ so you will have to fork and [patch it](https://git.io/vXhCo) yourself.
|
|
18
15
|
Add it to your `Gemfile`:
|
19
16
|
|
20
17
|
```ruby
|
21
|
-
gem 'administrate-field-state_machine', '~> 0.0.
|
18
|
+
gem 'administrate-field-state_machine', '~> 0.0.2'
|
22
19
|
```
|
23
20
|
|
24
21
|
Run:
|
@@ -35,6 +32,16 @@ ATTRIBUTE_TYPES = {
|
|
35
32
|
}.freeze
|
36
33
|
```
|
37
34
|
|
35
|
+
Add to your `FooController`:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
def permitted_attributes
|
39
|
+
super + [:state_event]
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
[`state_event`](https://github.com/state-machines/state_machines#explicit-vs-implicit-event-transitions) is used by the state machine gem to implicitly trigger the event.
|
44
|
+
|
38
45
|
## About
|
39
46
|
|
40
47
|
Administrate::Field::StateMachine is maintained by [z.productions].
|
@@ -2,7 +2,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'administrate-field-state_machine'
|
5
|
-
gem.version = '0.0.
|
5
|
+
gem.version = '0.0.2'
|
6
6
|
gem.authors = ['Michele Gerarduzzi']
|
7
7
|
gem.email = ['michele.gerarduzzi@gmail.com']
|
8
8
|
gem.homepage = 'https://github.com/z-productions/administrate-field-state_machine'
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<%#
|
2
2
|
# StateMachine Form Partial
|
3
3
|
|
4
|
-
This partial renders a selectable
|
5
|
-
Saving the state will trigger callbacks defined in the state machine
|
4
|
+
This partial renders a list of selectable transitions.
|
5
|
+
Saving the state will trigger the event callbacks defined in the state machine.
|
6
6
|
|
7
7
|
## Local variables:
|
8
8
|
|
@@ -20,13 +20,10 @@ Saving the state will trigger callbacks defined in the state machine
|
|
20
20
|
<%= f.select(
|
21
21
|
:state_event,
|
22
22
|
options_from_collection_for_select(
|
23
|
-
field.
|
24
|
-
:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
disabled: field.all_states - field.possible_states
|
29
|
-
}
|
30
|
-
)
|
23
|
+
field.transitions,
|
24
|
+
:event,
|
25
|
+
->(transition) { transition.event.to_s.humanize },
|
26
|
+
),
|
27
|
+
include_blank: 'Select…'
|
31
28
|
) %>
|
32
29
|
</div>
|
@@ -15,12 +15,9 @@ module Administrate
|
|
15
15
|
data
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
def possible_states
|
23
|
-
resource.state_paths.to_states
|
18
|
+
# First-level transitions that can be triggered from the current state
|
19
|
+
def transitions
|
20
|
+
resource.state_paths.map(&:first).uniq
|
24
21
|
end
|
25
22
|
end
|
26
23
|
end
|