Propagate SQL upgrade changes to base schema/data files.
Signed-off-by: Bill Erickson <berickxx@gmail.com>
CREATE INDEX config_copy_tag_type_owner_idx
ON config.copy_tag_type (owner);
+CREATE TABLE config.print_template (
+ id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL,
+ label TEXT NOT NULL, -- i18n
+ owner INT NOT NULL REFERENCES actor.org_unit (id),
+ active BOOLEAN NOT NULL DEFAULT FALSE,
+ locale TEXT REFERENCES config.i18n_locale(code)
+ ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
+ content_type TEXT NOT NULL DEFAULT 'text/html',
+ template TEXT NOT NULL,
+ CONSTRAINT name_once_per_lib UNIQUE (owner, name),
+ CONSTRAINT label_once_per_lib UNIQUE (owner, label)
+);
+
COMMIT;
( 609, 'MANAGE_CUSTOM_PERM_GRP_TREE', oils_i18n_gettext( 609,
'Allows a user to manage custom permission group lists.', 'ppl', 'description' )),
( 610, 'CLEAR_PURCHASE_REQUEST', oils_i18n_gettext(610,
- 'Clear Completed User Purchase Requests', 'ppl', 'description'))
+ 'Clear Completed User Purchase Requests', 'ppl', 'description')),
+ ( 611, 'ADMIN_PRINT_TEMPLATE', oils_i18n_gettext(611,
+ 'Modify print templates', 'ppl', 'description'))
;
)
);
+
+INSERT INTO config.print_template
+ (id, name, locale, active, owner, label, template)
+VALUES (
+ 1, 'patron_address', 'en-US', FALSE,
+ (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL),
+ oils_i18n_gettext(1, 'Address Label', 'cpt', 'label'),
+$TEMPLATE$
+[%-
+ SET patron = template_data.patron;
+ SET addr = template_data.address;
+-%]
+<div>
+ <div>
+ [% patron.first_given_name %]
+ [% patron.second_given_name %]
+ [% patron.family_name %]
+ </div>
+ <div>[% addr.street1 %]</div>
+ [% IF addr.street2 %]<div>[% addr.street2 %]</div>[% END %]
+ <div>
+ [% addr.city %], [% addr.state %] [% addr.post_code %]
+ </div>
+</div>
+$TEMPLATE$
+);
+
+-- Allow for 1k stock templates
+SELECT SETVAL('config.print_template_id_seq'::TEXT, 1000);
+
-
BEGIN;
-/*
-No longer have to deliver print templates to the client or store as workstatoin settings
--- trade-off is print data is now sent to the server
-Can define per-locale templates.
-immune to future technology changes
-Angular template modification requires recompiling the Angular build.
-https://metacpan.org/pod/HTML::Restrict
-security concerns of staff modifing templates directly since
-they execute in the borwser context.
-offline caveat
-*/
-
-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version);
CREATE TABLE config.print_template (
CONSTRAINT label_once_per_lib UNIQUE (owner, label)
);
-INSERT INTO config.print_template (id, name, locale, owner, label, template)
+INSERT INTO config.print_template
+ (id, name, locale, active, owner, label, template)
VALUES (
- 1, 'patron_address', 'en-US',
+ 1, 'patron_address', 'en-US', FALSE,
(SELECT id FROM actor.org_unit WHERE parent_ou IS NULL),
oils_i18n_gettext(1, 'Address Label', 'cpt', 'label'),
$TEMPLATE$
SET patron = template_data.patron;
SET addr = template_data.address;
-%]
-<div style="font-size:.7em;">
+<div>
<div>
[% patron.first_given_name %]
[% patron.second_given_name %]
$TEMPLATE$
);
--- TODO: add print template permission
-
-- Allow for 1k stock templates
SELECT SETVAL('config.print_template_id_seq'::TEXT, 1000);
+INSERT INTO permission.perm_list (id, code, description)
+VALUES (611, 'ADMIN_PRINT_TEMPLATE',
+ oils_i18n_gettext(611, 'Modify print templates', 'ppl', 'description'));
+
COMMIT;