1.7 5707 Width of breed field

We have some long breed names and so I pushed the allowed breed length out to 40 characters.

On the Patients|info|edit screen all works well.

However, on the Patients|Info screen, for some breeds the breed name is partially truncated.  For example

However, if I change it to something longer, the complete breed name shows eith space to spare:

Conclusion: the algorithm that calculates the field size is getting things a little too small at times.

Regards, Tim G

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: 1.7 5707 Width of breed field

If you remove the maxLength attribute for species and breed, it will display up to 50 characters. I've changed party.patientpet.adl to remove these in revision 5733.

Re: 1.7 5707 Width of breed field

Tim - I don't think that this is the problem.  Below is the current party.patientPet definition (and a Tomcat restart has been done since I updated the archetype), and then the display for Ginger - you can see that the breed display is not quite wide enough.  Note also that the Colour field has a max length of 30 - but in the patient Info screen, its field is longer than the Breed field.  Conclusion - the length of the field displayed on the Patients|Information screen (not the Patients|Info|Edit screen) is being calculated from the actual length of the breed text - but in some way the calculation result is sometimes wrong.

Regards, Tim G

Re: 1.7 5707 Width of breed field

The lookup fields resize. String fields will display maxLength characters, or 50 characters if maxLength > 50.

What resolution are you running at?

If I inspect the Breed element using Firebug, I get:

 <input type="text" id="c_517" 
       style="border: 1px inset rgb(240, 230, 140); color: rgb(0, 0, 0); background-color: rgb(255, 255, 153); font-family: arial,sans-serif; font-size: 12px; width: 20ex;" 
       tabindex="-1" 
       value="Welsh Corgi Pembroke" readonly=""> 

The field width is set to 20ex (i.e. the height of 20 'x' characters for the font).

The font is arial, or if not present, sans-serif.

An alternative is to use 20em, (i.e 20 * the font-size), but this makes the fields to too wide.

Re: 1.7 5707 Width of breed field

Ahah - yes as you can see below it is 20ex wide -presumably the 20 comes from the number of characters in "Welsh Corgi Pembroke".

If I inspect the same element when the breed is "Shih Tzu X Cavalier King Charles" then the field is 32ex wide (which is again the number of characters in the breed name). If I set the breed to something small, eg Pug, then the width is 3em.

Inspecting the other fields I find:  Species (Dog) - 3em; Colour (Tan & White) - 30ex; Sex (Female) - 6em; Name (Ginger) - 50ex.

So the logic appears to be: for some fields (Name, Colour - set width as Nex where N is the field size; for others (Species, Sex, Breed) - set width from number of characters and use em if small, ex if large.

This approach for the breed works if the breed name contains a number of small characters (eg "Shih Tzu X Cavalier King Charles" has 3 i's) but with long names with a small number of narrow characters, (eg "Welsh Corgi Pembroke") it produces a field width that is marginally small.

Recommendation: change the algorithm so that for long fields, instead of using Nex, it uses say (N-6)ex+6em.

Regards, Tim G

Re: 1.7 5707 Width of breed field

Some experimentation with html code shows that the above formula cannot be implemented because the style|width item cannot take a formula (ie width (18ex+6em) does not work.  Hence one needs to express the width as something in ex's or em's but not both.

Experimenting with the our full set of 689 breed names (ranging from 3 character 'Rat' to 38 character 'Schnauzer X Poodle X Yorkshire Terrier' shows that the formula: if less that 7 characters use Nem, else use (round(N(1+N/5)) ex) [where N is the number of characters], yields a reasonable fit that is probably slightly too big for long names but otherwise OK.

I will have a play with a more complex formula if I get time.

Regards, Tim G

Re: 1.7 5707 Width of breed field

Yet more experimentation shows that a better formula is:

  • less than 7 characters:  Nem
  • 7-24 characters: N+3+round(N/5) ex
  • 25+ characters: N+round(N/8) ex

The attached testlen.txt is in fact a zip file containing test.xls (spreadsheet to generate the HTML) and test.htm - the html code.

Regards, Tim G

AttachmentSize
testlen.txt 69.7 KB

Re: 1.7 5707 Width of breed field

I'm using html input fields to display these, to get a consistent L&F throughout the app. The main downside is that they require a width to be specified, which is dependent on the browser font.

I'll have a play with your suggestion; the alternative is to develop a new component that grows to fit the available text, up to a maximum width. This would need to emulate the L&F of the input field.

Raised as https://openvpms.atlassian.net/browse/OVPMS-1440

Thanks,

-Tim A

Syndicate content