smart_managing 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/helpers/smart_managing/application_helper.rb +8 -0
- data/app/managers/smart_managing/base.rb +5 -1
- data/app/views/smart_managing/_form.html.erb +1 -1
- data/app/views/smart_managing/index.html.erb +1 -0
- data/lib/smart_managing/controller_helpers.rb +10 -1
- data/lib/smart_managing/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fc5537edec2fee24dd50a3449d83b30cbfdc6cc
|
4
|
+
data.tar.gz: 2a7094500f379c0857e0ee78b64975998272d2f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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'
|
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(
|
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.
|
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>
|
@@ -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
|
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.
|
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-
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|