The regular expression introduced in bug 33478 outright replaces all CSS selectors in your local styles. This means that whatever styles you've defined will be applied to ALL elements of the notice template and not the specific one's you're attempting to target.
We should replace it with: [% slip.style.replace('([^\{\}]+?)\s*\{', '#slip_' _ slip.id _ ' $1 {') | $raw %] This will prepend the $slip_ID selector to any and all local selectors instead of replacing them
I also propose moving the <style> tags up into the <head> where they belong, as not all browsers support such tags inside the <body> and it's against the HTML standard to have them there.
Created attachment 172380 [details] [review] Bug 38089: Move style to head and correct regular expression This patch moves the local style sections from the body to the head where they belong and it also updates the regular expression used to prepend the slip_id id to css selectors rather than replace them
Created attachment 172421 [details] [review] Bug 38089: Move style to head and correct regular expression This patch moves the local style sections from the body to the head where they belong and it also updates the regular expression used to prepend the slip_id id to css selectors rather than replace them To test: 1 - Create a new notice in the 'Patron (custom slips)' module called 'Testing' 2 - Set print content as: Try the <span class="styled">styling</span> stuff. 3 - Set the 'Format' as: .styled {color:red;font-weight: bold;} 4 - Set system preference IntrnaetSlipPrinterJS to "//test" http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=IntranetSlipPrinterJS This will prevent auto printing popup 5 - Go to a patron and click Print -> Print Testing 6 - Note incorrect styling 7 - Apply patch, restart all 8 - Print Testing again 9 - Confirm styling is correct
Created attachment 172422 [details] [review] Bug 38089: (QA follow-up) Ensure style works on members/printslip.pl When moving the style up, it was moved before the code that handles printing a single slip, i.e. taking the variables and forming a slip hash. This patch moves that code to the top and additionally passes through the CODE of the notice so the ID is not blank
Created attachment 172464 [details] [review] Bug 38089: Move style to head and correct regular expression This patch moves the local style sections from the body to the head where they belong and it also updates the regular expression used to prepend the slip_id id to css selectors rather than replace them To test: 1 - Create a new notice in the 'Patron (custom slips)' module called 'Testing' 2 - Set print content as: Try the <span class="styled">styling</span> stuff. 3 - Set the 'Format' as: .styled {color:red;font-weight: bold;} 4 - Set system preference IntrnaetSlipPrinterJS to "//test" http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=IntranetSlipPrinterJS This will prevent auto printing popup 5 - Go to a patron and click Print -> Print Testing 6 - Note incorrect styling 7 - Apply patch, restart all 8 - Print Testing again 9 - Confirm styling is correct Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 172465 [details] [review] Bug 38089: (QA follow-up) Ensure style works on members/printslip.pl When moving the style up, it was moved before the code that handles printing a single slip, i.e. taking the variables and forming a slip hash. This patch moves that code to the top and additionally passes through the CODE of the notice so the ID is not blank Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 172473 [details] [review] Bug 38089: (follow-up) More fixes for errors in original submission The original submission missed a number of slip types that are print on demand without queueing. These all need an "id" passing in to the template and in some cases we were also missing passing in the new style parameter too (preservation)
Strictly speaking we are missing either a SO or a QA person here ;)
Pushed for 24.11! Well done everyone, thank you!
Backported to 24.05.x for upcoming 24.05.06