mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 15:40:01 -06:00
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>
This commit is contained in:
parent
6be32edde0
commit
1d6cc35c03
@ -818,6 +818,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.
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user