rao-component 0.0.10.pre → 0.0.11.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
  SHA1:
3
- metadata.gz: e4a636f3c43b919facc629f12a284851ff058981
4
- data.tar.gz: 3198b8d381c54e4e6f74f3b2f7682c9d09e9bf62
3
+ metadata.gz: d0eb08d89fc0b01b77547fe96cfb10263bbe2ca3
4
+ data.tar.gz: 0e63adb0d9fce8033ff5416679bfeba83515e90e
5
5
  SHA512:
6
- metadata.gz: 153d0400fba0d85c1933a9769c300c8e0a161759f386a44b228ffff3eb3cc3b50c72eb01d2bf6d308193e2b2348945b7dc1facc3580859af4954053ef93f0fa6
7
- data.tar.gz: 2fc2f27831bcec6a08f36ae522f33c28df17d6d8b3a44a56c283f8f6eab81c7d8852d5349f9fcb6497065d60e7bccb553767ed0f7c60e81fc5882b58581d7179
6
+ metadata.gz: 12bc5410ae3cc782669cda50bf9368d141afa5a13edba4208f71f9ac4eaa76b3cbf2eece7ae465f6511e2acc2494aaa90cbeff45923def3abe98975ea8e02559
7
+ data.tar.gz: 7aa78944d0fa51e76e1c402f10e8efa5a27de6d69be3d3bdfadd10d4300d701f80f4ca40b24b658abc28a4e5a7f686a64c700a63911665f86d44e0d18dfcf52e
data/README.md CHANGED
@@ -4,6 +4,20 @@ Short description and motivation.
4
4
  ## Usage
5
5
  How to use my plugin.
6
6
 
7
+ ## Adding acts_as_list support for collection tables.
8
+
9
+ To use this feature you have to add coffee-rails, jquery-rails and jquery-ui-rails gems to your applicaiton.
10
+
11
+ If you want to have sortable items via acts_as_list and drag and drop, you have to add the javascript to your
12
+ application:
13
+
14
+ ```
15
+ // app/assets/javascripts/applicaiton.js
16
+ //= require jquery
17
+ //= require jquery-ui
18
+ //= require rao-component/acts_as_list
19
+ ```
20
+
7
21
  ## Installation
8
22
  Add this line to your application's Gemfile:
9
23
 
@@ -0,0 +1,21 @@
1
+ $ ->
2
+ $('[data-acts-as-list-item]').each ->
3
+ $(@).draggable({
4
+ scope: $(@).attr('data-acts-as-list-item-scope'),
5
+ revert: true
6
+ })
7
+
8
+ $ ->
9
+ $('[data-acts-as-list-item]').each ->
10
+ redirect_target = $(@).attr('data-acts-as-list-item-on-drop-target')
11
+ authenticity_token = $( 'meta[name="csrf-token"]' ).attr( 'content' );
12
+
13
+ $(@).droppable({
14
+ accept: '.acts-as-list-item',
15
+ scope: $(@).attr('data-acts-as-list-item-scope'),
16
+ activeClass: 'btn-success',
17
+ drop: (event, ui) ->
18
+ dropped_element = $(ui.draggable)
19
+ dropped_element_to_param = dropped_element.attr('data-acts-as-list-item-uid')
20
+ $.redirect(redirect_target,{ authenticity_token: authenticity_token, dropped_id: dropped_element_to_param });
21
+ })
@@ -105,6 +105,7 @@ module Rao
105
105
  end
106
106
 
107
107
  def table_css_classes
108
+ return @options[:table_html] if @options.has_key?(:table_html)
108
109
  classes = ['table', 'collection-table', @resource_class.name.underscore.pluralize.gsub('/', '-')]
109
110
  classes << 'table-bordered' if bordered?
110
111
  classes << 'table-hover' if hover?
@@ -42,7 +42,7 @@ module Rao
42
42
  extend ActiveSupport::Concern
43
43
 
44
44
  def acts_as_list_actions(options = {}, &block)
45
- options.reverse_merge!(render_as: :acts_as_list, title: t('.column_titles.acts_as_list'), scope: nil)
45
+ options.reverse_merge!(render_as: :acts_as_list, title: '', scope: nil)
46
46
 
47
47
  scope = options.delete(:scope)
48
48
  scope = "#{scope}_id".intern if scope.is_a?(Symbol) && scope.to_s !~ /_id$/
@@ -9,7 +9,7 @@ module Rao
9
9
  #
10
10
  def batch_actions(options = {}, &block)
11
11
  @wrap_in_form = true
12
- title = @view.render partial: 'component/table/header_cells/batch_actions', locals: { options: options }
12
+ title = @view.render partial: 'rao/component/table/header_cells/batch_actions', locals: { options: options }
13
13
  options.reverse_merge!(render_as: :batch_actions, title: title)
14
14
  column(:batch_actions, options, &block)
15
15
  end
@@ -9,6 +9,8 @@
9
9
  - title = resource_class.human_attribute_name(name)
10
10
  - else
11
11
  - title = name
12
+ - elsif title === false
13
+ - title = nil
12
14
  - if options.has_key?(:sort)
13
15
  %td= sort_link(name, title, options[:sort])
14
16
  - else
@@ -7,5 +7,5 @@
7
7
  }
8
8
  data_attributes['acts-as-list-item-scope'] = "#{scope}-#{resource.send(scope)}" if scope.present?
9
9
 
10
- %span.btn.btn-xs.btn-default.acts-as-list-item{ data: data_attributes }
10
+ %span.btn.btn-sm.btn-xs.btn-default.acts-as-list-item{ data: data_attributes }
11
11
  %span.glyphicon.glyphicon-sort.fas.fa-sort
@@ -1,9 +1,11 @@
1
1
  - link_path = controller.url_for(action: :toggle_published, id: resource.to_param)
2
2
  - if resource.published?
3
- = button_to(link_path, class: 'btn btn-xs btn-danger btn-responsive', method: :post) do
3
+ = button_to(link_path, class: 'btn btn-sm btn-xs btn-danger btn-responsive', method: :post) do
4
+ %i.fas.fa-eye-slash
4
5
  %span.glyphicon.glyphicon-eye-close
5
6
  %span.btn-text= t('.unpublish', default: t('acts_as_published.actions.unpublish'))
6
7
  - else
7
- = button_to(link_path, class: 'btn btn-xs btn-success btn-responsive', method: :post) do
8
+ = button_to(link_path, class: 'btn btn-sm btn-xs btn-success btn-responsive', method: :post) do
9
+ %i.fas.fa-eye
8
10
  %span.glyphicon.glyphicon-eye-open
9
11
  %span.btn-text= t('.publish', default: t('acts_as_published.actions.publish'))
@@ -5,5 +5,5 @@
5
5
  'awesome-nested-set-item-on-drop-target': url_for([:reposition, resource])
6
6
  }
7
7
  data_attributes['awesome-nested-set-item-scope'] = scope.call(model) if options[:scope].present?
8
- %span.btn.btn-xs.btn-default.awesome-nested-set-item{ data: data_attributes }
8
+ %span.btn.btn-sm.btn-xs.btn-default.awesome-nested-set-item{ data: data_attributes }
9
9
  %span.glyphicon.glyphicon-sort
@@ -17,7 +17,7 @@
17
17
  :javascript
18
18
  $(document).ready(function() {
19
19
  $('.batch-action-checkbox').click(function() {
20
- var check_count = $('.batch-action-checkbox:checked').size();
20
+ var check_count = $('.batch-action-checkbox:checked').length;
21
21
  if( check_count > 0 ) {
22
22
  $("#batch-action-dropdown").show();
23
23
  } else {
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.10.pre
4
+ version: 0.0.11.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: 2019-02-01 00:00:00.000000000 Z
11
+ date: 2019-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -174,6 +174,7 @@ files:
174
174
  - MIT-LICENSE
175
175
  - README.md
176
176
  - Rakefile
177
+ - app/assets/javascripts/rao-component/acts_as_list.js.coffee
177
178
  - app/components/rao/component/base.rb
178
179
  - app/components/rao/component/collection_table.rb
179
180
  - app/components/rao/component/resource_table.rb