Finally I found which location is wrong , IT is in the JS
"comDate"....If I
rename it to "comdate" small letter it can saved and display,
I claim on ldap customPerson is using this "comDate" so I mislead that I
should use same in JS and Plugin... ANYONE can explain ?...as I still have
some confusion why it work. ( I try change all to comDate in plugin but it
fail)
Since attribute names are case-insensitive, we normalize them in IPA
framework to lower case because dictionary keys are case-sensitive.
So just use lower case everywhere and it should work.
attributeTypes: ( 2.25.28639311321113238241701611583088740684.14.2.2
NAME 'comDate' EQUALITY caseIgnoreMatch
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 cdate_plugin = {};
cdate_plugin.add_c_date = function() {
var facet = get_item(user_mod.entity_spec.facets, '$type',
'details');
var section = get_item(facet.sections, 'name', 'identity');
section.fields.push({
name: 'comdate',
type: 'multivalued',
label: 'Commencement Date'
});
return true;
};
phases.on('customization', cdate_plugin.add_c_date);
return cdate_plugin;
});
from ipaserver.plugins.user import user
from ipalib.parameters import Str
from ipalib.text import _
from ipalib import _
user.takes_params += (
Str('comdate?',
cli_name='comdate',
label=_('Commencement Date'),
),
)
user.default_attributes.append('comdate')
2017-11-09 20:20 GMT+08:00 Alexander Bokovoy <abokovoy(a)redhat.com>:
> On to, 09 marras 2017, barrykfl--- via FreeIPA-users wrote:
>
>> Hi:
>>
>> May be I missed write something on JSON..
>>
>> But I can use in command shell successfully. ipa user-mod apigee
>> --setattr comDate=1111 then ldap will appear user-show all will see.
>>
>> Any reference link if I missed ?
>>
> See
https://github.com/abbra/freeipa-userstatus-plugin as an example of
> how you can do that in a full plugin.
>
>
>
>
>> 2017-11-09 17:43 GMT+08:00 Pavel Vomacka <pvomacka(a)redhat.com>:
>>
>>
>>>
>>> On 11/09/2017 10:34 AM, barrykfl(a)gmail.com wrote:
>>>
>>> The 1111 will disappear after saved pressed . it will chnage to 1111 in
>>> ldap but the UI field blank not store.
>>>
>>> Now I understand, thank you. Could you please show me how you specified
>>> this new option in python code? Or you can check API Browser (IPA Server
>>> ->
>>> API Browser) in WebUI and find user-mod command there.
>>>
>>> The value is load from JSON which is returned by server (user-show). Then
>>> basically WebUI go through all fields in page and tries to find attribute
>>> in JSON response which is called the same as value of 'name'
attribute in
>>> field spec (in your case 'comDate'). Do you see 'comDate'
attribute in
>>> JSON
>>> response? (You can check that in developer console in browser in Network
>>> tab, in respective call.)
>>>
>>> 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 cdate_plugin = {};
>>>
>>>
>>> cdate_plugin.add_c_date = function() {
>>>
>>> var facet = get_item(user_mod.entity_spec.facets, '$type',
>>> 'details');
>>>
>>> var section = get_item(facet.sections, 'name',
'identity');
>>>
>>> section.fields.push({
>>> flags: ['w_if_no_aci'],
>>> $type: 'multivalued',
>>> name: 'comDate',
>>> label: 'Commencement Date'
>>>
>>> });
>>>
>>> return true;
>>>
>>> };
>>>
>>>
>>> phases.on('customization', cdate_plugin.add_c_date);
>>>
>>>
>>> return cdate_plugin;
>>>
>>> });
>>>
>>> [image: 內置圖片 1]
>>>
>>> 2017-11-09 16:51 GMT+08:00 Pavel Vomacka <pvomacka(a)redhat.com>:
>>>
>>>
>>>>
>>>> On 11/09/2017 09:18 AM, barrykfl(a)gmail.com wrote:
>>>>
>>>> Now work at certain area limitation:
>>>>
>>>> It can update successfully BUT no view on UI , then I tried replace
>>>> "textarea" as before it come a big field but also no view my
result. (
>>>> but
>>>> it really updated)
>>>>
>>>> Could you please reformulate it? I'm not sure whether I understand
>>>> what's
>>>> the problem now.
>>>>
>>>>
>>>> section.fields.push({
>>>> flags: ['w_if_no_aci'],
>>>> $type: 'multivalued',
>>>> name: 'comDate',
>>>> label: 'Commencement Date'
>>>>
>>>> });
>>>>
>>>> [image: 內置圖片 1]
>>>>
>>>>
>>>>
>>>> 2017-11-09 16:06 GMT+08:00 Pavel Vomacka <pvomacka(a)redhat.com>:
>>>>
>>>>
>>>>>
>>>>> On 11/09/2017 09:00 AM, barrykfl(a)gmail.com wrote:
>>>>>
>>>>> Add like this ...now the label gone nothing shown.
>>>>>
>>>>> section.fields.push({
>>>>> flags: ['w_if_no_aci']
>>>>> $type: 'multivalued',
>>>>> name: 'comDate',
>>>>> label: 'Commencement Date'
>>>>>
>>>>> });
>>>>>
>>>>> Yes, that's because of missing colon at the end of 'flags:
...' line.
>>>>> You can open Developer Console in browser (F12) and you will see an
>>>>> error.
>>>>>
>>>>>
>>>>>
>>>>> 2017-11-09 15:50 GMT+08:00 Pavel Vomacka
<pvomacka(a)redhat.com>:
>>>>>
>>>>>
>>>>>>
>>>>>> On 11/09/2017 08:36 AM, barrykfl(a)gmail.com wrote:
>>>>>>
>>>>>> Same Like this Lable no field no edit no save but fine in command
base
>>>>>> ...any different freeipa4.0 vs 3.0 procedure?
>>>>>>
>>>>>> Do you have IPA 4.x ? Or which version?
>>>>>>
>>>>>> Try to add following line into the specification of your new
field:
>>>>>>
>>>>>> flags: ['w_if_no_aci']
>>>>>>
>>>>>>
>>>>>> [image: 內置圖片 2]
>>>>>>
>>>>>> 2017-11-09 14:44 GMT+08:00 Pavel Vomacka
<pvomacka(a)redhat.com>:
>>>>>>
>>>>>>
>>>>>>> On 11/08/2017 07:29 AM, barrykfl--- via FreeIPA-users wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Dear all:
>>>>>>>
>>>>>>> I follow the guide of freeipa 3.0 abt web plugin web ui. At
command
>>>>>>> base I successfully made
>>>>>>> a custom attribute called Employee " Commencement
Date" . I can add
>>>>>>> using script / command.
>>>>>>>
>>>>>>> BUT in web UI , it Display "Commencent date" Label
only ....and
>>>>>>> cannot
>>>>>>> display edit field and allow me edit.
>>>>>>>
>>>>>>> After That I changed to Multivalue the field come out but
still the
>>>>>>> save button is grey I cannot save again.
>>>>>>>
>>>>>>> Which part I made wrong ? please advise . thx
>>>>>>>
>>>>>>> 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 cdate_plugin = {};
>>>>>>>
>>>>>>> cdate_plugin.add_c_date = function() {
>>>>>>> var facet = get_item(user_mod.entity_spec.facets,
'$type',
>>>>>>> 'details');
>>>>>>> var section = get_item(facet.sections, 'name',
'identity');
>>>>>>> section.fields.push({
>>>>>>> $name: 'comDate',
>>>>>>>
>>>>>>> The dollar character should be at the beginning of type
attribute not
>>>>>>> the name. So try to change it to:
>>>>>>> name: 'comDate',
>>>>>>> $type: 'multivalued'
>>>>>>>
>>>>>>> type: 'multivalued',
>>>>>>>
>>>>>>> label: 'Commencement Date'
>>>>>>> });
>>>>>>> return true;
>>>>>>> };
>>>>>>>
>>>>>>> phases.on('customization',
cdate_plugin.add_c_date);
>>>>>>>
>>>>>>> return cdate_plugin;
>>>>>>> });
>>>>>>>
>>>>>>>
>>>>>>> Does it help?
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> FreeIPA-users mailing list --
freeipa-users(a)lists.fedorahosted.org
>>>>>>> To unsubscribe send an email to
freeipa-users-leave(a)lists.fedo
>>>>>>>
rahosted.org
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Pavel^3 Vomacka
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> Pavel^3 Vomacka
>>>>>>
>>>>>>
>>>>>>
>>>>> --
>>>>> Pavel^3 Vomacka
>>>>>
>>>>>
>>>>>
>>>> --
>>>> Pavel^3 Vomacka
>>>>
>>>>
>>>>
>>> --
>>> Pavel^3 Vomacka
>>>
>>>
>>>
> _______________________________________________
>> FreeIPA-users mailing list -- freeipa-users(a)lists.fedorahosted.org
>> To unsubscribe send an email to freeipa-users-leave(a)lists.fedo
>>
rahosted.org
>>
>
>
> --
> / Alexander Bokovoy
>