From b70ebe5c9f718d184ae6a60931fdccf0e22b9c48 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Wed, 7 Dec 2011 10:34:15 -0600 Subject: [PATCH 1/3] Fixed matched/unmatched checkboxes in HBAC Test The checkboxes in HBAC Test run page have been fixed to show/hide matched or unmatched rules. The New Test button has been fixed to deselect the inputs in all facets. The test data has been updated as well. Ticket #388 --- install/ui/facet.js | 15 +- install/ui/hbactest.js | 87 ++- install/ui/test/data/hbacrule_find_pkeys.json | 122 +++- .../ui/test/data/hbacrule_get_records.json | 588 ++++++++++++++++-- install/ui/test/data/hbactest.json | 24 +- install/ui/test/data/hbactest_matched.json | 408 ++++++++++++ install/ui/test/data/hbactest_unmatched.json | 249 ++++++++ 7 files changed, 1410 insertions(+), 83 deletions(-) create mode 100644 install/ui/test/data/hbactest_matched.json create mode 100644 install/ui/test/data/hbactest_unmatched.json diff --git a/install/ui/facet.js b/install/ui/facet.js index df5743b1c..e16ee6704 100644 --- a/install/ui/facet.js +++ b/install/ui/facet.js @@ -107,7 +107,7 @@ IPA.facet = function(spec) { that.load = function(data) { that.data = data; - that.header.load(data.result.result); + that.header.load(data); }; that.refresh = function() { @@ -367,6 +367,8 @@ IPA.facet_header = function(spec) { }; that.load = function(data) { + if (!data) return; + var result = data.result.result; if (!that.facet.disable_facet_tabs) { var pkey = that.facet.pkey; @@ -392,7 +394,7 @@ IPA.facet_header = function(spec) { var facet = facets[j]; var link = $('li[name='+facet.name+'] a', span); - var values = data ? data[facet.name] : null; + var values = result ? result[facet.name] : null; if (values) { link.text(facet.label+' ('+values.length+')'); } else { @@ -472,6 +474,13 @@ IPA.table_facet = function(spec) { that.load = function(data) { that.facet_load(data); + if (!data) { + that.table.empty(); + that.table.summary.text(''); + that.table.pagination_control.css('visibility', 'hidden'); + return; + } + that.table.current_page = 1; that.table.total_pages = 1; @@ -483,6 +492,8 @@ IPA.table_facet = function(spec) { that.table.current_page_input.val(that.table.current_page); that.table.total_pages_span.text(that.table.total_pages); + + that.table.pagination_control.css('visibility', 'visible'); }; diff --git a/install/ui/hbactest.js b/install/ui/hbactest.js index d9a854f11..916a23803 100644 --- a/install/ui/hbactest.js +++ b/install/ui/hbactest.js @@ -117,7 +117,6 @@ IPA.hbac.test_entity = function(spec) { label: IPA.messages.objects.hbactest.run_test, managed_entity_name: 'hbacrule', disable_breadcrumb: true, - pagination: true, facet_group: 'default', columns: [ 'cn', @@ -198,13 +197,6 @@ IPA.hbac.test_facet = function(spec) { }).appendTo(buttons); }; - that.find = function() { - var filter = that.filter.val(); - var state = {}; - state[that.entity.name+'-'+that.name+'-filter'] = filter; - IPA.nav.push_state(state); - }; - that.prev = function() { var facet_group = that.entity.get_facet_group('default'); var index = facet_group.get_facet_index(that.name); @@ -262,7 +254,6 @@ IPA.hbac.test_facet = function(spec) { } command.on_success = function(data, text_status, xhr) { - if (that.filter) that.filter.focus(); that.load(data); }; @@ -368,7 +359,7 @@ IPA.hbac.test_select_facet = function(spec) { td.append(' '); that.external_text = $('', { - name: 'external', + name: id, focus: function() { that.external_radio.click(); } @@ -381,6 +372,13 @@ IPA.hbac.test_select_facet = function(spec) { that.create_buttons(footer); }; + that.find = function() { + var filter = that.filter.val(); + var state = {}; + state[that.entity.name+'-'+that.name+'-filter'] = filter; + IPA.nav.push_state(state); + }; + that.get_selected_values = function() { var values = that.table.get_selected_values(); if (values && values.length) return values; @@ -393,8 +391,9 @@ IPA.hbac.test_select_facet = function(spec) { }; that.reset = function() { - that.table.set_values([]); + delete that.selected_values; if (that.external_radio) that.external_radio.attr('checked', false); + if (that.external_text) that.external_text.val(''); }; that.save = function(record) { @@ -475,9 +474,9 @@ IPA.hbac.test_rules_facet = function(spec) { }; that.reset = function() { - that.table.set_values([]); + delete that.selected_values; if (that.enabled) that.enabled.attr('checked', false); - if (that.disabled) that.enabled.attr('checked', false); + if (that.disabled) that.disabled.attr('checked', false); }; that.save = function(record) { @@ -505,6 +504,8 @@ IPA.hbac.test_run_facet = function(spec) { var init = function() { that.table.selectable = false; + that.show_matched = true; + that.show_unmatched = true; }; that.create_content = function(container) { @@ -547,10 +548,15 @@ IPA.hbac.test_run_facet = function(spec) { header.append(' '); - that.matched = $('', { + that.matched_checkbox = $('', { id: 'hbactest-rules-matched', type: 'checkbox', - name: 'matched' + name: 'matched', + checked: true, + change: function() { + that.show_matched = that.matched_checkbox.is(':checked'); + that.refresh(); + } }).appendTo(header); $('