administrate-field-state_machine 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e56c0d26a762ae436509c8ffc1c0972d1ce979e8
4
+ data.tar.gz: 46cec486e91733e601f04e377be89c078f023192
5
+ SHA512:
6
+ metadata.gz: 2bcd428af796960a42b40e1a065602f24c16fff3bf707afe08c822b69c05cca8fa9d50eff89d2ad296d61a7feccb02996448021b35cb961d45fb1f3d6aec32a4
7
+ data.tar.gz: 74da2d430020e99a9873cfc83a054115a300bf2186b545ebb46f6e379ac5744c49751ba2da0b09c8dd15148a1d4a3a7a4c5fd177e9a8442cdca780708e3ae92d
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ # Changelog
2
+
3
+ ## [v0.0.1](https://github.com/z-productions/administrate-field-state_machine/tree/v0.0.1) (2016-11-16)
4
+ First release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,159 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ administrate-field-state_machine (0.0.1)
5
+ administrate (~> 0.3.0)
6
+ rails (>= 4.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (5.0.0.1)
12
+ actionpack (= 5.0.0.1)
13
+ nio4r (~> 1.2)
14
+ websocket-driver (~> 0.6.1)
15
+ actionmailer (5.0.0.1)
16
+ actionpack (= 5.0.0.1)
17
+ actionview (= 5.0.0.1)
18
+ activejob (= 5.0.0.1)
19
+ mail (~> 2.5, >= 2.5.4)
20
+ rails-dom-testing (~> 2.0)
21
+ actionpack (5.0.0.1)
22
+ actionview (= 5.0.0.1)
23
+ activesupport (= 5.0.0.1)
24
+ rack (~> 2.0)
25
+ rack-test (~> 0.6.3)
26
+ rails-dom-testing (~> 2.0)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
+ actionview (5.0.0.1)
29
+ activesupport (= 5.0.0.1)
30
+ builder (~> 3.1)
31
+ erubis (~> 2.7.0)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
34
+ activejob (5.0.0.1)
35
+ activesupport (= 5.0.0.1)
36
+ globalid (>= 0.3.6)
37
+ activemodel (5.0.0.1)
38
+ activesupport (= 5.0.0.1)
39
+ activerecord (5.0.0.1)
40
+ activemodel (= 5.0.0.1)
41
+ activesupport (= 5.0.0.1)
42
+ arel (~> 7.0)
43
+ activesupport (5.0.0.1)
44
+ concurrent-ruby (~> 1.0, >= 1.0.2)
45
+ i18n (~> 0.7)
46
+ minitest (~> 5.1)
47
+ tzinfo (~> 1.1)
48
+ administrate (0.3.0)
49
+ autoprefixer-rails (~> 6.0)
50
+ bourbon (~> 4.2)
51
+ datetime_picker_rails (~> 0.0.7)
52
+ jquery-rails (~> 4.0)
53
+ kaminari (~> 0.16)
54
+ momentjs-rails (~> 2.8)
55
+ neat (~> 1.1)
56
+ normalize-rails (~> 3.0)
57
+ rails (>= 4.2, < 5.1)
58
+ sass-rails (~> 5.0)
59
+ selectize-rails (~> 0.6)
60
+ arel (7.1.4)
61
+ autoprefixer-rails (6.5.3)
62
+ execjs
63
+ bourbon (4.2.7)
64
+ sass (~> 3.4)
65
+ thor (~> 0.19)
66
+ builder (3.2.2)
67
+ concurrent-ruby (1.0.2)
68
+ datetime_picker_rails (0.0.7)
69
+ momentjs-rails (>= 2.8.1)
70
+ erubis (2.7.0)
71
+ execjs (2.7.0)
72
+ globalid (0.3.7)
73
+ activesupport (>= 4.1.0)
74
+ i18n (0.7.0)
75
+ jquery-rails (4.2.1)
76
+ rails-dom-testing (>= 1, < 3)
77
+ railties (>= 4.2.0)
78
+ thor (>= 0.14, < 2.0)
79
+ kaminari (0.17.0)
80
+ actionpack (>= 3.0.0)
81
+ activesupport (>= 3.0.0)
82
+ loofah (2.0.3)
83
+ nokogiri (>= 1.5.9)
84
+ mail (2.6.4)
85
+ mime-types (>= 1.16, < 4)
86
+ method_source (0.8.2)
87
+ mime-types (3.1)
88
+ mime-types-data (~> 3.2015)
89
+ mime-types-data (3.2016.0521)
90
+ mini_portile2 (2.1.0)
91
+ minitest (5.9.1)
92
+ momentjs-rails (2.15.1)
93
+ railties (>= 3.1)
94
+ neat (1.8.0)
95
+ sass (>= 3.3)
96
+ thor (~> 0.19)
97
+ nio4r (1.2.1)
98
+ nokogiri (1.6.8.1)
99
+ mini_portile2 (~> 2.1.0)
100
+ normalize-rails (3.0.3)
101
+ rack (2.0.1)
102
+ rack-test (0.6.3)
103
+ rack (>= 1.0)
104
+ rails (5.0.0.1)
105
+ actioncable (= 5.0.0.1)
106
+ actionmailer (= 5.0.0.1)
107
+ actionpack (= 5.0.0.1)
108
+ actionview (= 5.0.0.1)
109
+ activejob (= 5.0.0.1)
110
+ activemodel (= 5.0.0.1)
111
+ activerecord (= 5.0.0.1)
112
+ activesupport (= 5.0.0.1)
113
+ bundler (>= 1.3.0, < 2.0)
114
+ railties (= 5.0.0.1)
115
+ sprockets-rails (>= 2.0.0)
116
+ rails-dom-testing (2.0.1)
117
+ activesupport (>= 4.2.0, < 6.0)
118
+ nokogiri (~> 1.6.0)
119
+ rails-html-sanitizer (1.0.3)
120
+ loofah (~> 2.0)
121
+ railties (5.0.0.1)
122
+ actionpack (= 5.0.0.1)
123
+ activesupport (= 5.0.0.1)
124
+ method_source
125
+ rake (>= 0.8.7)
126
+ thor (>= 0.18.1, < 2.0)
127
+ rake (11.3.0)
128
+ sass (3.4.22)
129
+ sass-rails (5.0.6)
130
+ railties (>= 4.0.0, < 6)
131
+ sass (~> 3.1)
132
+ sprockets (>= 2.8, < 4.0)
133
+ sprockets-rails (>= 2.0, < 4.0)
134
+ tilt (>= 1.1, < 3)
135
+ selectize-rails (0.12.4)
136
+ sprockets (3.7.0)
137
+ concurrent-ruby (~> 1.0)
138
+ rack (> 1, < 3)
139
+ sprockets-rails (3.2.0)
140
+ actionpack (>= 4.0)
141
+ activesupport (>= 4.0)
142
+ sprockets (>= 3.0.0)
143
+ thor (0.19.1)
144
+ thread_safe (0.3.5)
145
+ tilt (2.0.5)
146
+ tzinfo (1.2.2)
147
+ thread_safe (~> 0.1)
148
+ websocket-driver (0.6.4)
149
+ websocket-extensions (>= 0.1.0)
150
+ websocket-extensions (0.1.2)
151
+
152
+ PLATFORMS
153
+ ruby
154
+
155
+ DEPENDENCIES
156
+ administrate-field-state_machine!
157
+
158
+ BUNDLED WITH
159
+ 1.13.6
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2016 z.productions.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Administrate::Field::StateMachine
2
+
3
+ [![Code Climate](https://codeclimate.com/github/z-productions/administrate-field-state_machine/badges/gpa.svg)](https://codeclimate.com/github/z-productions/administrate-field-state_machine)
4
+
5
+ A plugin to handle [state machine] attributes in [Administrate].
6
+
7
+ The edit view uses a `<select>` element: if a transition path to the target state exists that state will be selectable,
8
+ otherwise it will be disabled.
9
+
10
+ **IMPORTANT**
11
+ This gem relies on the original resource being passed to the field.
12
+ This functionality is not yet merged in Administrate
13
+ ([a PR has been in review for a while](thoughtbot/administrate#381)),
14
+ so you will have to fork and [patch it](https://git.io/vXhCo) yourself.
15
+
16
+ ## Usage
17
+
18
+ Add it to your `Gemfile`:
19
+
20
+ ```ruby
21
+ gem 'administrate-field-state_machine', '~> 0.0.1'
22
+ ```
23
+
24
+ Run:
25
+
26
+ ```bash
27
+ $ bundle install
28
+ ```
29
+
30
+ Add to your `FooDashboard`:
31
+
32
+ ```ruby
33
+ ATTRIBUTE_TYPES = {
34
+ bar: Field::StateMachine
35
+ }.freeze
36
+ ```
37
+
38
+ ## About
39
+
40
+ Administrate::Field::StateMachine is maintained by [z.productions].
41
+
42
+ [state machine]: https://github.com/state-machines/state_machines
43
+ [Administrate]: https://github.com/thoughtbot/administrate
44
+ [z.productions]: https://www.z.productions/
@@ -0,0 +1,19 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'administrate-field-state_machine'
5
+ gem.version = '0.0.1'
6
+ gem.authors = ['Michele Gerarduzzi']
7
+ gem.email = ['michele.gerarduzzi@gmail.com']
8
+ gem.homepage = 'https://github.com/z-productions/administrate-field-state_machine'
9
+ gem.summary = 'A plugin to handle state machine attributes in Administrate'
10
+ gem.description = gem.summary
11
+ gem.license = 'MIT'
12
+
13
+ gem.require_paths = ['lib']
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+
17
+ gem.add_runtime_dependency 'administrate', '~> 0.3.0'
18
+ gem.add_runtime_dependency 'rails', '>= 4.2'
19
+ end
@@ -0,0 +1,32 @@
1
+ <%#
2
+ # StateMachine Form Partial
3
+
4
+ This partial renders a selectable state attribute.
5
+ Saving the state will trigger callbacks defined in the state machine
6
+
7
+ ## Local variables:
8
+
9
+ - `f`:
10
+ A Rails form generator, used to help create the appropriate input fields.
11
+ - `field`:
12
+ An instance of Administrate::Field::StateMachine.
13
+ A wrapper around the attribute pulled from the database.
14
+ %>
15
+
16
+ <div class="field-unit__label">
17
+ <%= f.label field.attribute %>
18
+ </div>
19
+ <div class="field-unit__field">
20
+ <%= f.select(
21
+ :state_event,
22
+ options_from_collection_for_select(
23
+ field.all_states,
24
+ :to_s,
25
+ :to_s,
26
+ {
27
+ selected: field.data.presence,
28
+ disabled: field.all_states - field.possible_states
29
+ }
30
+ )
31
+ ) %>
32
+ </div>
@@ -0,0 +1,13 @@
1
+ <%#
2
+ # StateMachine Index Partial
3
+
4
+ This partial renders the current state of the machine
5
+
6
+ ## Local variables:
7
+
8
+ - `field`:
9
+ An instance of Administrate::Field::StateMachine.
10
+ A wrapper around the attribute pulled from the database.
11
+ %>
12
+
13
+ <%= field %>
@@ -0,0 +1,13 @@
1
+ <%#
2
+ # StateMachine Show Partial
3
+
4
+ This partial renders the current state of the machine
5
+
6
+ ## Local variables:
7
+
8
+ - `field`:
9
+ An instance of Administrate::Field::StateMachine.
10
+ A wrapper around the attribute pulled from the database.
11
+ %>
12
+
13
+ <%= field %>
@@ -0,0 +1,27 @@
1
+ require 'administrate/field/base'
2
+ require 'rails'
3
+
4
+ module Administrate
5
+ module Field
6
+ class Engine < ::Rails::Engine
7
+ end
8
+
9
+ class StateMachine < Administrate::Field::Base
10
+ def self.searchable?
11
+ true
12
+ end
13
+
14
+ def to_s
15
+ data
16
+ end
17
+
18
+ def all_states
19
+ resource.class.state_machine.states.map(&:name)
20
+ end
21
+
22
+ def possible_states
23
+ resource.state_paths.to_states
24
+ end
25
+ end
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: administrate-field-state_machine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Michele Gerarduzzi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: administrate
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '4.2'
41
+ description: A plugin to handle state machine attributes in Administrate
42
+ email:
43
+ - michele.gerarduzzi@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - CHANGELOG.md
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE.md
53
+ - README.md
54
+ - administrate-field-state_machine.gemspec
55
+ - app/views/fields/state_machine/_form.html.erb
56
+ - app/views/fields/state_machine/_index.html.erb
57
+ - app/views/fields/state_machine/_show.html.erb
58
+ - lib/administrate/field/state_machine.rb
59
+ homepage: https://github.com/z-productions/administrate-field-state_machine
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.5.2
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: A plugin to handle state machine attributes in Administrate
83
+ test_files: []