diff options
author | Endi S. Dewata <edewata@redhat.com> | 2011-06-16 16:35:13 -0500 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2011-06-16 20:11:22 -0400 |
commit | 313f201ea5b236311837d687119a4dd67fdb9372 (patch) | |
tree | a01e33889d52354ed955ed3a204a0eec72004d7d /install/ui/association.js | |
parent | dbeae4e3f43a15c84d95447c0c38266f06402ea2 (diff) | |
download | freeipa-313f201ea5b236311837d687119a4dd67fdb9372.tar.gz freeipa-313f201ea5b236311837d687119a4dd67fdb9372.tar.xz freeipa-313f201ea5b236311837d687119a4dd67fdb9372.zip |
Merged direct and indirect association facets
The direct and indirect associations are now displayed in the same
facet. The type of association to be displayed can be selected
using radio buttons.
Ticket #1338
Diffstat (limited to 'install/ui/association.js')
-rw-r--r-- | install/ui/association.js | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/install/ui/association.js b/install/ui/association.js index 8030631b4..3c847c59c 100644 --- a/install/ui/association.js +++ b/install/ui/association.js @@ -674,7 +674,11 @@ IPA.association_facet = function (spec) { var that = IPA.facet(spec); that.attribute_member = spec.attribute_member; + that.indirect_attribute_member = spec.indirect_attribute_member; + that.other_entity = spec.other_entity; + + that.association_type = 'direct'; that.facet_group = spec.facet_group; that.read_only = spec.read_only; @@ -821,6 +825,48 @@ IPA.association_facet = function (spec) { } }).appendTo(that.controls); } + + if (that.indirect_attribute_member) { + var span = $('<span/>', { + 'class': 'right-aligned-controls' + }).appendTo(that.controls); + + span.append('Show Results '); + + that.direct_radio = $('<input/>', { + type: 'radio', + name: 'type', + value: 'direct', + click: function() { + that.association_type = $(this).val(); + that.refresh(); + return true; + } + }).appendTo(span); + + span.append(' Direct Enrollment '); + + that.indirect_radio = $('<input/>', { + type: 'radio', + name: 'type', + value: 'indirect', + click: function() { + that.association_type = $(this).val(); + that.refresh(); + return true; + } + }).appendTo(span); + + span.append(' Indirect Enrollment'); + } + }; + + that.get_attribute_name = function() { + if (that.association_type == 'direct') { + return that.attribute_member+'_'+that.other_entity; + } else { + return that.indirect_attribute_member+'_'+that.other_entity; + } }; that.create_content = function(container) { @@ -948,7 +994,7 @@ IPA.association_facet = function (spec) { that.table.current_page_input.val(that.table.current_page); that.table.total_pages_span.text(that.table.total_pages); - var pkeys = that.record[that.name]; + var pkeys = that.record[that.get_attribute_name()]; if (!pkeys || !pkeys.length) { that.table.empty(); that.table.summary.text('No entries.'); @@ -1003,7 +1049,7 @@ IPA.association_facet = function (spec) { if (!length) return; var batch = IPA.batch_command({ - 'name': that.entity_name+'_'+that.name, + 'name': that.entity_name+'_'+that.get_attribute_name(), 'on_success': on_success, 'on_error': on_error }); @@ -1026,12 +1072,22 @@ IPA.association_facet = function (spec) { that.refresh = function() { + if (that.association_type == 'direct') { + if (that.direct_radio) that.direct_radio.attr('checked', true); + if (that.add_button) that.add_button.css('display', 'inline'); + if (that.remove_button) that.remove_button.css('display', 'inline'); + } else { + if (that.indirect_radio) that.indirect_radio.attr('checked', true); + if (that.add_button) that.add_button.css('display', 'none'); + if (that.remove_button) that.remove_button.css('display', 'none'); + } + function on_success(data, text_status, xhr) { that.record = data.result.result; that.table.current_page = 1; - var pkeys = that.record[that.name]; + var pkeys = that.record[that.get_attribute_name()]; if (pkeys) { that.table.total_pages = Math.ceil(pkeys.length / that.table.page_length); |