inline_forms 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/helpers/inline_forms_helper.rb +1 -1
- data/inline_forms.gemspec +2 -2
- data/lib/generators/inline_forms/USAGE +5 -5
- data/lib/generators/inline_forms/inline_forms_generator.rb +4 -1
- data/lib/generators/inline_forms/templates/migration.erb +8 -7
- data/lib/generators/inline_forms/templates/model.erb +13 -11
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
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.
|
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.
|
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-
|
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
|
16
|
+
def _presentation
|
17
17
|
#define your presentation here
|
18
18
|
end
|
19
19
|
def inline_forms_field_list
|
20
20
|
[
|
21
|
-
[ :
|
22
|
-
[ :
|
23
|
-
[ :
|
24
|
-
[ :
|
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
|
-
|
5
|
-
<%=
|
6
|
-
|
7
|
-
|
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
|
-
|
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
|
-
|
5
|
-
<% end
|
4
|
+
<%= ' belongs_to :' + attribute.name + "\n" if attribute.belongs_to? -%>
|
5
|
+
<% end -%>
|
6
6
|
<% for attribute in attributes -%>
|
7
|
-
|
8
|
-
<% end
|
7
|
+
<%= ' has_many :' + attribute.name + "\n" if attribute.has_many? -%>
|
8
|
+
<% end -%>
|
9
9
|
|
10
|
-
def
|
11
|
-
|
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
|
-
|
17
|
-
<%=
|
18
|
-
|
19
|
-
|
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:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
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-
|
18
|
+
date: 2011-02-14 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|