Automember UI - default groups

In this patch was implemented and added a control for defining default automember groups.

There is a difference from UXD spec. In the spec the control was placed below table in the search facet. This was not working well with the combobox in the control. Open combobox requires some space below it. As it was placed at the bottom of the page it created unwanted blank space and forced showing scrollbars. Moving the control above the table solves the problem without rewriting combobox logic. It can be rewritten and moved down later.

https://fedorahosted.org/freeipa/ticket/2195
This commit is contained in:
Petr Voborník 2012-02-02 17:55:36 +01:00 committed by Endi S. Dewata
parent e6cdcad8df
commit fccea2dca4
9 changed files with 315 additions and 2 deletions

View File

@ -106,6 +106,21 @@ IPA.automember.rule_search_facet = function(spec) {
that.group_type = spec.group_type;
var init = function() {
that.default_group_widget = IPA.automember.default_group_widget({
entity: that.entity,
group_type: that.group_type
});
};
that.refresh = function() {
that.search_facet_refresh();
that.default_group_widget.refresh();
};
that.get_records_command_name = function() {
return that.managed_entity.name + that.group_type+'_get_records';
};
@ -139,6 +154,23 @@ IPA.automember.rule_search_facet = function(spec) {
return command;
};
that.create_content = function(container) {
var header = $('<div/>', {
'class': 'automember-header'
}).appendTo(container);
var content = $('<div/>', {
'class': 'automember-content'
}).appendTo(container);
that.default_group_widget.create(header);
that.table.create(content);
};
init();
return that;
};
@ -458,4 +490,158 @@ IPA.automember.condition_widget = function(spec) {
IPA.widget_factories['automember_condition'] = IPA.automember.condition_widget;
IPA.automember.default_group_widget = function(spec) {
spec = spec || {};
var that = IPA.widget(spec);
that.group_type = spec.group_type;
that.group = '';
var init = function() {
that.group_select = IPA.entity_select_widget({
name: 'automemberdefaultgroup',
other_entity: that.group_type,
other_field: 'cn',
show_undo: false
});
that.group_select.value_changed.attach(that.group_changed);
};
that.get_group = function() {
var group = that.group_select.save();
group = group.length === 0 ? '' : group[0];
return group;
};
that.set_group = function(group) {
if (group === that.group) return;
that.group = group;
that.group_select.update([group]);
};
that.group_changed = function() {
var group = that.get_group();
if (group === that.group) return;
if (group === '') {
that.remove_default_group();
} else {
that.set_default_group(group);
}
};
that.load = function(data) {
var group = data.result.result.automemberdefaultgroup;
if (group) group = group[0];
if (!group || group.indexOf('cn=') === -1) {
group = '';
} else {
//extract from dn
var i1 = group.indexOf('=');
var i2 = group.indexOf(',');
if (i1 > -1 && i2 > -1) {
group = group.substring(i1 + 1,i2);
}
}
that.update(group);
};
that.update = function(group) {
group = group || '';
that.set_group(group);
};
that.create_command = function(method) {
method = 'default_group_' + method;
var command_name = that.entity.name + that.group_type + '_' + method;
var command = IPA.command({
name: command_name,
entity: that.entity.name,
method: method,
options: {
type: that.group_type
}
});
return command;
};
that.refresh = function() {
var command = that.create_command('show');
command.on_success = that.load;
command.execute();
};
that.remove_default_group = function() {
var command = that.create_command('remove');
command.on_success = function() {
that.update('');
};
command.on_error = that.refresh;
command.execute();
};
that.set_default_group = function(group) {
var command = that.create_command('set');
command.on_success = that.load;
command.on_error = that.refresh;
command.set_option('automemberdefaultgroup', group);
command.execute();
};
that.create = function(container) {
var title = that.get_title();
var default_group = $('<div />', {
'class': 'default_group'
}).appendTo(container);
that.header = $('<h2/>', {
name: 'header',
text: title,
title: title
}).appendTo(default_group);
that.group_select.create(default_group);
};
that.get_title = function() {
if (that.group_type === 'group') {
return 'Default user group'; //TODO: translate
} else {
return 'Default host group'; //TODO: translate
}
};
init();
return that;
};
IPA.register('automember', IPA.automember.entity);

View File

@ -1485,4 +1485,38 @@ div.entity[name=hbactest] div.facet[name=run_test] .hbac-test-content {
.dnstype-table td {
font-weight: normal;
}
/* --- Automember --- */
.automember-header {
position: absolute;
top: 0;
left: 3px;
right: 3px;
height: 52px;
}
.automember-content {
position: absolute;
top: 52px;
left: 0;
right: 0;
bottom: 0px;
}
.automember-header .default_group {
border-bottom: 1px solid #DFDFDF;
border-top: 1px solid #DFDFDF;
padding-bottom: 5px;
padding-top: 8px;
}
.automember-header .default_group h2 {
display: inline-block;
margin: 0 15px 0 20px;
}
.automember-header .default_group label {
margin-right: 20px;
}

View File

@ -0,0 +1,14 @@
{
"error": null,
"id": null,
"result": {
"result": {
"automemberdefaultgroup": "No default group set",
"cn": [
"Group"
]
},
"summary": "Removed default group for automember \"group\"",
"value": "group"
}
}

View File

@ -0,0 +1,16 @@
{
"error": null,
"id": null,
"result": {
"result": {
"automemberdefaultgroup": [
"cn=foogroup,cn=groups,cn=accounts,dc=dev,dc=example,dc=com"
],
"cn": [
"Group"
]
},
"summary": "Set default group for automember \"group\"",
"value": "group"
}
}

View File

@ -0,0 +1,17 @@
{
"error": null,
"id": null,
"result": {
"result": {
"automemberdefaultgroup": [
"cn=foogroup,cn=groups,cn=accounts,dc=dev,dc=example,dc=com"
],
"cn": [
"Group"
],
"dn": "cn=group,cn=automember,cn=etc,dc=dev,dc=example,dc=com"
},
"summary": null,
"value": "group"
}
}

View File

@ -0,0 +1,14 @@
{
"error": null,
"id": null,
"result": {
"result": {
"automemberdefaultgroup": "No default group set",
"cn": [
"Hostgroup"
]
},
"summary": "Removed default group for automember \"hostgroup\"",
"value": "hostgroup"
}
}

View File

@ -0,0 +1,16 @@
{
"error": null,
"id": null,
"result": {
"result": {
"automemberdefaultgroup": [
"cn=foohostgroup,cn=hostgroups,cn=accounts,dc=dev,dc=example,dc=com"
],
"cn": [
"Hostgroup"
]
},
"summary": "Set default group for automember \"hostgroup\"",
"value": "hostgroup"
}
}

View File

@ -0,0 +1,15 @@
{
"error": null,
"id": null,
"result": {
"result": {
"automemberdefaultgroup": "No default group set",
"cn": [
"Hostgroup"
],
"dn": "cn=hostgroup,cn=automember,cn=etc,dc=dev,dc=example,dc=com"
},
"summary": null,
"value": "hostgroup"
}
}

View File

@ -2064,7 +2064,7 @@ IPA.combobox_widget = function(spec) {
type: 'text',
name: that.name,
title: that.tooltip,
readonly: !that.editable,
readonly: !that.editable || that.read_only,
keyup: function() {
that.input_field_changed.notify([], that);
},
@ -2147,7 +2147,8 @@ IPA.combobox_widget = function(spec) {
};
that.open = function() {
that.list_container.css('visibility', 'visible');
if (!that.read_only)
that.list_container.css('visibility', 'visible');
};
that.close = function() {