diff options
author | Petr VobornÃk <pvoborni@redhat.com> | 2012-02-02 17:55:36 +0100 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2012-02-07 00:48:07 -0600 |
commit | fccea2dca4d384ab2992103916cfe8801be53edd (patch) | |
tree | 22ba0f8f4bde3d55ee9ad23d251a0991fec787eb /install/ui/automember.js | |
parent | e6cdcad8df8712a5f452a74a3f3186146ef1e04b (diff) | |
download | freeipa.git-fccea2dca4d384ab2992103916cfe8801be53edd.tar.gz freeipa.git-fccea2dca4d384ab2992103916cfe8801be53edd.tar.xz freeipa.git-fccea2dca4d384ab2992103916cfe8801be53edd.zip |
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
Diffstat (limited to 'install/ui/automember.js')
-rw-r--r-- | install/ui/automember.js | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/install/ui/automember.js b/install/ui/automember.js index d6c3c7ee..e9b48dc8 100644 --- a/install/ui/automember.js +++ b/install/ui/automember.js @@ -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);
\ No newline at end of file |