Bugzilla – Attachment 156469 Details for
Bug 33478
Customise the format of notices when they are printed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33478: [WIP] CSS area instead of specific style inputs
Bug-33478-WIP-CSS-area-instead-of-specific-style-i.patch (text/plain), 21.11 KB, created by
Aleisha Amohia
on 2023-10-03 00:07:27 UTC
(
hide
)
Description:
Bug 33478: [WIP] CSS area instead of specific style inputs
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2023-10-03 00:07:27 UTC
Size:
21.11 KB
patch
obsolete
>From a4aeb5e54fb9f715871a2007b3f90bc6bcf6c778 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Tue, 3 Oct 2023 00:03:12 +0000 >Subject: [PATCH] Bug 33478: [WIP] CSS area instead of specific style inputs > >This patch implements a single style field for the slip to allow for more advanced CSS customisation. This prevents the forcing of default styles which override the SlipCSS syspref settings. There are links to insert selectors as helpers. >--- > .../bug_33478-add_letter_columns.pl | 46 +------ > installer/data/mysql/kohastructure.sql | 7 +- > .../includes/notice_format_translations.inc | 16 --- > .../prog/en/includes/slip_content.inc | 15 --- > .../prog/en/modules/circ/printslip.tt | 3 +- > .../prog/en/modules/members/printfeercpt.tt | 3 +- > .../prog/en/modules/members/printinvoice.tt | 3 +- > .../prog/en/modules/members/printnotice.tt | 3 +- > .../prog/en/modules/pos/printreceipt.tt | 3 +- > .../prog/en/modules/tools/letter.tt | 122 +++++++----------- > tools/letter.pl | 32 +---- > 11 files changed, 62 insertions(+), 191 deletions(-) > delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/notice_format_translations.inc > >diff --git a/installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl b/installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl >index 772413026be..91caa660790 100644 >--- a/installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl >+++ b/installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl >@@ -7,52 +7,12 @@ return { > my ($args) = @_; > my ($dbh, $out) = @$args{qw(dbh out)}; > >- if( !column_exists( 'letter', 'font_size' ) ) { >+ if( !column_exists( 'letter', 'style' ) ) { > $dbh->do(q{ >- ALTER TABLE letter ADD COLUMN `font_size` int(4) NOT NULL DEFAULT 14 AFTER `updated_on` >+ ALTER TABLE letter ADD COLUMN `style` mediumtext DEFAULT NULL AFTER `updated_on` > }); > >- say $out "Added column 'letter.font_size'"; >- } >- >- if( !column_exists( 'letter', 'text_justify' ) ) { >- $dbh->do(q{ >- ALTER TABLE letter ADD COLUMN `text_justify` enum('L','C','R') NOT NULL DEFAULT 'L' AFTER `font_size` >- }); >- >- say $out "Added column 'letter.text_justify'"; >- } >- >- if( !column_exists( 'letter', 'units' ) ) { >- $dbh->do(q{ >- ALTER TABLE letter ADD COLUMN `units` enum('POINT','INCH','MM','CM') NOT NULL DEFAULT 'INCH' AFTER `text_justify` >- }); >- >- say $out "Added column 'letter.units'"; >- } >- >- if( !column_exists( 'letter', 'notice_width' ) ) { >- $dbh->do(q{ >- ALTER TABLE letter ADD COLUMN `notice_width` float NOT NULL DEFAULT 8.5 AFTER `units` >- }); >- >- say $out "Added column 'letter.notice_width'"; >- } >- >- if( !column_exists( 'letter', 'top_margin' ) ) { >- $dbh->do(q{ >- ALTER TABLE letter ADD COLUMN `top_margin` float NOT NULL DEFAULT 0 AFTER `notice_width` >- }); >- >- say $out "Added column 'letter.top_margin'"; >- } >- >- if( !column_exists( 'letter', 'left_margin' ) ) { >- $dbh->do(q{ >- ALTER TABLE letter ADD COLUMN `left_margin` float NOT NULL DEFAULT 0 AFTER `top_margin` >- }); >- >- say $out "Added column 'letter.left_margin'"; >+ say $out "Added column 'letter.style'"; > } > }, > }; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index d2d2480a9ac..758594fb178 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3926,12 +3926,7 @@ CREATE TABLE `letter` ( > `message_transport_type` varchar(20) NOT NULL DEFAULT 'email' COMMENT 'transport type for this notice', > `lang` varchar(25) NOT NULL DEFAULT 'default' COMMENT 'lang of the notice', > `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification', >- `font_size` int(4) NOT NULL DEFAULT 14 COMMENT 'font size used when notice is printed', >- `text_justify` enum('L','C','R') NOT NULL DEFAULT 'L' COMMENT 'text justification used when notice is printed', >- `units` enum('POINT','INCH','MM','CM') NOT NULL DEFAULT 'INCH' COMMENT 'units to use for print measurements', >- `notice_width` float NOT NULL DEFAULT 8.5 COMMENT 'width of notice', >- `top_margin` float NOT NULL DEFAULT 0 COMMENT 'top margin for notice', >- `left_margin` float NOT NULL DEFAULT 0 COMMENT 'left margin for notice', >+ `style` mediumtext DEFAULT NULL COMMENT 'custom styles for this notice', > PRIMARY KEY (`id`), > UNIQUE KEY `letter_uniq_1` (`module`,`code`,`branchcode`,`message_transport_type`,`lang`), > KEY `message_transport_type_fk` (`message_transport_type`), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/notice_format_translations.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/notice_format_translations.inc >deleted file mode 100644 >index 972a911e7be..00000000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/notice_format_translations.inc >+++ /dev/null >@@ -1,16 +0,0 @@ >-[% BLOCK translate_justification_types %] >- [% SWITCH type %] >- [% CASE 'L' %]left >- [% CASE 'C' %]center >- [% CASE 'R' %]right >- [% END %] >-[% END %] >- >-[% BLOCK translate_unit_types %] >- [% SWITCH type %] >- [% CASE 'POINT' %]pt >- [% CASE 'INCH' %]in >- [% CASE 'MM' %]mm >- [% CASE 'CM' %]cm >- [% END %] >-[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/slip_content.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/slip_content.inc >index 10b754d77f9..07e00776b13 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/slip_content.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/slip_content.inc >@@ -1,18 +1,3 @@ >-<style> >- #slip, #receipt { >- text-align:[% PROCESS translate_justification_types type=notice.text_justify | trim %]; >- font-size:[% notice.font_size %]px; >- width:[% notice.notice_width %][% PROCESS translate_unit_types type=notice.units | trim %]; >- margin-top:[% notice.top_margin %][% PROCESS translate_unit_types type=notice.units | trim %]; >- margin-left:[% notice.left_margin %][% PROCESS translate_unit_types type=notice.units | trim %]; >- } >- >- h3, h4, th, td, th:last-child, td:last-child { >- text-align:[% PROCESS translate_justification_types type=notice.text_justify | trim %]; >- font-size:[% notice.font_size %]px; >- } >-</style> >- > [% IF notice.is_html %] > [% notice.content | $raw %] > [% ELSE %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >index 5596c769473..2ac23e1bc05 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >@@ -29,12 +29,11 @@ > [% IF ( Koha.Preference('SlipCSS') ) %] > <link rel="stylesheet" type="text/css" href="[% Koha.Preference('SlipCSS') | $raw %]" /> > [% END %] >+<link rel="stylesheet" type="text/css" href="[% slip.style | $raw %]" /> > > [% INCLUDE 'slip-print.inc' #printThenClose %] > </head> > >-[% PROCESS 'notice_format_translations.inc' %] >- > <body id="circ_printslip" class="circ"> > <div id="receipt"> > [% IF ( slip ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt >index 212ec61c2f0..ecc75eca542 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printfeercpt.tt >@@ -15,11 +15,10 @@ > <link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" /> > > [% Asset.css("css/printreceiptinvoice.css") | $raw %] >+<link rel="stylesheet" type="text/css" href="[% slip.style | $raw %]" /> > [% INCLUDE 'blocking_errors.inc' %] > </head> > >-[% PROCESS 'notice_format_translations.inc' %] >- > <body id="pat_printfeercpt" class="pat"> > <div id="receipt"> > [% IF ( slip ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt >index f1a2669a598..0499eef386e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt >@@ -15,11 +15,10 @@ > <link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" /> > > [% Asset.css("css/printreceiptinvoice.css") | $raw %] >+<link rel="stylesheet" type="text/css" href="[% slip.style | $raw %]" /> > [% INCLUDE 'blocking_errors.inc' %] > </head> > >-[% PROCESS 'notice_format_translations.inc' %] >- > <body id="printinvoice" class="pat"> > <div id="receipt"> > [% IF ( slip ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt >index e9412fd488f..11ddcc384f7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt >@@ -18,10 +18,9 @@ > [% IF ( Koha.Preference('SlipCSS') ) %] > <link rel="stylesheet" type="text/css" href="[% Koha.Preference('SlipCSS') | $raw %]" /> > [% END %] >+<link rel="stylesheet" type="text/css" href="[% slip.style | $raw %]" /> > </head> > >-[% PROCESS 'notice_format_translations.inc' %] >- > <body id="members_printslip" class="member"> > <div id="slip"> > [% IF ( slip ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/printreceipt.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/printreceipt.tt >index 67d38105970..5986cd10edd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/printreceipt.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/printreceipt.tt >@@ -14,11 +14,10 @@ > <link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" /> > > [% Asset.css("css/printreceiptinvoice.css") | $raw %] >+<link rel="stylesheet" type="text/css" href="[% slip.style | $raw %]" /> > [% INCLUDE 'blocking_errors.inc' %] > </head> > >-[% PROCESS 'notice_format_translations.inc' %] >- > <body id="pat_printfeercpt" class="pat"> > <div id="receipt"> > [% IF ( slip ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >index ed7f083f63b..ddba3059009 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >@@ -51,29 +51,16 @@ > .panel-group { > margin-top: 3px; > } >+ .css-helper::after { >+ content: " | "; >+ } >+ .css-helper:last-child::after { >+ content: none; >+ } > </style> > [% END %] > </head> > >-[% text_justification_types = [ 'L','C','R' ] %] >-[% BLOCK translate_justification_types %] >- [% SWITCH type %] >- [% CASE 'L' %]<span>Left</span> >- [% CASE 'C' %]<span>Center</span> >- [% CASE 'R' %]<span>Right</span> >- [% END %] >-[% END %] >- >-[% units = [ 'POINT','INCH','MM','CM' ] %] >-[% BLOCK translate_unit_types %] >- [% SWITCH type %] >- [% CASE 'POINT' %]<span>PostScript points</span> >- [% CASE 'INCH' %]<span>US Inches</span> >- [% CASE 'MM' %]<span>SI Millimeters</span> >- [% CASE 'CM' %]<span>SI Centimeters</span> >- [% END %] >-[% END %] >- > <body id="tools_letter" class="tools"> > [% WRAPPER 'header.inc' %] > [% INCLUDE 'letters-search.inc' %] >@@ -668,60 +655,25 @@ > <div class="panel-body"> > <fieldset class="rows"> > <div class="dialog message">These format settings apply when a notice is printed.</div> >- [% SET param = letters.$lang.params %] >- <div class="col-md-6"> >- <ol> >- <li> >- <label for="text_justify">Text justification: </label> >- <select name="text_justify" id="text_justify"> >- [% FOREACH text_justification_type IN text_justification_types %] >- [% IF ( text_justification_type == param.text_justify ) %] >- <option value="[% text_justification_type | html %]" selected="selected">[% PROCESS translate_justification_types type=text_justification_type %]</option> >- [% ELSE %] >- <option value="[% text_justification_type | html %]">[% PROCESS translate_justification_types type=text_justification_type %]</option> >- [% END %] >- [% END %] >- </select> >- </li> >- <li> >- <label for="font_size">Font size: </label> >- <input type="text" name="font_size" id="font_size" size="2" value="[% param.font_size | html %]" /> >- </li> >- <li> >- <label for="format_all">Apply format settings to all notices:</label> >- <input type="checkbox" name="format_all" id="format_all" value="1" /> >- <span class="hint">Existing format settings will be overwritten.</span> >- </li> >- </ol> >- </div> >- <div class="col-md-6"> >- <ol> >- <li> >- <label for="units">Units:</label> >- <select id="units" name="units"> >- [% FOREACH unit IN units %] >- [% IF ( unit == param.units ) %] >- <option value="[% unit | html %]" selected="selected">[% PROCESS translate_unit_types type=unit %]</option> >- [% ELSE %] >- <option value="[% unit | html %]">[% PROCESS translate_unit_types type=unit %]</option> >- [% END %] >- [% END %] >- </select> >- </li> >- <li> >- <label for="notice_width">Notice width:</label> >- <input type="text" size="4" name="notice_width" id="notice_width" value="[% param.notice_width | html %]" /> >- </li> >- <li> >- <label for="top_margin">Top margin:</label> >- <input type="text" size="4" name="top_margin" id="top_margin" value="[% param.top_margin | html %]" /> >- </li> >- <li> >- <label for="left_margin">Left margin:</label> >- <input type="text" size="4" name="left_margin" id="left_margin" value="[% param.left_margin | html %]" /> >- </li> >- </ol> >- </div> >+ <div class="col-md-12"> >+ <ol> >+ <li id="css-helpers"> >+ <label>Insert selectors to apply styles to: </label> >+ <a class="css-helper" id="headings">Headings</a> >+ <a class="css-helper" id="tables">Tables</a> >+ <a class="css-helper" id="text">All text</a> >+ </li> >+ <li> >+ <label for="style">Style (CSS): </label> >+ <textarea id="style" name="style" rows="15" cols="80">[% letters.$lang.params.style | $raw %]</textarea> >+ </li> >+ <li> >+ <label for="format_all">Apply format settings to all notices:</label> >+ <input type="checkbox" name="format_all" id="format_all" value="1" /> >+ <span class="hint">Existing format settings will be overwritten.</span> >+ </li> >+ </ol> >+ </div> > </fieldset> <!-- /.rows.mtt --> > </div> <!-- /.panel-body --> > </div> <!-- /.panel-collapse --> >@@ -746,6 +698,30 @@ > var new_lettercode = '[% new_lettercode | html %]'; > var new_branchcode = '[% new_branchcode | html %]'; > var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'notices', 'lettert', 'json' ) | $raw %]; >+ $(document).ready(function(){ >+ $("#headings").click(function(){ >+ $("#style").val(function(i, text) { >+ return text + '\nh1, h2, h3, h4, h5, h6 {\n' + >+ '// insert CSS here\n' + >+ '}'; >+ }); >+ }); >+ $("#tables").click(function(){ >+ $("#style").val(function(i, text) { >+ return text + '\ntable, th, td, th:last-child, td:last-child {\n' + >+ '// insert CSS here\n' + >+ '}'; >+ }); >+ }); >+ $("#text").click(function(){ >+ $("#style").val(function(i, text) { >+ return text + '\nh1, h2, h3, h4, h5, h6,\n' + >+ 'table, th, td, th:last-child, td:last-child {\n' + >+ '// insert CSS here\n' + >+ '}'; >+ }); >+ }); >+ }); > </script> > [% Asset.js("js/letter.js") | $raw %] > [% END %] >diff --git a/tools/letter.pl b/tools/letter.pl >index b23e3de2289..8af5a1049d2 100755 >--- a/tools/letter.pl >+++ b/tools/letter.pl >@@ -310,12 +310,7 @@ sub add_validate { > my $oldmodule = $input->param('oldmodule'); > my $code = $input->param('code'); > my $name = $input->param('name'); >- my $text_justify = $input->param('text_justify'); >- my $font_size = $input->param('font_size'); >- my $units = $input->param('units'); >- my $notice_width = $input->param('notice_width'); >- my $top_margin = $input->param('top_margin'); >- my $left_margin = $input->param('left_margin'); >+ my $style = $input->param('style'); > my $format_all = $input->param('format_all'); > my @mtt = $input->multi_param('message_transport_type'); > my @title = $input->multi_param('title'); >@@ -326,16 +321,7 @@ sub add_validate { > if ( $format_all ) { > my @letters = Koha::Notice::Templates->search({ lang => $lang })->as_list; > foreach my $letter ( @letters ) { >- $letter->set( >- { >- text_justify => $text_justify, >- font_size => $font_size, >- units => $units, >- notice_width => $notice_width, >- top_margin => $top_margin, >- left_margin => $left_margin, >- } >- )->store; >+ $letter->set({ style => $style })->store; > } > } > my $is_html = $input->param("is_html_$mtt\_$lang"); >@@ -371,12 +357,7 @@ sub add_validate { > title => $title, > content => $content, > lang => $lang, >- text_justify => $text_justify, >- font_size => $font_size, >- units => $units, >- notice_width => $notice_width, >- top_margin => $top_margin, >- left_margin => $left_margin, >+ style => $style > } > )->store; > >@@ -392,12 +373,7 @@ sub add_validate { > content => $content, > message_transport_type => $mtt, > lang => $lang, >- text_justify => $text_justify, >- font_size => $font_size, >- units => $units, >- notice_width => $notice_width, >- top_margin => $top_margin, >- left_margin => $left_margin, >+ style => $style > } > )->store; > logaction( 'NOTICES', 'CREATE', $letter->id, $letter->content, >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33478
:
149743
|
149785
|
149786
|
149787
|
149914
|
149915
|
149916
|
149917
|
149918
|
149999
|
150000
|
150001
|
150002
|
150003
|
150004
|
150005
|
150006
|
150007
|
150008
|
150009
|
150010
|
150011
|
150012
|
150265
|
150266
|
150267
|
150268
|
150269
|
150270
|
150271
|
150272
|
150273
|
150274
|
150275
|
150276
|
150277
|
150324
|
150325
|
150326
|
150327
|
150328
|
150329
|
150330
|
150331
|
150332
|
150333
|
150334
|
150335
|
150336
|
150337
|
150338
|
150339
|
150340
|
150341
|
150342
|
150343
|
150344
|
150345
|
151548
|
151580
|
151581
|
151582
|
151583
|
151584
|
151585
|
151586
|
151587
|
151588
|
151589
|
151590
|
151591
|
151592
|
151593
|
156469
|
157368
|
157369
|
157370
|
157371
|
157372
|
157373
|
157374
|
157375
|
157376
|
157377
|
157378
|
157379
|
157380
|
157381
|
157382
|
157387
|
158835
|
158836
|
158837
|
158838
|
158839
|
158840
|
158841
|
158842
|
158843
|
158844
|
158845
|
158846
|
158847
|
158848
|
158849
|
158856
|
162556
|
162557
|
162558
|
162559
|
162560
|
162561
|
162562
|
162563
|
162564
|
162565
|
162566
|
162567
|
162568
|
162569
|
163903
|
163904
|
163905
|
163906
|
163907
|
163908
|
163909
|
163910
|
163911
|
163912
|
163913
|
163914
|
163915
|
163916
|
163924
|
163925
|
163926
|
163927
|
163928
|
163929
|
163930
|
163931
|
163932
|
163933
|
163934
|
163935
|
163936
|
163937
|
163938
|
164719
|
164720
|
164721
|
164722
|
164723
|
164724
|
164725
|
164726
|
164727
|
164728
|
164729
|
164730
|
164731
|
164732
|
164733
|
164741
|
164742
|
164743
|
164744
|
164745
|
164746
|
164747
|
164748
|
164749
|
164750
|
164751
|
164752
|
164753
|
164754
|
164755