From: Josh Stompro Date: Tue, 4 Feb 2020 15:30:28 +0000 (-0600) Subject: LP#1861732 - Allow copy template stat cat unset value (-1) X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fstompro%2Flp1861732_copy_template_unset_statcat_values;p=working%2FEvergreen.git LP#1861732 - Allow copy template stat cat unset value (-1) Xul copy templates allowed the user to save an unset value for a stat_cat, which was stored as -1 in the xul copy template. When those values are migrated to the webstaff client copy templates, the -1 value is preserved. But that value is passed directly to the database when saving a record, and -1 isn't a valid value. This change treats -1 the same as null or a blank line when applying the template, which allows the template to unset a stat cat value like before in the XUL client. Testing Notes: 1. Create some copy stat cats if they don't exist. 2. Clear out actor.usr_settings for the testing user, mainly the webstaff copy template key of 'webstaff.cat.copy.templates'. 3. In XUL client, create a copy template that includes setting a stat cat to the "" value. 4. In the webstaff client, edit an item and try to apply the migrated copy template. Before fix - you won't be able to save the copy after applying the template, it will just silently fail. If you check the postgres logs you will see an error about trying to set the stat cat value to -1. After fix - You will be able to save the copy after applying the template, and if a value for that stat cat was already set, it will be unset by the template. Signed-off-by: Josh Stompro --- 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 f19c4c998a..87e774c686 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 @@ -1278,7 +1278,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , newval = newval.id(); } - if (""+newval == "" || newval == null) { + if (""+newval == "" || newval == null || newval == -1) { $scope.working.statcats[id] = undefined; newval = null; }