From 9405e1a9db11294a11efa24a7a3c36ea76a42f31 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Fri, 4 Nov 2011 20:43:39 -0500 Subject: Added paging on search facet. The search facet has been modified to support paging on most entities using the --pkey-only option to get the primary keys and a batch command to get the complete records. Paging on DNS records is not supported because a record may appear as multiple rows. The following entities do not have --pkey-only option: Automount Key, Self-Service Permissions, Delegation. The search and association facet have been refactored to reuse the common code from the table facet base class. Ticket #981 --- install/ui/association.js | 221 +++++----------------------------------------- 1 file changed, 21 insertions(+), 200 deletions(-) (limited to 'install/ui/association.js') diff --git a/install/ui/association.js b/install/ui/association.js index 6ef73daf..553966eb 100644 --- a/install/ui/association.js +++ b/install/ui/association.js @@ -457,9 +457,9 @@ IPA.association_table_widget = function (spec) { } var batch = IPA.batch_command({ - 'name': that.entity.name+'_'+that.name, - 'on_success': on_success, - 'on_error': on_error + name: that.entity.name+'_'+that.name, + on_success: on_success, + on_error: on_error }); for (var i=0; i 1) { - var state = {}; - state[that.entity_name+'-page'] = that.table.current_page - 1; - IPA.nav.push_state(state); - } - }; - - that.table.next_page = function() { - if (that.table.current_page < that.table.total_pages) { - var state = {}; - state[that.entity_name+'-page'] = that.table.current_page + 1; - IPA.nav.push_state(state); - } - }; - - that.table.set_page = function(page) { - if (page < 1) { - page = 1; - } else if (page > that.total_pages) { - page = that.total_pages; - } - var state = {}; - state[that.entity_name+'-page'] = page; - IPA.nav.push_state(state); - }; - - that.table.refresh = function() { - var state = {}; - var page = parseInt(IPA.nav.get_state(that.entity_name+'-page'), 10) || 1; - if (page < 1) { - state[that.entity_name+'-page'] = 1; - IPA.nav.push_state(state); - return; - } else if (page > that.table.total_pages) { - state[that.entity_name+'-page'] = that.table.total_pages; - IPA.nav.push_state(state); - return; - } - that.table.current_page = page; - that.table.current_page_input.val(page); - that.refresh_table(); - }; - - that.table.select_changed = function() { - - var values = that.table.get_selected_values(); + var other_entity = IPA.get_entity(that.other_entity); + that.init_table(other_entity); + }; - if (that.remove_button) { - if (values.length === 0) { - that.remove_button.addClass('action-button-disabled'); - } else { - that.remove_button.removeClass('action-button-disabled'); - } - } - }; - } + that.get_records_command_name = function() { + return that.entity.name+'_'+that.get_attribute_name(); + }; that.create_header = function(container) { @@ -1070,105 +992,8 @@ IPA.association_facet = function (spec) { dialog.open(that.container); }; - that.refresh_table = function() { - - that.table.current_page_input.val(that.table.current_page); - that.table.total_pages_span.text(that.table.total_pages); - - var pkeys = that.data[that.get_attribute_name()]; - if (!pkeys || !pkeys.length) { - that.table.empty(); - that.table.summary.text(IPA.messages.association.no_entries); - return; - } - - pkeys.sort(); - var total = 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); - - var list = 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