summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/kolab_client_task.php14
-rw-r--r--public_html/js/kolab_admin.js15
2 files changed, 21 insertions, 8 deletions
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index 370ad64..f1c5fb3 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -900,6 +900,7 @@ class kolab_client_task
case 'imap_acl':
$result['type'] = kolab_form::INPUT_TEXTAREA;
$result['data-type'] = 'acl';
+ $result['default'] = $field['default'];
$this->output->add_translation('aci.new', 'aci.edit', 'aci.remove',
'button.ok', 'button.cancel',
@@ -1265,9 +1266,11 @@ class kolab_client_task
}
$form = new kolab_form($attribs);
- $assoc_fields = array();
- $req_fields = array();
- $writeable = 0;
+
+ $default_values = array();
+ $assoc_fields = array();
+ $req_fields = array();
+ $writeable = 0;
$auto_fields = $this->output->get_env('auto_fields');
@@ -1312,7 +1315,9 @@ class kolab_client_task
$field['value'] = $value;
}
else if ($add_mode && !isset($field['value']) && isset($field['default'])) {
- $field['value'] = $field['default'];
+ $field['value'] = $field['default'];
+ $default_values[$idx] = $field['default'];
+
unset($field['default']);
}
@@ -1392,6 +1397,7 @@ class kolab_client_task
$ac_min_len = $this->config_get('autocomplete_min_length', 1, Conf::INT);
$this->output->set_env('form_id', $attribs['id']);
+ $this->output->set_env('default_values', $default_values);
$this->output->set_env('assoc_fields', $assoc_fields);
$this->output->set_env('required_fields', $req_fields);
$this->output->set_env('autocomplete_min_length', $ac_min_len);
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 7178c97..d7167c4 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -30,6 +30,7 @@ function kolab_admin()
this.request_timeout = 300;
this.message_time = 3000;
this.events = {};
+ this.attr_default_rx = /^(text|select|imap_acl)/;
// set jQuery ajax options
$.ajaxSetup({
@@ -2633,7 +2634,7 @@ function kolab_admin()
if (attr.validate != 'default')
data.validate = attr.validate;
- if (attr['default'] && attr.valtype == 'normal' && attr.type.match(/^(text|select)/))
+ if (attr['default'] && attr.valtype == 'normal' && attr.type.match(this.attr_default_rx))
data['default'] = attr['default'];
if (attr.valtype == 'normal' || attr.valtype == 'auto')
@@ -2728,6 +2729,12 @@ function kolab_admin()
action = data.id ? 'edit' : 'add';
if (reload) {
+ // remove unchanged defaults
+ $.each(this.env.default_values || [], function(i, v) {
+ if (v == data[i])
+ delete data[i];
+ });
+
data.section = section;
this.http_post(type + '.' + action, {data: data});
return false;
@@ -2826,7 +2833,7 @@ function kolab_admin()
row.attr('title', this.t('attribute.value.' + (data.valtype == 'static' ? 'static' : 'auto')) + ': ' + data.data);
}
- if (form_data.attr_default && data.valtype == 'normal' && data.type.match(/^(text|select)/)) {
+ if (form_data.attr_default && data.valtype == 'normal' && data.type.match(this.attr_default_rx)) {
data['default'] = form_data.attr_default;
}
@@ -2912,7 +2919,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']();
+ $('#attr_form_row_default')[type == 'normal' && field_type.match(this.attr_default_rx) ? 'show' : 'hide']();
optional[opt ? 'show' : 'hide']();
if (!opt)
@@ -2927,7 +2934,7 @@ function kolab_admin()
$('#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']();
+ $('#attr_form_row_default')[val_type == 'normal' && type.match(this.attr_default_rx) ? 'show' : 'hide']();
};
// Update attributes list on object classes change