Bug 14366

Summary: Units doesn't get saved usefully for patroncards
Product: Koha Reporter: David Cook <dcook>
Component: Label/patron card printingAssignee: Chris Nighswonger <cnighswonger>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: chris, derrynj, jonathan.druart, mtj, tomascohen
Version: master   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18246
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 14366 - Units doesn't get saved usefully for patroncards
[SIGNED OFF] Bug 14366 - Units doesn't get saved usefully for patroncards
Bug 14366 - Units doesn't get saved usefully for patroncards

Description David Cook 2015-06-09 04:23:44 UTC
"Units" gets saved into "layout_xml" for patroncards, but not into "units" in the `creator_layouts` table, so when you edit a layout for the patroncards, it'll always say "PostScript Points".

It looks like the code could use a good clean-up... but I have a small fix which sets it right so not going to refactor unnecessarily...
Comment 1 David Cook 2015-06-09 04:27:52 UTC Comment hidden (obsolete)
Comment 2 David Cook 2015-06-09 04:52:50 UTC
Of course... I'm not sure that the actual label creator is using the different units... that's fun...
Comment 3 Chris Nighswonger 2015-06-09 10:13:50 UTC
(In reply to David Cook from comment #2)
> Of course... I'm not sure that the actual label creator is using the
> different units... that's fun...

User selected units are converted to postscript points before rendering. Postscript points are the common denominator.
Comment 4 Katrin Fischer 2015-06-09 12:58:47 UTC
*** Bug 8602 has been marked as a duplicate of this bug. ***
Comment 5 Nick Clemens 2015-06-10 21:42:08 UTC Comment hidden (obsolete)
Comment 6 David Cook 2015-06-15 05:40:34 UTC
(In reply to Chris Nighswonger from comment #3)
> (In reply to David Cook from comment #2)
> > Of course... I'm not sure that the actual label creator is using the
> > different units... that's fun...
> 
> User selected units are converted to postscript points before rendering.
> Postscript points are the common denominator.

Are you certain? I tried changing a label by 1cm but it looks like it only changed by 1pt.

I haven't had time to look into this yet, unfortunately :/.
Comment 7 Chris Nighswonger 2015-06-15 12:58:18 UTC
(In reply to David Cook from comment #6)
> (In reply to Chris Nighswonger from comment #3)
> > (In reply to David Cook from comment #2)
> > > Of course... I'm not sure that the actual label creator is using the
> > > different units... that's fun...
> > 
> > User selected units are converted to postscript points before rendering.
> > Postscript points are the common denominator.
> 
> Are you certain? I tried changing a label by 1cm but it looks like it only
> changed by 1pt.
> 
> I haven't had time to look into this yet, unfortunately :/.

Point conversions are done here:

http://tinyurl.com/o99ve52

This bug is addressing the fact that labels do not save the user's preferred UOM, which explains the phenomena you are describing.

The real fix is for the labels code to be refactored to save templates as xml as patroncard code does. That was my long-term intention when I wrote the patroncard feature. Of course, even the best of intentions never materialize at times. :-P
Comment 8 Jonathan Druart 2015-06-16 09:22:37 UTC
Created attachment 40168 [details] [review]
Bug 14366 - Units doesn't get saved usefully for patroncards

This patch causes the "Units" to be saved and displayed correctly
for the "Edit layout" screen in Patroncards.

_TEST PLAN_

Before applying:
0) Create a new layout
1) Edit the layout, change the units, and click Save
2) Edit the layout again, and notice the units are still "PostScript Points"

Apply the patch:
3) Edit the layout again, change the units, and click Save
4) Edit the layout again, note that the units have changed to your
selection

5) Rejoice

Signed-off-by: Nick Clemens <nick@quecheelibrary.org>

Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Comment 9 Tomás Cohen Arazi 2015-07-08 18:19:44 UTC
Patch pushed to master.

Thanks David!
Comment 10 Chris Cormack 2015-07-14 20:32:57 UTC
Pushed to 3.20.x will be in 3.20.2
Comment 11 Mason James 2015-07-25 13:11:22 UTC
Pushed to 3.16.x, will be in 3.16.13