rao-component 0.0.42.pre → 0.0.43.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/components/rao/component/collection_table.rb +2 -0
- data/app/components/rao/component/resource_table.rb +2 -0
- data/app/concerns/rao/component/collection_table/aasm_concern.rb +57 -0
- data/app/concerns/rao/component/collection_table/active_storage_concern.rb +12 -0
- data/app/concerns/rao/component/resource_table/aasm_concern.rb +57 -0
- data/app/concerns/rao/component/resource_table/active_storage_concern.rb +12 -0
- data/app/views/rao/component/table/body_cells/_aasm_actions.html.haml +2 -0
- data/app/views/rao/component/table/body_cells/_aasm_state.html.haml +1 -0
- data/app/views/rao/component/table/body_cells/_attachment.html.haml +5 -0
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb3a2b46f7c5364e5ce22e2c30dca7a4e9d76c731be7a37e530cab8c0769dedc
|
4
|
+
data.tar.gz: a86458f84b82280a1289b91e9c5fa83d52cda06f33e3ec6305f324c4df7db497
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efc7e828d748ce676a227ebe85b4091ea7529e6977291c476f062f6761979f7ba01e4b556d6b3ba2b38c1b138b982c52d4ed961735fba816d0f9ceee0e638c70
|
7
|
+
data.tar.gz: af80458043e3cc5a2f487ae527a956ffb10e4af52087c92e276056e4e08e495b7cb3c9bdaad80ef376a8a70f5536f7d7fe248716cf8c3797e04c5491a60f8798
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Rao
|
2
|
+
module Component
|
3
|
+
# Usage:
|
4
|
+
#
|
5
|
+
# # app/models/cart.rb
|
6
|
+
# class Cart < ActiveRecord::Base
|
7
|
+
# include AASM
|
8
|
+
#
|
9
|
+
# aasm do
|
10
|
+
# # ...
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# # app/carts/index.html.haml
|
15
|
+
# = collection_table(collection: @carts) do |table|
|
16
|
+
# = table.aasm :default
|
17
|
+
#
|
18
|
+
# You will have to add a event triggering route to your resource:
|
19
|
+
#
|
20
|
+
# # config/routes.rb:
|
21
|
+
# Rails.application.routes do
|
22
|
+
# resources :carts do
|
23
|
+
# post 'trigger_event/:machine_name/:event_name', on: :member, action: 'trigger_event', as: :trigger_event
|
24
|
+
# end
|
25
|
+
# # ...
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# Additionally you will need a controller action to handle the triggering of events.
|
29
|
+
# Include Rao::ResourcesController::AasmConcern from rao-resources_controller
|
30
|
+
# if you don't want to implement it yourself:
|
31
|
+
#
|
32
|
+
# # app/controllers/pictures_controller.rb
|
33
|
+
# class PicturesController < ApplicationController
|
34
|
+
# include Rao::ResourcesController::AasmConcern
|
35
|
+
# # ...
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
module CollectionTable::AasmConcern
|
39
|
+
extend ActiveSupport::Concern
|
40
|
+
|
41
|
+
def aasm_state(name = nil, options = {}, &block)
|
42
|
+
name = name.presence || :default
|
43
|
+
column_name = (name == :default) ? "aasm_state" : "#{name}_state"
|
44
|
+
options.reverse_merge!(render_as: :aasm_state, state_machine_name: name)
|
45
|
+
column(column_name, options, &block)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def aasm_actions(name = nil, options = {}, &block)
|
50
|
+
name = name.presence || :default
|
51
|
+
column_name = (name == :default) ? "aasm_actions" : "#{name}_actions"
|
52
|
+
options.reverse_merge!(render_as: :aasm_actions, state_machine_name: name)
|
53
|
+
column(column_name, options, &block)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Rao
|
2
|
+
module Component
|
3
|
+
module CollectionTable::ActiveStorageConcern
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def attachment(name, options = {}, &block)
|
7
|
+
options.reverse_merge!(render_as: :attachment)
|
8
|
+
column(name, options, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Rao
|
2
|
+
module Component
|
3
|
+
# Usage:
|
4
|
+
#
|
5
|
+
# # app/models/cart.rb
|
6
|
+
# class Cart < ActiveRecord::Base
|
7
|
+
# include AASM
|
8
|
+
#
|
9
|
+
# aasm do
|
10
|
+
# # ...
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# # app/carts/show.html.haml
|
15
|
+
# = resource_table(resource: @carts) do |table|
|
16
|
+
# = table.aasm :default
|
17
|
+
#
|
18
|
+
# You will have to add a event triggering route to your resource:
|
19
|
+
#
|
20
|
+
# # config/routes.rb:
|
21
|
+
# Rails.application.routes do
|
22
|
+
# resources :carts do
|
23
|
+
# post 'trigger_event/:machine_name/:event_name', on: :member, action: 'trigger_event', as: :trigger_event
|
24
|
+
# end
|
25
|
+
# # ...
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# Additionally you will need a controller action to handle the triggering of events.
|
29
|
+
# Include Rao::ResourcesController::AasmConcern from rao-resources_controller
|
30
|
+
# if you don't want to implement it yourself:
|
31
|
+
#
|
32
|
+
# # app/controllers/pictures_controller.rb
|
33
|
+
# class PicturesController < ApplicationController
|
34
|
+
# include Rao::ResourcesController::AasmConcern
|
35
|
+
# # ...
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
module ResourceTable::AasmConcern
|
39
|
+
extend ActiveSupport::Concern
|
40
|
+
|
41
|
+
def aasm_state(name = nil, options = {}, &block)
|
42
|
+
name = name.presence || :default
|
43
|
+
row_name = (name == :default) ? "aasm_state" : "#{name}_state"
|
44
|
+
options.reverse_merge!(render_as: :aasm_state, state_machine_name: name)
|
45
|
+
row(row_name, options, &block)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def aasm_actions(name = nil, options = {}, &block)
|
50
|
+
name = name.presence || :default
|
51
|
+
row_name = (name == :default) ? "aasm_actions" : "#{name}_actions"
|
52
|
+
options.reverse_merge!(render_as: :aasm_actions, state_machine_name: name)
|
53
|
+
row(row_name, options, &block)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Rao
|
2
|
+
module Component
|
3
|
+
module ResourceTable::ActiveStorageConcern
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def attachment(name, options = {}, &block)
|
7
|
+
options.reverse_merge!(render_as: :attachment)
|
8
|
+
row(name, options, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,2 @@
|
|
1
|
+
- resource.aasm(options[:state_machine_name]).events(permitted: true).each do |event|
|
2
|
+
= link_to(resource.class.aasm(options[:state_machine_name]).human_event_name(event.name), { action: 'trigger_event', id: resource.to_param, machine_name: options[:state_machine_name], event_name: event.name }, class: 'btn btn-xs btn-primary', method: :post)
|
@@ -0,0 +1 @@
|
|
1
|
+
%span.badge.badge-primary= resource.aasm(options[:state_machine_name]).human_state
|
@@ -0,0 +1,5 @@
|
|
1
|
+
- if resource.send(name).attached?
|
2
|
+
= capture_haml do
|
3
|
+
= link_to(main_app.url_for(resource.send(name)), class: 'btn btn-xs btn-primary btn-responsive') do
|
4
|
+
%i.fas.fa-download
|
5
|
+
%span.btn-text= "#{t('rao.component.collection_table.download')} (#{resource.send(name).blob.content_type.split('/').last}, #{number_to_human_size(resource.send(name).blob.byte_size)})"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rao-component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.43.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -179,6 +179,8 @@ files:
|
|
179
179
|
- app/components/rao/component/base.rb
|
180
180
|
- app/components/rao/component/collection_table.rb
|
181
181
|
- app/components/rao/component/resource_table.rb
|
182
|
+
- app/concerns/rao/component/collection_table/aasm_concern.rb
|
183
|
+
- app/concerns/rao/component/collection_table/active_storage_concern.rb
|
182
184
|
- app/concerns/rao/component/collection_table/acts_as_list_concern.rb
|
183
185
|
- app/concerns/rao/component/collection_table/acts_as_published_concern.rb
|
184
186
|
- app/concerns/rao/component/collection_table/awesome_nested_set_concern.rb
|
@@ -187,6 +189,8 @@ files:
|
|
187
189
|
- app/concerns/rao/component/collection_table/date_concern.rb
|
188
190
|
- app/concerns/rao/component/collection_table/email_concern.rb
|
189
191
|
- app/concerns/rao/component/collection_table/thumbnail_concern.rb
|
192
|
+
- app/concerns/rao/component/resource_table/aasm_concern.rb
|
193
|
+
- app/concerns/rao/component/resource_table/active_storage_concern.rb
|
190
194
|
- app/concerns/rao/component/resource_table/boolean_concern.rb
|
191
195
|
- app/concerns/rao/component/resource_table/date_concern.rb
|
192
196
|
- app/concerns/rao/component/resource_table/email_concern.rb
|
@@ -194,9 +198,12 @@ files:
|
|
194
198
|
- app/helpers/rao/component/application_helper.rb
|
195
199
|
- app/views/rao/component/_collection_table.html.haml
|
196
200
|
- app/views/rao/component/_resource_table.html.haml
|
201
|
+
- app/views/rao/component/table/body_cells/_aasm_actions.html.haml
|
202
|
+
- app/views/rao/component/table/body_cells/_aasm_state.html.haml
|
197
203
|
- app/views/rao/component/table/body_cells/_acts_as_list.html.haml
|
198
204
|
- app/views/rao/component/table/body_cells/_acts_as_published.html.haml
|
199
205
|
- app/views/rao/component/table/body_cells/_association.html.haml
|
206
|
+
- app/views/rao/component/table/body_cells/_attachment.html.haml
|
200
207
|
- app/views/rao/component/table/body_cells/_awesome_nested_set.html.haml
|
201
208
|
- app/views/rao/component/table/body_cells/_batch_actions.html.haml
|
202
209
|
- app/views/rao/component/table/body_cells/_boolean.html.haml
|
@@ -236,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
243
|
- !ruby/object:Gem::Version
|
237
244
|
version: 1.3.1
|
238
245
|
requirements: []
|
239
|
-
rubygems_version: 3.1.
|
246
|
+
rubygems_version: 3.1.4
|
240
247
|
signing_key:
|
241
248
|
specification_version: 4
|
242
249
|
summary: View Components for Ruby on Rails.
|