rails-add_ons 0.5.0 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bfa3efd09a2fbc6c0da34dfd72764627d97bb124
4
- data.tar.gz: d7c48d772c2046d598d7426bc7569976d884cc98
3
+ metadata.gz: 27d2b81421d0d2fa001db6f2b7bd9071190c56c3
4
+ data.tar.gz: 5b2cd7b72fde14704f85b85cb166c4d6bae7ccac
5
5
  SHA512:
6
- metadata.gz: 9786e7da690497e8f5e735a2253502a37f3801a495b33ebd754d9ddfe3e0db4c4184b671a80fa63552baa359dcf04dc57cf2a56f1036bba70d54fcc359d843b1
7
- data.tar.gz: 11dd5006c8b6bf764679bb1b1a933f3a409ae2b1d0f84600e0d6dc5273cf4d071f2d175460c54b02b55e3599d3d3cd50caa483e549ec1b6c705120519415da3f
6
+ metadata.gz: 59f015f0b1adbb87c93bba6618aaa3a7e5ab4676ba6f30005e12c4dd253ce446d15da08eac7c7fcfcb8452bce07f2164ac412fe30b89e567459f1bf49c509fe4
7
+ data.tar.gz: c66a9e46718dc4827f95ebf1d4e84b5d5b086edb8939cd862a5fb46437c875331a3219018a59c20be930734b505e9d74ba0d1fcd4130ab2a44d6c704eb34727d
@@ -67,7 +67,7 @@ module Component
67
67
  end
68
68
 
69
69
  def table_css_classes
70
- classes = ['table']
70
+ classes = ['table', 'collection-table', @resource_class.name.underscore.pluralize]
71
71
  classes << 'table-bordered' if bordered?
72
72
  classes << 'table-hover' if hover?
73
73
  classes << 'table-inverse' if inverse?
@@ -77,4 +77,4 @@ module Component
77
77
  classes
78
78
  end
79
79
  end
80
- end
80
+ end
@@ -106,19 +106,23 @@ module ResourcesController
106
106
  private
107
107
 
108
108
  def new_resource_path
109
- url_for(action: :new, only_path: true)
109
+ resource_router.send(:url_for, { action: :new, only_path: true })
110
110
  end
111
111
 
112
112
  def collection_path
113
- url_for(action: :index, only_path: true)
113
+ resource_router.send(:url_for, { action: :index, only_path: true })
114
114
  end
115
115
 
116
116
  def resource_path(resource)
117
- url_for(action: :show, id: resource, only_path: true)
117
+ resource_router.send(:url_for, { action: :show, id: resource, only_path: true })
118
118
  end
119
119
 
120
120
  def edit_resource_path(resource)
121
- url_for(action: :edit, id: resource, only_path: true)
121
+ resource_router.send(:url_for, { action: :edit, id: resource, only_path: true })
122
+ end
123
+
124
+ def resource_router
125
+ self
122
126
  end
123
127
  end
124
128
 
@@ -2,19 +2,28 @@
2
2
  %thead
3
3
  %tr
4
4
  - columns.each do |name, options|
5
- - title = if resource_class.respond_to?(:human_attribute_name)
6
- - resource_class.human_attribute_name(name)
7
- - else
8
- - name
5
+ - title = options.delete(:title)
6
+ - if title.nil?
7
+ - if resource_class.respond_to?(:human_attribute_name)
8
+ - title = resource_class.human_attribute_name(name)
9
+ - else
10
+ - title = name
9
11
  - if options.has_key?(:sort)
10
12
  %td= sort_link(name, title, options[:sort])
11
13
  - else
12
14
  %td= title
13
15
  %tbody
14
16
  - collection.each do |resource|
15
- %tr
17
+ - tr_options = { class: resource_class.name.underscore }
18
+ - if resource.respond_to?(:model_name)
19
+ - tr_options[:id] = dom_id(resource)
20
+ - else
21
+ - tr_options[:id] = "#{resource.class.name.underscore}-#{resource.object_id}"
22
+ %tr{ tr_options }
16
23
  - columns.each do |name, options|
24
+ - td_options = { class: "attribute-#{name}", id: "#{tr_options[:id]}-#{name}"}
17
25
  - if options[:block].present?
18
- %td= options[:block].call(resource)
26
+ %td{ td_options }= options[:block].call(resource)
19
27
  - else
20
- %td= resource.send(name)
28
+ %td{ td_options }= resource.send(name)
29
+
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module AddOns
3
- VERSION = '0.5.0'
3
+ VERSION = '0.6.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-add_ons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
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: 2017-08-22 00:00:00.000000000 Z
11
+ date: 2017-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails