Add property which allows refresh command to use url value

'refresh_attribute' can be set to the name of url parameter name. This parameter with
its value is then passed to refresh command of the details facet.

Part of: https://fedorahosted.org/freeipa/ticket/5426

Reviewed-By: Martin Basti <mbasti@redhat.com>
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
Pavel Vomacka 2016-10-05 10:50:08 +02:00 committed by Martin Basti
parent 6d1374f7f8
commit bbca1d9219

View File

@ -538,6 +538,13 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) {
*/
that.refresh_command_name = spec.refresh_command_name || 'show';
/**
* Name of url argument which will be added to refresh RPC command as option.
*
* @property {string}
*/
that.refresh_attribute = spec.refresh_attribute || null;
/**
* Name of update command
*
@ -884,6 +891,23 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) {
}
};
/**
* Takes url argument which is named arg_name and its value. Creates object
* from this infromation {arg_name: arg_name_value} and attach it as option
* to command.
*
* @protected
* @param {rpc.command} command
* @param {string} argumnent name
*/
that.add_url_arg_to_command = function(command, arg_name) {
var additional_opt = {};
command.options = command.options || {};
additional_opt[arg_name] = that.state[arg_name];
$.extend(command.options, additional_opt);
};
/**
* Create update command based on field part of update info
* @protected
@ -1034,6 +1058,10 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) {
command.args = that.get_pkeys();
}
if (that.refresh_attribute) {
that.add_url_arg_to_command(command, that.refresh_attribute);
}
return command;
};