From daa70903a850ff33440d392134b534b94566c09b Mon Sep 17 00:00:00 2001 From: Terran McCanna Date: Fri, 19 Aug 2022 13:38:56 -0400 Subject: [PATCH] LP1821950 & LP1980409 Option to require call number label This uses a new Library Setting for "Require call number labels in Copy Editor" for the benefit of libraries that with to use a predefined Prefix (such as FIC or EZ) instead of individual call number labels for each volume. When the setting is True, the call number label field is marked required and the Save buttons disabled until a value is present. When the setting is False, the call number label is not required. In addition, the Angular interface adds an additional check for Prefix, so if the call number label is empty then the Prefix is required. Acknowledgements: Org Unit Setting created by Kyle Huckins Angular and AngularJS changes done by New Developers Working Group Signed-off-by: Terran McCanna Signed-off-by: Michele Morgan --- .../app/staff/cat/volcopy/vol-edit.component.html | 4 ++-- .../app/staff/cat/volcopy/vol-edit.component.ts | 25 +++++++++++++++++++--- .../lib/OpenILS/Application/Cat/AssetCommon.pm | 6 ++++-- .../web/js/ui/default/staff/cat/volcopy/app.js | 5 +++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html index 5926461ec4..2e295282a7 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html @@ -305,8 +305,8 @@ diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts index ab9309cf09..8c3f30a0c8 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts @@ -54,6 +54,9 @@ export class VolEditComponent implements OnInit { deleteVolCount: number = null; deleteCopyCount: number = null; + // Set default for Call Number Label requirement + requireCNL = true; + // When adding multiple vols via add-many popover. addVolCount: number = null; @@ -96,6 +99,12 @@ export class VolEditComponent implements OnInit { // It's possible the loaded data is not strictly allowed, // e.g. empty string call number labels .then(_ => this.emitSaveChange(true)); + + // Check to see if call number label is required + this.org.settings('cat.require_call_number_labels') + .then(settings => {this.requireCNL = + Boolean(settings['cat.require_call_number_labels']); + }); } copyStatLabel(copy: IdlObject): string { @@ -534,9 +543,19 @@ export class VolEditComponent implements OnInit { const badVols = this.context.volNodes().filter(volNode => { const vol = volNode.target; - return !( - vol.prefix() && vol.label() && vol.suffix && vol.label_class() - ); + + // If call number label is not required, then require prefix + if (!vol.label()) { + if (this.requireCNL == true) { + return !( + vol.label() + ); + } else { + return ( + vol.prefix() < 0 + ); + } + } }).length > 0; return !badVols; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm index 0da6db609b..079fed631e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm @@ -618,10 +618,12 @@ sub create_volume { ); my $label = undef; + my $labelexists = undef; if(@$vols) { # we've found an exising volume if($override->{all} || grep { $_ eq 'VOLUME_LABEL_EXISTS' } @{$override->{events}}) { $label = $vol->label; + $labelexists = 1; } else { return ( undef, @@ -632,7 +634,7 @@ sub create_volume { # create a temp label so we can create the new volume, # then de-dup it with the existing volume - $vol->label( "__SYSTEM_TMP_$$".time) if $label; + $vol->label( "__SYSTEM_TMP_$$".time) if $labelexists; $vol->creator($editor->requestor->id); $vol->create_date('now'); @@ -642,7 +644,7 @@ sub create_volume { $editor->create_asset_call_number($vol) or return (undef, $editor->die_event); - if($label) { + if($labelexists) { # now restore the label and merge into the existing record $vol->label($label); return OpenILS::Application::Cat::Merge::merge_volumes($editor, [$vol], $$vols[0]); diff --git a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js index 4a710135b2..e0c9722f5f 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js @@ -848,6 +848,11 @@ function(egCore , $q) { $scope.prefix = $scope.callNumber.prefix(); $scope.suffix = $scope.callNumber.suffix(); $scope.classification = $scope.callNumber.label_class(); + + // If no call number label, set to empty string to avoid merging problem + if ($scope.callNumber.label() == null) { + $scope.callNumber.label(''); + } $scope.label = $scope.callNumber.label(); $scope.copy_count = $scope.copies.length; -- 2.11.0