From: Jason Etheridge Date: Tue, 18 Apr 2017 04:59:14 +0000 (-0400) Subject: webstaff: new org unit settings for print labels X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fcollab%2Fgmcharlt%2Fwebstaff-sprint-4-5;p=working%2FEvergreen.git webstaff: new org unit settings for print labels and fix to stock call number template for affixes and cn_wrap filter for call numbers Signed-off-by: Jason Etheridge --- diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 6b49c3cc65..526486d9fe 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -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 index 0000000000..10e7ca758c --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.webstaff_print_label_ou_settings.sql @@ -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; diff --git a/Open-ILS/src/templates/staff/cat/printlabels/t_view.tt2 b/Open-ILS/src/templates/staff/cat/printlabels/t_view.tt2 index 8829e85482..418d4e8490 100644 --- a/Open-ILS/src/templates/staff/cat/printlabels/t_view.tt2 +++ b/Open-ILS/src/templates/staff/cat/printlabels/t_view.tt2 @@ -97,7 +97,7 @@
+ 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 }">

[% l('Call Number Template') %]

@@ -107,7 +107,7 @@
+ 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 }">
@@ -122,86 +122,15 @@
[% l('These settings do get saved with templates and will override corresponding Library Settings.') %]
- -
-
[% l('Spine and pocket label font family') %]
-
-
- -
-
[% 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".') %]
-
- -
-
[% l('Spine and pocket label font size') %]
-
-
- -
-
[% l('Set the default font size for spine and pocket labels') %]
-
- -
-
[% l('Spine and pocket label font weight') %]
-
-
- -
-
[% l('Set the preferred font weight for spine and pocket labels. You can specify "normal", "bold", "bolder", or "lighter".') %]
-
- -
-
[% l('Spine label maximum lines') %]
-
-
- -
-
[% l('Set the default maximum number of lines for spine labels.') %]
-
- -
-
[% l('Spine label left margin') %]
-
-
- -
-
[% l('Set the left margin for spine labels in number of characters.') %]
-
- -
-
[% l('Spine label line width') %]
-
-
- -
-
[% l('Set the default line width for spine labels in number of characters. This specifies the boundary at which lines must be wrapped.') %]
-
- -
-
[% l('Pocket label maximum lines') %]
-
-
- -
-
[% l('Set the default maximum number of lines for pocket labels.') %]
-
- -
-
[% l('Pocket label left margin') %]
-
-
- -
-
[% l('Set the left margin for pocket labels in number of characters.') %]
-
- -
-
[% l('Pocket label line width') %]
-
-
- -
-
[% l('Set the default line width for pocket labels in number of characters. This specifies the boundary at which lines must be wrapped.') %]
+
+
+
{{s.label}}
+
+
+ +
+
{{s.description}}
+
diff --git a/Open-ILS/src/templates/staff/share/print_templates/t_item_label.tt2 b/Open-ILS/src/templates/staff/share/print_templates/t_item_label.tt2 index 0480193a53..263e1b07ee 100644 --- a/Open-ILS/src/templates/staff/share/print_templates/t_item_label.tt2 +++ b/Open-ILS/src/templates/staff/share/print_templates/t_item_label.tt2 @@ -1,77 +1,278 @@ + + - - -
+ + + + - - -
+ -
 {{get_cn_for(copy)}}
 
-
+ + +
 {{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':' '}}
 
-
+ +
+ diff --git a/Open-ILS/src/templates/staff/share/print_templates/t_item_label_cn.tt2 b/Open-ILS/src/templates/staff/share/print_templates/t_item_label_cn.tt2 index 8e163810e8..85d201c279 100644 --- a/Open-ILS/src/templates/staff/share/print_templates/t_item_label_cn.tt2 +++ b/Open-ILS/src/templates/staff/share/print_templates/t_item_label_cn.tt2 @@ -1,11 +1,10 @@
-{{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']}}
 
diff --git a/Open-ILS/web/js/ui/default/staff/cat/printlabels/app.js b/Open-ILS/web/js/ui/default/staff/cat/printlabels/app.js index 1815652a20..aa90fb4a09 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/printlabels/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/printlabels/app.js @@ -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;