-<?xml version="1.0" encoding="Windows-1252"?>
<style>
/* TODO: move me */
+ body {
+
+ }
+
table.page-break {
- page-break-before: always;
+ page-break-before: always;
+ }
+
+ div.print-label-toolbox input[type=number], div.print-label-toolbox input[type=text] {
+ border: 1px solid #999;
+ border-radius: 3px;
+ margin-right: 12px;
+ width: 56px;
+ }
+
+ div.print-label-toolbox div.eg-print-label-section {
+ border-bottom: 1px solid #DED;
+ display: block;
+ margin: 0 0 10px 0;
+ padding: 0 0 10px 0;
+ }
+
+ div.print-label-toolbox input.ng-invalid {
+ background-color: #FFFF00;
+ color: #FF0000;
+ }
+
+ div.print-label-toolbox label {
+ padding-right: 4px;
+ }
+
+ div.print-label-toolbox ul {
+ display: block;
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+ }
+
+ div.print-label-toolbox ul li {
+ display: inline-block;
+ padding: 0 0 0 6px;
+ }
+
+ div.print-label-toolbox ul li:first-child {
+ display: inline-block;
+ padding: 0 0 0 0;
+ }
+
+ table.custom-label-table td {
+ vertical-align: top;
}
+ .print-template-text {
+ height: 36em;
+ width: 100%;
+ }
+
+ .cn-template-text {
+ height: 12em;
+ width: 100%;
+ }
</style>
-<div class="container-fluid" style="text-align:center">
- <div class="alert alert-info alert-less-pad strong-text-2">
- [% l('Print Item Labels') %]
- </div>
-</div>
-<div class="row">
- <div class="col-md-3">
- <div class="input-group">
- <span class="input-group-addon">[% l('Template') %]</span>
- <eg-basic-combo-box list="template_name_list" selected="template_name"></eg-basic-combo-box>
- </div>
- </div>
- <div class="col-md-1">
- <button class="btn btn-default" ng-click="applyTemplate(template_name)">[% l('Apply') %]</button>
- </div>
- <div class="col-md-2">
- <div class="input-group">
- <span class="input-group-addon">[% l('Printer') %]</span>
- <select class="form-control" ng-model="print.template_context">
- <option value="default">[% l('Default') %]</option>
- <option value="receipt">[% l('Receipt') %]</option>
- <option value="label">[% l('Label') %]</option>
- <option value="mail">[% l('Mail') %]</option>
- <option value="offline">[% l('Offline') %]</option>
- </select>
+<h2>[% l('Print Item Labels') %]</h2>
+
+<div class="row bg-info">
+ <div class="col-md-6">
+ <div class="row">
+ <div class="col-md-1">
+ <span class="h4">[% l('Template') %]</span>
+ </div>
+ <div class="col-md-5">
+ <eg-basic-combo-box list="template_name_list" selected="template_name"></eg-basic-combo-box>
+ </div>
+ <div class="col-md-1">
+ <button class="btn btn-default" ng-click="applyTemplate(template_name)">[% l('Apply') %]</button>
+ </div>
+ <div class="col-md-1">
+ <span class="h4">[% l('Printer') %]</span>
+ </div>
+ <div class="col-md-4">
+ <select class="form-control" ng-model="print.template_context">
+ <option value="default">[% l('Default') %]</option>
+ <option value="receipt">[% l('Receipt') %]</option>
+ <option value="label">[% l('Label') %]</option>
+ <option value="mail">[% l('Mail') %]</option>
+ <option value="offline">[% l('Offline') %]</option>
+ </select>
+ </div>
</div>
</div>
<div class="col-md-2">
[% l('Manual adjustments may be made here. These do not get saved with templates.') %]<br/>
</span>
</div>
- <div ng-repeat="cn in rendered_call_number_set">
- <textarea ng-model="cn.value" class="cn-template-text">
+ <div ng-repeat="cn in preview_scope.copies">
+ <textarea ng-model="cn.rendered_cn.value" class="cn-template-text">
</textarea>
</div>
</div>
<div ng-show="current_tab == 'settings'">
<div>
<span>
- <b>[% l('*All settings will be saved with templates') %]</b>
+ <b>*All settings will be saved with templates</b>
</span>
</div>
<form id="print_label_form" name="print_label_form">
<div class="print-label-toolbox">
- <div class="eg-print-label-group">
<div class="eg-print-label-section">
- <h4>[% l('Print Feed Option') %]</h4>
+ <h4>Print Feed Option</h4>
<ul>
<li ng-repeat="x in preview_scope.toolbox_settings.feed_option.options">
<label>{{x.label}}:</label>
<input name="label-feed-option" ng-model="preview_scope.toolbox_settings.feed_option.selected" ng-change="redraw_label_table()" type="radio" value="{{x.value}}" />
</li>
</ul>
- </div>
- <div class="eg-print-label-section" ng-if="preview_scope.toolbox_settings.feed_option.selected === 'sheet'">
- <p><strong>[% l('Starting Position on Label Grid') %]</strong>
- <eg-help-popover help-text="[% l('Specify the starting row and column where labels should begin printing. Values must not exceed the respective row and column size specified in "Print Grid Size"') %]"></p>
- <ul>
- <li>
- <label>[% l('Row') %]:</label>
- <input type="number" eg-print-label-valid-int eg-print-label-row-bounds ng-model="preview_scope.toolbox_settings.page.start_position.row" ng-min="1" required />
- </li>
- <li>
- <label>[% l('Column') %]:</label>
- <input type="number" eg-print-label-valid-int="" eg-print-label-column-bounds ng-model="preview_scope.toolbox_settings.page.start_position.column" ng-min="1" required />
- </li>
- </ul>
- </div>
- </div>
- <div class="eg-print-label-group">
- <div class="eg-print-label-section">
- <h4>[% l('Label Set Configuration') %]
- <eg-help-popover help-text="[% l('A label set is a group of labels that should print data from the same bibliographic record. In this
-section, identify the number of labels contained in each set, which columns should print spine label data, and which columns should print pocket label data.') %]"></h4>
+ </div>
+ <div class="eg-print-label-section">
+ <h4>Print Option</h4>
<ul>
<li ng-repeat="x in preview_scope.toolbox_settings.mode.options">
<label>{{x.label}}:</label>
<input name="label-output-mode" ng-model="preview_scope.toolbox_settings.mode.selected" type="radio" value="{{x.value}}" />
</li>
</ul>
- </div>
- <div class="eg-print-label-section" ng-if="preview_scope.valid_print_label_start_column() && preview_scope.valid_print_label_start_row() && preview_scope.toolbox_settings.page.dimensions.columns > 1">
- <label>[% l('Number of Labels in Set') %]:</label>
- <input type="number" eg-print-label-valid-int="" ng-min="1" ng-model="preview_scope.toolbox_settings.page.label.set.size" />
- <ul>
- <li ng-repeat="i in preview_scope.toolbox_settings.page.label.set.size | columnRowRange">
- <label>[% l('Column') %] {{i + 1}}</label>
- <select id="eg_print_label_column_spec_{{i}}" ng-model="preview_scope.toolbox_settings.page.column_class[i]" ng-change="redraw_label_table()">
- <option value="spine">[% l('Spine Label') %]</option>
- <option value="pocket">[% l('Pocket Label') %]</option>
- </select>
- </li>
- </ul>
- </div>
</div>
- <div class="eg-print-label-group">
- <h4>[% l('Page Settings') %]</h4>
- <div class="eg-print-label-section">
- <p><strong>[% l('Page Margins') %]</strong>
- <eg-help-popover help-text="[% l('Must be in format "0.25in", "2.5cm", "1.5in", etc. (units of measurement must be valid CSS)') %]"></p>
+ <h3>Page Settings</h3>
+ <div class="eg-print-label-section">
+ <h4>Page Margins</h4>
+ <p>Must be in format "0.25in", "2.5cm", "1.5in", etc. (units of measurement must be valid CSS)</p>
<ul>
<li ng-repeat="(x, y) in preview_scope.toolbox_settings.page.margins">
<label>{{y.label}}:</label>
<input type="text" eg-print-label-valid-css ng-model="preview_scope.toolbox_settings.page.margins[x].size" required />
</li>
</ul>
- </div>
- <div class="eg-print-label-section">
- <p><strong>[% l('Print Grid Size') %]</strong>
- <span ng-if="preview_scope.toolbox_settings.feed_option.selected === 'sheet'"><eg-help-popover help-text="[% l('Please specify the number of columns and rows on the print medium. This setting is only used to control page layouts and breaks. It will not limit the number of rows printed, which is determined by the number of selected copies. The column count should include each label in a row. For example, if you have a row with two sets of labels that include one spine and one pocket, the count is four.') %]"></span>
- <span ng-if="preview_scope.toolbox_settings.feed_option.selected === 'continuous'"><eg-help-popover help-text="[% l('Please specify the number of columns on the print medium. The column count should include each label on your medium. For example, if your medium has a spine and pocket label, the count is two.') %]"></span></p>
+ </div>
+ <div class="eg-print-label-section">
+ <h4>Print Grid Size</h4>
+ <p>Please specify the number of columns and rows (if applicable) on the print medium. This setting is only used to control page layouts and breaks. It will not limit the number of rows printed, which is determined by the number of selected copies. The column count should include each label in a row. For example, if you have a row with two sets of labels that include one spine and one pocket, the count is four.</p>
<ul>
<li ng-if="preview_scope.toolbox_settings.feed_option.selected === 'sheet'">
- <label>[% l('Rows') %]:</label>
+ <label>Rows:</label>
<input type="number" ng-model="preview_scope.toolbox_settings.page.dimensions.rows" ng-min="1" required />
</li>
<li>
- <label>[% l('Columns') %]:</label>
+ <label>Columns:</label>
<input type="number" ng-model="preview_scope.toolbox_settings.page.dimensions.columns" ng-min="1" required />
</li>
</ul>
- </div>
- <div class="eg-print-label-section">
- <p><label>[% l('Gap Between Rows') %]</label>
- <eg-help-popover help-text="[%l ('Must be in format "0.25in", "2.5cm", "1.5in", etc. (units of measurement must be valid CSS)') %]"></p>
- <p><input type="text" ng-model="preview_scope.toolbox_settings.page.space_between_labels.vertical.size" ng-min="0" eg-print-label-valid-css required /></p>
- </div>
- <div class="eg-print-label-section" ng-if="preview_scope.toolbox_settings.feed_option.selected === 'sheet'">
- <p><label>[% l('Gap Between') %] <span ng-if="preview_scope.toolbox_settings.page.label.set.size > 1">[% l(' Label Sets') %]</span><span ng-if="preview_scope.toolbox_settings.page.label.set.size === 1">[% l(' Columns') %]</span></label>
- <eg-help-popover help-text="[% l('Gap between each label set (spine/pocket combo) or, when using only one type of label, between each
-label. Use pocket label left margin to identify how much space to provide between labels within one set. Must be in format "0.25in", "2.5cm", "1.5in", etc. (units of measurement must be valid CSS)') %]"></p>
- <p><input type="text" ng-model="preview_scope.toolbox_settings.page.label.gap.size" ng-min="0" eg-print-label-valid-css required /></p>
- </div>
- </div>
+ </div>
+ <div class="eg-print-label-section">
+ <label>Gap Between Rows</label> <input type="text" ng-model="preview_scope.toolbox_settings.page.space_between_labels.vertical.size" ng-min="0" eg-print-label-valid-css required />
+ <p>Must be in format "0.25in", "2.5cm", "1.5in", etc. (units of measurement must be valid CSS)</p><br />
+ <label>Gap Between Columns of a Label Set</label>
+ <input type="text" ng-model="preview_scope.toolbox_settings.page.label.gap.size" ng-min="0" eg-print-label-valid-css required />
+ <p>Gap between a label “set” (i.e. gap between each spine/pocket combo). Use label 2 left margin to identify how much space to provide between labels within one set. Must be in format "0.25in", "2.5cm", "1.5in", etc. (units of measurement must be valid CSS)</p>
+ </div>
+ <div class="eg-print-label-section" ng-if="preview_scope.toolbox_settings.page.dimensions.rows > 1 || preview_scope.toolbox_settings.page.dimensions.columns > 1">
+ <h4>Starting Position on Label Grid</h4>
+ <p>Specify the starting <span ng-if="preview_scope.toolbox_settings.feed_option.selected == 'sheet'">row and </span>column where labels should begin printing. Values must not exceed the respective <span ng-if="preview_scope.toolbox_settings.feed_option.selected == 'sheet'">row and </span>column size specified in "Print Grid Size"</p>
+ <ul>
+ <li ng-if="preview_scope.toolbox_settings.feed_option.selected === 'sheet'">
+ <label>Row:</label>
+ <input type="number" eg-print-label-valid-int eg-print-label-row-bounds ng-model="preview_scope.toolbox_settings.page.start_position.row" ng-min="1" required />
+ </li>
+ <li>
+ <label>Column:</label>
+ <input type="number" eg-print-label-valid-int="" eg-print-label-column-bounds ng-model="preview_scope.toolbox_settings.page.start_position.column" ng-min="1" required />
+ </li>
+ </ul>
+ </div>
+ <div class="eg-print-label-section">
+ <h4>Label Set Configuration</h4>
+ <label>Number of Labels in Set:</label>
+ <input type="number" eg-print-label-valid-int="" ng-min="1" ng-model="preview_scope.toolbox_settings.page.label.set.size" />
+ <br />
+ <br />
+ <ul ng-if="preview_scope.valid_print_label_start_column() && preview_scope.valid_print_label_start_row() && preview_scope.toolbox_settings.mode.selected === 'spine-pocket'">
+ <li ng-repeat="i in preview_scope.toolbox_settings.page.label.set.size | columnRowRange">
+ <label>Col. {{i + 1}}</label>
+ <select id="eg_print_label_column_spec_{{i}}" ng-model="preview_scope.toolbox_settings.page.column_class[i]" ng-change="redraw_label_table()">
+ <option value="spine">Label 1</option>
+ <option value="pocket">Label 2</option>
+ </select>
+ </li>
+ </ul>
+ <br />
+ </div>
</div>
</form>
- <div class="eg-print-label-group">
- <div>
- <h4>Font & Label Settings</h4>
+ <div>
<span>
[% l('These settings do get saved with templates and will override corresponding Library Settings.') %]<br/>
</span>
- </div>
- <div ng-repeat="s in org_unit_settings">
- <div class="row" style="margin-top: 5mm;">
- <div class="col-md-6"><label>{{s.label}} <eg-help-popover help-text="{{s.description}}"></label></div>
+ </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>
- </div>
+ </div>
+ <div class="row">
+ <div>{{s.description}}</div>
+ </div>
+ </div>
</div>
<div ng-show="current_tab == 'template'">
<div ng-if="print.load_failed" class="alert alert-danger">
</div>
<!-- col -->
</div>
+
bucketSvc.bucketNeedsRefresh = true;
return $q.all(promises).then(drawBucket);
}
-
- $scope.moveToPending = function(copies) {
- angular.forEach(copies, function(copy) {
- bucketSvc.pendingList.push(copy.id);
- });
- $scope.detachCopies(copies);
- }
$scope.spawnHoldingsEdit = function (copies) {
var cp_list = []
}
$scope.print_labels = function() {
- var cp_list = []
+ var cp_list = []; console.log($scope.gridControls.selectedItems());
angular.forEach($scope.gridControls.selectedItems(), function (i) {
cp_list.push(i.id);
})
+ var cp_full = [], promises = [];
+ promises.push(
+ egCore.pcrud.search('ccbi', { bucket: bucketSvc.currentBucket.a[2], "target_copy": { "in": cp_list } }).then(
+ null
+ , null
+ , function (ccbi) {
+ cp_full.push(egCore.idl.toHash(ccbi, true));
+ }
+ )
+ );
- egCore.net.request(
- 'open-ils.actor',
- 'open-ils.actor.anon_cache.set_value',
- null, 'print-labels-these-copies', {
- copies : cp_list
- }
- ).then(function(key) {
- if (key) {
- var url = egCore.env.basePath + 'cat/printlabels/' + key;
- $timeout(function() { $window.open(url, '_blank') });
+ $q.all(promises).then(function () {
+ // console.log(cp_full);
+ if (cp_full.length > 0) {
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.anon_cache.set_value',
+ null, 'print-labels-these-copies', {
+ copies : cp_list
+ }
+ ).then(function(key) {
+ if (key) {
+ var url = egCore.env.basePath + 'cat/printlabels/' + key;
+ $timeout(function() { $window.open(url, '_blank') });
+ } else {
+ alert('Could not create anonymous cache key!');
+ }
+ });
} else {
- alert('Could not create anonymous cache key!');
+ alert('Could not create print label export.');
}
});
}
$scope.requestItems = function() {
var copy_list = $scope.gridControls.selectedItems().map(
function (i) {
- return i.id;
+ i.id;
}
);
var record_list = $scope.gridControls.selectedItems().map(
.then(function(resp) { // get_barcodes
- if (resp.count) {
- return $q.when(resp);
- } else {
- // Search again including deleted records
- return egCore.net.request('open-ils.search',
- 'open-ils.search.biblio.tcn', args.record_tcn, true);
+ if (evt = egCore.evt.parse(resp)) {
+ alert(evt); // FIXME
+ return;
}
- }).then(function(resp2) {
-
- if (!resp2.count) {
+ if (!resp.count) {
$scope.recordNotFound = args.record_tcn;
$scope.selectMe = true;
return;
}
- if (resp2.count > 1) {
+ if (resp.count > 1) {
$scope.moreRecordsFound = args.record_tcn;
$scope.selectMe = true;
return;
}
- var record_id = resp2.ids[0];
+ var record_id = resp.ids[0];
return loadRecord(record_id);
});
}
$scope.conjoinedGridDataProvider.refresh();
});
init_parts_url();
- $scope.grid_actions.refresh();
$location.update_path('/cat/catalog/record/' + $scope.record_id);
// update_path() bypasses the controller for path
// /cat/catalog/record/:record_id. Manually set title here too.
}
$scope.selectedHoldingsPrintLabels = function() {
- egCore.net.request(
- 'open-ils.actor',
- 'open-ils.actor.anon_cache.set_value',
- null, 'print-labels-these-copies', {
- copies : gatherSelectedHoldingsIds()
- }
- ).then(function(key) {
- if (key) {
- var url = egCore.env.basePath + 'cat/printlabels/' + key;
- $timeout(function() { $window.open(url, '_blank') });
- } else {
- alert('Could not create anonymous cache key!');
- }
- });
+ var cp_list = gatherSelectedHoldingsIds();
+ var cp_full = [], promises = [];
+ if (cp_list.length > 0) {
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.anon_cache.set_value',
+ null, 'print-labels-these-copies', {
+ copies : cp_list
+ }
+ ).then(function(key) {
+ if (key) {
+ var url = egCore.env.basePath + 'cat/printlabels/' + key;
+ $timeout(function() { $window.open(url, '_blank') });
+ } else {
+ alert('Could not create anonymous cache key!');
+ }
+ });
+ } else {
+ alert('Could not create print label export.');
+ }
}
$scope.selectedHoldingsDamaged = function () {
});
}
- $scope.selectedHoldingsDiscard = function () {
- var copy_list = gatherSelectedRawCopies();
- if (copy_list.length == 0) return;
- egCirc.mark_discard(copy_list.map(function(cp) {
- return {id: cp.id(), barcode: cp.barcode()};})).then(function() {
- holdingsSvcInst.fetchAgain().then(function() {
- $scope.holdingsGridDataProvider.refresh();
- });
- });
- }
-
$scope.selectedHoldingsMissing = function () {
- var copy_list = gatherSelectedRawCopies();
- if (copy_list.length == 0) return;
- egCirc.mark_missing(copy_list.map(function(cp) {
- return {id: cp.id(), barcode: cp.barcode()};})).then(function() {
- holdingsSvcInst.fetchAgain().then(function() {
- $scope.holdingsGridDataProvider.refresh();
- });
+ egCirc.mark_missing(gatherSelectedHoldingsIds()).then(function() {
+ holdingsSvcInst.fetchAgain().then(function() {
+ $scope.holdingsGridDataProvider.refresh();
});
+ });
}
$scope.selectedHoldingsCopyAlertsAdd = function() {
// ------------------------------------------------------------------
// Holds
var provider = egGridDataProvider.instance({});
- var holds = []; // current list of holds
- var hold_count = 0;
-
$scope.hold_grid_data_provider = provider;
$scope.grid_actions = egHoldGridActions;
$scope.grid_actions.refresh = function () { holds = []; hold_count = 0; provider.refresh() };
$scope.hold_grid_controls = {};
+ var holds = []; // current list of holds
+ var hold_count = 0;
provider.get = function(offset, count) {
if ($scope.record_tab != 'holds') return $q.when();
* Parent scope for list and detail views
*/
.controller('SearchCtrl',
- ['$scope','$q','$window','$location','$timeout','egCore','egNet','egGridDataProvider','egItem', 'egCirc',
-function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc , egCirc) {
+ ['$scope','$location','$timeout','egCore','egGridDataProvider','egItem',
+function($scope , $location , $timeout , egCore , egGridDataProvider , itemSvc) {
$scope.args = {}; // search args
// sub-scopes (search / detail-view) apply their version
itemSvc.add_copies_to_bucket([$scope.args.copyId]);
}
- $scope.show_in_catalog = function() {
- window.open('/eg/staff/cat/catalog/record/' + $scope.args.recordId + '/catalog', '_blank');
- }
-
- $scope.print_labels = function() {
- itemSvc.print_spine_labels([$scope.args.copyId]);
- }
-
-
$scope.make_copies_bookable = function() {
itemSvc.make_copies_bookable([{
id : $scope.args.copyId,
itemSvc.manage_reservations([$scope.args.copyBarcode]);
}
- $scope.findAcquisition = function() {
- var acqData;
- var promises = [];
- $scope.openAcquisitionLineItem([$scope.args.copyId]);
- }
-
- $scope.openAcquisitionLineItem = function (cp_list) {
- var hasResults = false;
- var promises = [];
-
- angular.forEach(cp_list, function (copyId) {
- promises.push(
- egNet.request(
- 'open-ils.acq',
- 'open-ils.acq.lineitem.retrieve.by_copy_id',
- egCore.auth.token(),
- copyId
- ).then(function (acqData) {
- if (acqData) {
- if (acqData.a) {
- acqData = egCore.idl.toHash(acqData);
- var url = '/eg/acq/po/view/' + acqData.purchase_order + '/' + acqData.id;
- $timeout(function () { $window.open(url, '_blank') });
- hasResults = true;
- }
- }
- })
- )
- });
-
- $q.all(promises).then(function () {
- !hasResults ? alert('There is no corresponding purchase order for this item.') : false;
- });
- }
-
$scope.requestItems = function() {
itemSvc.requestItems([$scope.args.copyId],[$scope.args.recordId]);
}
});
}
- $scope.show_triggered_events = function() {
- $location.path('/cat/item/' + $scope.args.copyId + '/triggered_events');
- }
-
- $scope.show_item_holds = function() {
- $location.path('/cat/item/' + $scope.args.copyId + '/holds');
- }
-
- $scope.show_record_holds = function() {
- window.open('/eg/staff/cat/catalog/record/' + $scope.args.recordId + '/holds', '_blank');
- }
-
- $scope.add_item_alerts = function() {
- egCirc.add_copy_alerts([$scope.args.copyId]);
- }
-
- $scope.manage_item_alerts = function() {
- egCirc.manage_copy_alerts([$scope.args.copyId]);
- }
-
-
$scope.attach_to_peer_bib = function() {
itemSvc.attach_to_peer_bib([{
id : $scope.args.copyId,
}]);
}
- $scope.selectedHoldingsDiscard = function () {
- itemSvc.selectedHoldingsDiscard([{
- id : $scope.args.copyId,
- barcode : $scope.args.barcode
- }]);
- }
-
$scope.selectedHoldingsMissing = function () {
itemSvc.selectedHoldingsMissing([{
id : $scope.args.copyId,
- barcode : $scope.args.barcode
+ barcode : $scope.args.copyBarcode
}]);
}
['$scope','$q','$routeParams','$location','$timeout','$window','egCore',
'egGridDataProvider','egItem','egUser','$uibModal','egCirc','egConfirmDialog',
'egProgressDialog', 'ngToast',
-// function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
-// egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog,
-// egProgressDialog, ngToast) {
- function($scope , $q , $routeParams , $location , $timeout , $window , egCore , egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog,
- egProgressDialog, ngToast) {
+function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
+ egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog,
+ egProgressDialog, ngToast) {
+
var copyId = [];
var cp_list = $routeParams.idList;
if (cp_list) {
copyId = cp_list.split(',');
}
- var modified_items = new Set();
-
$scope.context.page = 'list';
/*
$scope.args.barcode = '';
var barcodes = [];
- angular.forEach(newVal.split(/\r?\n/), function(line) {
- //remove all whitespace and commas
- line = line.replace(/[\s,]+/g,'');
-
- //Or remove leading/trailing whitespace
- //line = line.replace(/(^[\s,]+|[\s,]+$/g,'');
-
+ angular.forEach(newVal.split(/\n/), function(line) {
if (!line) return;
+ // scrub any trailing spaces or commas from the barcode
+ line = line.replace(/(.*?)($|\s.*|,.*)/,'$1');
barcodes.push(line);
});
var barcode = barcodes.pop();
egProgressDialog.increment();
- if (barcode == undefined) { // All done here.
+ if (!barcode) { // All done here.
egProgressDialog.close();
copyGrid.refresh();
- if(itemSvc.copies[0]){ // Were any copies actually retrieved
- copyGrid.selectItems([itemSvc.copies[0].index]);
- }
+ copyGrid.selectItems([itemSvc.copies[0].index]);
return;
}
return cp_id_list;
}
- $scope.refreshGridData = function() {
- var chain = $q.when();
- var all_items = itemSvc.copies.map(function(item) {
- return item.id;
- });
- angular.forEach(all_items.reverse(), function(i) {
- itemSvc.copies.shift();
- chain = chain.then(function() {
- return itemSvc.fetch(null, i);
- });
- });
- return chain.then(function() {
- copyGrid.refresh();
- });
- }
-
-
$scope.add_copies_to_bucket = function() {
var copy_list = gatherSelectedHoldingsIds();
itemSvc.add_copies_to_bucket(copy_list);
}
- $scope.locateAcquisition = function() {
- if (gatherSelectedHoldingsIds) {
- var cp_list = gatherSelectedHoldingsIds();
- if (cp_list) {
- if (cp_list.length > 0) {
- $scope.openAcquisitionLineItem(cp_list);
- }
- }
- }
- }
-
$scope.update_inventory = function() {
var copy_list = gatherSelectedHoldingsIds();
itemSvc.updateInventory(copy_list, $scope.gridControls.allItems()).then(function(res) {
itemSvc.selectedHoldingsDamaged(copyGrid.selectedItems());
}
- $scope.selectedHoldingsDiscard = function () {
- itemSvc.selectedHoldingsDiscard(copyGrid.selectedItems());
- }
-
$scope.selectedHoldingsMissing = function () {
itemSvc.selectedHoldingsMissing(copyGrid.selectedItems());
}
}
$scope.print_labels = function() {
- egCore.net.request(
+ var cp_list = gatherSelectedHoldingsIds();
+ !$scope.gridDataProvider.sort ? cp_list.reverse() : $scope.gridDataProvider.sort.length === 0 ? cp_list.reverse() : false;
+ var i = 1;
+ if (cp_list.length > 0) {
+ egCore.net.request(
'open-ils.actor',
'open-ils.actor.anon_cache.set_value',
null, 'print-labels-these-copies', {
- copies : gatherSelectedHoldingsIds()
+ copies : cp_list
}
- ).then(function(key) {
+ ).then(function(key) {
if (key) {
var url = egCore.env.basePath + 'cat/printlabels/' + key;
$timeout(function() { $window.open(url, '_blank') });
} else {
alert('Could not create anonymous cache key!');
}
- });
+ });
+ } else {
+ alert('Could not generate print labels.');
+ }
}
$scope.print_list = function() {
}
if (copyId.length > 0) {
- var fetch_list = [];
- angular.forEach(copyId, function (c) {
- fetch_list.push(itemSvc.fetch(null,c));
- });
-
- return $q.all(fetch_list).then(function (res) { copyGrid.refresh(); });
- }
-
- $scope.statusIconColumn = {
- isEnabled: true,
- template: function(item) {
- var icon = '';
- if (modified_items.has(item['id'])) {
- icon = '<span class="glyphicon glyphicon-floppy-saved"' +
- 'title="' + egCore.strings.ITEM_SUCCESSFULLY_MODIFIED + '" ' +
- 'aria-label="' + egCore.strings.ITEM_SUCCESSFULLY_MODIFIED + '">' +
- '</span>';
+ itemSvc.fetch(null,copyId).then(
+ function() {
+ copyGrid.refresh();
}
- return icon
- }
- }
-
- if (typeof BroadcastChannel != 'undefined') {
- var holdings_bChannel = new BroadcastChannel("eg.holdings.update");
- holdings_bChannel.onmessage = function(e) {
- angular.forEach(e.data.copies, function(i) {
- modified_items.add(i);
- });
- ngToast.create(egCore.strings.ITEMS_SUCCESSFULLY_MODIFIED);
- $scope.refreshGridData();
- }
- $scope.$on('$destroy', function() {
- holdings_bChannel.close();
- });
+ );
}
}])
service.flesh = {
flesh: 3,
flesh_fields: {
- acp: ['call_number', 'location', 'status', 'location', 'floating', 'circ_modifier', 'age_protect', 'circ_lib'],
- acn: ['record', 'prefix', 'suffix', 'owning_lib'],
+ acp: ['call_number', 'location', 'status', 'location', 'floating', 'circ_modifier', 'age_protect'],
+ acn: ['record', 'prefix', 'suffix'],
bre: ['simple_record', 'creator', 'editor']
},
select: {
},
mode: {
options: [
- { label: "Spine Label", value: "spine-only" },
- { label: "Pocket Label", value: "spine-pocket" }
+ { label: "Label 1 Only", value: "spine-only" },
+ { label: "Labels 1 & 2", value: "spine-pocket" }
],
selected: "spine-pocket"
},
page: {
- column_class: ["spine", "pocket"],
+ column_class: ["spine"],
dimensions: {
columns: 2,
rows: 1
).then(function (data) {
if (data) {
-
$scope.preview_scope = {
'copies': []
, 'settings': {}
- , 'toolbox_settings': JSON.parse(JSON.stringify(toolbox_settings))
+ , 'toolbox_settings': toolbox_settings
, 'get_cn_for': function (copy) {
- var key = $scope.rendered_cn_key_by_copy_id[copy.id];
- if (key) {
- var manual_cn = $scope.rendered_call_number_set[key];
- if (manual_cn && manual_cn.value) {
- return manual_cn.value;
- } else {
- return '..';
- }
+ if (copy.rendered_cn) {
+ return copy.rendered_cn.value;
} else {
return '...';
}
}
}
});
- egCore.hatch.getItem('cat.printlabels.last_toolbox_settings').then(function (last_toolbox_settings) {
- if (last_toolbox_settings) {
- $scope.preview_scope.toolbox_settings = JSON.parse(JSON.stringify(last_toolbox_settings));
- }
- });
})
);
$q.all(promises2).then(function () {
// today, staff, current_location, etc.
+ $scope.preview_scope.copies.sort((a, b) => (data.copies.indexOf(a.id) > data.copies.indexOf(b.id)) ? 1 : ((data.copies.indexOf(b.id) > data.copies.indexOf(a.id)) ? -1 : 0));
egCore.print.fleshPrintScope($scope.preview_scope);
$scope.template_changed(); // load the default
$scope.rebuild_cn_set();
+ if ($scope.preview_scope.toolbox_settings && $scope.template_name && $scope.print.template_content) {
+ var re = /eg\_plt/i;
+ if (re.test($scope.print.template_content)) {
+ $scope.applyTemplate($scope.template_name);
+ $scope.redraw_label_table();
+ }
+ }
});
});
}
- $scope.checkForToolboxCustomizations = function (tText, redraw) {
- var re = /eg\_plt\_(\d+)/;
- redraw ? $scope.redraw_label_table() : false;
- return re.test(tText);
- }
-
$scope.fetchTemplates = function (set_default) {
return egCore.hatch.getItem('cat.printlabels.templates').then(function (t) {
if (t) {
$scope.preview_scope.settings[s] = $scope.templates[n].settings[s];
}
if ($scope.templates[n].toolbox_settings) {
- $scope.preview_scope.toolbox_settings = JSON.parse(JSON.stringify($scope.templates[n].toolbox_settings));
+ $scope.preview_scope.toolbox_settings = $scope.templates[n].toolbox_settings;
+ $scope.create_print_label_table();
}
egCore.hatch.setItem('cat.printlabels.default_template', n);
$scope.save_locally();
content: $scope.print.template_content
, context: $scope.print.template_context
, cn_content: $scope.print.cn_template_content
- , settings: JSON.parse(JSON.stringify($scope.preview_scope.settings))
- , toolbox_settings: JSON.parse(JSON.stringify($scope.preview_scope.toolbox_settings))
+ , settings: $scope.preview_scope.settings
+ , toolbox_settings: $scope.preview_scope.toolbox_settings
};
$scope.template_name_list = Object.keys($scope.templates);
.then(
function (html) {
$scope.print.template_content = html;
- $scope.checkForToolboxCustomizations(html, true);
},
function () {
$scope.print.template_content = '';
);
egCore.hatch.getItem('cat.printlabels.last_settings').then(function (s) {
if (s) {
- $scope.preview_scope.settings = JSON.parse(JSON.stringify(s));
+ $scope.preview_scope.settings = s;
}
});
- egCore.hatch.getItem('cat.printlabels.last_toolbox_settings').then(function (t) {
- if (t) {
- $scope.preview_scope.toolbox_settings = JSON.parse(JSON.stringify(t));
- }
- });
-
}
$scope.reset_to_default = function () {
'item_label_cn'
);
egCore.hatch.removeItem('cat.printlabels.last_settings');
- egCore.hatch.removeItem('cat.printlabels.last_toolbox_settings');
for (s in $scope.preview_scope.settings) {
$scope.preview_scope.settings[s] = undefined;
}
- $scope.preview_scope.toolbox_settings = JSON.parse(JSON.stringify(toolbox_settings));
-
+ $scope.preview_scope.settings = {};
egCore.org.settings($scope.org_unit_setting_list).then(function (res) {
$scope.preview_scope.settings = res;
});
'item_label_cn',
$scope.print.cn_template_content
);
- egCore.hatch.setItem('cat.printlabels.last_settings', JSON.parse(JSON.stringify($scope.preview_scope.settings)));
- egCore.hatch.setItem('cat.printlabels.last_toolbox_settings', JSON.parse(JSON.stringify($scope.preview_scope.toolbox_settings)));
+ egCore.hatch.setItem('cat.printlabels.last_settings', $scope.preview_scope.settings);
}
$scope.imported_print_templates = { data: '' };
content: el.content
, context: el.context
, cn_content: el.cn_content
- , settings: JSON.parse(JSON.stringify(el.settings))
+ , settings: el.settings
+ , toolbox_settings: el.toolbox_settings
};
- if (el.toolbox_settings) {
- $scope.templates[k].toolbox_settings = JSON.parse(JSON.stringify(el.toolbox_settings));
- }
});
$scope.saveTemplate();
$scope.template_changed(); // refresh
}
});
- $scope.rendered_call_number_set = {};
- $scope.rendered_cn_key_by_copy_id = {};
$scope.rebuild_cn_set = function () {
$timeout(function () {
- $scope.rendered_call_number_set = {};
- $scope.rendered_cn_key_by_copy_id = {};
for (var i = 0; i < $scope.preview_scope.copies.length; i++) {
var copy = $scope.preview_scope.copies[i];
+ copy.rendered_cn = {};
var rendered_cn = document.getElementById('cn_for_copy_' + copy.id);
if (rendered_cn && rendered_cn.textContent) {
- var key = rendered_cn.textContent;
- if (typeof $scope.rendered_call_number_set[key] == 'undefined') {
- $scope.rendered_call_number_set[key] = {
- value: key
- };
- }
- $scope.rendered_cn_key_by_copy_id[copy.id] = key;
+ copy.rendered_cn = { value : rendered_cn.textContent };
}
}
$scope.preview_scope.tickle = Date() + ' ' + Math.random();
});
}
- $scope.redraw_label_table = function () {
+ $scope.create_print_label_table = function () {
if ($scope.print_label_form.$valid && $scope.print.template_content && $scope.preview_scope) {
$scope.preview_scope.label_output_copies = labelOutputRowsFilter($scope.preview_scope.copies, $scope.preview_scope.toolbox_settings);
- var d = new Date().getTime().toString();
var html = $scope.print.template_content;
- if ($scope.checkForToolboxCustomizations(html)) {
- html = html.replace(/eg\_plt\_\d+/, "eg_plt_" + d);
- $scope.print.template_content = html;
- } else {
- var table = "<table id=\"eg_plt_" + d + "_{{$index}}\" eg-print-label-table style=\"border-collapse: collapse; border: 0 solid transparent; border-spacing: 0; margin: {{$index === 0 ? toolbox_settings.page.margins.top.size : 0}} 0 0 0;\" class=\"custom-label-table{{$index % toolbox_settings.page.dimensions.rows === 0 && $index > 0 && toolbox_settings.feed_option.selected === 'sheet' ? ' page-break' : ''}}\" ng-init=\"parentIndex = $index\" ng-repeat=\"row in label_output_copies\">\n";
- table += "<tr>\n";
- table += "<td style=\"border: 0 solid transparent; padding: {{parentIndex % toolbox_settings.page.dimensions.rows === 0 && toolbox_settings.feed_option.selected === 'sheet' && parentIndex > 0 ? toolbox_settings.page.space_between_labels.vertical.size : parentIndex > 0 ? toolbox_settings.page.space_between_labels.vertical.size : 0}} 0 0 {{$index === 0 ? toolbox_settings.page.margins.left.size : col.styl ? col.styl : toolbox_settings.page.space_between_labels.horizontal.size}};\" ng-repeat=\"col in row.columns\">\n";
- table += "<pre class=\"{{col.cls}}\" style=\"border: none; margin-bottom: 0; margin-top: 0; overflow: hidden;\" ng-if=\"col.cls === 'spine'\">\n";
- table += "{{col.c ? get_cn_for(col.c) : ''}}";
- table += "</pre>\n";
- table += "<pre class=\"{{col.cls}}{{parentIndex % toolbox_settings.page.dimensions.rows === 0 && parentIndex > 0 && toolbox_settings.feed_option.selected === 'sheet' ? ' page-break' : ''}}\" style=\"border: none; margin-bottom: 0; margin-top: 0; overflow: hidden;\" ng-if=\"col.cls === 'pocket'\">\n";
- table += "{{col.c ? col.c.barcode : ''}}\n";
- table += "{{col.c ? col.c['call_number.label'] : ''}}\n";
- table += "{{col.c ? get_bib_for(col.c).author : ''}}\n";
- table += "{{col.c ? (get_bib_for(col.c).title | wrap:28:'once':' ') : ''}}\n";
- table += "</pre>\n";
- table += "</td>\n"
- table += "</tr>\n";
- table += "</table>";
- var comments = html.match(/\<\!\-\-(?:(?!\-\-\>)(?:.|\s))*\-\-\>\s*/g);
- html = html.replace(/\<\!\-\-(?:(?!\-\-\>)(?:.|\s))*\-\-\>\s*/g, '');
- var style = html.match(/\<style[^\>]*\>(?:(?!\<\/style\>)(?:.|\s))*\<\/style\>\s*/gi);
- var output = (comments ? comments.join("\n") : "") + (style ? style.join("\n") : "") + table;
- output = output.replace(/\n+/, "\n");
- $scope.print.template_content = output;
- }
+ var d = new Date(); //Added to table ID with 'eg_plt_' to cause $complie on $scope.print.template_content to fire due to template content change.
+ var table = "<table id=\"eg_plt_" + d.getTime().toString() + "_{{$index}}\" eg-print-label-table style=\"border-collapse: collapse; border: 0 solid transparent; border-spacing: 0; margin: {{$index === 0 ? toolbox_settings.page.margins.top.size : 0}} 0 0 0;\" class=\"custom-label-table{{$index % toolbox_settings.page.dimensions.rows === 0 && $index > 0 && toolbox_settings.feed_option.selected === 'sheet' ? ' page-break' : ''}}\" ng-init=\"parentIndex = $index\" ng-repeat=\"row in label_output_copies\">\n";
+ table += "<tr>\n";
+ table += "<td style=\"border: 0 solid transparent; padding: {{parentIndex % toolbox_settings.page.dimensions.rows === 0 && toolbox_settings.feed_option.selected === 'sheet' && parentIndex > 0 ? toolbox_settings.page.space_between_labels.vertical.size : parentIndex > 0 ? toolbox_settings.page.space_between_labels.vertical.size : 0}} 0 0 {{$index === 0 ? toolbox_settings.page.margins.left.size : col.styl ? col.styl : toolbox_settings.page.space_between_labels.horizontal.size}};\" ng-repeat=\"col in row.columns\">\n";
+ table += "<pre class=\"{{col.cls}}\" style=\"border: none; margin-bottom: 0; margin-top: 0; overflow: hidden;\" ng-if=\"col.cls === 'spine'\">\n";
+ table += "{{col.c ? get_cn_for(col.c) : ''}}";
+ table += "</pre>\n";
+ table += "<pre class=\"{{col.cls}}{{parentIndex % toolbox_settings.page.dimensions.rows === 0 && parentIndex > 0 && toolbox_settings.feed_option.selected === 'sheet' ? ' page-break' : ''}}\" style=\"border: none; margin-bottom: 0; margin-top: 0; overflow: hidden;\" ng-if=\"col.cls === 'pocket'\">\n";
+ table += "{{col.c ? col.c.barcode : ''}}\n";
+ table += "{{col.c ? col.c['call_number.label'] : ''}}\n";
+ table += "{{col.c ? get_bib_for(col.c).author : ''}}\n";
+ table += "{{col.c ? (get_bib_for(col.c).title | wrap:28:'once':' ') : ''}}\n";
+ table += "</pre>\n";
+ table += "</td>\n"
+ table += "</tr>\n";
+ table += "</table>";
+ var comments = html.match(/\<\!\-\-(?:(?!\-\-\>)(?:.|\s))*\-\-\>\s*/g);
+ html = html.replace(/\<\!\-\-(?:(?!\-\-\>)(?:.|\s))*\-\-\>\s*/g, "");
+ var style = html.match(/\<style[^\>]*\>(?:(?!\<\/style\>)(?:.|\s))*\<\/style\>\s*/gi);
+ var output = (style ? style.join("\n") : "") + (comments ? comments.join("\n") : "") + table;
+ output = output.replace(/\n+/, "\n");
+ $scope.print.template_content = output;
+ $scope.save_locally();
}
}
+ $scope.redraw_label_table = function () {
+ var d = new Date(); //Added to table ID with 'eg_plt_' to cause $complie on $scope.print.template_content to fire due to template content change.
+ var table = "<table id=\"eg_plt_" + d.getTime().toString() + "\"\></table>\n";
+ $scope.print.template_content += table;
+ $scope.create_print_label_table();
+ }
+
+ $scope.$watch('preview_scope.toolbox_settings.page.dimensions.columns',
+ function (newVal, oldVal) {
+ if (newVal && newVal != oldVal && $scope.preview_scope) {
+ $scope.redraw_label_table();
+ }
+ }
+ );
+
$scope.$watch('print.cn_template_content', function (newVal, oldVal) {
if (newVal && newVal != oldVal) {
$scope.rebuild_cn_set();
}
});
- $scope.$watchGroup(['preview_scope.toolbox_settings.page.margins.top.size', 'preview_scope.toolbox_settings.page.margins.left.size', 'preview_scope.toolbox_settings.page.dimensions.rows', 'preview_scope.toolbox_settings.page.dimensions.columns', 'preview_scope.toolbox_settings.page.space_between_labels.horizontal.size', 'preview_scope.toolbox_settings.page.space_between_labels.vertical.size', 'preview_scope.toolbox_settings.page.start_position.row', 'preview_scope.toolbox_settings.page.start_position.column', 'preview_scope.toolbox_settings.page.label.gap.size'], function (newVal, oldVal) {
+ $scope.$watchGroup(['preview_scope.toolbox_settings.page.margins.top.size', 'preview_scope.toolbox_settings.page.margins.left.size', 'preview_scope.toolbox_settings.page.dimensions.rows', 'preview_scope.toolbox_settings.page.space_between_labels.horizontal.size', 'preview_scope.toolbox_settings.page.space_between_labels.vertical.size', 'preview_scope.toolbox_settings.page.start_position.row', 'preview_scope.toolbox_settings.page.start_position.column', 'preview_scope.toolbox_settings.page.label.gap.size'], function (newVal, oldVal) {
if (newVal && newVal != oldVal && $scope.preview_scope.label_output_copies) {
$scope.redraw_label_table();
}
});
$scope.$watch("preview_scope.toolbox_settings.mode.selected", function (newVal, oldVal) {
- if (newVal && newVal != oldVal && $scope.preview_scope) {
+ if (newVal && newVal != oldVal) {
var ts_p = $scope.preview_scope.toolbox_settings.page;
if (ts_p.label.set.size === 1) {
if (newVal === "spine-pocket") {
});
$scope.$watch("preview_scope.toolbox_settings.page.label.set.size", function (newVal, oldVal) {
- if (newVal && newVal != oldVal && oldVal) {
+ if (newVal && newVal != oldVal) {
var ts_p = $scope.preview_scope.toolbox_settings.page;
if (angular.isNumber(newVal)) {
while (ts_p.column_class.length > ts_p.label.set.size) {
ts_p.column_class.push("spine");
}
}
- }
- });
-
- $scope.$watch('print.cn_template_content', function (newVal, oldVal) {
- if (newVal && newVal != oldVal) {
- $scope.rebuild_cn_set();
- }
- });
-
- $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.redraw_label_table();
}
});
.filter('cn_wrap', function () {
return function (input, w, h, wrap_type) {
- var names;
+ var addedElements = 0;
+ /* Pattern matches for LC ([0]) and non-LC ([1]) CNs */
+ var patterns = [/^([A-Z]{1,3})\s*(\d{1,4})(\.*\d{1,3})?\s*(\d[A-Z0-9]{0,3})?(\.*[A-Z]\d{1,3})?(\d[A-Z0-9]{0,3})?([A-Z]\d{1,3})?(.*)?/i, /^([A-Z]+)?\s*(\d+)(\.\d+)?\s*(.*)?$/i];
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');
+ var cn_patt; /* <- regex from patterns to use based on wrap_type */
+ var z = 3; /* <-Text match position in patterns for variable text (7th position in LC regex pattern); default to non-LC (3rd position in non-LC regex pattern) */
+ if (wrap_type === 3 || wrap_type === 'lc') {
+ cn_patt = patterns[0];
+ z = 7;
+ } else {
+ cn_patt = patterns[1];
+ }
+
+ var result = callnum.match(cn_patt);
+ if (result) {
+ result = result.slice(1);
+ /* Fix the variable lines of the call number that are longer than 'w'; proceed through algorithm to break up the elements in a standard spine label format (on spaces, periods, decimals, etc.) */
+ if (result[z + addedElements]) {
+ result[z + addedElements] = result[z + addedElements].replace(/\s+$/, "");
+ if (result[z + addedElements].length > w) {
+ var n = z + addedElements;
+ var sub_patt = [/^([^\.]+?)(?!\.) ([^\s]+)$/, /^(.+?) ([^\s]+)$/];
+ while (n < result.length) {
+ var y = result[n].match(sub_patt[0]) ? 0 : result[n].match(sub_patt[1]) ? 1 : 0;
+ if (result[n].match(sub_patt[y]) && result[n].length > w) {
+ var str = result[n].match(sub_patt[y]);
+ result[n] = str[1];
+ result.splice(n + 1, 0, str[2]);
+ addedElements++;
+ } else {
+ n++;
+ }
+ }
+ }
}
-
- /* If result is null, leave callnum alone. Can't parse this malformed call num */
} else {
- callnum = callnum.split(/\s+/).join('\t');
+ result = [];
+ divideOnCharLen(callnum, result, 0, 0);
}
+ prefix ? result.splice(0, 0, prefix) : false;
+ suffix ? result.push(suffix) : false;
- if (prefix) {
- callnum = prefix + '\t' + callnum;
+ /* Give each line a final check and cleanup if it exceeds width of 'w' */
+ addedElements = 0;
+ for (var i = 0; i < result.length; i++) {
+ if (result[i]) {
+ divideOnCharLen(result[i], result, i, addedElements);
+ }
}
- if (suffix) {
- callnum += '\t' + suffix;
+ var output = [];
+ for (var j = 0; j < result.length; j++) {
+ result[j] ? result[j] = result[j].replace(/^\s*(.*?)\s*$/, "$1") : false;
+ result[j] ? output.push(result[j]) : false;
}
+ output = output.slice(0, h); /*Limit lines to height in org unit settings (or default) */
- /* 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);
- }
+ return output.join('\n');
+
+ function divideOnCharLen(val, arr, index, incr) {
+ var x = 1;
+ while ((val.length / x) > w) {
+ x++;
+ }
+ var charMatch = val.match(new RegExp(".{1," + Math.ceil((val.length / x)) + "}", "g"));
+ if (charMatch) {
+ for (var t = 0; t < charMatch.length; t++) {
+ if (t === 0) {
+ arr[index] = charMatch[t];
} else {
- /* otherwise we're set */
- tb[j] = name;
+ arr.splice((index + t), 0, charMatch[t]);
+ incr++;
}
}
}
- j++;
}
- return tb.join('\n');
}
})
flesh_fields : {
asc : ['owner','entries'],
asce : ['value']
- },
- order_by : [{'class':'asc', 'field':'owner'},{'class':'asc', 'field':'name'},{'class':'asce', 'field':'value'} ]
},
{ atomic : true }
);
return egCore.pcrud.search('bmp',
{record : rec, deleted : 'f'},
- {order_by: {bmp : 'label_sortkey DESC'}},
- {atomic : true}
+ null, {atomic : true}
).then(function(list) {
service.bmp_parts[rec] = list;
return list;
'<div class="col-xs-5" ng-class="{'+"'has-error'"+':barcode_has_error}">'+
'<input id="{{callNumber.id()}}_{{copy.id()}}"'+
' eg-enter="nextBarcode(copy.id())" class="form-control"'+
- ' type="text" ng-model="barcode" ng-change="updateBarcode()"'+
- ' ng-focus="selectOnFocus($event)" autofocus/>'+
+ ' type="text" ng-model="barcode" ng-change="updateBarcode()"/>'+
'<div class="label label-danger" ng-if="duplicate_barcode">{{duplicate_barcode_string}}</div>'+
'<div class="label label-danger" ng-if="empty_barcode">{{empty_barcode_string}}</div>'+
'</div>'+
if (!$scope.copy.barcode()) $scope.copy.empty_barcode = true;
- $scope.selectOnFocus = function($event) {
- if (!$scope.copy.empty_barcode)
- $event.target.select();
- }
-
$scope.nextBarcode = function (i) {
$scope.focusNext(i, $scope.barcode);
}
if ($scope.defaults.barcode_checkdigit) itemSvc.barcode_checkdigit = true;
if ($scope.defaults.auto_gen_barcode) itemSvc.auto_gen_barcode = true;
}
-
- // Fetch the list of bib-level callnumbers based on the applied
- // classification scheme. If none is defined, default to "1"
- // (Generic) since it provides the most options.
- egCore.net.request(
- 'open-ils.cat',
- 'open-ils.cat.biblio.record.marc_cn.retrieve',
- $scope.record_id,
- $scope.batch.classification || 1
- ).then(function(list) {
- $scope.batch.marcCallNumbers = [];
- list.forEach(function(hash) {
- $scope.batch.marcCallNumbers.push(Object.values(hash)[0]);
- });
- });
});
}
+ $scope.fetchDefaults();
- $scope.$watch('defaults.statcat_filter', function(n,o) {
- if (n && n != o)
- $scope.saveDefaults();
+ $scope.$watch('defaults.statcat_filter', function() {
+ $scope.saveDefaults();
});
$scope.$watch('defaults.auto_gen_barcode', function (n,o) {
itemSvc.auto_gen_barcode = n
statcat_filter: undefined
};
- // Returns true if we are editing multiple copies and at least
- // one field contains multiple values.
- $scope.hasMulti = function() {
- var keys = Object.keys($scope.working.MultiMap);
- // for-loop for shortcut exit
- for (var i = 0; i < keys.length; i++) {
- if ($scope.working.MultiMap[keys[i]] &&
- $scope.working.MultiMap[keys[i]].length > 1) {
- return true;
- }
- }
- return false;
- }
-
$scope.copyAlertUpdate = function (alerts) {
if (!$scope.in_item_select &&
$scope.workingGridControls &&
// trim out all deleted ones; the API used to
// do the update doesn't actually consult
// isdeleted for stat cat entries
- if (cp.stat_cat_entries()) {
- cp.stat_cat_entries(
- cp.stat_cat_entries().filter(function (e) {
- return !Boolean(e.isdeleted());
- })
- );
- }
+ cp.stat_cat_entries(
+ cp.stat_cat_entries().filter(function (e) {
+ return !Boolean(e.isdeleted());
+ })
+ );
cp.ischanged(1);
}
$scope.clearWorking = function () {
angular.forEach($scope.working, function (v,k,o) {
- if (k != 'MultiMap') $scope.working.MultiMap[k] = [];
if (!angular.isObject(v)) {
if (typeof v != 'undefined')
$scope.working[k] = undefined;
- } else if (k != 'circ_lib' && k != 'MultiMap') {
+ } else if (k != 'circ_lib') {
angular.forEach(v, function (sv,sk) {
if (typeof v != 'undefined')
$scope.working[k][sk] = undefined;
}
$scope.circTypeValue = function (x) {
- if (x === null || x === undefined) return egCore.strings.UNSET;
+ if (x === null) return egCore.strings.UNSET;
var s = $scope.circ_type_list.filter(function(y) {
return y.code() == x;
});
}
$scope.ageprotectName = function (x) {
- if (x === null || x === undefined) return egCore.strings.UNSET;
+ if (x === null) return egCore.strings.UNSET;
var s = $scope.age_protect_list.filter(function(y) {
return y.id() == x;
});
}
$scope.floatingName = function (x) {
- if (x === null || x === undefined) return egCore.strings.UNSET;
+ if (x === null) return egCore.strings.UNSET;
var s = $scope.floating_list.filter(function(y) {
return y.id() == x;
});
}
$scope.circmodName = function (x) {
- if (x === null || x === undefined) return egCore.strings.UNSET;
+ if (x === null) return egCore.strings.UNSET;
var s = $scope.circ_modifier_list.filter(function(y) {
return y.code() == x;
});
$scope.record_id = data.record_id;
- // Fetch defaults
- $scope.fetchDefaults();
-
function fetchRaw () {
if (!$scope.only_vols) $scope.dirty = true;
$scope.add_vols_copies = true;
).then(function(copy_ids) {
if (and_exit) {
$scope.dirty = false;
+ !$scope.completedGridDataProvider.sort ? copy_ids.reverse() : $scope.completedGridDataProvider.sort.length === 0 ? copy_ids.reverse() : false;
if ($scope.defaults.print_item_labels) {
+ var cp_full = [];
+ var i = 1;
+ angular.forEach(copy_ids, function (copy) {
+ cp_full.push({ id: i, target_copy: copy});
+ i++;
+ });
egCore.net.request(
'open-ils.actor',
'open-ils.actor.anon_cache.set_value',
null, 'print-labels-these-copies', {
- copies : copy_ids
+ copies : cp_full
}
).then(function(key) {
if (key) {
var n = new egCore.idl.acpn();
n.isnew(1);
n.creator(note.creator);
- n.pub(note.pub ? 't' : 'f');
+ n.pub(note.pub);
n.title(note.title);
n.value(note.value);
n.owning_copy(cp.id());
{ order_by : { 'acpt' : ['label'] } }, { atomic: true }
).then(function(list) {
return list.map(function(item) {
- return item.label() + " (" + egCore.org.get(item.owner()).shortname() + ")";
+ return item.label();
});
});
}
$scope.clearWorking = function () {
angular.forEach($scope.working, function (v,k,o) {
+ $scope.working.MultiMap[k] = [];
if (!angular.isObject(v)) {
if (typeof v != 'undefined')
$scope.working[k] = undefined;
- } else if (k != 'circ_lib' && k != 'MultiMap') {
+ } else if (k != 'circ_lib') {
angular.forEach(v, function (sv,sk) {
$scope.working[k][sk] = undefined;
});
{already_checked_in : final_resp.evt.copy_barcode};
}
- if ($scope.trim_list && checkinSvc.checkins.length > 20) {
+ if ($scope.trim_list && checkinSvc.checkins.length > 20)
//cut array short at 20 items
checkinSvc.checkins.length = 20;
- checkinGrid.prepend(20);
- } else {
- checkinGrid.prepend();
- }
},
function() {
// Checkin was rejected somewhere along the way.
checkinSvc.checkins.splice(pos, 1);
})['finally'](function() {
- // when all is said and done, refocus
+
+ // when all is said and done, refresh the grid and refocus
+ checkinGrid.refresh();
$scope.focusMe = true;
});
}
}
- $scope.showMarkDiscard = function(items) {
- var copies = [];
- angular.forEach(items, function(item) {
- if (item.acp) {
- copies.push(egCore.idl.toHash(item.acp));
- }
- });
- if (copies.length) {
- egCirc.mark_discard(copies).then(function() {
- // update grid items?
- });
- }
- }
-
$scope.abortTransit = function(items) {
var transit_ids = [];
angular.forEach(items, function(item) {
}
$scope.printSpineLabels = function(items){
- var copy_ids = [];
+ var cp_list = [];
+ var i = 1;
angular.forEach(items, function(item) {
- if (item.acp) copy_ids.push(item.acp.id());
+ if (item.acp) cp_list.push(item.acp.id());
});
- itemSvc.print_spine_labels(copy_ids);
+ !$scope.gridDataProvider.sort ? cp_list.reverse() : $scope.gridDataProvider.sort.length === 0 ? cp_list.reverse() : false;
+ itemSvc.print_spine_labels(cp_list);
}
$scope.addCopyAlerts = function(items) {