netzke-basepack 0.5.8 → 0.5.9
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/CHANGELOG.rdoc +18 -0
- data/README.rdoc +11 -4
- data/Rakefile +19 -3
- data/TODO.rdoc +1 -1
- data/generators/netzke_basepack/netzke_basepack_generator.rb +13 -0
- data/generators/netzke_basepack/templates/create_netzke_field_lists.rb +18 -0
- data/generators/netzke_basepack/templates/public_assets/ts-checkbox.gif +0 -0
- data/install.rb +1 -1
- data/javascripts/basepack.js +124 -30
- data/lib/app/models/netzke_field_list.rb +261 -0
- data/lib/app/models/netzke_model_attr_list.rb +21 -0
- data/lib/app/models/netzke_persistent_array_auto_model.rb +58 -0
- data/lib/netzke-basepack.rb +17 -2
- data/lib/netzke/active_record.rb +10 -0
- data/lib/netzke/active_record/association_attributes.rb +102 -0
- data/lib/netzke/active_record/attributes.rb +100 -0
- data/lib/netzke/active_record/combobox_options.rb +43 -0
- data/lib/netzke/active_record/data_accessor.rb +9 -12
- data/lib/netzke/attributes_configurator.rb +195 -0
- data/lib/netzke/basic_app.rb +47 -4
- data/lib/netzke/configuration_panel.rb +1 -1
- data/lib/netzke/data_accessor.rb +7 -30
- data/lib/netzke/fields_configurator.rb +106 -41
- data/lib/netzke/form_panel.rb +28 -125
- data/lib/netzke/form_panel/form_panel_api.rb +2 -3
- data/lib/netzke/form_panel/form_panel_fields.rb +147 -0
- data/lib/netzke/form_panel/form_panel_js.rb +35 -15
- data/lib/netzke/grid_panel.rb +130 -213
- data/lib/netzke/grid_panel/grid_panel_api.rb +254 -257
- data/lib/netzke/grid_panel/grid_panel_columns.rb +226 -0
- data/lib/netzke/grid_panel/grid_panel_js.rb +126 -119
- data/lib/netzke/grid_panel/record_form_window.rb +7 -1
- data/lib/netzke/json_array_editor.rb +61 -0
- data/lib/netzke/plugins/configuration_tool.rb +1 -1
- data/lib/netzke/property_editor.rb +3 -3
- data/lib/netzke/search_panel.rb +164 -27
- data/lib/netzke/tab_panel.rb +14 -12
- data/stylesheets/basepack.css +43 -2
- data/test/app_root/app/models/book.rb +1 -1
- data/test/app_root/app/models/role.rb +3 -0
- data/test/app_root/app/models/user.rb +3 -0
- data/test/app_root/config/database.yml +1 -1
- data/test/app_root/db/migrate/20090102223630_create_netzke_field_lists.rb +18 -0
- data/test/app_root/db/migrate/20090423214303_create_roles.rb +11 -0
- data/test/app_root/db/migrate/20090423222114_create_users.rb +12 -0
- data/test/fixtures/books.yml +4 -2
- data/test/fixtures/categories.yml +2 -2
- data/test/fixtures/genres.yml +6 -6
- data/test/fixtures/roles.yml +8 -0
- data/test/fixtures/users.yml +11 -0
- data/test/test_helper.rb +2 -0
- data/test/unit/active_record_basepack_test.rb +2 -2
- data/test/unit/fields_configuration_test.rb +18 -0
- data/test/unit/grid_panel_test.rb +29 -27
- metadata +41 -16
- data/lib/app/models/netzke_auto_column.rb +0 -4
- data/lib/app/models/netzke_auto_field.rb +0 -4
- data/lib/app/models/netzke_auto_table.rb +0 -61
- data/lib/netzke/active_record/basepack.rb +0 -134
- data/lib/netzke/grid_panel/javascripts/filters.js +0 -7
- data/test/app_root/db/migrate/20090102223630_create_netzke_layouts.rb +0 -14
- data/test/unit/helper_model_test.rb +0 -30
@@ -1,12 +1,26 @@
|
|
1
|
-
require '
|
1
|
+
require 'active_record'
|
2
2
|
require 'searchlogic'
|
3
3
|
require 'will_paginate'
|
4
4
|
|
5
5
|
module Netzke
|
6
6
|
class GridPanel < Base
|
7
7
|
module GridPanelApi
|
8
|
+
|
9
|
+
#
|
10
|
+
# Grid's native API
|
11
|
+
#
|
12
|
+
|
13
|
+
def get_data(params = {})
|
14
|
+
if !ext_config[:prohibit_read]
|
15
|
+
records = get_records(params)
|
16
|
+
{:data => records.map{|r| r.to_array(columns, self)}, :total => ext_config[:enable_pagination] && records.total_entries}
|
17
|
+
else
|
18
|
+
flash :error => "You don't have permissions to read data"
|
19
|
+
{:feedback => @flash}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
8
23
|
def post_data(params)
|
9
|
-
success = true
|
10
24
|
mod_records = {}
|
11
25
|
[:create, :update].each do |operation|
|
12
26
|
data = ActiveSupport::JSON.decode(params["#{operation}d_records"]) if params["#{operation}d_records"]
|
@@ -14,8 +28,10 @@ module Netzke
|
|
14
28
|
mod_records[operation] = process_data(data, operation)
|
15
29
|
mod_records[operation] = nil if mod_records[operation].empty?
|
16
30
|
end
|
17
|
-
break if !success
|
18
31
|
end
|
32
|
+
|
33
|
+
on_data_changed
|
34
|
+
|
19
35
|
{
|
20
36
|
:update_new_records => mod_records[:create],
|
21
37
|
:update_mod_records => mod_records[:update] || {},
|
@@ -23,48 +39,20 @@ module Netzke
|
|
23
39
|
}
|
24
40
|
end
|
25
41
|
|
26
|
-
def get_data(params = {})
|
27
|
-
if !ext_config[:prohibit_read]
|
28
|
-
records = get_records(params)
|
29
|
-
{:data => records.map{|r| r.to_array(normalized_columns, self)}, :total => ext_config[:enable_pagination] && records.total_entries}
|
30
|
-
else
|
31
|
-
flash :error => "You don't have permissions to read data"
|
32
|
-
{:feedback => @flash}
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
42
|
def delete_data(params)
|
37
43
|
if !ext_config[:prohibit_delete]
|
38
44
|
record_ids = ActiveSupport::JSON.decode(params[:records])
|
39
45
|
data_class.destroy(record_ids)
|
46
|
+
on_data_changed
|
40
47
|
{:feedback => "Deleted #{record_ids.size} record(s)", :load_store_data => get_data}
|
41
48
|
else
|
42
49
|
{:feedback => "You don't have permissions to delete data"}
|
43
50
|
end
|
44
51
|
end
|
45
52
|
|
46
|
-
# Given an index of a column among enabled (non-excluded) columns, provides the index (position) in the table
|
47
|
-
def normalize_index(index)
|
48
|
-
norm_index = 0
|
49
|
-
index.times do
|
50
|
-
while true do
|
51
|
-
norm_index += 1
|
52
|
-
break unless normalized_columns[norm_index][:excluded]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
norm_index
|
56
|
-
end
|
57
|
-
|
58
53
|
def resize_column(params)
|
59
54
|
raise "Called api_resize_column while not configured to do so" if ext_config[:enable_column_resize] == false
|
60
|
-
|
61
|
-
save_columns!
|
62
|
-
{}
|
63
|
-
end
|
64
|
-
|
65
|
-
def hide_column(params)
|
66
|
-
raise "Called api_hide_column while not configured to do so" if ext_config[:enable_column_hide] == false
|
67
|
-
column_at(normalize_index(params[:index].to_i))[:hidden] = params[:hidden].to_b
|
55
|
+
columns[normalize_index(params[:index].to_i)][:width] = params[:size].to_i
|
68
56
|
save_columns!
|
69
57
|
{}
|
70
58
|
end
|
@@ -83,276 +71,285 @@ module Netzke
|
|
83
71
|
{}
|
84
72
|
end
|
85
73
|
|
86
|
-
|
74
|
+
def hide_column(params)
|
75
|
+
raise "Called api_hide_column while not configured to do so" if ext_config[:enable_column_hide] == false
|
76
|
+
columns[normalize_index(params[:index].to_i)][:hidden] = params[:hidden].to_b
|
77
|
+
save_columns!
|
78
|
+
{}
|
79
|
+
end
|
80
|
+
|
81
|
+
# Returns choices for a column
|
87
82
|
def get_combobox_options(params)
|
88
83
|
column = params[:column]
|
89
84
|
query = params[:query]
|
90
85
|
{:data => data_class.options_for(column, query).map{|s| [s]}}
|
86
|
+
# {:data => data_class.options_for(column, query).map{|s| [s]}}
|
91
87
|
end
|
92
88
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
89
|
+
def move_rows(params)
|
90
|
+
if defined?(ActsAsList) && data_class.ancestors.include?(ActsAsList::InstanceMethods)
|
91
|
+
ids = JSON.parse(params[:ids]).reverse
|
92
|
+
ids.each_with_index do |id, i|
|
93
|
+
r = data_class.find(id)
|
94
|
+
r.insert_at(params[:new_index].to_i + i + 1)
|
95
|
+
end
|
96
|
+
on_data_changed
|
97
|
+
else
|
98
|
+
raise RuntimeError, "Data class should 'acts_as_list' to support moving rows"
|
99
|
+
end
|
100
|
+
{}
|
101
|
+
end
|
102
|
+
|
103
|
+
#
|
104
|
+
# Some aggregatees' overridden API
|
105
|
+
#
|
106
|
+
|
107
|
+
## Edit in form specific API
|
108
|
+
def add_form__item__netzke_submit(params)
|
109
|
+
res = aggregatee_instance(:add_form__item).netzke_submit(params)
|
110
|
+
|
111
|
+
if res[:set_form_values]
|
112
|
+
# successful creation
|
113
|
+
on_data_changed
|
114
|
+
res[:set_form_values] = nil
|
115
|
+
end
|
116
|
+
res.to_nifty_json
|
117
|
+
end
|
98
118
|
|
99
|
-
|
100
|
-
|
119
|
+
def edit_form__item__netzke_submit(params)
|
120
|
+
res = aggregatee_instance(:edit_form__item).netzke_submit(params)
|
101
121
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
122
|
+
if res[:set_form_values]
|
123
|
+
on_data_changed
|
124
|
+
res[:set_form_values] = nil
|
125
|
+
end
|
126
|
+
|
127
|
+
res.to_nifty_json
|
128
|
+
end
|
106
129
|
|
107
|
-
|
130
|
+
def multi_edit_form__item__netzke_submit(params)
|
131
|
+
ids = ActiveSupport::JSON.decode(params.delete(:ids))
|
132
|
+
data = ids.collect{ |id| ActiveSupport::JSON.decode(params[:data]).merge("id" => id) }
|
133
|
+
|
134
|
+
mod_records_count = process_data(data, :update).count
|
135
|
+
|
136
|
+
# remove duplicated flash messages
|
137
|
+
@flash = @flash.inject([]){ |r,hsh| r.include?(hsh) ? r : r.push(hsh) }
|
138
|
+
|
139
|
+
if mod_records_count > 0
|
140
|
+
on_data_changed
|
141
|
+
flash :notice => "Updated #{mod_records_count} records."
|
142
|
+
{:set_result => "ok", :feedback => @flash}.to_nifty_json
|
143
|
+
else
|
144
|
+
{:feedback => @flash}.to_nifty_json
|
145
|
+
end
|
146
|
+
end
|
108
147
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
148
|
+
protected
|
149
|
+
# Override this method to react on each operation that caused changing of data
|
150
|
+
def on_data_changed; end
|
151
|
+
|
152
|
+
# Given an index of a column among enabled (non-excluded) columns, provides the index (position) in the table
|
153
|
+
def normalize_index(index)
|
154
|
+
norm_index = 0
|
155
|
+
index.times do
|
156
|
+
while true do
|
157
|
+
norm_index += 1
|
158
|
+
break unless columns[norm_index][:included] == false
|
116
159
|
end
|
117
160
|
end
|
118
|
-
|
119
|
-
search
|
161
|
+
norm_index
|
120
162
|
end
|
121
|
-
end
|
122
163
|
|
123
|
-
|
124
|
-
|
164
|
+
# Returns searchlogic's search with all the conditions
|
165
|
+
def get_search(params)
|
166
|
+
@search ||= begin
|
167
|
+
# make params coming from Ext grid filters understandable by searchlogic
|
168
|
+
search_params = normalize_params(params)
|
169
|
+
|
170
|
+
# merge with conditions coming from the config
|
171
|
+
search_params[:conditions].deep_merge!(config[:conditions] || {})
|
172
|
+
|
173
|
+
# merge with extra conditions (in searchlogic format, come from the extended search form)
|
174
|
+
search_params[:conditions].deep_merge!(
|
175
|
+
normalize_extra_conditions(ActiveSupport::JSON.decode(params[:extra_conditions]))
|
176
|
+
) if params[:extra_conditions]
|
177
|
+
|
178
|
+
search = data_class.search(search_params)
|
125
179
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
180
|
+
# applying scopes
|
181
|
+
scopes.each do |s|
|
182
|
+
if s.is_a?(Array)
|
183
|
+
scope_name, *args = s
|
184
|
+
search.send(scope_name, *args)
|
185
|
+
else
|
186
|
+
search.send(s, true)
|
187
|
+
end
|
188
|
+
end
|
132
189
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
protected
|
190
|
+
search
|
191
|
+
end
|
192
|
+
end
|
137
193
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
194
|
+
# Params:
|
195
|
+
# <tt>:operation</tt>: :update or :create
|
196
|
+
def process_data(data, operation)
|
197
|
+
success = true
|
198
|
+
# mod_record_ids = []
|
199
|
+
mod_records = {}
|
200
|
+
if !ext_config[:"prohibit_#{operation}"]
|
201
|
+
modified_records = 0
|
202
|
+
data.each do |record_hash|
|
203
|
+
id = record_hash.delete('id')
|
204
|
+
record = operation == :create ? data_class.new : data_class.find(id)
|
205
|
+
success = true
|
149
206
|
|
150
|
-
|
151
|
-
|
207
|
+
# merge with strong default attirbutes
|
208
|
+
record_hash.merge!(config[:strong_default_attrs]) if config[:strong_default_attrs]
|
152
209
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
210
|
+
# process all attirubutes for this record
|
211
|
+
record_hash.each_pair do |k,v|
|
212
|
+
begin
|
213
|
+
record.send("#{k}=",v)
|
214
|
+
rescue ArgumentError => exc
|
215
|
+
flash :error => exc.message
|
216
|
+
success = false
|
217
|
+
break
|
218
|
+
end
|
161
219
|
end
|
162
|
-
end
|
163
220
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
221
|
+
# try to save
|
222
|
+
# modified_records += 1 if success && record.save
|
223
|
+
mod_records[id] = record.to_array(columns, self) if success && record.save
|
224
|
+
# mod_record_ids << id if success && record.save
|
168
225
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
226
|
+
# flash eventual errors
|
227
|
+
if !record.errors.empty?
|
228
|
+
success = false
|
229
|
+
record.errors.each_full do |msg|
|
230
|
+
flash :error => msg
|
231
|
+
end
|
174
232
|
end
|
175
233
|
end
|
234
|
+
# flash :notice => "#{operation.to_s.capitalize}d #{modified_records} record(s)"
|
235
|
+
else
|
236
|
+
success = false
|
237
|
+
flash :error => "You don't have permissions to #{operation} data"
|
176
238
|
end
|
177
|
-
|
178
|
-
else
|
179
|
-
success = false
|
180
|
-
flash :error => "You don't have permissions to #{operation} data"
|
239
|
+
mod_records
|
181
240
|
end
|
182
|
-
mod_records
|
183
|
-
end
|
184
241
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
242
|
+
# get records
|
243
|
+
def get_records(params)
|
244
|
+
# Restore params from widget_session if requested
|
245
|
+
if params[:with_last_params]
|
246
|
+
params = widget_session[:last_params]
|
247
|
+
else
|
248
|
+
# remember the last params
|
249
|
+
widget_session[:last_params] = params
|
250
|
+
end
|
194
251
|
|
195
|
-
|
252
|
+
search = get_search(params)
|
196
253
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
254
|
+
# sorting
|
255
|
+
if params[:sort]
|
256
|
+
assoc, method = params[:sort].split('__')
|
257
|
+
sort_string = method.nil? ? assoc : "#{assoc}_#{method}"
|
258
|
+
sort_string = (params[:dir] == "ASC" ? "ascend_by_" : "descend_by_") + sort_string
|
259
|
+
search.order(sort_string)
|
260
|
+
end
|
204
261
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
262
|
+
# pagination
|
263
|
+
if ext_config[:enable_pagination]
|
264
|
+
per_page = ext_config[:rows_per_page]
|
265
|
+
page = params[:limit] ? params[:start].to_i/params[:limit].to_i + 1 : 1
|
266
|
+
search.paginate(:per_page => per_page, :page => page)
|
267
|
+
else
|
268
|
+
search.all
|
269
|
+
end
|
212
270
|
end
|
213
|
-
end
|
214
271
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
272
|
+
# When providing the edit_form aggregatee, fill in the form with the requested record
|
273
|
+
def load_aggregatee_with_cache(params)
|
274
|
+
if params[:id] == 'editForm'
|
275
|
+
aggregatees[:edit_form][:item].merge!(:record_id => params[:record_id])
|
276
|
+
end
|
219
277
|
|
220
|
-
|
221
|
-
# successful creation
|
222
|
-
res[:set_form_values] = nil
|
223
|
-
res[:on_successfull_record_creation] = true
|
278
|
+
super
|
224
279
|
end
|
225
|
-
res
|
226
|
-
end
|
227
280
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
ids = JSON.parse(params[:ids]).reverse
|
232
|
-
ids.each_with_index do |id, i|
|
233
|
-
r = data_class.find(id)
|
234
|
-
r.insert_at(params[:new_index].to_i + i + 1)
|
235
|
-
end
|
236
|
-
else
|
237
|
-
raise RuntimeError, "Data class should 'acts_as_list' to support moving rows"
|
281
|
+
# Search scopes, in searchlogic format
|
282
|
+
def scopes
|
283
|
+
@scopes ||= config[:scopes] || []
|
238
284
|
end
|
239
|
-
{}
|
240
|
-
end
|
241
285
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
286
|
+
# Converts Ext.ux.grid.GridFilters filters to searchlogic conditions, e.g.
|
287
|
+
# {"0" => {
|
288
|
+
# "data" => {
|
289
|
+
# "type" => "numeric",
|
290
|
+
# "comparison" => "gt",
|
291
|
+
# "value" => 10 },
|
292
|
+
# "field" => "id"
|
293
|
+
# },
|
294
|
+
# "1" => {
|
295
|
+
# "data" => {
|
296
|
+
# "type" => "string",
|
297
|
+
# "value" => "pizza"
|
298
|
+
# },
|
299
|
+
# "field" => "food_name"
|
300
|
+
# }}
|
301
|
+
#
|
302
|
+
# =>
|
303
|
+
#
|
304
|
+
# {"id_gt" => 100, "food_name_contains" => "pizza"}
|
305
|
+
def convert_filters(column_filter)
|
306
|
+
res = {}
|
307
|
+
column_filter.each_pair do |k,v|
|
308
|
+
field = v["field"].dup
|
255
309
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
# "data" => {
|
266
|
-
# "type" => "string",
|
267
|
-
# "value" => "pizza"
|
268
|
-
# },
|
269
|
-
# "field" => "food_name"
|
270
|
-
# }}
|
271
|
-
#
|
272
|
-
# =>
|
273
|
-
#
|
274
|
-
# {"id_gt" => 100, "food_name_contains" => "pizza"}
|
275
|
-
def convert_filters(column_filter)
|
276
|
-
res = {}
|
277
|
-
column_filter.each_pair do |k,v|
|
278
|
-
field = v["field"].dup
|
279
|
-
case v["data"]["type"]
|
280
|
-
when "string"
|
281
|
-
field << "_contains"
|
282
|
-
when "numeric"
|
283
|
-
field << "_#{v["data"]["comparison"]}"
|
310
|
+
case v["data"]["type"]
|
311
|
+
when "string"
|
312
|
+
field << "_contains"
|
313
|
+
when "numeric", "date"
|
314
|
+
field << "_#{v["data"]["comparison"]}"
|
315
|
+
end
|
316
|
+
|
317
|
+
value = v["data"]["value"]
|
318
|
+
res.merge!({field => value})
|
284
319
|
end
|
285
|
-
|
286
|
-
res.merge!({field => value})
|
320
|
+
res
|
287
321
|
end
|
288
|
-
res
|
289
|
-
end
|
290
322
|
|
291
|
-
|
292
|
-
|
293
|
-
|
323
|
+
def normalize_extra_conditions(conditions)
|
324
|
+
conditions.deep_convert_keys{|k| k.to_s.gsub("__", "_").to_sym}
|
325
|
+
end
|
294
326
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
327
|
+
# make params understandable to searchlogic
|
328
|
+
def normalize_params(params)
|
329
|
+
# filters
|
330
|
+
conditions = params[:filter] && convert_filters(params[:filter])
|
331
|
+
|
332
|
+
normalized_conditions = {}
|
333
|
+
conditions && conditions.each_pair do |k, v|
|
334
|
+
normalized_conditions.merge!(k.gsub("__", "_") => v)
|
335
|
+
end
|
299
336
|
|
300
|
-
|
301
|
-
conditions && conditions.each_pair do |k, v|
|
302
|
-
assoc, method = k.split('__')
|
303
|
-
normalized_conditions.merge!(method.nil? ? {assoc => v} : {assoc => {method => v}})
|
337
|
+
{:conditions => normalized_conditions}
|
304
338
|
end
|
305
|
-
|
306
|
-
{:conditions => normalized_conditions}
|
307
|
-
end
|
308
339
|
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
end
|
320
|
-
|
321
|
-
end
|
340
|
+
# def check_for_positive_result(res)
|
341
|
+
# if res[:set_form_values]
|
342
|
+
# # successful creation
|
343
|
+
# res[:set_form_values] = nil
|
344
|
+
# res.merge!({
|
345
|
+
# :parent => {:on_successfull_edit => true}
|
346
|
+
# })
|
347
|
+
# true
|
348
|
+
# else
|
349
|
+
# false
|
350
|
+
# end
|
351
|
+
# end
|
322
352
|
|
323
|
-
def check_for_positive_result(res)
|
324
|
-
if res[:set_form_values]
|
325
|
-
# successful creation
|
326
|
-
res[:set_form_values] = nil
|
327
|
-
res.merge!({
|
328
|
-
:parent => {:on_successfull_edit => true}
|
329
|
-
})
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
def edit_form__netzke_submit(params)
|
334
|
-
res = aggregatee_instance(:edit_form).netzke_submit(params)
|
335
|
-
|
336
|
-
check_for_positive_result(res)
|
337
|
-
|
338
|
-
res.to_nifty_json
|
339
|
-
end
|
340
|
-
|
341
|
-
def multi_edit_form__netzke_submit(params)
|
342
|
-
ids = ActiveSupport::JSON.decode(params.delete(:ids))
|
343
|
-
|
344
|
-
res = {}
|
345
|
-
ids.each do |id|
|
346
|
-
form_instance = aggregatee_instance(:edit_form, :record => data_class.find(id))
|
347
|
-
res = form_instance.netzke_submit(params)
|
348
|
-
break if !res[:set_form_values]
|
349
|
-
end
|
350
|
-
|
351
|
-
check_for_positive_result(res)
|
352
|
-
|
353
|
-
res.to_nifty_json
|
354
|
-
end
|
355
|
-
|
356
353
|
end
|
357
354
|
end
|
358
355
|
end
|