inline_forms 0.9.22 → 0.9.23

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.22
1
+ 0.9.23
@@ -0,0 +1,22 @@
1
+ # FIXME not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES[:info]=:string
2
+
3
+ def infoadmin_show(object, attribute)
4
+ object.send(attribute)._presentation rescue ''
5
+ end
6
+
7
+ def infoadmin_edit(object, attribute)
8
+ object.send('build_' + attribute.to_s) unless object.send(attribute)
9
+ o = object.send(attribute).class.name.constantize
10
+ if cancan_enabled?
11
+ values = o.accessible_by(current_ability).order(o.order_by_clause)
12
+ else
13
+ values = o.order(o.order_by_clause)
14
+ end
15
+ # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form!
16
+ collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id', '_presentation', :selected => object.send(attribute).id)
17
+ end
18
+
19
+ def infoadmin_update(object, attribute)
20
+ object[attribute.to_s.foreign_key.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_s.foreign_key.to_sym]
21
+ end
22
+
@@ -58,7 +58,7 @@ module InlineFormsHelper
58
58
  out << "</li>"
59
59
  ""
60
60
  if cancan_enabled?
61
- if can?(:manage, model.constantize)
61
+ if can?(:create, model.constantize)
62
62
  if parent_class.nil?
63
63
  raw out
64
64
  else
@@ -24,6 +24,7 @@ they are @object. We need this magic here to rewrite all the @variables to varia
24
24
  <% parent_class = nil %>
25
25
  <% parent_id = nil %>
26
26
  <% objects = @objects %>
27
+ <% model_name = @Klass.to_s %>
27
28
  <% else %>
28
29
  <% # the controller gave us an @parent_class, so ... %>
29
30
  <% attribute = @Klass.to_s.underscore.pluralize %>
@@ -34,6 +35,7 @@ they are @object. We need this magic here to rewrite all the @variables to varia
34
35
  <% parent_id=@parent_id %>
35
36
  <% objects = @objects %>
36
37
  <% ul_needed = false unless @ul_needed %>
38
+ <% model_name = attribute.to_s.singularize.camelcase %>
37
39
  <% end %>
38
40
  <% else %>
39
41
  <% # here we come from _show %>
@@ -41,6 +43,7 @@ they are @object. We need this magic here to rewrite all the @variables to varia
41
43
  <% human_readable_class = attribute.to_s.singularize.humanize.downcase %>
42
44
  <% path_to_new='new_' + attribute.to_s.singularize + '_path' %>
43
45
  <% conditions = [ "#{parent_class.name.foreign_key} = ?", parent_id ] %>
46
+ <% model_name = attribute.to_s.singularize.camelcase %>
44
47
 
45
48
  <% if cancan_enabled? %>
46
49
  <% objects = parent_class.find(parent_id).send(attribute).accessible_by(current_ability).order(attribute.to_s.singularize.camelcase.constantize.order_by_clause).paginate :page => params[:page], :per_page => @PER_PAGE || 5, :conditions => conditions %>
@@ -54,7 +57,7 @@ they are @object. We need this magic here to rewrite all the @variables to varia
54
57
  <ul id="<%= update_span -%>" class="inline_forms_list">
55
58
  <% end %>
56
59
  <!-- # link to new -->
57
- <%= link_to_new_record("Add a new #{human_readable_class}", objects.first.class.name, path_to_new, update_span, parent_class, parent_id) -%>
60
+ <%= link_to_new_record("Add a new #{human_readable_class}", model_name, path_to_new, update_span, parent_class, parent_id) -%>
58
61
  <!-- # list of objects -->
59
62
  <% for object in objects %>
60
63
  <% if parent_class.nil? %>
data/inline_forms.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{inline_forms}
8
- s.version = "0.9.22"
8
+ s.version = "0.9.23"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ace Suares"]
12
- s.date = %q{2011-07-17}
12
+ s.date = %q{2011-07-31}
13
13
  s.description = %q{Inline Forms aims to ease the setup of forms that provide inline editing. The field list can be specified in the model.}
14
14
  s.email = %q{ace@suares.an}
15
15
  s.extra_rdoc_files = [
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
35
35
  "app/helpers/form_elements/geo_code_curacao.rb",
36
36
  "app/helpers/form_elements/image.rb",
37
37
  "app/helpers/form_elements/info.rb",
38
+ "app/helpers/form_elements/infoadmin.rb",
38
39
  "app/helpers/form_elements/question_list.rb",
39
40
  "app/helpers/form_elements/scale_with_integers.rb",
40
41
  "app/helpers/form_elements/scale_with_values.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 22
10
- version: 0.9.22
9
+ - 23
10
+ version: 0.9.23
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ace Suares
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-17 00:00:00 -04:00
18
+ date: 2011-07-31 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -136,6 +136,7 @@ files:
136
136
  - app/helpers/form_elements/geo_code_curacao.rb
137
137
  - app/helpers/form_elements/image.rb
138
138
  - app/helpers/form_elements/info.rb
139
+ - app/helpers/form_elements/infoadmin.rb
139
140
  - app/helpers/form_elements/question_list.rb
140
141
  - app/helpers/form_elements/scale_with_integers.rb
141
142
  - app/helpers/form_elements/scale_with_values.rb