smart_managing 0.0.2 → 0.0.3

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: a26d1c85f13702505e7c9d22255abe85933da91b
4
- data.tar.gz: 3547a9eeea46bad3fe575c2822c504139394cc32
3
+ metadata.gz: 0fc5537edec2fee24dd50a3449d83b30cbfdc6cc
4
+ data.tar.gz: 2a7094500f379c0857e0ee78b64975998272d2f1
5
5
  SHA512:
6
- metadata.gz: 788074aca22352cebdf7f4d0313491d432b72cfdb102af459f332177defbb874218b36bbb87d46321720a33dbdcdd6c2b0ac81cf205562c2fbadc1bf048f9fd2
7
- data.tar.gz: 2f493f02bbb2cc2a5ef4b823b20378b73e867526f322701eb2b348587d43ebcb349c02ac1842f7818de0b65222748566dd43768188136a16709d2f8064e070dc
6
+ metadata.gz: 15f6b24aadde8a2e97cbc03cb0ac6391f59cce3fe58aca96609065c3f37667de2a53d5a90430406dde19c2b9ec9f70677debb1fafd5580abae507d4620355790
7
+ data.tar.gz: faff7d42f9b679bbc302f665d2ff7e3421c77ceccf186c0ffdb9bf49fac0bada502ac3ccc50e56b0e7b714570418f78cd2fe1c69d44073b2e56b44fe6b87687d
data/README.md CHANGED
@@ -9,7 +9,7 @@ install it before to install SmartManaging.
9
9
 
10
10
  To install SmartManaging you have to add this in your Gemfile :
11
11
  ```ruby
12
- gem 'smart_listing', github: 'GCorbel/smart_listing', branch: 'refactoring'
12
+ gem 'smart_listing', github: 'GCorbel/smart_listing'
13
13
  gem 'smart_managing'
14
14
  ```
15
15
 
@@ -15,6 +15,14 @@ module SmartManaging
15
15
  new_polymorphic_path(klass)
16
16
  end
17
17
 
18
+ def field_for(form:, klass:, attr:)
19
+ if klass.reflect_on_association(attr)
20
+ form.send(:association, attr)
21
+ else
22
+ form.send(:input, attr)
23
+ end
24
+ end
25
+
18
26
  private
19
27
 
20
28
  def klass
@@ -11,7 +11,7 @@ module SmartManaging
11
11
  end
12
12
 
13
13
  def attributes
14
- klass.columns.map(&:name)
14
+ klass.columns.map {|column| standardize(column.name)}
15
15
  end
16
16
 
17
17
  def klass
@@ -31,5 +31,9 @@ module SmartManaging
31
31
  def controller_name
32
32
  controller.controller_name
33
33
  end
34
+
35
+ def standardize(column)
36
+ column.gsub(/_id$/, '')
37
+ end
34
38
  end
35
39
  end
@@ -3,7 +3,7 @@
3
3
  wrapper: :smart_managing_form,
4
4
  html: { class: 'form-horizontal' } do |f| %>
5
5
  <% editable_attributes.each do |attr| %>
6
- <%= f.input attr %>
6
+ <%= field_for(form: f, klass: object.class, attr: attr) %>
7
7
  <% end %>
8
8
  <div class="form-group">
9
9
  <label class="control-label col-md-3"></label>
@@ -1 +1,2 @@
1
+ <h1><%= resource_name.capitalize %></h1>
1
2
  <%= smart_listing_render %>
@@ -13,12 +13,21 @@ module SmartManaging
13
13
 
14
14
  def self.included(c)
15
15
  return unless c < ActionController::Base
16
- c.helper_method :manager
16
+ c.helper_method :manager, :smart_listing_resource,
17
+ :smart_listing_collection
17
18
  c.include SmartListing::Helper::ControllerExtensions
18
19
  c.helper SmartListing::Helper
19
20
  c.respond_to :html, :js
20
21
  end
21
22
 
23
+ def smart_listing_collection
24
+ collection
25
+ end
26
+
27
+ def smart_listing_resource
28
+ resource
29
+ end
30
+
22
31
  def manager
23
32
  @manager ||= manager_class.new(self)
24
33
  end
@@ -1,3 +1,3 @@
1
1
  module SmartManaging
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_managing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guirec Corbel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-08 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails