From 358caa7da44c997b505f54ec70cb6be58d188751 Mon Sep 17 00:00:00 2001 From: Pavel Vomacka Date: Tue, 7 Mar 2017 21:30:45 +0100 Subject: [PATCH] WebUI: Add Adapter for certmap_match result table Result of certmap_match command is in the following format: [{domain: 'domain1', uid:[uid11,uid12,uid13]}, {domain: 'domain2', uid:[uid21, uid22, uid23},...] For correct displaying in table we need to reformat it to the following: [{domain: 'domain1', uid: 'uid11'}, {domain: 'domain1', uid: 'uid12'},... This can be done using this Adapter. Part of: https://pagure.io/freeipa/issue/6601 Reviewed-By: Petr Vobornik --- install/ui/src/freeipa/field.js | 79 +++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js index ea548c033..5df2f6c9a 100644 --- a/install/ui/src/freeipa/field.js +++ b/install/ui/src/freeipa/field.js @@ -1494,6 +1494,84 @@ field.AlternateAttrFieldAdapter = declare([field.Adapter], { }); +/** + * Custom adapter specifically implemented for certmap_match where it + * transform items in format {domain: "xxx", uid: [arrayof_uids]} to + * {[{domain: "xxx", uid: "uid1"}, {domain: "xxx", uid: 'uid2'}, ...]}. + * This is necessary for possibility to correctly display table. + * + * @class + * @extends field.Adapter + */ +field.CertMatchTransformAdapter = declare([field.Adapter], { + + /** + * @param {Array} record + */ + transform_one_record: function(record) { + var domain = record.domain; + var uids = record.uid; + var results = []; + + for (var i=0, l=uids.length; i