administrate-field-aasm 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: edb7ef7f0ce0c75e5dfc935f6e47e92e29986658b207411b065f3228a03d8e19
4
+ data.tar.gz: b99985de574e8649c5c4037c4c576cb3d8468f63e784b8e1498d2f0186479ff4
5
+ SHA512:
6
+ metadata.gz: '0190646688f0b7b23895702a1045bf4b85b04248d5854ff21e782f9f143979951a2f1366fc04c6cdd747476c9b883cdf76bf060c5a017a41a821284c47553959'
7
+ data.tar.gz: 13ce47508fbba66f770d42810950fdacdea4c31649792d35f2b2147440094467080cdb6d76e45bddd10655cfe4a1ea65e707b04cbaac67b5038a0da059565f16
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2021 Theeraphat Jantakat
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # Administrate::Field::Aasm
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'administrate-field-aasm'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Add to your dashboard:
20
+ ```ruby
21
+ ATTRIBUTE_TYPES = [
22
+ state: Field::Aasm
23
+ ]
24
+
25
+ SHOW_PAGE_ATTRIBUTES = %i[
26
+ ...
27
+ state
28
+ ...
29
+ ]
30
+ ```
31
+
32
+ Add to your `routes.rb`
33
+ ```ruby
34
+ resources :orders do
35
+ member do
36
+ put '/:event', to: 'orders#transit_state'
37
+ end
38
+ end
39
+ ```
40
+
41
+ Add to your controller
42
+ ```ruby
43
+ def transit_state
44
+ if requested_resource.try("may_#{params[:event]}?".to_sym)
45
+ requested_resource.try(params[:event].to_sym)
46
+ requested_resource.save
47
+ redirect_to admin_order_path(requested_resource), notice: "#{params[:event].humanize} successfully."
48
+ else
49
+ redirect_to admin_order_path(requested_resource), alert: "#{params[:event].humanize} fail."
50
+ end
51
+ end
52
+ ```
53
+
54
+ ## License
55
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require "bundler/setup"
2
+
3
+ require "bundler/gem_tasks"
4
+
5
+ require "rake/testtask"
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << 'test'
9
+ t.pattern = 'test/**/*_test.rb'
10
+ t.verbose = false
11
+ end
12
+
13
+ task default: :test
@@ -0,0 +1,6 @@
1
+ <div class="field-unit__label">
2
+ <%= f.label field.attribute %>
3
+ </div>
4
+ <div class="field-unit__field">
5
+ <%= f.text_field field.attribute %>
6
+ </div>
@@ -0,0 +1 @@
1
+ <%= field.to_s %>
@@ -0,0 +1,17 @@
1
+ <div class="row mb-2">
2
+ <div class="col-md-auto">
3
+ <div class="btn btn-text btn-block disabled">
4
+ Current Status: <%= field.to_s.humanize %>
5
+ </div>
6
+ </div>
7
+ </div>
8
+
9
+ <div class="row">
10
+ <% field.events.each do |event| %>
11
+ <div class="col-md-2">
12
+ <%= link_to event.name.to_s.humanize, "/admin/orders/#{field.id}/#{event.name.to_s}", method: :put, data: { confirm: "#{event.name}?"}, class: 'btn btn-success btn-block' %>
13
+ </div>
14
+ <% end %>
15
+ </div>
16
+
17
+
@@ -0,0 +1,23 @@
1
+ require 'administrate/field/base'
2
+ require 'rails'
3
+
4
+ module Administrate
5
+ module Field
6
+ class Aasm < Base
7
+ class Engine < ::Rails::Engine
8
+ end
9
+
10
+ def to_s
11
+ data
12
+ end
13
+
14
+ def events
15
+ resource.aasm.events
16
+ end
17
+
18
+ def id
19
+ resource.id
20
+ end
21
+ end
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: administrate-field-aasm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Theeraphat Jantakat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-06-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: administrate
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Custom Administrate Field for AASM gem.
42
+ email:
43
+ - pppangpondpp7@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - app/views/fields/aasm/_form.html.erb
52
+ - app/views/fields/aasm/_index.html.erb
53
+ - app/views/fields/aasm/_show.html.erb
54
+ - lib/administrate/field/aasm.rb
55
+ homepage: https://github.com/pondpaun7z/administrate-field-aasm
56
+ licenses:
57
+ - MIT
58
+ metadata:
59
+ homepage_uri: https://github.com/pondpaun7z/administrate-field-aasm
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubygems_version: 3.2.3
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Custom Administrate Field for AASM gem.
79
+ test_files: []