summaryrefslogtreecommitdiff
path: root/public_html/js
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-10-16 13:11:09 (GMT)
committerAleksander Machniak <alec@alec.pl>2013-10-16 13:11:09 (GMT)
commit3444203fdd2c7f207673f58ff5aa3aa940882e41 (patch)
tree34a79da7d628dbbd17bcd84eca2b00c55207d3d8 /public_html/js
parentf603dc2610d53db8d3eca839e47347d5a27a8035 (diff)
downloadkolab-wap-3444203fdd2c7f207673f58ff5aa3aa940882e41.tar.gz
Implement 'default' value support for form_fields of type text, text-quota and select (Request #2358)kolab-webadmin-3.1.1
Conflicts: lib/client/kolab_client_task_settings.php public_html/js/kolab_admin.js
Diffstat (limited to 'public_html/js')
-rw-r--r--public_html/js/kolab_admin.js27
1 files changed, 20 insertions, 7 deletions
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 2433c10..9a1e776 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -1811,6 +1811,9 @@ function kolab_admin()
if (attr.maxcount)
data.maxcount = attr.maxcount;
+ if (attr['default'] && attr.valtype == 'normal' && attr.type.match(/^(text|select)/))
+ data['default'] = attr['default'];
+
if (attr.valtype == 'normal' || attr.valtype == 'auto')
request.attributes.form_fields[i] = data;
if (attr.valtype == 'auto' || attr.valtype == 'auto-readonly') {
@@ -1959,6 +1962,10 @@ function kolab_admin()
value = this.t('attribute.value.' + (data.valtype == 'static' ? 'static' : 'auto')) + ': ' + data.data;
}
+ if (form_data.attr_default && data.valtype == 'normal' && data.type.match(/^(text|select)/)) {
+ data['default'] = form_data.attr_default;
+ }
+
// Update table row
$('td.name', row).text(this.env.attributes[attr]);
$('td.type', row).text(data.type);
@@ -1986,9 +1993,10 @@ function kolab_admin()
$('select[name="attr_type"]').val(type);
$('select[name="attr_value"]').val(attr ? data.valtype : 'normal');
+ $('input[name="attr_default"]').val(data['default'] || '');
$('input[name="attr_optional"]').attr('checked', attr ? data.optional : false);
- $('input[name="attr_data"]').val(attr ? data.data : '');
- $('input[name="attr_maxcount"]').val(data.maxcount ? data.maxcount : '');
+ $('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") : '');
$('span', name_select.parent()).remove();
@@ -2003,8 +2011,8 @@ function kolab_admin()
}
this.form_element_update({name: 'attr_options'});
- this.type_attr_type_change('select[name="attr_type"]');
- this.type_attr_value_change('select[name="attr_value"]');
+ this.type_attr_type_change();
+ this.type_attr_value_change();
};
// Initialize attribute name selector
@@ -2023,13 +2031,14 @@ function kolab_admin()
// Update attribute form on attribute name change
this.type_attr_name_change = function(elem)
{
- this.type_attr_value_change('select[name="attr_value"]');
+ this.type_attr_value_change();
};
// Update attribute form on value type change
this.type_attr_value_change = function(elem)
{
- var type = $(elem).val(),
+ var type = $(elem || 'select[name="attr_value"]').val(),
+ field_type = $('select[name="attr_type"]').val(),
optional = $('#attr_form_row_optional'),
select = $('select[name="attr_name"]').val(),
attr_name = this.env.attributes[select],
@@ -2038,6 +2047,7 @@ function kolab_admin()
$('input[name="attr_data"]')[type != 'normal' ? 'show' : 'hide']();
$('#attr_form_row_readonly')[type != 'static' ? 'show' : 'hide']();
+ $('#attr_form_row_default')[type == 'normal' && field_type.match(/^(text|select)/) ? 'show' : 'hide']();
optional[opt ? 'show' : 'hide']();
if (!opt)
@@ -2047,9 +2057,12 @@ function kolab_admin()
// Update attribute form on type change
this.type_attr_type_change = function(elem)
{
- var type = $(elem).val();
+ var type = $(elem || 'select[name="attr_type"]').val(),
+ val_type = $('select[name="attr_value"]').val();
+
$('#attr_form_row_maxcount')[type == 'list' || type == 'list-autocomplete' ? 'show' : 'hide']();
$('#attr_form_row_options')[type == 'select' || type == 'multiselect' ? 'show' : 'hide']();
+ $('#attr_form_row_default')[val_type == 'normal' && type.match(/^(text|select)/) ? 'show' : 'hide']();
};
// Update attributes list on object classes change