diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2011-11-18 19:47:39 -0600 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2011-12-06 22:08:07 +0000 |
commit | caa9d52666e5beb7321dc6c80820eeacca356077 (patch) | |
tree | 01b91c26442e559632afbf652968c0dbd9c0291b /install/ui/search.js | |
parent | a8ea42bda841c8773d68886614faf9efd38e33bd (diff) | |
download | freeipa-caa9d52666e5beb7321dc6c80820eeacca356077.tar.gz freeipa-caa9d52666e5beb7321dc6c80820eeacca356077.tar.xz freeipa-caa9d52666e5beb7321dc6c80820eeacca356077.zip |
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
Diffstat (limited to 'install/ui/search.js')
-rw-r--r-- | install/ui/search.js | 65 |
1 files changed, 18 insertions, 47 deletions
diff --git a/install/ui/search.js b/install/ui/search.js index 493edb7f5..221aa5538 100644 --- a/install/ui/search.js +++ b/install/ui/search.js @@ -48,22 +48,9 @@ IPA.search_facet = function(spec) { that.managed_entity = IPA.get_entity(that.managed_entity_name); - var columns = that.columns.values; - for (var i=0; i<columns.length; i++) { - var column = columns[i]; - - var metadata = IPA.get_entity_param(that.managed_entity_name, column.name); - column.primary_key = metadata && metadata.primary_key; - column.link = column.primary_key; - } - that.init_table(that.managed_entity); }; - that.create_content = function(container) { - that.table.create(container); - }; - that.create_header = function(container) { that.facet_create_header(container); @@ -124,7 +111,6 @@ IPA.search_facet = function(spec) { }).appendTo(that.controls); }; - that.show = function() { that.facet_show(); @@ -178,45 +164,24 @@ IPA.search_facet = function(spec) { IPA.nav.push_state(state); }; - that.load_pkeys = function(result) { - that.pkeys = []; + that.get_pkeys = function(data) { + var result = data.result.result; + var pkey_name = that.managed_entity.metadata.primary_key; + var pkeys = []; for (var i=0; i<result.length; i++) { var record = result[i]; - var values = record[that.managed_entity.metadata.primary_key]; - that.pkeys.push(values[0]); + var values = record[pkey_name]; + pkeys.push(values[0]); } - return that.pkeys; - }; - - that.on_error = function(xhr, text_status, error_thrown) { - that.report_error(error_thrown); + return pkeys; }; that.get_search_command_name = function() { - return that.managed_entity.name + '_find' + (that.pagination ? "_pkeys" : ""); + return that.managed_entity.name + '_find' + (that.pagination ? '_pkeys' : ''); }; that.refresh = function() { - function on_success(data, text_status, xhr) { - - that.load(data.result.result); - - if (data.result.truncated) { - var message = IPA.messages.search.truncated; - message = message.replace('${counter}', data.result.count); - that.table.summary.text(message); - } else { - that.table.summary.text(data.result.summary); - } - - that.table.current_page_input.val(that.table.current_page); - that.table.total_pages_span.text(that.table.total_pages); - - that.filter.focus(); - that.select_changed(); - } - var filter = []; var current_entity = that.managed_entity; filter.unshift(IPA.nav.get_state(current_entity.name+'-filter')); @@ -233,9 +198,7 @@ IPA.search_facet = function(spec) { args: filter, options: { all: that.search_all - }, - on_success: on_success, - on_error: that.on_error + } }); if (that.pagination) { @@ -243,6 +206,15 @@ IPA.search_facet = function(spec) { command.set_option('sizelimit', 0); } + command.on_success = function(data, text_status, xhr) { + that.filter.focus(); + that.load(data); + }; + + command.on_error = function(xhr, text_status, error_thrown) { + that.report_error(error_thrown); + }; + command.execute(); }; @@ -260,7 +232,6 @@ IPA.search_facet = function(spec) { init(); // methods that should be invoked by subclasses - that.search_facet_create_content = that.create_content; that.search_facet_refresh = that.refresh; return that; |