LP1735816: Delete Copy Notes in the Web Client user/rsteed/lp1735816_del_copy_notes_web
authorJason Boyer <jboyer@library.in.gov>
Thu, 21 Jun 2018 19:57:41 +0000 (15:57 -0400)
committerRemington Steed <rjs7@calvin.edu>
Mon, 25 Jun 2018 16:22:54 +0000 (12:22 -0400)
A combination of calling convention errors and
template picky-ness prevented the deletion of
copy notes in the web client. This patch returns
that ability.

Signed-off-by: Jason Boyer <jboyer@library.in.gov>
Signed-off-by: Remington Steed <rjs7@calvin.edu>
Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm
Open-ILS/src/templates/staff/cat/volcopy/t_copy_notes.tt2
Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js

index e52d94f..f9f60dc 100644 (file)
@@ -250,7 +250,7 @@ sub update_copy_notes {
         } elsif ($incoming_note->ischanged) {
             $incoming_note = $editor->update_asset_copy_note($incoming_note)
         } elsif ($incoming_note->isdeleted) {
-            $incoming_note = $editor->delete_asset_copy_note($incoming_note->id)
+            $incoming_note = $editor->delete_asset_copy_note($incoming_note)
         }
     
     }
index a679afa..96c7d18 100644 (file)
@@ -68,7 +68,7 @@
             <div class="col-md-3">
               <label>
                 <input type="checkbox" ng-model="deleted" ng-change="n.isdeleted(deleted)"/>
-                [% l('Deleted?') %]
+                [% l('Delete?') %]
               </label>
             </div>
           </div>
index a744a0c..a96568e 100644 (file)
@@ -1859,9 +1859,16 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
                 egCore.org.settings([
                     'ui.staff.require_initials.copy_notes'
                 ]).then(function(set) {
-                    $scope.require_initials = Boolean(set['ui.staff.require_initials.copy_notes']);
+                    $scope.require_initials_ous = Boolean(set['ui.staff.require_initials.copy_notes']);
                 });
 
+                $scope.are_initials_required = function() {
+                  $scope.require_initials = $scope.require_initials_ous && ($scope.note.value.length > 0 || $scope.note.title.length > 0);
+                };
+
+                $scope.$watch('note.value.length', $scope.are_initials_required);
+                $scope.$watch('note.title.length', $scope.are_initials_required);
+
                 $scope.note_list = [];
                 if (copy_list.length == 1) {
                     $scope.note_list = copy_list[0].notes();
@@ -1869,28 +1876,30 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
 
                 $scope.ok = function(note) {
 
-                    if ($scope.initials) {
-                        note.value = egCore.strings.$replace(
-                            egCore.strings.COPY_NOTE_INITIALS, {
-                            value : note.value, 
-                            initials : $scope.initials,
-                            ws_ou : egCore.org.get(
-                                egCore.auth.user().ws_ou()).shortname()
+                    if (note.value.length > 0 || note.title.length > 0) {
+                        if ($scope.initials) {
+                            note.value = egCore.strings.$replace(
+                                egCore.strings.COPY_NOTE_INITIALS, {
+                                value : note.value,
+                                initials : $scope.initials,
+                                ws_ou : egCore.org.get(
+                                    egCore.auth.user().ws_ou()).shortname()
+                            });
+                        }
+
+                        angular.forEach(copy_list, function (cp) {
+                            if (!angular.isArray(cp.notes())) cp.notes([]);
+                            var n = new egCore.idl.acpn();
+                            n.isnew(1);
+                            n.creator(note.creator);
+                            n.pub(note.pub);
+                            n.title(note.title);
+                            n.value(note.value);
+                            n.owning_copy(cp.id());
+                            cp.notes().push( n );
                         });
                     }
 
-                    angular.forEach(copy_list, function (cp) {
-                        if (!angular.isArray(cp.notes())) cp.notes([]);
-                        var n = new egCore.idl.acpn();
-                        n.isnew(1);
-                        n.creator(note.creator);
-                        n.pub(note.pub);
-                        n.title(note.title);
-                        n.value(note.value);
-                        n.owning_copy(cp.id());
-                        cp.notes().push( n );
-                    });
-
                     $uibModalInstance.close();
                 }