smart_managing 0.0.3 → 0.0.4

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: 0fc5537edec2fee24dd50a3449d83b30cbfdc6cc
4
- data.tar.gz: 2a7094500f379c0857e0ee78b64975998272d2f1
3
+ metadata.gz: e560bcbd874c90af15363bdde5ce98fc9f581b78
4
+ data.tar.gz: ed4eb064e2c5638e2027799998663d80e594c8a0
5
5
  SHA512:
6
- metadata.gz: 15f6b24aadde8a2e97cbc03cb0ac6391f59cce3fe58aca96609065c3f37667de2a53d5a90430406dde19c2b9ec9f70677debb1fafd5580abae507d4620355790
7
- data.tar.gz: faff7d42f9b679bbc302f665d2ff7e3421c77ceccf186c0ffdb9bf49fac0bada502ac3ccc50e56b0e7b714570418f78cd2fe1c69d44073b2e56b44fe6b87687d
6
+ metadata.gz: 82d8bb6cda78743a210550619d0fbc2eb2c7446171d5104f9c28697500c456f5d6be40db3f3c4ad8289b767d4665b29ca6f9b09e7fe919fb3fcea79bc954f4f3
7
+ data.tar.gz: 8ffbd22735c47a2902500c9d1f9bd23aeb3b3e48e69e295ed7ab669d7250ce15f6f45cc3d653dc15d3d217460e1c550a32b2b26e27565a693e8c82bbe6153d89
@@ -16,8 +16,8 @@ module SmartManaging
16
16
  end
17
17
 
18
18
  def field_for(form:, klass:, attr:)
19
- if klass.reflect_on_association(attr)
20
- form.send(:association, attr)
19
+ if klass.reflect_on_association(attr.to_sym)
20
+ form.send(:association, attr.to_sym)
21
21
  else
22
22
  form.send(:input, attr)
23
23
  end
@@ -10,6 +10,10 @@ module SmartManaging
10
10
  attributes.size
11
11
  end
12
12
 
13
+ def permitted_params
14
+ klass.columns.map(&:name)
15
+ end
16
+
13
17
  def attributes
14
18
  klass.columns.map {|column| standardize(column.name)}
15
19
  end
@@ -1,16 +1,7 @@
1
1
  <td colspan="<%= colspan %>">
2
- <%= simple_form_for object, remote: true,
3
- wrapper: :smart_managing_form,
4
- html: { class: 'form-horizontal' } do |f| %>
5
- <% editable_attributes.each do |attr| %>
6
- <%= field_for(form: f, klass: object.class, attr: attr) %>
7
- <% end %>
8
- <div class="form-group">
9
- <label class="control-label col-md-3"></label>
10
- <div class="col-md-5">
11
- <%= f.button :submit, "Save", class: "btn btn-primary" %>
12
- <button class="btn btn-link cancel">Cancel</button>
13
- </div>
14
- </div>
2
+ <% if SmartManaging.config.style == :bootstrap3 %>
3
+ <%= render 'form_bootstrap3', object: object %>
4
+ <% else %>
5
+ <%= render 'form_bootstrap2', object: object %>
15
6
  <% end %>
16
7
  </td>
@@ -0,0 +1,11 @@
1
+ <%= simple_form_for object, remote: true,
2
+ wrapper: :smart_managing_bootstrap2,
3
+ html: { class: 'form-horizontal' } do |f| %>
4
+ <% editable_attributes.each do |attr| %>
5
+ <%= field_for(form: f, klass: object.class, attr: attr) %>
6
+ <% end %>
7
+ <div class="form-actions">
8
+ <%= f.button :submit, "Save", class: "btn btn-primary" %>
9
+ <button class="btn btn-link cancel">Cancel</button>
10
+ </div>
11
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <%= simple_form_for object, remote: true,
2
+ wrapper: :smart_managing_bootstrap3,
3
+ html: { class: 'form-horizontal' } do |f| %>
4
+ <% editable_attributes.each do |attr| %>
5
+ <%= field_for(form: f, klass: object.class, attr: attr) %>
6
+ <% end %>
7
+ <div class="form-group">
8
+ <label class="control-label col-md-3"></label>
9
+ <div class="col-md-5">
10
+ <%= f.button :submit, "Save", class: "btn btn-primary" %>
11
+ <button class="btn btn-link cancel">Cancel</button>
12
+ </div>
13
+ </div>
14
+ <% end %>
@@ -1 +1,7 @@
1
1
  Dir["#{Rails.root}/app/managers/*.rb"].each {|file| require file }
2
+
3
+ SmartManaging.configure do |config|
4
+ config.global_options({
5
+ #style: :bootstrap3 #options available are :bootstrap3 or :bootstrap2
6
+ })
7
+ end
@@ -1,5 +1,5 @@
1
1
  SimpleForm.setup do |config|
2
- config.wrappers :smart_managing_form, tag: 'div', class: 'control-group form-group', error_class: 'has-error' do |b|
2
+ config.wrappers :smart_managing_bootstrap3, tag: 'div', class: 'control-group form-group', error_class: 'has-error' do |b|
3
3
  b.use :html5
4
4
  b.use :placeholder
5
5
  b.use :label, class: 'col-md-3'
@@ -9,4 +9,15 @@ SimpleForm.setup do |config|
9
9
  ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
10
10
  end
11
11
  end
12
+
13
+ config.wrappers :smart_managing_bootstrap2, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
14
+ b.use :html5
15
+ b.use :placeholder
16
+ b.use :label
17
+ b.wrapper :tag => 'div', :class => 'controls' do |ba|
18
+ ba.use :input
19
+ ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
20
+ ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
21
+ end
22
+ end
12
23
  end
@@ -0,0 +1,27 @@
1
+ module SmartManaging
2
+ def self.configure(&block)
3
+ yield @config ||= SmartManaging::Configuration.new
4
+ end
5
+
6
+ def self.config
7
+ @config ||= SmartManaging::Configuration.new
8
+ end
9
+
10
+ class Configuration
11
+ DEFAULTS = {
12
+ style: :bootstrap3
13
+ }
14
+
15
+ def initialize
16
+ @options = DEFAULTS
17
+ end
18
+
19
+ def method_missing(sym, *args, &block)
20
+ @options[sym]
21
+ end
22
+
23
+ def style=(value)
24
+ @options[:style] = value
25
+ end
26
+ end
27
+ end
@@ -53,7 +53,13 @@ module SmartManaging
53
53
  end
54
54
 
55
55
  def build_resource_params
56
- [params.fetch(manager.model_sym, {}).permit(manager.attributes)]
56
+ parameters = params
57
+ parameters = parameters.fetch(manager.model_sym, {})
58
+ if parameters.respond_to?(:permit)
59
+ [parameters.permit(manager.permitted_params)]
60
+ else
61
+ [parameters]
62
+ end
57
63
  end
58
64
  end
59
65
  end
@@ -1,3 +1,3 @@
1
1
  module SmartManaging
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -5,6 +5,7 @@ require 'smart_listing'
5
5
  require 'simple_form'
6
6
  require 'smart_managing/engine'
7
7
  require 'smart_managing/controller_helpers'
8
+ require 'smart_managing/config'
8
9
 
9
10
  module SmartManaging
10
11
  UNEDITABLE_ATTRIBUTES = ['id', 'created_at', 'updated_at']
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_managing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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-10 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: smart_listing
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: coffee-rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '4.0'
61
+ version: '3.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '4.0'
68
+ version: '3.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bootstrap-sass
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: simple_form
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 3.1.0.rc2
89
+ version: '2.0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 3.1.0.rc2
96
+ version: '2.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: sqlite3
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -164,7 +164,7 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '1.0'
167
- description:
167
+ description: Easy way to create a managing interface.
168
168
  email:
169
169
  - guirec.corbel@gmail.com
170
170
  executables: []
@@ -177,18 +177,19 @@ files:
177
177
  - app/helpers/smart_managing/application_helper.rb
178
178
  - app/managers/smart_managing/base.rb
179
179
  - app/views/smart_managing/_form.html.erb
180
+ - app/views/smart_managing/_form_bootstrap2.html.erb
181
+ - app/views/smart_managing/_form_bootstrap3.html.erb
180
182
  - app/views/smart_managing/_item.html.erb
181
183
  - app/views/smart_managing/_list.html.erb
182
184
  - app/views/smart_managing/index.html.erb
183
- - config/routes.rb
184
185
  - lib/generators/smart_managing/install/install_generator.rb
185
186
  - lib/generators/smart_managing/install/templates/initializer.rb
186
187
  - lib/generators/smart_managing/install/templates/simple_form_smart_managing.rb
187
188
  - lib/smart_managing.rb
189
+ - lib/smart_managing/config.rb
188
190
  - lib/smart_managing/controller_helpers.rb
189
191
  - lib/smart_managing/engine.rb
190
192
  - lib/smart_managing/version.rb
191
- - lib/tasks/smart_managing_tasks.rake
192
193
  homepage: https://github.com/GCorbel/smart_managing
193
194
  licenses:
194
195
  - MIT
data/config/routes.rb DELETED
@@ -1,2 +0,0 @@
1
- Rails.application.routes.draw do
2
- end
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :smart_managing do
3
- # # Task goes here
4
- # end