summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-04-15 10:24:36 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-04-15 10:25:48 (GMT)
commit76162e3c08f78b0db9a5730d45d039b099741c6a (patch)
treef9b836e1269263b57889141d03285ce3503df656
parent3899e02d0c124fb0058e3d355793c442821feb9c (diff)
downloadkolab-wap-76162e3c08f78b0db9a5730d45d039b099741c6a.tar.gz
Fix checkboxes handling - fixes e.g. Hosted and Optional checkboxes in object type form
-rw-r--r--public_html/js/kolab_admin.js23
1 files changed, 11 insertions, 12 deletions
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 659645c..b3ef717 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -769,8 +769,8 @@ function kolab_admin()
delete data.json[this.name + '-unit'];
});
- // checkbox inputs
- $('input[type="checkbox"]', form).each(function() {
+ // "boolean" checkbox inputs
+ $('input[type="checkbox"][value="TRUE"]', form).each(function() {
data.json[this.name] = this.checked ? 'TRUE' : 'FALSE';
});
@@ -1272,18 +1272,17 @@ function kolab_admin()
this.serialize_form = function(id)
{
- var i, v, json = {},
- form = $(id),
- query = form.serializeArray(),
- extra = this.env.extra_fields || [];
+ var json = {}, form = $(id), query = form.serializeArray();
- for (i in query)
- json[query[i].name] = query[i].value;
+ // convert to name-value object
+ $.each(query, function() { json[this.name] = this.value; });
// read extra (disabled) fields
- for (i=0; i<extra.length; i++)
- if (v = $('[name="'+extra[i]+'"]', form).val())
- json[extra[i]] = v;
+ $.each(this.env.extra_fields || [], function() {
+ var value = $('[name="' + this + '"]', form).val();
+ if (value)
+ json[this] = value;
+ });
// serializeArray() doesn't work properly for multi-select
$('select[multiple="multiple"]', form).each(function() {
@@ -2011,7 +2010,7 @@ function kolab_admin()
$('select[name="attr_value"]').val(attr ? data.valtype : 'normal');
$('select[name="attr_validate"]').val(attr ? data.validate : '');
$('input[name="attr_default"]').val(data['default'] || '');
- $('input[name="attr_optional"]').attr('checked', attr ? data.optional : false);
+ $('input[name="attr_optional"]').prop('checked', attr ? data.optional : false);
$('input[name="attr_data"]').val(data.data || '');
$('input[name="attr_maxcount"]').val(data.maxcount || '');
$('textarea[name="attr_options"]').val(data.values ? data.values.join("\n") : '');