webstaff: new org unit settings for print labels collab/gmcharlt/webstaff-sprint-4-5
authorJason Etheridge <jason@esilibrary.com>
Tue, 18 Apr 2017 04:59:14 +0000 (00:59 -0400)
committerJason Etheridge <jason@esilibrary.com>
Tue, 18 Apr 2017 14:09:28 +0000 (10:09 -0400)
and fix to stock call number template for affixes

and cn_wrap filter for call numbers

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.webstaff_print_label_ou_settings.sql [new file with mode: 0644]
Open-ILS/src/templates/staff/cat/printlabels/t_view.tt2
Open-ILS/src/templates/staff/share/print_templates/t_item_label.tt2
Open-ILS/src/templates/staff/share/print_templates/t_item_label_cn.tt2
Open-ILS/web/js/ui/default/staff/cat/printlabels/app.js

index 6b49c3c..526486d 100644 (file)
@@ -16628,6 +16628,207 @@ VALUES
      'coust', 'description'),
  'bool');
 
+
+INSERT into config.org_unit_setting_type (
+     name
+    ,grp
+    ,label
+    ,description
+    ,datatype
+) VALUES ( ----------------------------------------
+     'webstaff.cat.label.font.family'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.font.family'
+        ,'Item Print Label Font Family'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.font.family'
+        ,'Set the preferred font family for item print labels. You can specify a list of CSS fonts, separated by commas, in order of preference; the system will use the first font it finds with a matching name. For example, "Arial, Helvetica, serif"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.font.size'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.font.size'
+        ,'Item Print Label Font Size'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.font.size'
+        ,'Set the default font size for item print labels. Please include a unit of measurement that is valid CSS. For example, "12pt" or "16px" or "1em"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.font.weight'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.font.weight'
+        ,'Item Print Label Font Weight'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.font.weight'
+        ,'Set the default font weight for item print labels. Please use the CSS specification for values for font-weight.  For example, "normal", "bold", "bolder", or "lighter"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.left_label.left_margin'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.left_label.left_margin'
+        ,'Item Print Label - Left Margin for Left Label'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.left_label.left_margin'
+        ,'Set the default left margin for the leftmost item print Label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.right_label.left_margin'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.right_label.left_margin'
+        ,'Item Print Label - Left Margin for Right Label'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.right_label.left_margin'
+        ,'Set the default left margin for the rightmost item print label (or in other words, the desired space between the two labels). Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.left_label.height'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.left_label.height'
+        ,'Item Print Label - Height for Left Label'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.left_label.height'
+        ,'Set the default height for the leftmost item print label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.left_label.width'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.left_label.width'
+        ,'Item Print Label - Width for Left Label'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.left_label.width'
+        ,'Set the default width for the leftmost item print label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.right_label.height'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.right_label.height'
+        ,'Item Print Label - Height for Right Label'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.right_label.height'
+        ,'Set the default height for the rightmost item print label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.right_label.width'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.right_label.width'
+        ,'Item Print Label - Width for Right Label'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.right_label.width'
+        ,'Set the default width for the rightmost item print label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), (
+     'webstaff.cat.label.inline_css'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.inline_css'
+        ,'Item Print Label - Inline CSS'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.inline_css'
+        ,'This setting allows you to inject arbitrary CSS into the item print label template.  For example, ".printlabel { text-transform: uppercase; }"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), (
+     'webstaff.cat.label.call_number_wrap_filter_height'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.call_number_wrap_filter_height'
+        ,'Item Print Label - Call Number Wrap Filter Height'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.call_number_wrap_filter_height'
+        ,'This setting is used to set the default height (in number of lines) to use for call number wrapping in the left print label.'
+        ,'coust'
+        ,'description'
+    )
+    ,'integer'
+), (
+     'webstaff.cat.label.call_number_wrap_filter_width'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.call_number_wrap_filter_width'
+        ,'Item Print Label - Call Number Wrap Filter Width'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.call_number_wrap_filter_width'
+        ,'This setting is used to set the default width (in number of characters) to use for call number wrapping in the left print label.'
+        ,'coust'
+        ,'description'
+    )
+    ,'integer'
+);
+
 INSERT INTO config.global_flag (name, label, value, enabled) VALUES (
     'circ.holds.retarget_interval',
     oils_i18n_gettext(
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.webstaff_print_label_ou_settings.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.webstaff_print_label_ou_settings.sql
new file mode 100644 (file)
index 0000000..10e7ca7
--- /dev/null
@@ -0,0 +1,252 @@
+BEGIN;
+
+--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT into config.org_unit_setting_type (
+     name
+    ,grp
+    ,label
+    ,description
+    ,datatype
+) VALUES ( ----------------------------------------
+     'webstaff.cat.label.font.family'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.font.family'
+        ,'Item Print Label Font Family'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.font.family'
+        ,'Set the preferred font family for item print labels. You can specify a list of CSS fonts, separated by commas, in order of preference; the system will use the first font it finds with a matching name. For example, "Arial, Helvetica, serif"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.font.size'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.font.size'
+        ,'Item Print Label Font Size'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.font.size'
+        ,'Set the default font size for item print labels. Please include a unit of measurement that is valid CSS. For example, "12pt" or "16px" or "1em"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.font.weight'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.font.weight'
+        ,'Item Print Label Font Weight'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.font.weight'
+        ,'Set the default font weight for item print labels. Please use the CSS specification for values for font-weight.  For example, "normal", "bold", "bolder", or "lighter"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.left_label.left_margin'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.left_label.left_margin'
+        ,'Item Print Label - Left Margin for Left Label'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.left_label.left_margin'
+        ,'Set the default left margin for the leftmost item print Label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.right_label.left_margin'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.right_label.left_margin'
+        ,'Item Print Label - Left Margin for Right Label'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.right_label.left_margin'
+        ,'Set the default left margin for the rightmost item print label (or in other words, the desired space between the two labels). Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.left_label.height'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.left_label.height'
+        ,'Item Print Label - Height for Left Label'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.left_label.height'
+        ,'Set the default height for the leftmost item print label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.left_label.width'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.left_label.width'
+        ,'Item Print Label - Width for Left Label'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.left_label.width'
+        ,'Set the default width for the leftmost item print label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.right_label.height'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.right_label.height'
+        ,'Item Print Label - Height for Right Label'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.right_label.height'
+        ,'Set the default height for the rightmost item print label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), ( ----------------------------------------
+     'webstaff.cat.label.right_label.width'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.right_label.width'
+        ,'Item Print Label - Width for Right Label'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.right_label.width'
+        ,'Set the default width for the rightmost item print label. Please include a unit of measurement that is valid CSS. For example, "1in" or "2.5cm"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), (
+     'webstaff.cat.label.inline_css'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.inline_css'
+        ,'Item Print Label - Inline CSS'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.inline_css'
+        ,'This setting allows you to inject arbitrary CSS into the item print label template.  For example, ".printlabel { text-transform: uppercase; }"'
+        ,'coust'
+        ,'description'
+    )
+    ,'string'
+), (
+     'webstaff.cat.label.call_number_wrap_filter_height'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.call_number_wrap_filter_height'
+        ,'Item Print Label - Call Number Wrap Filter Height'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.call_number_wrap_filter_height'
+        ,'This setting is used to set the default height (in number of lines) to use for call number wrapping in the left print label.'
+        ,'coust'
+        ,'description'
+    )
+    ,'integer'
+), (
+     'webstaff.cat.label.call_number_wrap_filter_width'
+    ,'cat'
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.call_number_wrap_filter_width'
+        ,'Item Print Label - Call Number Wrap Filter Width'
+        ,'coust'
+        ,'label'
+    )
+    ,oils_i18n_gettext(
+         'webstaff.cat.label.call_number_wrap_filter_width'
+        ,'This setting is used to set the default width (in number of characters) to use for call number wrapping in the left print label.'
+        ,'coust'
+        ,'description'
+    )
+    ,'integer'
+
+
+);
+
+-- for testing, setting removal:
+--DELETE FROM actor.org_unit_setting WHERE name IN (
+--     'webstaff.cat.label.font.family'
+--    ,'webstaff.cat.label.font.size'
+--    ,'webstaff.cat.label.font.weight'
+--    ,'webstaff.cat.label.left_label.height'
+--    ,'webstaff.cat.label.left_label.width'
+--    ,'webstaff.cat.label.left_label.left_margin'
+--    ,'webstaff.cat.label.right_label.height'
+--    ,'webstaff.cat.label.right_label.width'
+--    ,'webstaff.cat.label.right_label.left_margin'
+--    ,'webstaff.cat.label.inline_css'
+--    ,'webstaff.cat.label.call_number_wrap_filter_height'
+--    ,'webstaff.cat.label.call_number_wrap_filter_width'
+--);
+--DELETE FROM config.org_unit_setting_type_log WHERE field_name IN (
+--     'webstaff.cat.label.font.family'
+--    ,'webstaff.cat.label.font.size'
+--    ,'webstaff.cat.label.font.weight'
+--    ,'webstaff.cat.label.left_label.height'
+--    ,'webstaff.cat.label.left_label.width'
+--    ,'webstaff.cat.label.left_label.left_margin'
+--    ,'webstaff.cat.label.right_label.height'
+--    ,'webstaff.cat.label.right_label.width'
+--    ,'webstaff.cat.label.right_label.left_margin'
+--    ,'webstaff.cat.label.inline_css'
+--    ,'webstaff.cat.label.call_number_wrap_filter_height'
+--    ,'webstaff.cat.label.call_number_wrap_filter_width'
+--);
+--DELETE FROM config.org_unit_setting_type WHERE name IN (
+--     'webstaff.cat.label.font.family'
+--    ,'webstaff.cat.label.font.size'
+--    ,'webstaff.cat.label.font.weight'
+--    ,'webstaff.cat.label.left_label.height'
+--    ,'webstaff.cat.label.left_label.width'
+--    ,'webstaff.cat.label.left_label.left_margin'
+--    ,'webstaff.cat.label.right_label.height'
+--    ,'webstaff.cat.label.right_label.width'
+--    ,'webstaff.cat.label.right_label.left_margin'
+--    ,'webstaff.cat.label.inline_css'
+--    ,'webstaff.cat.label.call_number_wrap_filter_height'
+--    ,'webstaff.cat.label.call_number_wrap_filter_width'
+--);
+
+
+COMMIT;
index 8829e85..418d4e8 100644 (file)
@@ -97,7 +97,7 @@
                 </h4>
                 <div eg-print-template-output ng-show="true"
                     content="print.cn_template_content"
-                    context="{ copy : preview_scope.copies[0] }"></div>
+                    context="{ copy : preview_scope.copies[0], get_cn_and_location_prefix : preview_scope.get_cn_and_location_prefix, get_cn_and_location_suffix : preview_scope.get_cn_and_location_suffix, settings : preview_scope.settings }"></div>
                 <h4>
                     [% l('Call Number Template') %]
                 </h4>
                 <div ng-repeat="copy in preview_scope.copies">
                     <div id="cn_for_copy_{{copy.id}}" eg-print-template-output ng-show="false"
                         content="print.cn_template_content"
-                        context="{ copy : copy }"></div>
+                        context="{ copy : copy, get_cn_and_location_prefix : preview_scope.get_cn_and_location_prefix, get_cn_and_location_suffix : preview_scope.get_cn_and_location_suffix, settings : preview_scope.settings }"></div>
                 </div>
             </div>
             <div ng-show="current_tab == 'call_numbers'">
             </div>
             <div ng-show="current_tab == 'settings'">
                 <div><span>[% l('These settings do get saved with templates and will override corresponding Library Settings.') %]<br/></span></div>
-                <!-- FIXME: pull these labels and descriptions from the IDL -->
-                <div class="row" style="border-top: solid black">
-                    <div class="col-md-6" style="font-weight: bold">[% l('Spine and pocket label font family') %]</div>
-                    <div class="col-md-6"><input type="text" ng-model="preview_scope.settings['cat.label.font.family']"></input></div>
-                </div>
-
-                <div class="row">
-                    <div>[% l('Set the preferred font family for spine and pocket labels. You can specify a list of fonts, separated by commas, in order of preference; the system will use the first font it finds with a matching name. For example, "Arial, Helvetica, serif".') %]</div>
-                </div>
-
-                <div class="row" style="border-top: solid black">
-                    <div class="col-md-6" style="font-weight: bold">[% l('Spine and pocket label font size') %]</div>
-                    <div class="col-md-6"><input type="text" ng-model="preview_scope.settings['cat.label.font.size']"></input></div>
-                </div>
-
-                <div class="row">
-                    <div>[% l('Set the default font size for spine and pocket labels') %]</div>
-                </div>
-
-                <div class="row" style="border-top: solid black">
-                    <div class="col-md-6" style="font-weight: bold">[% l('Spine and pocket label font weight') %]</div>
-                    <div class="col-md-6"><input type="text" ng-model="preview_scope.settings['cat.label.font.weight']"></input></div>
-                </div>
-
-                <div class="row">
-                    <div>[% l('Set the preferred font weight for spine and pocket labels. You can specify "normal", "bold", "bolder", or "lighter".') %]</div>
-                </div>
-
-                <div class="row" style="border-top: solid black">
-                    <div class="col-md-6" style="font-weight: bold">[% l('Spine label maximum lines') %]</div>
-                    <div class="col-md-6"><input type="text" ng-model="preview_scope.settings['cat.spine.line.height']"></input></div>
-                </div>
-
-                <div class="row">
-                    <div>[% l('Set the default maximum number of lines for spine labels.') %]</div>
-                </div>
-
-                <div class="row" style="border-top: solid black">
-                    <div class="col-md-6" style="font-weight: bold">[% l('Spine label left margin') %]</div>
-                    <div class="col-md-6"><input type="text" ng-model="preview_scope.settings['cat.spine.line.margin']"></input></div>
-                </div>
-
-                <div class="row">
-                    <div>[% l('Set the left margin for spine labels in number of characters.') %]</div>
-                </div>
-
-                <div class="row" style="border-top: solid black">
-                    <div class="col-md-6" style="font-weight: bold">[% l('Spine label line width') %]</div>
-                    <div class="col-md-6"><input type="text" ng-model="preview_scope.settings['cat.spine.line.width']"></input></div>
-                </div>
-
-                <div class="row">
-                    <div>[% l('Set the default line width for spine labels in number of characters. This specifies the boundary at which lines must be wrapped.') %]</div>
-                </div>
-
-                <div class="row" style="border-top: solid black">
-                    <div class="col-md-6" style="font-weight: bold">[% l('Pocket label maximum lines') %]</div>
-                    <div class="col-md-6"><input type="text" ng-model="preview_scope.settings['cat.pocket.line.height']"></input></div>
-                </div>
-
-                <div class="row">
-                    <div>[% l('Set the default maximum number of lines for pocket labels.') %]</div>
-                </div>
-
-                <div class="row" style="border-top: solid black">
-                    <div class="col-md-6" style="font-weight: bold">[% l('Pocket label left margin') %]</div>
-                    <div class="col-md-6"><input type="text" ng-model="preview_scope.settings['cat.pocket.line.margin']"></input></div>
-                </div>
-
-                <div class="row">
-                    <div>[% l('Set the left margin for pocket labels in number of characters.') %]</div>
-                </div>
-
-                <div class="row" style="border-top: solid black">
-                    <div class="col-md-6" style="font-weight: bold">[% l('Pocket label line width') %]</div>
-                    <div class="col-md-6"><input type="text" ng-model="preview_scope.settings['cat.pocket.line.width']"></input></div>
-                </div>
-
-                <div class="row">
-                    <div>[% l('Set the default line width for pocket labels in number of characters. This specifies the boundary at which lines must be wrapped.') %]</div>
+                <div ng-repeat="s in org_unit_settings">
+                    <div class="row" style="margin-top: 5mm; border-top: solid thin black">
+                        <div class="col-md-6" style="font-weight: bold">{{s.label}}</div>
+                        <div class="col-md-6"><input type="text" ng-model="preview_scope.settings[s.name]"></input></div>
+                    </div>
+
+                    <div class="row">
+                        <div>{{s.description}}</div>
+                    </div>
                 </div>
 
             </div>
index 0480193..263e1b0 100644 (file)
 <!--
-Template for printing spine and pocket labels.  Available
-macros include:
+Template for printing item labels (spine, pocket, etc.).
 
-copies - list; each entry is a fleshed, flattened copy record
-with a variety of keys, including
+Like receipt slip templates, this template uses AngularJS
+which fuses HTML and code together.  The code portion is
+mostly used to bind data for the item labels being printed
+to various HTML elements, but you can also use code to
+perform conditional logic, transform the data, etc.
 
-  barcode
-  call_number.record.simple_record.title (title)
-  call_number.label 
-  location.name
+-->
+<!--
 
-There are also utility functions:
+The <style> section is for holding most of our CSS, which
+is a language for controlling the appearance of HTML markup.
 
-  get_cn_for(copy)  -> returns the formatted call number from the
-                       Call Number Template and Call Numbers tab
+The {{ and }} markers are similar to HTML's < and > characters,
+but are for separating AngularJS variables and code from the
+HTML itself.
 
-  get_bib_for(copy) -> returns an "MVR" with keys like title,
-                       author, publisher, pubdate, series,
-                       edition, and isbn
+-->
+<style>
+    /* The .spine here defines a CSS "class", which in this case, is used by our
+       left label */
+    .spine {
 
-Line-wrapping may be done with the | wrap filter.  The first
-parameter is the number of characters to target for the string
-width.  The second parameter is the wrapping algorithm to use.
-The third parameter is the prefix to use for the second and
-subsequent wrapped lines.  One use for this is indentation
-with spaces.
+        /* this pulls from the "Item Print Label Font Family" setting, but will
+           default to 'monospace' */
+        font-family: {{settings['webstaff.cat.label.font.family'] || 'monospace'}};
 
-Available wrapping algorithms:
+        /* this pulls from the "Item Print Label Font Size" setting, but will
+           default to 'normal' */
+        font-size: {{settings['webstaff.cat.label.font.size'] || '10'}};
 
-once    = Wraps a line just once
-default = Keeps wrapping a line until no more wraps are possible
+        /* this pulls from the "Item Print Label Font Weight" setting, but will
+           default to 'normal' */
+        font-weight: {{settings['webstaff.cat.label.font.weight'] || 'normal'}};
 
-Certain library settings are also available:
+        /* this pulls from the "Item Print Label - Height for Left Label"
+           setting, but will default to '1.25in' */
+        height: {{settings['webstaff.cat.label.left_label.height'] || '1.25in'}};
+        min-height: {{settings['webstaff.cat.label.left_label.height'] || '1.25in'}};
+        max-height: {{settings['webstaff.cat.label.left_label.height'] || '1.25in'}};
 
-    Spine label maximum lines:           settings['cat.spine.line.height']
-    Spine label left margin:             settings['cat.spine.line.margin']
-    Spine label line width:              settings['cat.spine.line.width']
-    Spine and pocket label font family:  settings['cat.label.font.family']
-    Spine and pocket label font size:    settings['cat.label.font.size']
-    Spine and pocket label font weight:  settings['cat.label.font.weight']
+        /* this pulls from the "Item Print Label - Width for Left Label"
+           setting, but will default to '1in' */
+        width: {{settings['webstaff.cat.label.left_label.width'] || '1in'}};
+        min-width: {{settings['webstaff.cat.label.left_label.width'] || '1in'}};
+        max-width: {{settings['webstaff.cat.label.left_label.width'] || '1in'}};
 
--->
-<style>
-    .spine {
-        font-family: {{settings['cat.label.font.family'] || 'monospace'}};
-        font-weight: {{settings['cat.label.font.weight'] || 'normal'}};
-        font-size: {{settings['cat.label.font.size'] || '10'}};
-        height: {{settings['cat.spine.line.height'] || '1in'}};
-        width: {{settings['cat.spine.line.width'] || '1in'}};
-        left-margin: {{settings['cat.spine.line.margin'] || '0in'}};
+        /* this pulls from the "Item Print Label - Left Margin for Left Label"
+           setting, but will default to '0in' */
+        margin-left: {{settings['webstaff.cat.label.left_label.left_margin'] || '0in'}};
     }
+
+    /* This CSS class is used by our right label */
     .pocket {
-        font-family: {{settings['cat.label.font.family'] || 'monospace'}};
-        font-weight: {{settings['cat.label.font.weight'] || 'normal'}};
-        font-size: {{settings['cat.label.font.size'] || '10'}};
-        height: {{settings['cat.pocket.line.height'] || '1in'}};
-        width: {{settings['cat.pocket.line.width'] || '3in'}};
-        left-margin: {{settings['cat.pocket.line.margin'] || '0in'}};
+
+        /* this pulls from the "Item Print Label Font Family" setting, but will
+           default to 'monospace' */
+        font-family: {{settings['webstaff.cat.label.font.family'] || 'monospace'}};
+
+        /* this pulls from the "Item Print Label Font Size" setting, but will
+           default to 'normal' */
+        font-size: {{settings['webstaff.cat.label.font.size'] || '10'}};
+
+        /* this pulls from the "Item Print Label Font Weight" setting, but will
+           default to 'normal' */
+        font-weight: {{settings['webstaff.cat.label.font.weight'] || 'normal'}};
+
+        /* this pulls from the "Item Print Label - Height for Left Label"
+           setting, but will default to '1.25in' */
+        height: {{settings['webstaff.cat.label.right_label.height'] || '1.25in'}};
+        min-height: {{settings['webstaff.cat.label.right_label.height'] || '1.25in'}};
+        max-height: {{settings['webstaff.cat.label.right_label.height'] || '1.25in'}};
+
+        /* this pulls from the "Item Print Label - Width for Left Label"
+           setting, but will default to '2.625in' */
+        width: {{settings['webstaff.cat.label.right_label.width'] || '2.625in'}};
+        min-width: {{settings['webstaff.cat.label.right_label.width'] || '2.625in'}};
+        max-width: {{settings['webstaff.cat.label.right_label.width'] || '2.625in'}};
+
+        /* this pulls from the "Item Print Label - Left Margin for Left Label"
+           setting, but will default to '0in' */
+        margin-left: {{settings['webstaff.cat.label.right_label.left_margin'] || '0in'}};
+
     }
+
+    /* This is to help mitigate artifacts in the Preview pane which don't
+       actually print */
     .labels ::-webkit-scrollbar { 
         display: none; 
     }
+
+    /* This pulls from the "Item Print Label - Inline CSS" setting */
+    {{settings['webstaff.cat.label.inline_css']||''}}
+
 </style>
-<table class="labels" style="page-break-after: always;" ng-repeat="copy in copies">
-<tr valign="top">
-<td>
+
+<!-- Here we are implementing our combined label as 2-column HTML <table>, with
+     each table containing a <pre> tag for preserving whitespace and linefeeds.
+
+     The ng-repeat attribute is from AngularJS, and in this case is looping
+     through a list of all the items that were selected when the Print Label
+     interface was invoked.  Each iteration puts item data into the variable
+     "copy", which may be referenced in the HTML by escaping it with {{ and }}
+
+     The following are available, and you may treat these similar to the
+     "macros" in earlier versions of Evergreen:
+
+                copy['active_date']
+                copy['age_protect']
+                copy['alert_message']
+                copy['barcode']
+                copy['call_number.copies']
+                copy['call_number.create_date']
+                copy['call_number.deleted']
+                copy['call_number.edit_date']
+                copy['call_number.id']
+                copy['call_number.label']
+                copy['call_number.label_class']
+                copy['call_number.label_sortkey']
+                copy['call_number.notes']
+                copy['call_number.owning_lib']
+                copy['call_number.prefix.id']
+                copy['call_number.prefix.label']
+                copy['call_number.prefix.label_sortkey']
+                copy['call_number.prefix.owning_lib']
+                copy['call_number.record.active']
+                copy['call_number.record.author_field_entries']
+                copy['call_number.record.call_numbers']
+                copy['call_number.record.create_date']
+                copy['call_number.record.creator.ws_ou']
+                copy['call_number.record.deleted']
+                copy['call_number.record.edit_date']
+                copy['call_number.record.fingerprint']
+                copy['call_number.record.fixed_fields']
+                copy['call_number.record.full_record_entries']
+                copy['call_number.record.id']
+                copy['call_number.record.identifier_field_entries']
+                copy['call_number.record.keyword_field_entries']
+                copy['call_number.record.language']
+                copy['call_number.record.last_xact_id']
+                copy['call_number.record.marc']
+                copy['call_number.record.metarecord']
+                copy['call_number.record.notes']
+                copy['call_number.record.owner']
+                copy['call_number.record.quality']
+                copy['call_number.record.series_field_entries']
+                copy['call_number.record.share_depth']
+                copy['call_number.record.simple_record.author']
+                copy['call_number.record.simple_record.fingerprint']
+                copy['call_number.record.simple_record.id']
+                copy['call_number.record.simple_record.isbn']
+                copy['call_number.record.simple_record.issn']
+                copy['call_number.record.simple_record.pubdate']
+                copy['call_number.record.simple_record.publisher']
+                copy['call_number.record.simple_record.quality']
+                copy['call_number.record.simple_record.tcn_source']
+                copy['call_number.record.simple_record.tcn_value']
+                copy['call_number.record.simple_record.title']
+                copy['call_number.record.source']
+                copy['call_number.record.subject_field_entries']
+                copy['call_number.record.tcn_source']
+                copy['call_number.record.tcn_value']
+                copy['call_number.record.title_field_entries']
+                copy['call_number.suffix.id']
+                copy['call_number.suffix.label']
+                copy['call_number.suffix.label_sortkey']
+                copy['call_number.suffix.owning_lib']
+                copy['call_number.uri_maps']
+                copy['call_number.uris']
+                copy['circ_as_type']
+                copy['circ_lib']
+                copy['circ_modifier']
+                copy['circulate']
+                copy['copy_number']
+                copy['cost']
+                copy['create_date']
+                copy['deleted']
+                copy['deposit']
+                copy['deposit_amount']
+                copy['dummy_author']
+                copy['dummy_isbn']
+                copy['dummy_title']
+                copy['edit_date']
+                copy['fine_level']
+                copy['floating']
+                copy['holdable']
+                copy['id']
+                copy['loan_duration']
+                copy['location.checkin_alert']
+                copy['location.circulate']
+                copy['location.copies']
+                copy['location.deleted']
+                copy['location.holdable']
+                copy['location.hold_verify']
+                copy['location.id']
+                copy['location.label_prefix']
+                copy['location.label_suffix']
+                copy['location.name']
+                copy['location.opac_visible']
+                copy['location.orders']
+                copy['location.owning_lib']
+                copy['mint_condition']
+                copy['opac_visible']
+                copy['price']
+                copy['ref']
+                copy['status_changed_time']
+                copy['status.copy_active']
+                copy['status.holdable']
+                copy['status.id']
+                copy['status.is_available']
+                copy['status.name']
+                copy['status.opac_visible']
+                copy['status.restrict_copy_delete']
+
+    There are also two functions available.  The following pulls manually
+    edited call numbers for a given item:
+
+                get_cn_for(copy)
+
+    And this one pulls bibliographic data for a given item:
+
+                get_bib_for(copy)
+
+    It returns a data structure similar to "copy" that has the following fields:
+
+                get_bib_for(copy)['author']
+                get_bib_for(copy)['copy_count']
+                get_bib_for(copy)['doc_id']
+                get_bib_for(copy)['doc_type']
+                get_bib_for(copy)['edition']
+                get_bib_for(copy)['isbn']
+                get_bib_for(copy)['physical_description']
+                get_bib_for(copy)['pubdate']
+                get_bib_for(copy)['publisher']
+                get_bib_for(copy)['series.0']
+                get_bib_for(copy)['synopsis']
+                get_bib_for(copy)['tcn']
+                get_bib_for(copy)['title']
+                get_bib_for(copy)['toc']
+                get_bib_for(copy)['types_of_resource.0']
+
+    Finally, there are filter functions which can be used to modify or transform
+    data being outputted.  For example, consider the following:
+
+                get_bib_for(copy)['title'] | limitTo:28
+
+    This would show up to the first 28 characters for an item's title and
+    truncate the rest.  Now, this:
+
+                get_bib_for(copy)['title'] | wrap:28
+
+    This would try to the wrap the item's title every 28 characters.
+
+                get_bib_for(copy)['title'] | wrap:28:multi:'  '
+
+    This does the same thing but indents subsequent lines with 2 spaces each.
+    
+                get_bib_for(copy)['title'] | wrap:28:once:'  '
+
+    This wraps the title just once, prefixes the second line with two spaces,
+    and truncates anything after the 2nd line.
+
+-->
+
+<table class="labels" style="page-break-after: always;" ng-repeat="copy in copies"><tr valign="top"><td>
+
 <!-- Spine Label contents -->
-<!-- The get_cn_for() function will retrieve edited call numbers from the Call Numbers tab -->
 <pre class="spine" style="border:none" ng-show="true">
 {{get_cn_for(copy)}}
 </pre>
-</td>
-<td>
+
+</td><td>
+
 <!-- Pocket Label contents -->
 <pre class="pocket" style="border:none" ng-show="true">
 {{copy.barcode}}
@@ -79,6 +280,6 @@ Certain library settings are also available:
 {{get_bib_for(copy).author }}
 {{get_bib_for(copy).title | wrap:28:'once':' '}}
 </pre>
-</td>
-</tr>
-</table>
+
+</td></tr></table>
+
index 8e16381..85d201c 100644 (file)
@@ -1,11 +1,10 @@
 <pre>
-{{copy['call_number.prefix.label'] || copy['location.label_prefix']}}
 {{
-       
-       copy['call_number.label']
-       
-    |   wrap:5
-
+    [
+         get_cn_and_location_prefix(copy)
+        ,copy['call_number.label']
+        ,get_cn_and_location_suffix(copy)
+    ]
+    | cn_wrap:settings['webstaff.cat.label.call_number_wrap_filter_width']:settings['webstaff.cat.label.call_number_wrap_filter_height']:copy['call_number.label_class']
 }}
-{{copy['call_number.suffix.label'] || copy['location.label_suffix']}}
 </pre>
index 1815652..aa90fb4 100644 (file)
@@ -133,20 +133,62 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
                     ,'get_bib_for' : function(copy) {
                         return $scope.record_details[copy['call_number.record.id']];
                     }
+                    ,'get_cn_prefix' : function(copy) {
+                        return copy['call_number.prefix.label'];
+                    }
+                    ,'get_cn_suffix' : function(copy) {
+                        return copy['call_number.suffix.label'];
+                    }
+                    ,'get_location_prefix' : function(copy) {
+                        return copy['location.label_prefix'];
+                    }
+                    ,'get_location_suffix' : function(copy) {
+                        return copy['location.label_suffix'];
+                    }
+                    ,'get_cn_and_location_prefix' : function(copy,separator) {
+                        var prefix = copy['location.label_prefix'] + ' ' + copy['call_number.prefix.label'];
+                        prefix = prefix.trim();
+                        if (separator && prefix != '') { prefix += separator; }
+                        return prefix;
+                    }
+                    ,'get_cn_and_location_suffix' : function(copy,separator) {
+                        var suffix = copy['call_number.suffix.label'] + ' ' + copy['location.label_suffix'] ;
+                        suffix = suffix.trim();
+                        if (separator && suffix != '') { suffix = separator + suffix; }
+                        return suffix;
+                    }
                 };
                 $scope.record_details = {};
+                $scope.org_unit_settings = {};
 
                 var promises = [];
+                $scope.org_unit_setting_list = [
+                     'webstaff.cat.label.font.family'
+                    ,'webstaff.cat.label.font.size'
+                    ,'webstaff.cat.label.font.weight'
+                    ,'webstaff.cat.label.inline_css'
+                    ,'webstaff.cat.label.left_label.height'
+                    ,'webstaff.cat.label.left_label.left_margin'
+                    ,'webstaff.cat.label.left_label.width'
+                    ,'webstaff.cat.label.right_label.height'
+                    ,'webstaff.cat.label.right_label.left_margin'
+                    ,'webstaff.cat.label.right_label.width'
+                    ,'webstaff.cat.label.call_number_wrap_filter_height'
+                    ,'webstaff.cat.label.call_number_wrap_filter_width'
+                ];
+
+                promises.push(
+                    egCore.pcrud.search('coust',{name:$scope.org_unit_setting_list}).then(
+                         null
+                        ,null
+                        ,function(yaous) {
+                            $scope.org_unit_settings[yaous.name()] = egCore.idl.toHash(yaous, true);
+                        }
+                    )
+                );
 
                 promises.push(
-                    egCore.org.settings([
-                         'cat.label.font.family'
-                        ,'cat.label.font.size'
-                        ,'cat.label.font.weight'
-                        ,'cat.spine.line.height'
-                        ,'cat.spine.line.width'
-                        ,'cat.spine.line.margin'
-                    ]).then(function(res) {
+                    egCore.org.settings($scope.org_unit_setting_list).then(function(res) {
                         $scope.preview_scope.settings = res;
                         egCore.hatch.getItem('cat.printlabels.last_settings').then(function(last_settings) {
                             if (last_settings) {
@@ -186,7 +228,6 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
                     $q.all(promises2).then(function() {
                         // today, staff, current_location, etc.
                         egCore.print.fleshPrintScope($scope.preview_scope);
-                        console.log($scope.record_details);
                         $scope.template_changed(); // load the default
                         $scope.rebuild_cn_set();
                     });
@@ -316,16 +357,9 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
             $scope.preview_scope.settings[s] = undefined;
         }
         $scope.preview_scope.settings = {};
-        egCore.org.settings([
-             'cat.label.font.family'
-            ,'cat.label.font.size'
-            ,'cat.label.font.weight'
-            ,'cat.spine.line.height'
-            ,'cat.spine.line.width'
-            ,'cat.spine.line.margin'
-        ]).then(function(res) {
+        egCore.org.settings($scope.org_unit_setting_list).then(function(res) {
             $scope.preview_scope.settings = res;
-        })
+        });
 
         $scope.template_changed();
     }
@@ -397,6 +431,18 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
         }
     });
 
+    $scope.$watch("preview_scope.settings['webstaff.cat.label.call_number_wrap_filter_height']", function(newVal, oldVal) {
+        if (newVal && newVal != oldVal) {
+            $scope.rebuild_cn_set();
+        }
+    });
+
+    $scope.$watch("preview_scope.settings['webstaff.cat.label.call_number_wrap_filter_width']", function(newVal, oldVal) {
+        if (newVal && newVal != oldVal) {
+            $scope.rebuild_cn_set();
+        }
+    });
+
     $scope.current_tab = 'call_numbers';
     $scope.set_tab = function(tab) {
         $scope.current_tab = tab;
@@ -427,6 +473,91 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
     };
 }])
 
+.filter('cn_wrap', function() {
+    return function(input, w, h, wrap_type) {
+        var names;
+        var prefix = input[0];
+        var callnum = input[1];
+        var suffix = input[2];
+
+        if (!w) { w = 8; }
+        if (!h) { h = 9; }
+
+        /* handle spine labels differently if using LC */
+        if (wrap_type == 'lc' || wrap_type == 3) {
+            /* Establish a pattern where every return value should be isolated on its own line 
+               on the spine label: subclass letters, subclass numbers, cutter numbers, trailing stuff (date) */
+            var patt1 = /^([A-Z]{1,3})\s*(\d+(?:\.\d+)?)\s*(\.[A-Z]\d*)\s*([A-Z]\d*)?\s*(\d\d\d\d(?:-\d\d\d\d)?)?\s*(.*)$/i;
+            var result = callnum.match(patt1);
+            if (result) { 
+                callnum = result.slice(1).join('\t');  
+            } else {
+                callnum = callnum.split(/\s+/).join('\t');
+            } 
+
+            /* If result is null, leave callnum alone. Can't parse this malformed call num */
+        } else {
+            callnum = callnum.split(/\s+/).join('\t');
+        }
+
+        if (prefix) {
+            callnum = prefix + '\t' + callnum;
+        }
+        if (suffix) {
+            callnum += '\t' + suffix;
+        }
+
+        /* At this point, the call number pieces are separated by tab characters.  This allows
+        *  some space-containing constructs like "v. 1" to appear on one line
+        */
+        callnum = callnum.replace(/\t\t/g,'\t');  /* Squeeze out empties */ 
+        names = callnum.split('\t');
+        var j = 0; var tb = [];
+        while (j < h) {
+            
+            /* spine */
+            if (j < w) {
+
+                var name = names.shift();
+                if (name) {
+                    name = String( name );
+
+                    /* if the name is greater than the label width... */
+                    if (name.length > w) {
+                        /* then try to split it on periods */
+                        var sname = name.split(/\./);
+                        if (sname.length > 1) {
+                            /* if we can, then put the periods back in on each splitted element */
+                            if (name.match(/^\./)) sname[0] = '.' + sname[0];
+                            for (var k = 1; k < sname.length; k++) sname[k] = '.' + sname[k];
+                            /* and put all but the first one back into the names array */
+                            names = sname.slice(1).concat( names );
+                            /* if the name fragment is still greater than the label width... */
+                            if (sname[0].length > w) {
+                                /* then just truncate and throw the rest back into the names array */
+                                tb[j] = sname[0].substr(0,w);
+                                names = [ sname[0].substr(w) ].concat( names );
+                            } else {
+                                /* otherwise we're set */
+                                tb[j] = sname[0];
+                            }
+                        } else {
+                            /* if we can't split on periods, then just truncate and throw the rest back into the names array */
+                            tb[j] = name.substr(0,w);
+                            names = [ name.substr(w) ].concat( names );
+                        }
+                    } else {
+                        /* otherwise we're set */
+                        tb[j] = name;
+                    }
+                }
+            }
+            j++;
+        }
+        return tb.join('\n');
+    }
+})
+
 .filter('wrap', function() {
     return function(input, w, wrap_type, indent) {
         var output;