rao-component 0.0.39.pre → 0.0.44.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/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 +4 -0
- data/config/locales/en.yml +4 -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: b1cea273ab02260fe2b2bed7736233adfbf4319f3fbbb9f70ad9eef1db1327da
|
4
|
+
data.tar.gz: 65d390844d356e5db5b6a440e1199716125d2d9b4164d8ac67b332f6e55b87f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28796942da26154d31fd953e4662c6b4ece5e76e1051bef626c094f234d5e7cb381aa751d56f8688da542d1a1e6f66fd0d769984b43f40c6bcaaeb43a9ed7031
|
7
|
+
data.tar.gz: 4d3e2d876c1106cec60c943a05f7f70dc8a860fd634226eeeea0ab5158a4cc3145c02db4378816829aee6894e50c9d46d505bc685590af635649ce5321dddccb
|
@@ -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
@@ -7,10 +7,13 @@ de:
|
|
7
7
|
acts_as_published: Veröffentlichung
|
8
8
|
awesome_nested_set: Sortierung
|
9
9
|
destroy: Löschen
|
10
|
+
destroy_confirmation: Sind Sie sicher?
|
10
11
|
edit: Bearbeiten
|
11
12
|
show: Anzeigen
|
12
13
|
download: Download
|
13
14
|
visit: Öffnen
|
15
|
+
resource_table:
|
16
|
+
download: Download
|
14
17
|
table:
|
15
18
|
body_cells:
|
16
19
|
boolean:
|
@@ -20,6 +23,7 @@ de:
|
|
20
23
|
batch_actions:
|
21
24
|
title: Stapelverarbeitung
|
22
25
|
destroy: Löschen
|
26
|
+
destroy_many: Löschen
|
23
27
|
publish: Veröffentlichen
|
24
28
|
unpublish: Zurückziehen
|
25
29
|
date:
|
data/config/locales/en.yml
CHANGED
@@ -7,10 +7,13 @@ en:
|
|
7
7
|
acts_as_published: Publishing
|
8
8
|
awesome_nested_set: Sorting
|
9
9
|
destroy: Delete
|
10
|
+
destroy_confirmation: Are you sure?
|
10
11
|
edit: Edit
|
11
12
|
show: Show
|
12
13
|
download: Download
|
13
14
|
visit: Open
|
15
|
+
resource_table:
|
16
|
+
download: Download
|
14
17
|
table:
|
15
18
|
body_cells:
|
16
19
|
boolean:
|
@@ -20,6 +23,7 @@ en:
|
|
20
23
|
batch_actions:
|
21
24
|
title: Batch actions
|
22
25
|
destroy: Delete
|
26
|
+
destroy_many: Delete
|
23
27
|
publish: Publish
|
24
28
|
unpublish: Unpublish
|
25
29
|
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.44.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-28 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.
|