Add adapter attribute for choosing record

The new attribute of the adapter contains the name of record which will be
extracted from API call result.

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

Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
Pavel Vomacka 2016-06-05 18:03:17 +02:00 committed by Petr Vobornik
parent 740099cf0b
commit 5a8ad3e982

View File

@ -801,6 +801,13 @@ field.Adapter = declare(null, {
*/
result_index: 0,
/**
* Name of the record which we want to extract from the result.
* Used in dnslocations.
* @type {String}
*/
result_name: 'result',
/**
* Extract record from RPC call response
*
@ -821,10 +828,10 @@ field.Adapter = declare(null, {
var dr = data.result;
var record = null;
if (dr) {
if (IPA.defined(dr.result)) record = dr.result;
if (IPA.defined(dr[this.result_name])) record = dr[this.result_name];
else if (dr.results) {
var result = dr.results[this.result_index];
if (result) record = result.result;
if (result) record = result[this.result_name];
}
}
return record;