From caa9d52666e5beb7321dc6c80820eeacca356077 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Fri, 18 Nov 2011 19:47:39 -0600 Subject: Refactored facet.load(). The load() in IPA.facet has been modified to accept the complete data returned by the server instead of just the result. This is needed by HBAC Test to access other attributes returned in the test result. Ticket #388 --- install/ui/facet.js | 232 +++++++++++++++++++++++++++++----------------------- 1 file changed, 128 insertions(+), 104 deletions(-) (limited to 'install/ui/facet.js') diff --git a/install/ui/facet.js b/install/ui/facet.js index 3a1ae92e..71ad5c08 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); + that.header.load(data.result.result); }; that.clear = function() { @@ -141,21 +141,20 @@ IPA.facet = function(spec) { that.entity.redirect_facet); }; - var redirect_errors = [4001]; + var redirect_error_codes = [4001]; - that.on_error = function(xhr, text_status, error_thrown) { + that.redirect_error = function(error_thrown) { /*If the error is in talking to the server, don't attempt to redirect, as there is nothing any other facet can do either. */ if (that.entity.redirect_facet) { - for (var i=0; i that.table.total_pages) { + state[that.entity_name+'-page'] = that.table.total_pages; + IPA.nav.push_state(state); + return; + } + that.table.current_page = page; + + if (!that.pkeys || !that.pkeys.length) { + that.table.empty(); + that.table.summary.text(IPA.messages.association.no_entries); + that.table.unselect_all(); + return; + } + + that.pkeys.sort(); + var total = that.pkeys.length; + + var start = (that.table.current_page - 1) * that.table.page_length + 1; + var end = that.table.current_page * that.table.page_length; + end = end > total ? total : end; + + var summary = IPA.messages.association.paging; + summary = summary.replace('${start}', start); + summary = summary.replace('${end}', end); + summary = summary.replace('${total}', total); + that.table.summary.text(summary); + + that.values = that.pkeys.slice(start-1, end); + + var columns = that.table.columns.values; + if (columns.length == 1) { // show pkey only + var name = columns[0].name; + that.table.empty(); + for (var i=0; i that.table.total_pages) { - state[that.entity_name+'-page'] = that.table.total_pages; - IPA.nav.push_state(state); - return; - } - that.table.current_page = page; - - if (!that.pkeys || !that.pkeys.length) { - that.table.empty(); - that.table.summary.text(IPA.messages.association.no_entries); - return; - } - - that.pkeys.sort(); - var total = that.pkeys.length; - - var start = (that.table.current_page - 1) * that.table.page_length + 1; - var end = that.table.current_page * that.table.page_length; - end = end > total ? total : end; - - var summary = IPA.messages.association.paging; - summary = summary.replace('${start}', start); - summary = summary.replace('${end}', end); - summary = summary.replace('${total}', total); - that.table.summary.text(summary); - - that.values = that.pkeys.slice(start-1, end); - - var columns = that.table.columns.values; - if (columns.length == 1) { // show pkey only - var name = columns[0].name; - that.table.empty(); - for (var i=0; i