summaryrefslogtreecommitdiffstats
path: root/public_html
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-09-20 14:01:42 +0200
committerAleksander Machniak <alec@alec.pl>2013-09-20 14:02:37 +0200
commit69ef0de8ffd1460ebba165fc7210034b3235a791 (patch)
tree2faaa4328083161a59271b9e3470ed8c71247921 /public_html
parent6d132a638c03de4e571dace6aaeebaaea8d1c315 (diff)
downloadwebadmin-69ef0de8ffd1460ebba165fc7210034b3235a791.tar.gz
Add possibility to set 'validate' flag for form_fields in object type definition
Diffstat (limited to 'public_html')
-rw-r--r--public_html/js/kolab_admin.js12
-rw-r--r--public_html/skins/default/ui.js9
2 files changed, 17 insertions, 4 deletions
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 2433c10..983ae8c 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -1810,6 +1810,8 @@ function kolab_admin()
data.optional = true;
if (attr.maxcount)
data.maxcount = attr.maxcount;
+ if (attr.validate != 'default')
+ data.validate = attr.validate;
if (attr.valtype == 'normal' || attr.valtype == 'auto')
request.attributes.form_fields[i] = data;
@@ -1928,7 +1930,7 @@ function kolab_admin()
// Saves attribute form, create/update attribute row
this.type_attr_save = function()
{
- var attr, row, value = '', data = {},
+ var attr, row, data = {},
form_data = this.serialize_form('#'+this.env.form_id),
name_select = $('select[name="attr_name"]');
@@ -1936,6 +1938,7 @@ function kolab_admin()
data.type = form_data.attr_type;
data.valtype = form_data.attr_value;
data.optional = form_data.attr_optional;
+ data.validate = form_data.attr_validate;
data.data = data.valtype != 'normal' ? form_data.attr_data : null;
data.maxcount = data.type == 'list' || data.type == 'list-autocomplete' ? form_data.attr_maxcount : 0;
data.values = data.type == 'select' || data.type == 'multiselect' ? form_data.attr_options : [];
@@ -1944,7 +1947,7 @@ function kolab_admin()
// new attribute
attr = name_select.val();
row = $('<tr><td class="name"></td><td class="type"></td><td class="readonly"></td>'
- +'<td class="optional"></td><td class="value"></td><td class="actions">'
+ +'<td class="optional"></td><td class="validate"></td><td class="actions">'
+'<a class="button delete" title="delete" onclick="kadm.type_attr_delete(\''+attr+'\')" href="#delete"></a>'
+'<a class="button edit" title="edit" onclick="kadm.type_attr_edit(\''+attr+'\')" href="#edit"></a></td></tr>')
.attr('id', 'attr_table_row_' + attr).appendTo('#type_attr_table > tbody');
@@ -1956,7 +1959,7 @@ function kolab_admin()
}
if (data.valtype != 'normal') {
- value = this.t('attribute.value.' + (data.valtype == 'static' ? 'static' : 'auto')) + ': ' + data.data;
+ row.attr('title', this.t('attribute.value.' + (data.valtype == 'static' ? 'static' : 'auto')) + ': ' + data.data);
}
// Update table row
@@ -1964,7 +1967,7 @@ function kolab_admin()
$('td.type', row).text(data.type);
$('td.readonly', row).text(data.valtype == 'auto-readonly' ? this.env.yes_label : this.env.no_label);
$('td.optional', row).text(data.optional ? this.env.yes_label : this.env.no_label);
- $('td.value', row).text(value);
+ $('td.validate', row).text(this.t('attribute.validate.' + data.validate));
// Update env data
this.env.attr_table[attr] = data;
@@ -1986,6 +1989,7 @@ function kolab_admin()
$('select[name="attr_type"]').val(type);
$('select[name="attr_value"]').val(attr ? data.valtype : 'normal');
+ $('select[name="attr_validate"]').val(attr ? data.validate : '');
$('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 : '');
diff --git a/public_html/skins/default/ui.js b/public_html/skins/default/ui.js
index ac56bc7..11b513d 100644
--- a/public_html/skins/default/ui.js
+++ b/public_html/skins/default/ui.js
@@ -145,6 +145,15 @@ function form_load(id)
{
if (id != 'search-form')
init_tabs(id);
+
+ if (id == 'type-form') {
+ // add double-click event on attributes list
+ $('#type_attr_table tbody').on('dblclick', 'tr:not("#type_attr_form")', function() {
+ var button = $('a.button.edit', this);
+ if (button.length)
+ button.click();
+ });
+ }
};
// UI resize handler