From 308b7b3a4965d4cef55929099939f2446104eaec Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Tue, 11 Jan 2011 17:07:46 +0700 Subject: Added group association table for SUDO command. A section has been added to the SUDO command details page for managing the association with SUDO command groups. New test data has been added as well. --- install/static/sudocmd.js | 159 +++++++++++++++++++++ install/static/sudocmdgroup.js | 1 + install/static/test/data/sudocmd_memberof_add.json | 53 +++++++ .../static/test/data/sudocmd_memberof_remove.json | 50 +++++++ .../static/test/data/sudocmd_memberof_show.json | 61 ++++++++ install/static/test/data/sudocmd_show.json | 4 + 6 files changed, 328 insertions(+) create mode 100644 install/static/test/data/sudocmd_memberof_add.json create mode 100644 install/static/test/data/sudocmd_memberof_remove.json create mode 100644 install/static/test/data/sudocmd_memberof_show.json (limited to 'install') diff --git a/install/static/sudocmd.js b/install/static/sudocmd.js index 864063f6..307f0990 100755 --- a/install/static/sudocmd.js +++ b/install/static/sudocmd.js @@ -107,8 +107,167 @@ function ipa_sudocmd_details_facet(spec) { section.create_field({'name': 'sudocmd'}); section.create_field({'name': 'description'}); + section = ipa_details_section({ + 'name': 'groups', + 'label': 'Groups' + }); + that.add_section(section); + + var field = ipa_sudocmd_member_sudocmdgroup_table_widget({ + 'name': 'memberof', + 'label': 'Groups', + 'other_entity': 'sudocmdgroup', + 'save_values': false + }); + section.add_field(field); + that.details_facet_init(); }; + return that; +} + +function ipa_sudocmd_member_sudocmdgroup_table_widget(spec) { + + spec = spec || {}; + + var that = ipa_association_table_widget(spec); + + that.init = function() { + + var column = that.create_column({ + name: 'cn', + primary_key: true, + width: '150px' + }); + + column.setup = function(container, record) { + container.empty(); + + var value = record[column.name]; + value = value ? value.toString() : ''; + + $('', { + 'href': '#'+value, + 'html': value, + 'click': function (value) { + return function() { + var state = IPA.tab_state(that.other_entity); + state[that.other_entity + '-facet'] = 'details'; + state[that.other_entity + '-pkey'] = value; + $.bbq.pushState(state); + return false; + } + }(value) + }).appendTo(container); + }; + + that.create_column({ + name: 'description', + label: 'Description', + width: '150px' + }); + + that.create_adder_column({ + name: 'cn', + primary_key: true, + width: '100px' + }); + + that.create_adder_column({ + name: 'description', + width: '100px' + }); + + that.association_table_widget_init(); + }; + + that.get_records = function(on_success, on_error) { + + if (!that.values.length) return; + + var batch = ipa_batch_command({ + 'name': that.entity_name+'_'+that.name+'_show', + 'on_success': on_success, + 'on_error': on_error + }); + + for (var i=0; i