URL: https://github.com/freeipa/freeipa/pull/782
Title: #782: [WIP] Improving GUI text in "Add DNS Zones" popup

pvomacka commented:
Hello @felipevolpone ,
Thank you for your patch. 
For adding arbitrary text into a dialog or details page is probably the most 
suitable IPA.html_widget (but it has a big disadvantage - described below in 
section A). You can put it into the section you created. It might look like 
  name: 'dnszone_title',
  show_header: false,
  fields: [
      field: false,
      $type: 'html',
      name: 'info',
      html: "Select the required zone type."
  layout: {
    $factory: IPA.fluid_layout,
    widget_cls: "col-sm-12 controls",
    label_cls: "hide"
Layout attribute of the section might not be needed, but I would say that here 
it good to add it. It hides label of field and set width of the field to 100% 
of the dialog. 

(Simpler solutions below - B and C)
A) The html attribute contains text which will be displayed. Text there should 
be taken from translatable strings. It can be done by using 
`text.get('i18n:path.to.the.string')` and writing the string into 
ipaserver/internal.py. The main challenge here might be to find a place where 
the string has to be loaded. It has to be done before building the whole dialog 
and its sections. You will probably need to override `dialog_build_properites` 
attribute of entity specification and there change `$post_ops` operation which 
where is the function which builds adder dialog for entity (add there loading 
of translate string).

B) (not tested) Another solution would be to set text field instead of html one 
and turn off the field in the same way as above and then set it non-writable 
and read_only. Then hide the label and there the `text.get()` should work 
directly in field definition. (should not be needed to change behavior of 
building entity's adder dialog). 

C) Another solution will be to create new widget, which will work in the same 
way as `IPA.html_widget` but it will support translatable strings.

If you have any question feel free to ask. :)

See the full comment at 
Manage your subscription for the Freeipa-devel mailing list:
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to