vidl-toolbox 0.0.10 → 0.0.11
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/lib/toolbox/default_controller.rb +24 -3
- data/lib/toolbox/helpers.rb +1 -1
- data/lib/toolbox/version.rb +1 -1
- metadata +1 -1
@@ -285,14 +285,30 @@ module Toolbox
|
|
285
285
|
edit_config(rec).controlsets.each do |controlset|
|
286
286
|
controlset.widget_list.widgets.each do |widget|
|
287
287
|
case widget.type
|
288
|
-
|
289
|
-
|
290
|
-
|
288
|
+
when :auto_complete
|
289
|
+
if controlset.collection_config
|
290
|
+
# remove autocomplete text field for new or existing entries
|
291
|
+
a = Toolbox::Helpers.collection_attribute_name(controlset.collection_config, rec)
|
292
|
+
coll = params[a]
|
293
|
+
if coll
|
294
|
+
coll.each { |p| remove_autocomplete_text p, widget} if coll.is_a? Array
|
295
|
+
coll.each_key { |p| remove_autocomplete_text p, widget} if coll.is_a? Hash
|
296
|
+
end
|
297
|
+
if rec # may also have new entries...
|
298
|
+
a = Toolbox::Helpers.collection_attribute_name(controlset.collection_config, nil)
|
299
|
+
coll = params[a]
|
300
|
+
coll.each { |p| remove_autocomplete_text p, widget} if coll
|
301
|
+
end
|
302
|
+
else
|
303
|
+
remove_autocomplete_text params, widget
|
304
|
+
end
|
291
305
|
when :date
|
292
306
|
#params[widget.name] = Date.strptime(params[widget.name], '%d.%m.%y')
|
293
307
|
end
|
294
308
|
end
|
295
309
|
end
|
310
|
+
puts 'After preprocessing:'
|
311
|
+
puts params.inspect
|
296
312
|
params
|
297
313
|
end
|
298
314
|
|
@@ -309,6 +325,11 @@ module Toolbox
|
|
309
325
|
|
310
326
|
private
|
311
327
|
|
328
|
+
def remove_autocomplete_text param, widget
|
329
|
+
value = param.delete widget.name
|
330
|
+
param[widget.name.to_s.foreign_key] = nil if value == '' || value == nil
|
331
|
+
end
|
332
|
+
|
312
333
|
def set_record obj
|
313
334
|
instance_variable_set "@#{model_name}".to_sym, obj
|
314
335
|
end
|
data/lib/toolbox/helpers.rb
CHANGED
@@ -3,7 +3,7 @@ module Toolbox
|
|
3
3
|
module Helpers
|
4
4
|
|
5
5
|
def self.collection_attribute_name collection_config, rec
|
6
|
-
new_or_existing = rec.new_record? ? '
|
6
|
+
new_or_existing = rec && !rec.new_record? ? 'existing' : 'new'
|
7
7
|
"#{new_or_existing}_#{collection_config.type.name.to_s.underscore}_attributes"
|
8
8
|
end
|
9
9
|
|
data/lib/toolbox/version.rb
CHANGED