From: Galen Charlton Date: Wed, 9 Dec 2015 14:58:16 +0000 (-0500) Subject: teach vol/copy editor how to deal with copy alerts X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9e248144003106c7e29eb950c8423badc92717df;p=working%2FEvergreen.git teach vol/copy editor how to deal with copy alerts Signed-off-by: Galen Charlton Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index a86090aafd..6d39e16906 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -7201,6 +7201,7 @@ SELECT usr, + @@ -7227,6 +7228,7 @@ SELECT usr, + 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 14a52d4b63..e52d94f341 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm @@ -258,6 +258,39 @@ sub update_copy_notes { return undef; } +sub update_copy_alerts { + my($class, $editor, $copy) = @_; + + return undef if $copy->isdeleted; + + my $evt; + my $incoming_copy_alerts = $copy->copy_alerts; + + for my $incoming_copy_alert (@$incoming_copy_alerts) { + next unless $incoming_copy_alert; + + if ($incoming_copy_alert->isnew) { + next if ($incoming_copy_alert->isdeleted); # if it was added and deleted in the same session + + my $new_copy_alert = Fieldmapper::asset::copy_alert->new(); + $new_copy_alert->copy( $copy->id ); + $new_copy_alert->temp( $incoming_copy_alert->temp ); + $new_copy_alert->ack_time( $incoming_copy_alert->ack_time ); + $new_copy_alert->note( $incoming_copy_alert->note ); + $new_copy_alert->alert_type( $incoming_copy_alert->alert_type ); + $new_copy_alert->create_staff( $incoming_copy_alert->create_staff || $editor->requestor->id ); + $incoming_copy_alert = $editor->create_asset_copy_alert($new_copy_alert) + or return $editor->event; + } elsif ($incoming_copy_alert->ischanged) { + $incoming_copy_alert = $editor->update_asset_copy_alert($incoming_copy_alert) + } elsif ($incoming_copy_alert->isdeleted) { + $incoming_copy_alert = $editor->delete_asset_copy_alert($incoming_copy_alert->id) + } + + } + + return undef; +} sub update_copy_tags { my($class, $editor, $copy) = @_; @@ -303,8 +336,6 @@ sub update_copy_tags { return undef; } - - sub update_copy { my($class, $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib) = @_; @@ -415,9 +446,13 @@ sub update_fleshed_copies { my $notes = $copy->notes; $copy->clear_notes; + my $tags = $copy->tags; $copy->clear_tags; + my $copy_alerts = $copy->copy_alerts; + $copy->clear_copy_alerts; + if( $copy->isdeleted ) { $evt = $class->delete_copy($editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib); return $evt if $evt; @@ -445,6 +480,9 @@ sub update_fleshed_copies { $copy->tags( $tags ); $evt = $class->update_copy_tags($editor, $copy); + $copy->copy_alerts( $copy_alerts ); + $evt = $class->update_copy_alerts($editor, $copy); + return $evt if $evt; } diff --git a/Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 b/Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 index bba9ab1138..6107ec50d3 100644 --- a/Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 +++ b/Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 @@ -384,6 +384,13 @@ type="button"> [% l('Copy Notes') %] + diff --git a/Open-ILS/src/templates/staff/cat/volcopy/t_copy_alerts.tt2 b/Open-ILS/src/templates/staff/cat/volcopy/t_copy_alerts.tt2 new file mode 100644 index 0000000000..043a5eadba --- /dev/null +++ b/Open-ILS/src/templates/staff/cat/volcopy/t_copy_alerts.tt2 @@ -0,0 +1,94 @@ +
+ + + +
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 2592be771a..36827fe60a 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 @@ -136,6 +136,21 @@ function(egCore , $q) { ); }; + service.get_copy_alert_types = function(orgs) { + return egCore.pcrud.search('ccat', + { active : 't' }, + {}, + { atomic : true } + ); + }; + + service.get_copy_alerts = function(copy_id) { + return egCore.pcrud.search('aca', { copy : copy_id, ack_time : null }, + { flesh : 1, flesh_fields : { aca : ['alert_type'] } }, + { atomic : true } + ); + }; + service.get_locations = function(orgs) { return egCore.pcrud.search('acpl', {owning_lib : orgs, deleted : 'f'}, @@ -263,6 +278,10 @@ function(egCore , $q) { if (!cp.parts()) cp.parts([]); // just in case... + service.get_copy_alerts(cp.id()).then(function(aca) { + cp.copy_alerts(aca); + }); + var lib = cp.call_number().owning_lib(); var cn = cp.call_number().id(); @@ -824,6 +843,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , statcats : true, copy_notes : true, copy_tags : true, + copy_alerts : true, attributes : { status : true, loan_duration : true, @@ -1853,6 +1873,63 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , }); } + $scope.copy_alerts_dialog = function(copy_list) { + if (!angular.isArray(copy_list)) copy_list = [copy_list]; + + return $modal.open({ + templateUrl: './cat/volcopy/t_copy_alerts', + animation: true, + controller: + ['$scope','$modalInstance', + function($scope , $modalInstance) { + + itemSvc.get_copy_alert_types().then(function(ccat) { + $scope.alert_types = ccat; + }); + + $scope.focusNote = true; + $scope.copy_alert = { + create_staff : egCore.auth.user().id(), + note : '', + temp : false + }; + + if (copy_list.length == 1) { + $scope.copy_alert_list = copy_list[0].copy_alerts(); + } + + $scope.ok = function(copy_alert) { + + if (typeof(copy_alert.note) != 'undefined' && + copy_alert.note != '') { + angular.forEach(copy_list, function (cp) { + var a = new egCore.idl.aca(); + a.isnew(1); + a.create_staff(copy_alert.create_staff); + a.note(copy_alert.note); + a.temp(copy_alert.temp ? 't' : 'f'); + a.copy(cp.id()); + a.ack_time(null); + a.alert_type( + $scope.alert_types.filter(function(at) { + return at.id() == copy_alert.alert_type; + })[0] + ); + cp.copy_alerts().push( a ); + }); + } + + $modalInstance.close(); + } + + $scope.cancel = function($event) { + $modalInstance.dismiss(); + $event.preventDefault(); + } + }] + }); + } + }]) .directive("egVolTemplate", function () { @@ -1874,6 +1951,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , statcats : true, copy_notes : true, copy_tags : true, + copy_alerts : true, attributes : { status : true, loan_duration : true,