diff options
Diffstat (limited to 'install/ui')
-rw-r--r-- | install/ui/src/freeipa/dns.js | 4 | ||||
-rw-r--r-- | install/ui/src/freeipa/facet.js | 4 | ||||
-rw-r--r-- | install/ui/src/freeipa/field.js | 1 | ||||
-rw-r--r-- | install/ui/src/freeipa/ipa.js | 2 | ||||
-rw-r--r-- | install/ui/src/freeipa/rpc.js | 43 | ||||
-rw-r--r-- | install/ui/src/freeipa/widget.js | 16 |
6 files changed, 61 insertions, 9 deletions
diff --git a/install/ui/src/freeipa/dns.js b/install/ui/src/freeipa/dns.js index e59f6e5ad..260b6f872 100644 --- a/install/ui/src/freeipa/dns.js +++ b/install/ui/src/freeipa/dns.js @@ -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); diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js index 419011627..0bb697be0 100644 --- a/install/ui/src/freeipa/facet.js +++ b/install/ui/src/freeipa/facet.js @@ -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); } diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js index 0bc8c6f5e..c2e96b392 100644 --- a/install/ui/src/freeipa/field.js +++ b/install/ui/src/freeipa/field.js @@ -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; }, diff --git a/install/ui/src/freeipa/ipa.js b/install/ui/src/freeipa/ipa.js index be671d8f4..2dd5a8f2e 100644 --- a/install/ui/src/freeipa/ipa.js +++ b/install/ui/src/freeipa/ipa.js @@ -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; diff --git a/install/ui/src/freeipa/rpc.js b/install/ui/src/freeipa/rpc.js index d49f60fee..756d4090f 100644 --- a/install/ui/src/freeipa/rpc.js +++ b/install/ui/src/freeipa/rpc.js @@ -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; });
\ No newline at end of file diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index b058293fe..3aba7da52 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -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); |