LP1437112 save default search library to local storage. Committed. Will add the...
authorVictoria Lewis <vlewis@catalystitservices.com>
Fri, 28 Aug 2015 19:35:59 +0000 (12:35 -0700)
committerVictoria Lewis <vlewis@catalystitservices.com>
Fri, 28 Aug 2015 19:35:59 +0000 (12:35 -0700)
Open-ILS/src/templates/staff/admin/workstation/t_search_prefs.tt2
Open-ILS/web/js/ui/default/staff/admin/workstation/app.js
Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js

index fc6e8f1..cde8e68 100644 (file)
@@ -34,8 +34,7 @@
                 <div class="input-group-btn" dropdown>
                                         <select class="btn btn-default dropdown-toggle" ng-model="selectedOrg">
                     <option ng-repeat="org in orgList" value="{{org}}"
-                     ng-selected="org.shortname == selectedOrg">
-                        <!--{{org.shortname}} -->
+                      ng-selected="org.shortname == selectedOrg">
                         {{getOrgLabel(org.shortname)}}
                     </option>
                                  </select>
index ec23e43..3414251 100644 (file)
@@ -180,58 +180,42 @@ function($scope , $window , $location , egCore , egConfirmDialog) {
 /*
  *  Search Preferences Controller
  */
-.controller('SearchPrefsCtrl', 
+.controller('SearchPrefsCtrl',
     ['$scope','$window','$location', 'egCore', 'egOrg','egConfirmDialog', 'egAuth',
 function($scope , $window , $location, egCore, egOrg, egConfirmDialog, egAuth) {
     console.log('SearchPrefsCtrl');
-    
-var allOrgs = [];
-    var permMap = {};
-    $scope.contextOrg = egCore.org.get(egCore.auth.user().ws_ou());
-
-    // fetch the stored search lib info
-    egCore.hatch.getItem($scope.orgList)
-    .then(function(all) {
-        allOrgs = all || []; 
-        $scope.org = 
-            allOrgs.map(function(w) { return w.shortname });
-        return egCore.hatch.getItem('eg.search.lib.default');
-    })
-    .then(function(def) { 
-        if (def == undefined) {
-           // def =  $scope.orgList[0].shortname; 
-           egCore.hatch.setItem(
-            'eg.search.lib.default', $scope.orgList[0]);  
-            $scope.defaultSearchLib = $scope.orgList[0];
-            def =  $scope.orgList[0].shortname; 
-            
-            //alert(" def " + def);
-           // $scope.defaultSearchLib = $scope.orgList[0].shortname;  
-        } else {
-            $scope.defaultSearchLib = def;
-            //The option initially loaded will be the default Search Library
-        }
-        alert(def  + "def 214 ");
-        $scope.activeSearchLib = def; //Should we make this also show default workstation's library if no default search library exists?
-        $scope.selectedOrg = def;
-    });
-
     $scope.orgList = egOrg.list().map(function(org) {
         return {
             id : org.id(),
             shortname : org.shortname(), 
             depth : org.ou_type().depth()
+        }
+    });
+
+    egCore.hatch.getItem('eg.search.lib.default')
+    .then(function(def) {
+        if (def == undefined) {
+           egCore.hatch.setItem(
+            'eg.search.lib.default', $scope.orgList[0]);
+            def =  $scope.orgList[0].shortname;
+        }
+        //This lets our dropdown auto-select our default search lib.
+        $scope.selectedOrg = def;
+        angular.forEach($scope.orgList, function(val, key) {
+            if(JSON.stringify(def.shortname) == JSON.stringify(val.shortname)){
+            $scope.selectedOrg = val.shortname;
             }
         });
-        
-        $scope.getOrgLabel = function(org) {
-        return org == $scope.defaultSearchLib ? 
-            egCore.strings.$replace(egCore.strings.DEFAULT_ORG_LABEL, {org:org}) : org;
+    });
+
+    $scope.getOrgLabel = function(org) {
+        return org == $scope.defaultSearchLib?
+            egCore.strings.$replace(egCore.strings.DEFAULT_ORG_LABEL, {org:org}) :org;
     }
 
     $scope.setDefaultSearchLib = function() {
         egCore.hatch.setItem(
-            'eg.search.lib.default', $scope.selectedOrg)
+            'eg.search.lib.default', JSON.parse($scope.selectedOrg))
         .then(function() { $scope.defaultSearchLib = $scope.selectedOrg });
     }
 
index 06a1889..f58eab2 100644 (file)
@@ -98,6 +98,7 @@ function($scope,  egCore,  egGridDataProvider , egConfirmDialog) {
                 coArgs, {title : $scope.selectedNcType()}
             );
         }
+        $scope.args.barcode=' ';
     }
 
     function performCheckout(method, args, data) {