LP1821950 & LP1980409 Option to require call number label
authorTerran McCanna <tmccanna@georgialibraries.org>
Fri, 19 Aug 2022 17:38:56 +0000 (13:38 -0400)
committerMichele Morgan <mmorgan@noblenet.org>
Thu, 13 Oct 2022 17:32:45 +0000 (13:32 -0400)
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 <tmccanna@georgialibraries.org>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>

Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts
Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm
Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js

index e8c2b43..0e9142d 100644 (file)
           <ng-container *ngIf="copyIdx === 0">
             <input class="form-control form-control-sm" type="text"
               spellcheck="false"
-              [required]="true"
-              [ngClass]="{invalid: !volNode.target.label()}"
+              [required]="requireCNL"
+              [ngClass]="{invalid: !volNode.target.label() && requireCNL}"
               [ngModel]="volNode.target.label()"
               (change)="applyVolValue(volNode.target, 'label', $event.target.value)">
           </ng-container>
index 4fcf63e..26266f0 100644 (file)
@@ -53,6 +53,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;
 
@@ -95,6 +98,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 {
@@ -581,9 +590,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;
index 0da6db6..079fed6 100644 (file)
@@ -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]);
index 4a71013..e0c9722 100644 (file)
@@ -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;