inline_forms 0.6.2 → 0.6.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.2
1
+ 0.6.3
@@ -23,7 +23,7 @@ module InlineFormsHelper
23
23
  # out += content_tag :tr, name_cell + value_cell
24
24
  # out += "\n"
25
25
  # else
26
- out << h(object.presentation)
26
+ out << h(object._presentation)
27
27
  attributes.each do | attribute, name, form_element, values |
28
28
  #css_class_id = form_element == :associated ? "subform_#{attribute.to_s}_#{object.id}" : "field_#{attribute.to_s}_#{object.id}"
29
29
  css_class_id = "field_#{attribute.to_s}_#{object.id}"
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.6.2"
8
+ s.version = "0.6.3"
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-02-13}
12
+ s.date = %q{2011-02-14}
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 = [
@@ -13,15 +13,15 @@ This will create:
13
13
 
14
14
  app/models/thing.rb:
15
15
  class Thing < ActiveRecord::Base
16
- def presentation
16
+ def _presentation
17
17
  #define your presentation here
18
18
  end
19
19
  def inline_forms_field_list
20
20
  [
21
- [ :string, 'name', :text_field ],
22
- [ :text, 'description', :text_area ],
23
- [ :boolean, 'yesno', :check_box ],
24
- [ :boolean, 'gender', :boolean_with_values ],
21
+ [ :name, 'name', :text_field ],
22
+ [ :description, 'description', :text_area ],
23
+ [ :yesno, 'yesno', :check_box ],
24
+ [ :gender, 'gender', :boolean_with_values ],
25
25
  ]
26
26
  end
27
27
  end
@@ -45,8 +45,11 @@ module InlineForms
45
45
 
46
46
  source_root File.expand_path('../templates', __FILE__)
47
47
 
48
+ def copy_stylesheet
49
+ copy_file File.expand_path('../../../../public/stylesheets', __FILE__) + "/inline_forms.css", "public/stylesheets/inline_forms.css" unless File.exists?('public/stylesheets/inline_forms.css')
50
+ end
51
+
48
52
  def generate_model
49
- #copy_file "stylesheet.css", "public/stylesheets/#{file_name}.css"
50
53
  template "model.erb", "app/models/#{model_file_name}.rb"
51
54
  end
52
55
 
@@ -1,15 +1,16 @@
1
1
  class InlineFormsCreate<%= table_name.camelize %> < ActiveRecord::Migration
2
2
  def self.up
3
3
  create_table :<%= table_name %> do |t|
4
- <% for attribute in attributes -%>
5
- <%= '#' if attribute.migration_type == :unknown || attribute.special_relation? -%>
6
- t.<%= attribute.migration_type %> :<%= attribute.migration_name %>
7
- <% end -%>
4
+ <% for attribute in attributes -%>
5
+ <%= ( attribute.migration_type == :unknown || attribute.special_relation? ) ? '#' : ' ' -%>
6
+ <%= ' t.' + attribute.migration_type.to_s %> :<%= attribute.migration_name %>
7
+ <% end -%>
8
8
  t.timestamps
9
9
  end
10
- end
10
+ end
11
11
 
12
- def self.down
13
- drop_table :<%= table_name %>
12
+ def self.down
13
+ drop_table :<%= table_name %>
14
14
  end
15
+
15
16
  end
@@ -1,22 +1,24 @@
1
1
  class <%= name %> < ActiveRecord::Base
2
2
 
3
3
  <% for attribute in attributes -%>
4
- <%= 'belongs_to :' + attribute.name if attribute.belongs_to? %>
5
- <% end %>
4
+ <%= ' belongs_to :' + attribute.name + "\n" if attribute.belongs_to? -%>
5
+ <% end -%>
6
6
  <% for attribute in attributes -%>
7
- <%= 'has_many :' + attribute.name if attribute.has_many? %>
8
- <% end %>
7
+ <%= ' has_many :' + attribute.name + "\n" if attribute.has_many? -%>
8
+ <% end -%>
9
9
 
10
- def presentation
11
- 'please define presentation!'
10
+ def _presentation
11
+ <% for attribute in attributes -%>
12
+ <%= ' "' + ( attribute.type.to_s || 'put your presentation here' ) + '"' + "\n" if attribute.name == '_presentation' -%>
13
+ <% end -%>
12
14
  end
13
15
 
14
16
  def inline_forms_field_list
15
17
  [
16
- <% for attribute in attributes -%>
17
- <%= '#' if attribute.relation? -%>
18
- <%= '[ :' + attribute.name + ', "' + attribute.name + '", :' + attribute.field_type.to_s + ' ], ' %>
19
- <% end -%>
20
- ]
18
+ <% for attribute in attributes -%>
19
+ <%= attribute.relation? ? '#' : ' ' -%>
20
+ <%= ' [ :' + attribute.name + ', "' + attribute.name + '", :' + attribute.field_type.to_s + " ], \n" unless attribute.name == '_presentation' -%>
21
+ <% end -%>
22
+ ]
21
23
  end
22
24
  end
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: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 2
10
- version: 0.6.2
9
+ - 3
10
+ version: 0.6.3
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-02-13 00:00:00 -04:00
18
+ date: 2011-02-14 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency