mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
webui: extract rpc value from object envelope
adapt Web UI to a newer style of encapsulation object data https://fedorahosted.org/freeipa/ticket/4394 Reviewed-By: Endi Sukma Dewata <edewata@redhat.com>
This commit is contained in:
parent
9aac0524c9
commit
5568e357d1
@ -824,7 +824,7 @@ IPA.dns.record_search_facet = function(spec) {
|
||||
|
||||
var original = records[i];
|
||||
var record = {
|
||||
idnsname: original.idnsname,
|
||||
idnsname: rpc.extract_objects(original.idnsname),
|
||||
values: []
|
||||
};
|
||||
|
||||
@ -2280,7 +2280,7 @@ IPA.dns.ptr_redirection_dialog = function(spec) {
|
||||
|
||||
for (var i=0; i<zones.length; i++) {
|
||||
|
||||
var zone_name = zones[i].idnsname[0];
|
||||
var zone_name = rpc.extract_objects(zones[i].idnsname)[0];
|
||||
if (that.reverse_address.indexOf(zone_name) > -1) {
|
||||
var msg = text.get('@i18n:objects.dnsrecord.ptr_redir_zone');
|
||||
msg = msg.replace('${zone}', zone_name);
|
||||
|
@ -1710,11 +1710,11 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
|
||||
|
||||
var result = data.result.result;
|
||||
var pkey_name = that.managed_entity.metadata.primary_key;
|
||||
var adapter = builder.build('adapter', 'adapter', {context: that});
|
||||
|
||||
for (var i=0; i<result.length; i++) {
|
||||
var record = result[i];
|
||||
var pkey = record[pkey_name];
|
||||
if (pkey instanceof Array) pkey = pkey[0];
|
||||
var pkey = adapter.load(record, pkey_name)[0];
|
||||
records_map.put(pkey, record);
|
||||
}
|
||||
|
||||
|
@ -824,6 +824,7 @@ field.Adapter = declare(null, {
|
||||
if (util.is_empty(value) && !util.is_empty(def)) {
|
||||
value = util.normalize_value(def);
|
||||
}
|
||||
value = rpc.extract_objects(value);
|
||||
return value;
|
||||
},
|
||||
|
||||
|
@ -587,7 +587,7 @@ IPA.update_password_expiration = function() {
|
||||
|
||||
var now, expires, notify_days, diff, message, container, notify;
|
||||
|
||||
expires = IPA.whoami.krbpasswordexpiration;
|
||||
expires = rpc.extract_objects(IPA.whoami.krbpasswordexpiration);
|
||||
expires = expires ? datetime.parse(expires[0]) : null;
|
||||
|
||||
notify_days = IPA.server_config.ipapwdexpadvnotify;
|
||||
|
@ -923,5 +923,48 @@ rpc.create_4304_error_handler = function(adder_dialog) {
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Property names to identify objects and values to extract in
|
||||
* `rpc.extract_objects(array)` method.
|
||||
* @type {Array}
|
||||
*/
|
||||
rpc.extract_types = ['__base64__', '__datetime__', '__dns_name__'];
|
||||
|
||||
/**
|
||||
* Extract values from specially encoded objects
|
||||
*
|
||||
* '''
|
||||
* // from
|
||||
* [{"__datetime__": "20140625103152Z"}]
|
||||
* // to
|
||||
* ["20140625103152Z"]
|
||||
* '''
|
||||
*
|
||||
* - in-place operations, modifies input array
|
||||
* - object properties to extract are defined in `rpc.extract_types`
|
||||
* - other types are left intact
|
||||
*
|
||||
* @param {Array} values
|
||||
* @return {Array}
|
||||
*/
|
||||
rpc.extract_objects = function(values) {
|
||||
|
||||
if (!values) return values;
|
||||
|
||||
var et = rpc.extract_types;
|
||||
for (var i=0, l=values.length; i<l; i++) {
|
||||
var val = values[i];
|
||||
if (typeof val === 'object') {
|
||||
for (var j=0, m=et.length; j<m; j++) {
|
||||
if (val[et[j]] !== undefined) {
|
||||
values[i] = val[et[j]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return values;
|
||||
};
|
||||
|
||||
return rpc;
|
||||
});
|
@ -2257,11 +2257,13 @@ IPA.column = function (spec) {
|
||||
|
||||
that.entity = IPA.get_entity(spec.entity);
|
||||
that.name = spec.name;
|
||||
that.param = spec.param || that.name;
|
||||
|
||||
that.label = text.get(spec.label);
|
||||
that.width = spec.width;
|
||||
that.primary_key = spec.primary_key;
|
||||
that.link = spec.link;
|
||||
that.adapter = builder.build('adapter', spec.adapter || 'adapter', { context: that });
|
||||
that.formatter = builder.build('formatter', spec.formatter);
|
||||
|
||||
if (!that.entity) {
|
||||
@ -2290,7 +2292,7 @@ IPA.column = function (spec) {
|
||||
* @param {boolean} suppress_link
|
||||
*/
|
||||
that.setup = function(container, record, suppress_link) {
|
||||
var value = record[that.name];
|
||||
var value = that.adapter.load(record);
|
||||
var type;
|
||||
if (that.formatter) {
|
||||
value = that.formatter.parse(value);
|
||||
@ -2327,6 +2329,9 @@ IPA.column = function (spec) {
|
||||
*/
|
||||
that.set_value = function(container, value, type, suppress_link) {
|
||||
|
||||
if (value instanceof Array) {
|
||||
value = value.join(', ');
|
||||
}
|
||||
value = value ? value.toString() : '';
|
||||
container.empty();
|
||||
|
||||
@ -2835,8 +2840,9 @@ IPA.table_widget = function (spec) {
|
||||
|
||||
var columns = that.columns.values;
|
||||
for (var i=0; i<columns.length; i++){
|
||||
|
||||
var name = columns[i].name;
|
||||
var values = result[name];
|
||||
var values = columns[i].adapter.load(result);
|
||||
if (!values) continue;
|
||||
|
||||
if (values instanceof Array){
|
||||
@ -2865,7 +2871,7 @@ IPA.table_widget = function (spec) {
|
||||
for (var i=0; i<columns.length; i++){
|
||||
var column = columns[i];
|
||||
|
||||
value = record[column.name];
|
||||
value = column.adapter.load(record);
|
||||
value = value ? value.toString() : '';
|
||||
|
||||
if (column.primary_key) {
|
||||
@ -3825,13 +3831,15 @@ IPA.entity_select_widget = function(spec) {
|
||||
|
||||
that.search_success = function(data, text_status, xhr) {
|
||||
|
||||
var adapter = builder.build('adapter', 'adapter', { context: that });
|
||||
|
||||
//get options
|
||||
var options = [];
|
||||
|
||||
var entries = data.result.result;
|
||||
for (var i=0; i<data.result.count; i++) {
|
||||
var entry = entries[i];
|
||||
var values = entry[that.other_field];
|
||||
var values = adapter.load(entry, that.other_field);
|
||||
var value = values[0];
|
||||
|
||||
options.push(value);
|
||||
|
Loading…
Reference in New Issue
Block a user