summaryrefslogtreecommitdiff
path: root/public_html
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-10-05 07:29:07 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-11-26 13:29:46 (GMT)
commit7454f900765c913a14a2127c1d446545a4639b64 (patch)
tree725f896a4381c9f1304d485af862f7d113624669 /public_html
parente8c98e43e017f43baf4471b50a3d04a0baaf4469 (diff)
downloadkolab-wap-7454f900765c913a14a2127c1d446545a4639b64.tar.gz
Add required attributes check in object types management
Diffstat (limited to 'public_html')
-rw-r--r--public_html/js/kolab_admin.js31
1 files changed, 25 insertions, 6 deletions
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index fd4d3fd..b6c9a72 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -1549,9 +1549,10 @@ function kolab_admin()
this.type_save = function(reload, section)
{
- var i, attr, request = {},
+ var i, n, attr, request = {},
data = this.serialize_form('#'+this.env.form_id),
- action = data.id ? 'edit' : 'add';
+ action = data.id ? 'edit' : 'add',
+ required = this.env.attributes_required || [];
if (reload) {
data.section = section;
@@ -1571,6 +1572,9 @@ function kolab_admin()
return;
}
+ // remove objectClass from required attributes list
+ required = $.map(required, function(a) { return a == 'objectClass' ? null : a; });
+
request.id = data.id;
request.key = data.key;
request.name = data.name;
@@ -1583,6 +1587,14 @@ function kolab_admin()
// Build attributes array compatible with the API format
// @TODO: use attr_table format
for (i in this.env.attr_table) {
+ // attribute doesn't exist in specified object classes set
+ if (!(n = this.env.attributes[i]))
+ continue;
+
+ // check required attributes
+ if (required.length)
+ required = $.map(required, function(a) { return a != n ? a : null; });
+
attr = this.env.attr_table[i];
data = {};
@@ -1615,6 +1627,11 @@ function kolab_admin()
}
}
+ if (required.length) {
+ this.display_message(this.t('attribute.required.error').replace(/\$1/, required.join(',')), 'error');
+ return;
+ }
+
this.set_busy(true, 'saving');
this.api_post('type.' + action, request, 'type_' + action + '_response');
};
@@ -1836,16 +1853,18 @@ function kolab_admin()
if (!this.api_response(response))
return;
- var i, lc, list = response.result.attribute.list,
- required = response.result.attribute.required,
+ var i, lc, list = response.result.attribute.list || [],
select = $('select[name="attr_name"]');
this.env.attributes = {};
+ this.env.attributes_required = response.result.attribute.required || [];
select.empty();
for (i in list) {
- lc = list[i].toLowerCase()
- this.env.attributes[list[i].toLowerCase()] = list[i];
+ if (i == 'objectClass')
+ continue;
+ lc = list[i].toLowerCase();
+ this.env.attributes[lc] = list[i];
$('<option>').text(list[i]).val(lc).appendTo(select);
}
};