Hi Pavel,
Thank you very much for the pointer. I'm able to achieve what I was looking
for. Below is the JS I ended up using.
Thanks again.
--Prashant
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 fav_color_plugin = {};
fav_color_plugin.add_fav_color_number_pre_op = function() {
var facet = get_item(user_mod.entity_spec.facets, '$type',
'details');
var section = get_item(facet.sections, 'name', 'misc');
section.fields.splice(3, 0, {
name: 'favoritecolor',
label: 'Favorite Color',
read_only: true
});
var add_user_fields =
user_mod.entity_spec.adder_dialog.sections[0].fields;
add_user_fields.splice(3, 0, {
name: 'favoritecolor',
required: true,
});
return true;
};
phases.on('customization',
fav_color_plugin.add_fav_color_number_pre_op);
return fav_color_plugin;
});
On Mon, Sep 4, 2017 at 10:05 PM, Prashant M. Bapat <prashant.bapat(a)gmail.com
wrote:
> Hi Pavel,
>
> Thanks for the quick response.
>
> Let me try this and come back.
>
> Regards.
> --Prashant
>
>
> On Mon, Sep 4, 2017 at 4:19 PM, Pavel Vomacka <pvomacka(a)redhat.com
wrote:
>
>>
>>
>> On 09/04/2017 07:54 AM, Prashant M. Bapat via FreeIPA-users wrote:
>>
>> Hi All,
>>
>> Hi Prashant,
>>
>>
>> I wanted to add a custom attribute to user. I followed the freeipa
>> extension guide here
http://www.freeipa.org/im
>> ages/5/5b/FreeIPA33-extending-freeipa.pdf
>>
>> So far I have add this to the LDAP schema and added a custom python code
>> to /usr/lib/python2.7/site-packages/ipaserver/plugins/.
>>
>> With this the CLI part is working fine.
>>
>> The new attribute (say "favoritecolorname") should be mandatory for
all
>> users. I want the "user_add" call to validate the string using a
regex.
>> This works perfectly! I used this guide
https://abbra.fedorapeop
>>
le.org/guide.html
>>
>> I'm stuck with chaning the User Add dialog in Web UI. I need this new
>> atribute "favoritecolor" to be mandatory. Is there any sample code on
>> chaning the default user add dialog ?
>>
>> You can take a look here:
https://pvoborni.fedorapeople.
>> org/plugins/employeenumber/employeenumber.js . Only thing you need to
>> change is to find fields using:
>>
>> var fields = user_mod.entity_spec.adder_dialog.sections[1].fields;
>>
>>
>> and then push new field into the section:
>>
>> var fields.push({field_spec});
>>
>> In this case you also don't need helper function.
>>
>> That should work, in case you have any other troubles let me know.
>>
>>
>> Any pointers would be great.
>>
>> Thanks.
>> --Prashant
>>
>>
>> _______________________________________________
>> FreeIPA-users mailing list -- freeipa-users(a)lists.fedorahosted.org
>> To unsubscribe send an email to freeipa-users-leave(a)lists.fedorahosted.org
>>
>>
>> --
>> Pavel^3 Vomacka
>>
>>
>