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 | |
parent | dbeae4e3f43a15c84d95447c0c38266f06402ea2 (diff) | |
download | freeipa.git-313f201ea5b236311837d687119a4dd67fdb9372.tar.gz freeipa.git-313f201ea5b236311837d687119a4dd67fdb9372.tar.xz freeipa.git-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
-rw-r--r-- | install/ui/association.js | 62 | ||||
-rw-r--r-- | install/ui/details.js | 4 | ||||
-rw-r--r-- | install/ui/entity.js | 36 | ||||
-rw-r--r-- | install/ui/ipa.css | 2 |
4 files changed, 93 insertions, 11 deletions
diff --git a/install/ui/association.js b/install/ui/association.js index 8030631b..3c847c59 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); diff --git a/install/ui/details.js b/install/ui/details.js index f5a3e4d8..d4a013ad 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -376,7 +376,7 @@ IPA.details_facet = function(spec) { name: 'expand_all', href: 'expand_all', label: 'Expand All', - 'class': 'expand-collapse-all', + 'class': 'right-aligned-controls', style: 'display: none;', click: function() { that.expand_button.css('display', 'none'); @@ -395,7 +395,7 @@ IPA.details_facet = function(spec) { name: 'collapse_all', href: 'collapse_all', label: 'Collapse All', - 'class': 'expand-collapse-all', + 'class': 'right-aligned-controls', click: function() { that.expand_button.css('display', 'inline'); that.collapse_button.css('display', 'none'); diff --git a/install/ui/entity.js b/install/ui/entity.js index 783cfcbd..8ccdb8ea 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -795,7 +795,20 @@ IPA.entity_builder = function(){ if (spec.facet_group == 'memberindirect' || spec.facet_group == 'memberofindirect') { - spec.read_only = true; + + var length = spec.attribute_member.length; + var direct_attribute_member = spec.attribute_member.substring(0, length-8); + var direct_facet_name = direct_attribute_member+'_'+spec.other_entity; + + facet = entity.get_facet(direct_facet_name); + + if (facet) { // merge into previously created direct facet + facet.indirect_attribute_member = spec.attribute_member; + return that; + + } else { + spec.read_only = true; + } } spec.label = spec.label || @@ -823,15 +836,28 @@ IPA.entity_builder = function(){ spec = spec || {}; - var attribute_members = entity.metadata.attribute_members; + var direct_associations = []; + var indirect_associations = []; + + for (var association in entity.metadata.attribute_members) { + if (association == 'memberindirect' || + association == 'memberofindirect') { + indirect_associations.push(association); + } else { + direct_associations.push(association); + } + } - for (var attribute_member in attribute_members) { + // make sure direct facets are created first + var attribute_members = direct_associations.concat(indirect_associations); + for (var i=0; i<attribute_members.length; i++) { + var attribute_member = attribute_members[i]; var other_entities = entity.metadata.attribute_members[attribute_member]; - for (var i=0; i<other_entities.length; i++) { + for (var j=0; j<other_entities.length; j++) { - var other_entity = other_entities[i]; + var other_entity = other_entities[j]; var association_name = attribute_member+'_'+other_entity; var facet = entity.get_facet(association_name); diff --git a/install/ui/ipa.css b/install/ui/ipa.css index abf71008..45a17865 100644 --- a/install/ui/ipa.css +++ b/install/ui/ipa.css @@ -1191,7 +1191,7 @@ table.scrollable tbody { height: 4em; } -.expand-collapse-all { +.right-aligned-controls { position: absolute; right: 0; padding-right: 1.5em; |