diff options
author | Pavel Vomacka <pvomacka@redhat.com> | 2017-03-07 21:30:00 +0100 |
---|---|---|
committer | David Kupka <dkupka@redhat.com> | 2017-03-08 16:22:01 +0100 |
commit | 1d6cc35c03669ea67d9e9ee9ca0ff62401d1b157 (patch) | |
tree | 6aea0e84f0daf3789dc12763b93542e905b85321 | |
parent | 6be32edde0ae16473d4d109747adae78f9d725e4 (diff) | |
download | freeipa-1d6cc35c03669ea67d9e9ee9ca0ff62401d1b157.tar.gz freeipa-1d6cc35c03669ea67d9e9ee9ca0ff62401d1b157.tar.xz freeipa-1d6cc35c03669ea67d9e9ee9ca0ff62401d1b157.zip |
WebUI: Possibility to choose object when API call returns list of objects
In case that API call returns array of objects which contains data, using
'object_index' attribute in adapter specification we can set which object
should be used.
It is possible to choose only one object specified by its index in array.
Part of: https://pagure.io/freeipa/issue/6601
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
-rw-r--r-- | install/ui/src/freeipa/field.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js index 3c027bc43..ea548c033 100644 --- a/install/ui/src/freeipa/field.js +++ b/install/ui/src/freeipa/field.js @@ -819,6 +819,15 @@ field.Adapter = declare(null, { result_index: 0, /** + * When result of API call is an array of object this object index + * allows to specify exact object in array according to its position. + * Default value is null which means do not use object_index. + * + * @type {Number|null} + */ + object_index: null, + + /** * Name of the record which we want to extract from the result. * Used in dnslocations. * @type {String} @@ -849,6 +858,10 @@ field.Adapter = declare(null, { else if (dr.results) { var result = dr.results[this.result_index]; if (result) record = result[this.result_name]; + var res_type = typeof record; + var obj_in_type = typeof this.object_index; + if (res_type === 'object' && obj_in_type === 'number') + record = record[this.object_index]; } } return record; |