have a working form serialization

pull/6827/head
Philipp Tessenow 14 years ago
parent c36787068b
commit fc7387a539
  1. 19
      assets/javascripts/reporting/controls.js
  2. 1
      assets/javascripts/reporting/group_bys.js
  3. 2
      lib/widget/group_bys.rb

@ -80,14 +80,17 @@ Reporting.Controls = {
},
serialize_settings_form: function() {
var ret_str = Form.serialize('query_form');
var rows = Sortable.serialize('group_by_rows');
var columns = Sortable.serialize('group_by_columns');
if (rows !== null && rows != "") {
ret_str += "&" + rows;
}
if(columns !== null && columns != "") {
ret_str += "&" + columns;
var ret_str, grouping_str;
ret_str = Form.serialize('query_form');
grouping_str = $w('rows columns').inject('', function(grouping, type) {
return grouping + $('group_by_' + type).select('.group_by_element').map(function(group_by) {
return 'groups[' + type + '][]=' + group_by.readAttribute('data-group-by');
}).inject('', function(all_group_str, group_str) {
return all_group_str + '&' + group_str;
});
});
if (grouping_str.length > 0) {
ret_str += grouping_str;
}
return ret_str;
},

@ -10,7 +10,6 @@ Reporting.GroupBys = {
constraint:'horizontal',
containment: ['group_by_columns','group_by_rows'],
dropOnEmpty: true,
format: /^(.*)$/,
hoverclass: 'drag_container_accept',
onUpdate: Reporting.GroupBys.ordering_changed
};

@ -5,7 +5,7 @@ class Widget::GroupBys < Widget::Base
content_tag :div, :id => "group_by_#{type}", :class => 'drag_target drag_container' do
out = ''
#TODO render existing group_bys of type <type>
out += content_tag :select, :id => "add_group_by_#{type}", :name => "groups[#{type}][]", :class => 'select-small' do
out += content_tag :select, :id => "add_group_by_#{type}", :class => 'select-small' do
options = tag :option, :value => ''
engine::GroupBy.all.each do |group_by_class|
options += content_tag :option, :value => group_by_class.underscore_name, :'data-label' => "#{l(group_by_class.label)}" do

Loading…
Cancel
Save