rao-component 0.0.41.pre → 0.0.46.pre
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 +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/collection_table/batch_actions_concern.rb +1 -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
- data/app/views/rao/component/table/header_cells/_batch_actions.html.haml +3 -3
- data/config/locales/de.yml +2 -0
- data/config/locales/en.yml +2 -0
- data/lib/rao/component/configuration.rb +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: 640ec88b1c4c4e0f86a0e992a4c7268ab109138e3abe5b279ecb3ef05c2b87d9
|
4
|
+
data.tar.gz: b41517ff56a2abba7bb183afa1a3aeb58e31061f931d5a53333966cf23bd95ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 749cab223faf2d6dd91bfd22010026a2fe6dc1d6b4c4f3c1a06e6e09fbbd97584f9e0a64fb823953881a21e15300358c4071ba8c75601545b352884d582caf2c
|
7
|
+
data.tar.gz: 5843ee7e3ee06aaaa6a2e5baf75f4ba662af49867f297e76a51317b49c385f2acdaedb6b42728f34138407d9e36017378ed0d293593c5dcbd5b0491a456b79c8
|
@@ -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
|
@@ -9,6 +9,7 @@ module Rao
|
|
9
9
|
#
|
10
10
|
def batch_actions(options = {}, &block)
|
11
11
|
@wrap_in_form = true
|
12
|
+
options[:actions] ||= instance_exec(&Rao::Component::Configuration.batch_actions_default_actions)
|
12
13
|
title = @view.render partial: 'rao/component/table/header_cells/batch_actions', locals: { options: options }
|
13
14
|
options.reverse_merge!(render_as: :batch_actions, title: title)
|
14
15
|
column(:batch_actions, options, &block)
|
@@ -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)})"
|
@@ -6,13 +6,13 @@
|
|
6
6
|
%form{ method: 'post', id: 'batch-action-form' }
|
7
7
|
= hidden_field_tag :authenticity_token, form_authenticity_token
|
8
8
|
.dropdown.batch-action-dropdown
|
9
|
-
%button.btn.btn-default.dropdown-toggle{"aria-expanded" => "true", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", id: 'batch-action-dropdown' }
|
10
|
-
|
9
|
+
%button.btn.btn-xs.btn-default.dropdown-toggle{"aria-expanded" => "true", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", id: 'batch-action-dropdown' }
|
10
|
+
/=# t('.title')
|
11
11
|
%span.caret
|
12
12
|
%ul.dropdown-menu{"aria-labelledby" => 'batch-action-dropdown' }
|
13
13
|
- options[:actions].each do |action, target|
|
14
14
|
%li
|
15
|
-
%a{ href: target, class: 'batch-action-form-submit-link' }= t(".#{action}")
|
15
|
+
%a{ href: target, class: 'batch-action-form-submit-link btn btn-xs btn-link' }= t(".#{action}")
|
16
16
|
|
17
17
|
:javascript
|
18
18
|
$(document).ready(function() {
|
data/config/locales/de.yml
CHANGED
@@ -13,6 +13,7 @@ de:
|
|
13
13
|
download: Download
|
14
14
|
visit: Öffnen
|
15
15
|
resource_table:
|
16
|
+
destroy_confirmation: Sind Sie sicher?
|
16
17
|
download: Download
|
17
18
|
table:
|
18
19
|
body_cells:
|
@@ -23,6 +24,7 @@ de:
|
|
23
24
|
batch_actions:
|
24
25
|
title: Stapelverarbeitung
|
25
26
|
destroy: Löschen
|
27
|
+
destroy_many: Löschen
|
26
28
|
publish: Veröffentlichen
|
27
29
|
unpublish: Zurückziehen
|
28
30
|
date:
|
data/config/locales/en.yml
CHANGED
@@ -13,6 +13,7 @@ en:
|
|
13
13
|
download: Download
|
14
14
|
visit: Open
|
15
15
|
resource_table:
|
16
|
+
destroy_confirmation: Are you sure?
|
16
17
|
download: Download
|
17
18
|
table:
|
18
19
|
body_cells:
|
@@ -23,6 +24,7 @@ en:
|
|
23
24
|
batch_actions:
|
24
25
|
title: Batch actions
|
25
26
|
destroy: Delete
|
27
|
+
destroy_many: Delete
|
26
28
|
publish: Publish
|
27
29
|
unpublish: Unpublish
|
28
30
|
date:
|
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.46.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-10-21 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.
|