From: Mike Risher Date: Tue, 19 May 2020 16:35:49 +0000 (+0000) Subject: lp1751356 Typing to select with item stat cat dropdowns X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fmrisher%2Flp1751356-item-stat-cats-combobox;p=working%2FEvergreen.git lp1751356 Typing to select with item stat cat dropdowns Stat cat dropdowns don’t show you characters as you type and doesn’t seem to work reliably. Modify them to resolve these issues. Signed-off-by: Mike Risher Changes to be committed: modified: Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 modified: Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js --- 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 7168f6ada1..80ce31ee43 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 @@ -516,15 +516,8 @@
  • - + +
  • 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 501a9c1785..27e05ea391 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 @@ -1286,7 +1286,21 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , } $scope.statcatUpdate = function (id) { - var newval = $scope.working.statcats[id]; + var newval; + + // use sc_selected_text to find the selected stat cat's id and update the working.statcats object with that id + angular.forEach($scope.statcats, function(statcat) { + if (statcat.id() === id) { + angular.forEach(statcat.entries(), function (entry) { + if (statcat.sc_selected_text === '') { + $scope.working.statcats[id] = null; + } else if (entry.value() === statcat.sc_selected_text) { + newval = entry.id(); + $scope.working.statcats[id] = entry.id(); + } + }) + } + }) if (typeof newval != 'undefined') { if (angular.isObject(newval)) { // we'll use the pkey @@ -1392,8 +1406,20 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , delete $scope.working.MultiMap[k]; }); egCore.hatch.setItem('cat.copy.last_template', n); + angular.forEach($scope.statcats, function(statcat) { + if ($scope.working.statcats[statcat.id()]) { + angular.forEach(statcat.entries(), function (entry) { + if (entry.id() === $scope.working.statcats[statcat.id()]) { + $scope.working.statcats[statcat.id()] = entry.id(); + statcat.sc_selected_text = entry.value(); + } + }) + } else { + statcat.sc_selected_text = undefined; + $scope.working.statcats[statcat.id()] = undefined; + } + }); } - $scope.copytab = 'working'; $scope.tab = 'edit'; $scope.summaryRecord = null; @@ -1829,6 +1855,12 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , if (!none && Object.keys(value_hash).length == 1) { $scope.working.statcats[sc.id()] = value_hash[Object.keys(value_hash)[0]]; + // populate stat cat combo-box with correct text + angular.forEach(item.stat_cat_entries(), function (entry) { + if (entry.id() === $scope.working.statcats[sc.id()]) { + sc.sc_selected_text=entry.value(); + } + }); $scope.working.statcats_multi[sc.id()] = false; } else if (item_list.length > 1 && Object.keys(value_hash).length > 0) { $scope.working.statcats[sc.id()] = undefined; @@ -1899,6 +1931,11 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , if (!$scope.in_item_select) { $scope.working.statcats[s.id()] = undefined; } + s.sc_entry_values = s.entries().map(entry => { + return entry.value(); + }); + s.sc_entry_values.unshift(''); + if (!s.sc_selected_text) s.sc_selected_text = ''; createStatcatUpdateWatcher(s.id()); }); $scope.in_item_select = false; @@ -2080,6 +2117,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , $scope.workingSaveAndExit = function () { $scope.workingToComplete(); + $scope.removeNullStatCats(); $scope.saveAndExit(); } @@ -2087,6 +2125,17 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , $scope.saveCompletedCopies(true); } + $scope.removeNullStatCats = function () { + $scope.completed_copies.forEach(cp => { + var sces = cp.stat_cat_entries(); + sces = sces.filter(entry => { + var id = entry.stat_cat(); + return ($scope.working.statcats[id] !== null); + }); + cp.stat_cat_entries(sces); + }); + } + } $scope.copy_notes_dialog = function(copy_list) { @@ -2459,6 +2508,19 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , } }); $scope.template_name = ''; + angular.forEach($scope.statcats, function(statcat) { + if ($scope.working.statcats[statcat.id()]) { + angular.forEach(statcat.entries(), function (entry) { + if (entry.id() === $scope.working.statcats[statcat.id()]) { + $scope.working.statcats[statcat.id()] = entry.id(); + statcat.sc_selected_text = entry.value(); + } + }) + } else { + statcat.sc_selected_text = undefined; + $scope.working.statcats[statcat.id()] = undefined; + } + }) } $scope.deleteTemplate = function (n) { @@ -2475,6 +2537,14 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , $scope.saveTemplate = function (n) { if (n) { var tmpl = {}; + + angular.forEach($scope.statcats, function(statcat) { + angular.forEach(statcat.entries(), function (entry) { + if (entry.value() === statcat.sc_selected_text) { + $scope.working.statcats[statcat.id()] = entry.id(); + } + }) + }) angular.forEach($scope.working, function (v,k) { if (angular.isObject(v)) { // we'll use the pkey @@ -2632,6 +2702,9 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , $scope.working.statcats = {}; $scope.working.statcats[s.id()] = undefined; + s.sc_entry_values = s.entries().map(entry => { + return entry.value(); + }); createStatcatUpdateWatcher(s.id()); }); });