diff options
author | Pavel Vomacka <pvomacka@redhat.com> | 2016-08-26 12:50:00 +0200 |
---|---|---|
committer | Martin Babinsky <mbabinsk@redhat.com> | 2016-09-07 09:17:49 +0200 |
commit | 40f923f56b4777e3e18c9f76ba1a745ed69ef0a6 (patch) | |
tree | 61c9a2603081ff53bdf4d122ffe88b608800066e /install/ui | |
parent | 37f3ad8867f347289adcadcc473871c54aa9ca9d (diff) | |
download | freeipa-40f923f56b4777e3e18c9f76ba1a745ed69ef0a6.tar.gz freeipa-40f923f56b4777e3e18c9f76ba1a745ed69ef0a6.tar.xz freeipa-40f923f56b4777e3e18c9f76ba1a745ed69ef0a6.zip |
Add support for additional options taken from table facet
Sometimes the entity_show command must be called with options which are gathered
from result of entity_find command. These options needs to be passed as
arguments in URL which points to details page.
This functionality is implemented to table facet. There is new property
'additional_navigation_arguments' which is prepared for array of attributes
which will be passed to URL.
Part of: https://fedorahosted.org/freeipa/ticket/6238
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
Diffstat (limited to 'install/ui')
-rw-r--r-- | install/ui/src/freeipa/facet.js | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js index 4553c5c65..06eca189f 100644 --- a/install/ui/src/freeipa/facet.js +++ b/install/ui/src/freeipa/facet.js @@ -1819,6 +1819,15 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { var that = IPA.facet(spec, no_init); /** + * Names of additional row attributes which will be send to another facet + * during navigation as URL parameters. + * + * @property {Array<string>} + */ + that.additional_navigation_arguments = spec.additional_navigation_arguments; + + + /** * Entity of data displayed in the table * @property {entity.entity} */ @@ -2268,6 +2277,38 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { /** + * Extract data from command response and return them. + * + * @param pkey {string} primary key of row which is chosen + * @param attrs {Array} names of attributes which will be extracted + */ + that.get_row_attribute_values = function(key, attrs) { + var result = that.data.result.result; + var options = {}; + var row; + + if (result) { + for (var i=0, l=result.length; i<l; i++) { + row = result[i]; + + var pkey = row[that.table.name]; + if (pkey == key) break; + } + + if (row) { + for (var j=0, le=attrs.length; j<le; j++) { + var attr = attrs[j]; + var new_attr = {}; + new_attr[attr] = row[attr]; + $.extend(options, new_attr); + } + } + } + + return options; + }; + + /** * * Method which will be called after clicking on pkey in table. * @@ -2279,6 +2320,12 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { */ that.on_column_link_click = function(value, entity) { var pkeys = [value]; + var args; + + var attributes = that.additional_navigation_arguments; + if (lang.isArray(attributes)) { + args = that.get_row_attribute_values(value, attributes); + } // for nested entities var containing_entity = entity.get_containing_entity(); @@ -2287,7 +2334,7 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { pkeys.push(value); } - navigation.show_entity(entity.name, that.details_facet_name, pkeys); + navigation.show_entity(entity.name, that.details_facet_name, pkeys, args); return false; }; |