qm-acts-as-generic-controller 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ 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.1.
|
12
|
+
gemspec.version = "0.1.9"
|
13
13
|
gemspec.files = Rake::FileList.new [ "MIT-LICENSE", "Rakefile", "lib/*", "app/views/generic_controller/*" ]
|
14
14
|
gemspec.add_dependency "qui-common-helpers", ">= 0.0.8"
|
15
15
|
gemspec.add_dependency "qui-index-table", ">= 0.0.8"
|
@@ -9,6 +9,15 @@
|
|
9
9
|
<%- end -%>
|
10
10
|
|
11
11
|
<%- form_for form_for_param, :html => { :multipart => true } do |f| -%>
|
12
|
+
<%- if params[:association_attribute] -%>
|
13
|
+
<%= hidden_field_tag :association_attribute_name, params[:association_attribute] %>
|
14
|
+
<%= hidden_field_tag :association_attribute_value, params[:association_attribute].scan(/[^\[\]]+/).inject(params) { |memo, obj| memo[obj] } %>
|
15
|
+
|
16
|
+
<%- elsif params[:association_attribute_name] and params[:association_attribute_value] -%>
|
17
|
+
<%= hidden_field_tag :association_attribute_name, params[:association_attribute_name] %>
|
18
|
+
<%= hidden_field_tag :association_attribute_value, params[:association_attribute_value] %>
|
19
|
+
<%- end -%>
|
20
|
+
|
12
21
|
<%= f.error_messages %>
|
13
22
|
<%- unless klass.generic_form_fieldsets -%>
|
14
23
|
<fieldset>
|
@@ -44,7 +44,9 @@
|
|
44
44
|
<%- if has_privileges and (v[:kind] == :has_many or v[:kind] == :has_and_belongs_to_many) and (v[:generic_create] or not v[:through]) -%>
|
45
45
|
<%- tab_contents[k] = capture do -%>
|
46
46
|
<%- if v[:generic_create] and has_privileges_to_generic_create -%>
|
47
|
-
|
47
|
+
<%- association_attribute = "#{v[:class_name].table_name.singularize}[#{table_name}_id]" -%>
|
48
|
+
<%= link_to t(:"toolbar.create"), polymorphic_path([ "new", section, v[:class_name].table_name.singularize ], { association_attribute => record.id, :association_attribute => association_attribute }), :class => "create" %>
|
49
|
+
|
48
50
|
<%- end -%>
|
49
51
|
|
50
52
|
<%= render :partial => "generic_controller/index_table", :locals => { :records => record.send(k), :class_name => v[:class_name] } %>
|
@@ -121,15 +121,42 @@ module QM
|
|
121
121
|
if instance_variable_get(singular_variable).save
|
122
122
|
flash[:notice] = :savedAsFlash
|
123
123
|
if defined?(section)
|
124
|
-
format.html {
|
125
|
-
|
124
|
+
format.html {
|
125
|
+
if params[:commit_and_create]
|
126
|
+
if params[:association_attribute_name] and params[:association_attribute_value]
|
127
|
+
redirect_to polymorphic_url([ "new", section, model.table_name.singularize ], params[:association_attribute_name] => params[:association_attribute_value])
|
128
|
+
else
|
129
|
+
redirect_to polymorphic_url([ "new", section, model.table_name.singularize ])
|
130
|
+
|
131
|
+
end
|
132
|
+
else
|
133
|
+
redirect_to [ section, instance_variable_get(singular_variable) ]
|
134
|
+
end
|
135
|
+
}
|
136
|
+
|
137
|
+
format.xml { render :xml => instance_variable_get(singular_variable).to_xml(:only => current_user.privileged_attributes(model, :read)), :status => :created, :location => [ section, instance_variable_get(singular_variable) ] }
|
138
|
+
|
139
|
+
|
126
140
|
else
|
127
|
-
format.html {
|
141
|
+
format.html {
|
142
|
+
if params[:commit_and_create]
|
143
|
+
if params[:association_attribute_name] and params[:association_attribute_value]
|
144
|
+
redirect_to polymorphic_url([ "new", model.table_name.singularize ], params[:association_attribute_name] => params[:association_attribute_value])
|
145
|
+
else
|
146
|
+
redirect_to polymorphic_url([ "new", model.table_name.singularize ])
|
147
|
+
end
|
148
|
+
|
149
|
+
else
|
150
|
+
redirect_to instance_variable_get(singular_variable)
|
151
|
+
end
|
152
|
+
|
153
|
+
}
|
154
|
+
|
128
155
|
format.xml {
|
129
156
|
if defined?(current_user) and current_user.respond_to? :privileged_attributes
|
130
157
|
render :xml => instance_variable_get(singular_variable).to_xml(:only => current_user.privileged_attributes(model, :read)), :status => :created, :location => instance_variable_get(singular_variable)
|
131
158
|
else
|
132
|
-
render :xml => instance_variable_get(singular_variable), :status => :created, :location => instance_variable_get(singular_variable)
|
159
|
+
render :xml => instance_variable_get(singular_variable).to_xml(:only => current_user.privileged_attributes(model, :read)), :status => :created, :location => instance_variable_get(singular_variable)
|
133
160
|
end
|
134
161
|
}
|
135
162
|
end
|
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: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 9
|
10
|
+
version: 0.1.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marcin Lewandowski
|