qm-acts-as-generic-controller 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile
CHANGED
@@ -9,9 +9,9 @@ begin
|
|
9
9
|
gemspec.email = "marcin@saepia.net"
|
10
10
|
gemspec.homepage = "http://q.saepia.net"
|
11
11
|
gemspec.authors = ["Marcin Lewandowski"]
|
12
|
-
gemspec.version = "0.0.
|
12
|
+
gemspec.version = "0.0.15"
|
13
13
|
gemspec.files = Rake::FileList.new [ "MIT-LICENSE", "Rakefile", "lib/*", "app/views/generic_controller/*" ]
|
14
|
-
gemspec.add_dependency "qui-common-helpers", ">= 0.0.
|
14
|
+
gemspec.add_dependency "qui-common-helpers", ">= 0.0.7"
|
15
15
|
gemspec.add_dependency "qui-tabs", ">= 0.0.3"
|
16
16
|
gemspec.add_dependency "qui-toolbar", ">= 0.0.4"
|
17
17
|
gemspec.add_dependency "rfc822"
|
@@ -58,7 +58,7 @@
|
|
58
58
|
<%- case record.column_for_attribute(attribute_name).type -%>
|
59
59
|
<%- when :text -%>
|
60
60
|
<%= f.text_area attribute_name, :rows => 5, :cols => 60 %>
|
61
|
-
<%- when :date -%>
|
61
|
+
<%- when :date, :datetime -%>
|
62
62
|
<%= f.calendar_date_select attribute_name %>
|
63
63
|
<%- when :boolean -%>
|
64
64
|
<span class="boolean">
|
@@ -82,7 +82,7 @@ module QM
|
|
82
82
|
respond_to do |format|
|
83
83
|
if instance_variable_get(singular_variable).save
|
84
84
|
flash[:notice] = :savedAsFlash
|
85
|
-
if defined?(
|
85
|
+
if defined?(section)
|
86
86
|
format.html { redirect_to [ section, instance_variable_get(singular_variable) ] }
|
87
87
|
format.xml { render :xml => instance_variable_get(singular_variable), :status => :created, :location => [ section, instance_variable_get(singular_variable) ] }
|
88
88
|
else
|
@@ -103,7 +103,7 @@ module QM
|
|
103
103
|
respond_to do |format|
|
104
104
|
if instance_variable_get(singular_variable).save
|
105
105
|
flash[:notice] = :savedAsFlash
|
106
|
-
if defined?(
|
106
|
+
if defined?(section)
|
107
107
|
format.html { redirect_to [ section, instance_variable_get(singular_variable) ] }
|
108
108
|
format.xml { head :ok }
|
109
109
|
else
|
@@ -13,7 +13,7 @@ module QM
|
|
13
13
|
|
14
14
|
def has_many(association_id, options = {}, &extension)
|
15
15
|
@generic_field_associations ||= {}
|
16
|
-
@generic_field_associations[association_id.to_sym] = { :kind => :has_many, :class_name => ( options
|
16
|
+
@generic_field_associations[association_id.to_sym] = { :kind => :has_many, :class_name => ( options.has_key?(:class_name) ? options[:class_name].constantize : association_id.to_s.classify.constantize ), :readonly => options[:readonly] || false, :through => options[:through].present?, :generic_create => options[:generic_create] || false }
|
17
17
|
|
18
18
|
options.delete :generic_create
|
19
19
|
|
@@ -22,7 +22,7 @@ module QM
|
|
22
22
|
|
23
23
|
def has_and_belongs_to_many(association_id, options = {}, &extension)
|
24
24
|
@generic_field_associations ||= {}
|
25
|
-
@generic_field_associations[association_id.to_sym] = { :kind => :has_and_belongs_to_many, :class_name => ( options
|
25
|
+
@generic_field_associations[association_id.to_sym] = { :kind => :has_and_belongs_to_many, :class_name => ( options.has_key?(:class_name) ? options[:class_name].constantize : association_id.to_s.classify.constantize ), :readonly => options[:readonly] || false, :through => options[:through].present?, :generic_create => options[:generic_create] || false }
|
26
26
|
|
27
27
|
options.delete :generic_create
|
28
28
|
|
@@ -31,8 +31,11 @@ module QM
|
|
31
31
|
|
32
32
|
def belongs_to(association_id, options = {})
|
33
33
|
@generic_field_associations ||= {}
|
34
|
-
|
35
|
-
|
34
|
+
unless options.has_key?(:polymorphic)
|
35
|
+
klass = ( options.has_key?(:class_name) ? options[:class_name].to_s.constantize : association_id.to_s.classify.constantize )
|
36
|
+
|
37
|
+
@generic_field_associations[association_id.to_sym] = { :kind => :belongs_to, :class_name => klass, :foreign_key => options[:foreign_key] || "#{klass.to_s.tableize}_id" }
|
38
|
+
end
|
36
39
|
|
37
40
|
super association_id, options
|
38
41
|
end
|
@@ -24,9 +24,14 @@ module QM
|
|
24
24
|
elsif options[:kind] == :radio
|
25
25
|
field_name = "#{table_name}[#{klass.generic_field_associations[attribute_name][:foreign_key]}]"
|
26
26
|
allow_nil ||= options[:record].column_for_attribute(klass.generic_field_associations[attribute_name][:foreign_key]).null
|
27
|
-
end
|
28
|
-
|
29
|
-
|
27
|
+
end
|
28
|
+
|
29
|
+
if klass.respond_to? :limit_for_user and defined?(current_user)
|
30
|
+
collection = klass.generic_field_associations[attribute_name][:class_name].limit_for_user(current_user)
|
31
|
+
else
|
32
|
+
collection = klass.generic_field_associations[attribute_name][:class_name].all
|
33
|
+
end
|
34
|
+
|
30
35
|
render :partial => "generic_controller/multiple_select", :locals => { :mode => :activerecord,
|
31
36
|
:attribute_name => attribute_name,
|
32
37
|
:field_name => field_name,
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qm-acts-as-generic-controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 15
|
10
|
+
version: 0.0.15
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marcin Lewandowski
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-14 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +26,12 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 17
|
30
30
|
segments:
|
31
31
|
- 0
|
32
32
|
- 0
|
33
|
-
-
|
34
|
-
version: 0.0.
|
33
|
+
- 7
|
34
|
+
version: 0.0.7
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|