dynamic_fieldsets 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/VERSION +1 -1
- data/app/controllers/dynamic_fieldsets/fields_controller.rb +14 -1
- data/app/models/dynamic_fieldsets/field.rb +6 -0
- data/app/views/dynamic_fieldsets/fields/_form.html.erb +3 -0
- data/app/views/dynamic_fieldsets/fields/show.html.erb +1 -1
- data/dynamic_fieldsets.gemspec +2 -2
- data/lib/generators/dynamic_fieldsets/templates/config.rb +1 -1
- metadata +3 -3
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== unreleased changes
|
2
|
+
|
3
|
+
== 0.1.3
|
4
|
+
|
5
|
+
* Fixed a typo in the generated config
|
6
|
+
* Updated the field model so that type can be set through the controller
|
7
|
+
|
1
8
|
== 0.1.2
|
2
9
|
|
3
10
|
* Fixed a bug where fields would not display correctly on the show page if they were never filled out
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -76,9 +76,22 @@ module DynamicFieldsets
|
|
76
76
|
|
77
77
|
# PUT /dynamic_fieldsets/fields/1
|
78
78
|
def update
|
79
|
-
|
79
|
+
# note that on update, we need to get a Field object so that the type can be changed
|
80
|
+
@field = DynamicFieldsets::Field.find(params[:id])
|
80
81
|
|
81
82
|
respond_to do |format|
|
83
|
+
# this is sort of a bad hack to make field type changes work
|
84
|
+
# it is setup to allow validations to stop the type from changing using validations
|
85
|
+
# this could be improved by figuring out how to set the type using update_attributes (JH 3-2-2012)
|
86
|
+
if @field.type != params[:dynamic_fieldsets_field][:type]
|
87
|
+
@field.type = params[:dynamic_fieldsets_field][:type]
|
88
|
+
if @field.save
|
89
|
+
@field = DynamicFieldsets::Field.find(params[:id])
|
90
|
+
else
|
91
|
+
format.html { render :action => "edit", :notice => 'Could not change the field type.' }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
82
95
|
if @field.update_attributes(params[:dynamic_fieldsets_field])
|
83
96
|
format.html { redirect_to(dynamic_fieldsets_field_path(@field), :notice => 'Successfully updated a field.') }
|
84
97
|
else
|
@@ -50,6 +50,12 @@ module DynamicFieldsets
|
|
50
50
|
def self.descendant_collection
|
51
51
|
descendants.collect { |d| [d.to_s.gsub("DynamicFieldsets::", "").underscore.humanize, d.to_s ] }
|
52
52
|
end
|
53
|
+
|
54
|
+
# Very similar to the output in descendant collection
|
55
|
+
# @return [String] A pretty version of the type
|
56
|
+
def display_type
|
57
|
+
type.gsub("DynamicFieldsets::", "").underscore.humanize
|
58
|
+
end
|
53
59
|
|
54
60
|
# Form partial Methods
|
55
61
|
|
@@ -22,6 +22,9 @@
|
|
22
22
|
</div>
|
23
23
|
|
24
24
|
<div class="field">
|
25
|
+
<% unless @field.new_record? %>
|
26
|
+
<p>Be careful changing the field type on a field that already has records associated with. Changing to an incompatible type could cause data loss.</p>
|
27
|
+
<% end %>
|
25
28
|
<%= f.label :type %>:
|
26
29
|
<%= f.select :type, options_for_select(DynamicFieldsets::Field.descendant_collection, @field.type), :include_blank => "Choose One" %>
|
27
30
|
</div>
|
data/dynamic_fieldsets.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "dynamic_fieldsets"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeremiah Hemphill", "Ethan Pemble", "John Carter"]
|
12
|
-
s.date = "2012-02
|
12
|
+
s.date = "2012-03-02"
|
13
13
|
s.description = "Dynamic fieldsets for rails controllers"
|
14
14
|
s.email = "jeremiah@cloudspace.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -3,7 +3,7 @@ DynamicFieldsets.configure do |config|
|
|
3
3
|
# can cause the single table inheritance to fail. This is due to the object
|
4
4
|
# space getting reset after every request. In production and test environemnts,
|
5
5
|
# this information will not be used because the object space will be complete.
|
6
|
-
# config.available_field_types = [ "DynamicFieldsets::CheckboxField", "DynamicFieldsets::
|
6
|
+
# config.available_field_types = [ "DynamicFieldsets::CheckboxField", "DynamicFieldsets::DateField", "DynamicFieldsets::DatetimeField", "DynamicFieldsets::InstructionField", "DynamicFieldsets::MultipleSelectField", "DynamicFieldsets::RadioField", "DynamicFieldsets::SelectField", "DynamicFieldsets::TextField", "DynamicFieldsets::TextareaField" ]
|
7
7
|
|
8
8
|
# This should correspond to the beginning of the id for the fields for on the form
|
9
9
|
# For example: fsa-8
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: dynamic_fieldsets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jeremiah Hemphill
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2012-02
|
15
|
+
date: 2012-03-02 00:00:00 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rails
|
@@ -429,7 +429,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
429
429
|
requirements:
|
430
430
|
- - ">="
|
431
431
|
- !ruby/object:Gem::Version
|
432
|
-
hash: -
|
432
|
+
hash: -2479662043084122620
|
433
433
|
segments:
|
434
434
|
- 0
|
435
435
|
version: "0"
|