summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorPavel Vomacka <pvomacka@redhat.com>2016-10-05 11:52:10 +0200
committerMartin Basti <mbasti@redhat.com>2017-03-14 10:40:10 +0100
commit2e6e0698865e7d530c6ebf87a12e46f990ac1d87 (patch)
treef38d558cb0bd35409b4e35ad7eef5d9f5f6018e1 /install
parent042e113db9bc66dcd0da0d5e8b8d025212695705 (diff)
downloadfreeipa-2e6e0698865e7d530c6ebf87a12e46f990ac1d87.tar.gz
freeipa-2e6e0698865e7d530c6ebf87a12e46f990ac1d87.tar.xz
freeipa-2e6e0698865e7d530c6ebf87a12e46f990ac1d87.zip
Extend _show command after _find command in table facets
Allow pagination to table facets which needs to call _show on all rows with additional parameter. 'show_command_additional_attr' can be set to any attribute from result of _find command. This attribute is taken with its value and added to options of _each command for each row. Part of: https://fedorahosted.org/freeipa/ticket/5426 Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
Diffstat (limited to 'install')
-rw-r--r--install/ui/src/freeipa/facet.js42
1 files changed, 40 insertions, 2 deletions
diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js
index ab5af1ff9..bbd47b6f9 100644
--- a/install/ui/src/freeipa/facet.js
+++ b/install/ui/src/freeipa/facet.js
@@ -1847,6 +1847,14 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
that.search_all_entries = spec.search_all_entries;
/**
+ * Attribute from *_find command which will be used in batch *_show command
+ * which is called for each row.
+ *
+ * @property {String}
+ */
+ that.show_command_additional_attr = spec.show_command_additional_attr || null;
+
+ /**
* Member resolution(no_member: true ) in rpc request is skipped by default
* to improve performance of getting data.
*
@@ -2144,7 +2152,7 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
// get the complete records
that.get_records(
- records_map.keys,
+ records_map,
function(data, text_status, xhr) {
var results = data.result.results;
for (var i=0; i<records_map.length; i++) {
@@ -2227,7 +2235,9 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
* @param {Function} on_success command success handler
* @param {Function} on_failure command error handler
*/
- that.create_get_records_command = function(pkeys, on_success, on_error) {
+ that.create_get_records_command = function(records, on_success, on_error) {
+
+ var pkeys = records.keys;
var batch = rpc.batch_command({
name: that.get_records_command_name(),
@@ -2244,6 +2254,10 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
args: [pkey]
});
+ if (that.show_command_additional_attr) {
+ that.extend_get_records_command(command, records, pkey);
+ }
+
if (!that.always_request_members && that.table.entity.has_members()) {
command.set_options({no_members: true});
}
@@ -2254,6 +2268,24 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
return batch;
};
+
+ /**
+ * This allows to use pagination in situations when for loading whole search
+ * page you need *_show command with
+ *
+ */
+ that.extend_get_records_command = function(command, records, pkey) {
+ var record = records.get(pkey);
+ var item = record[that.show_command_additional_attr];
+ if (item) {
+ var temp_option = {};
+ temp_option[that.show_command_additional_attr] = item;
+ command.set_options(temp_option);
+ }
+ };
+
+
+
/**
* Execute command for obtaining complete records
*
@@ -2431,6 +2463,12 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
}
};
+ that.fetch_records = function() {
+ if (!that.table) return null;
+
+ return that.table.records;
+ };
+
if (!no_init) that.init_table_columns();
that.table_facet_create_get_records_command = that.create_get_records_command;