[Freeipa-users] How to add multivalued attribute to UI

John Duino jduino at oblong.com
Wed Sep 16 18:21:57 UTC 2015


Greetings!

I am wanting to add a multivalued attribute (mailAlternateAddress, from objectClass:MailRecipient) to the User UI. We are running IPA 4.1.0-18.el7.centos.4.x86_64, on CentOS7. Adding it to the CLI was fairly straightforward.
I have a plugin at /usr/share/ipa/ui/js/plugins/altemail/altemail.js that I basically copied/hacked from some other docs/example I found. Two problems:
1) It will only show the first entry of mailAlternateAddress it finds (which I assume is a limitation of the get_item() function.)
2) While it inserts a text box in the UI in the Contacts section, it does not have the same ADD and DELETE buttons that, say, the 'mail' attribute has.

Any help would be appreciated! Here is the plugin:
define([
        'freeipa/phases',
        'freeipa/user'],
        function(phases, user_mod) {

//helper function
function get_item(array, attr, value) {

        for (var i=0,l=array.length; i<l; i++) {
                if (array[i][attr] === value) return array[i];
        }
        return null;
}

var altemail_plugin = {};

// adds 'mailalternateaddress' field into user details facet
altemail_plugin.add_altemail_pre_op = function() {

        var facet = get_item(user_mod.entity_spec.facets, '$type', 'details');
        var section = get_item(facet.sections, 'name', 'contact');
        section.fields.push({
                type: 'multivalued',
                name: 'mailalternateaddress',
                label: 'E-mail Alias'
        });
        return true;
};

phases.on('customization', altemail_plugin.add_altemail_pre_op);

return altemail_plugin;
});




More information about the Freeipa-users mailing list