rao-component 0.0.40.pre → 0.0.45.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 818186b5a19b93b2586fdc5bc45236b05e8f4bd866a04c5e88bc615291a4d086
4
- data.tar.gz: 59531701ad7c7df4bf590f8fda0e8bce4f452e74fcd3dcca8d2b852c1aeb41db
3
+ metadata.gz: dbff79caf585f94598abededd785240488eaac349c754b267718916e9bbbd60a
4
+ data.tar.gz: ac3dbdcaa716b5ccf897e1d1143d839feead2c542833661fceff6feb560597a9
5
5
  SHA512:
6
- metadata.gz: 600dc460a21cdd067304ab468f58436ca1200f41275321eea9f3069e876bcc784b5e73e26dc2de16a6d53d33a4d95eac1a1fcf50b230496e6837c440cfd28298
7
- data.tar.gz: 1ac37197988f3eb1ff65bc2f64c74f9defc1202a1e1647d54c07854f7637d230e9079efea4866244c80c0ce21efad83147813075992ec20cd2a235285c569f74
6
+ metadata.gz: 71fd5523c269c1fe0d336129e7d296bd3eb3bc4be74a36f44f185bbde35575205b63fb5ddcf2edd8fdf53175443b54dd4bb4bed68b68b23b06f760f0febc47ed
7
+ data.tar.gz: 3542a313eeaf2504cbe82fb5574f3fda4117aaa04b8bb359a216a33e72c380f90bbfc59f64b11bcddfd1fb70a171231ac561f19705c41b51d5a411593a71b6bb
@@ -10,6 +10,8 @@ module Rao
10
10
  # = t.timestamps format: :short
11
11
  #
12
12
  class CollectionTable < Base
13
+ include AasmConcern
14
+ include ActiveStorageConcern
13
15
  include AwesomeNestedSetConcern
14
16
  include ActsAsPublishedConcern
15
17
  include ActsAsListConcern
@@ -10,6 +10,8 @@ module Rao
10
10
  # = t.timestamps format: :short
11
11
  #
12
12
  class ResourceTable < Base
13
+ include AasmConcern
14
+ include ActiveStorageConcern
13
15
  include BooleanConcern
14
16
  include DateConcern
15
17
  include EmailConcern
@@ -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
- = t('.title')
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() {
@@ -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:
@@ -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:
@@ -13,6 +13,11 @@ module Rao
13
13
  resource: { resize: "320x240" }
14
14
  }
15
15
  }
16
+ mattr_accessor(:batch_actions_default_actions) do
17
+ -> {
18
+ { destroy_many: @view.url_for(action: :destroy_many) }
19
+ }
20
+ end
16
21
  end
17
22
  end
18
23
  end
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.40.pre
4
+ version: 0.0.45.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-03-17 00:00:00.000000000 Z
11
+ date: 2020-07-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.2
246
+ rubygems_version: 3.1.4
240
247
  signing_key:
241
248
  specification_version: 4
242
249
  summary: View Components for Ruby on Rails.