On Thu, May 18, 2017 at 3:36 AM, Pavel Vomacka <pvoma...@redhat.com> wrote:
> Hello Steve,
>
> On 05/16/2017 05:21 PM, Steve Huston wrote:
>>
>> I've extended the UI for host addition by including a multivalued
>> widget which stores puppetVar values (as well as the accompanying
>> Python plugin to handle it and schema update in the directory).  This
>> works well, but I'd like to add one more thing and am not sure how to
>> do it.
>>
>> There are certain variables which are basically always set for every
>> host, and so I'd like them to default to those values in the UI, while
>> still giving the admin the choice to edit or remove them just like
>> they were entered by hand.  I'm not sure, however, how to "push"
>> values into the UI that way.
>
> Could you please write an example of the variable?

Sure, here's the UI code I wrote (limited to just this one in particular):

// adds things we want on the adder page
astrocustom_plugin.add_host_pre_op = function() {

  var section = get_item(host_mod.entity_spec.adder_dialog.sections,
'name', 'other');
  {
    name: 'puppetvar',
    $type: 'multivalued',
    label: 'Puppet Variables',
  });

  return true;
};

phases.on('customization', astrocustom_plugin.add_host_pre_op);

This works perfectly, giving me a multivalued entry on the host adding
dialog box where I can add puppetvars to the resultant LDAP record
when the host is saved.  What I'd like to do now is make it so that
there defaults to being a few pre-filled as if I typed them, with the
'undo' buttons shown so they can be removed if not needed, or edited
before saving.  Here's an example of me having added three values -
basically, when I click the add button from the host page and this
dialog appears, I'd like it to look something like this with those
values there already that I can edit or remove if I don't need them:

https://www.dropbox.com/s/j56mze39va3u7m0/Screenshot%202017-05-18%2010.42.38.png?dl=0


>> Is there some attribute of a field I can edit to insert a default
>> value into the UI, while still allowing that to be removed or edited
>> before the user submits the page?
>>
>>
> In case you want to prefill a dialog by default values you can do it by
> using that.get_field('fieldname').set_value(['value1']); in open() method of
> the dialog. But I'm not sure whether this is what you want. If not please
> send an example of what you want to achieve.

Hopefully the above example explains my intention.  It's possible that
the answer you just gave here is exactly what I need, but I don't know
enough about javascript hacking yet to follow it.

-- 
Steve Huston - W2SRH - Unix Sysadmin, PICSciE/CSES & Astrophysical Sci
  Princeton University  |    ICBM Address: 40.346344   -74.652242
    345 Lewis Library   |"On my ship, the Rocinante, wheeling through
  Princeton, NJ   08544 | the galaxies; headed for the heart of Cygnus,
    (267) 793-0852      | headlong into mystery."  -Rush, 'Cygnus X-1'
_______________________________________________
FreeIPA-users mailing list -- freeipa-users@lists.fedorahosted.org
To unsubscribe send an email to freeipa-users-le...@lists.fedorahosted.org

Reply via email to