KMAIN 1908 LP 1437112 Added a library selector that displays an
authorVictoria Lewis <vlewis@catalystitservices.com>
Thu, 15 Oct 2015 18:59:47 +0000 (11:59 -0700)
committerVictoria Lewis <vlewis@catalystitservices.com>
Thu, 15 Oct 2015 18:59:47 +0000 (11:59 -0700)
indented org unit tree instead of a flat list for selecting default
search library and preferred library modified
Open-ILS/src/templates/staff/admin/workstation/t_search_prefs.tt2 and
Open-ILS/web/js/ui/default/staff/admin/workstation/app.js

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/cat/catalog/app.js

index 5b1c12a..e6a7a04 100644 (file)
@@ -1,82 +1,88 @@
 <div class="container" id="admin-workstation-printing">
 
-  <style>
+<style>
     /* TODO: more context and move me */
     textarea {
-      height: 400px;
-      width: 100%;
+        height: 400px;
+        width: 100%;
     }
     h2 { margin-bottom: 15px }
       
-  </style>
+</style>
 
-  <div class="row"> 
-    <div class="col-md-12">
-      <h2>[% l('Library & Search Preferences') %]</h2>
+    <div class="row">
+        <div class="col-md-12">
+            <h2>[% l('Library & Search Preferences') %]</h2>
+        </div>
     </div>
-  </div>
 
-  <div class="row"> 
-    <div class="col-md-12">
-      
-      <div class="tab-content">
-        <div class="tab-pane active">
+    <div class="row">
+        <div class="col-md-6">
+            <h3>Default Search Library</h3>
+            <p>The default search library setting determines what library is searched from the advanced 
+            search screen and portal page by default. Manual selection of a search library will override 
+            it. One recommendation is to set the search library to the highest point you would normally 
+            want to search.</p>
+            <div class="btn-group " dropdown>
+                <button type="button" class="btn btn-default dropdown-toggle">
+                    <span style="padding-right: 5px;">{{getDefaultSelectedName}}</span>
+                    <span class="caret"></span>
+                </button>
+                <ul class="dropdown-menu">
+                    <li ng-repeat="org in orgList"  ng-hide="hiddenTest(org.id)">
+                        <a href ng-click="orgDefaultChanged(org)"  a-disabled="disableTest(org.id)"
+                            style="padding-left: {{org.depth * 10 + 5}}px">
+                            {{org.shortname}}
+                        </a>
+                    </li>
+                </ul>
+            </div>
+        </div>      <!-- col -->
+    </div><!-- row -->
+
+    <div class="row">
+        <div class="col-md-6">
+            <h3>Preferred Library</h3>
+            <p>The preferred library is used to show copies and URIs regardless of the library 
+            searched. One recommendation is to set this to your workstation library so that local 
+            copies show up first in search results.</p>
+            <div class="btn-group " dropdown>
+                <button type="button" class="btn btn-default dropdown-toggle">
+                    <span style="padding-right: 5px;">{{getPrefDefaultSelectedName}}</span> 
+                    <span class="caret"></span>
+                </button>
+                <ul class="dropdown-menu">
+                    <li ng-repeat="org in orgList"  ng-hide="hiddenTest(org.id)">
+                        <a href ng-click="prefOrgDefaultChanged(org)"  a-disabled="disableTest(org.id)"
+                        style="padding-left: {{org.depth * 10 + 5}}px">
+                            {{org.shortname}}
+                        </a>
+                    </li>
+                </ul>
+            </div>
+        </div> <!-- col -->
+    </div>  <!-- row -->
 
-          <!-- printer config UI -->
-          <div class="row" ng-hide="isTestView">
-            <div class="col-md-6">
-                       <h3>Default Search Library</h3>
-                       <p>The default search library setting determines what library is searched from the advanced 
-                       search screen and portal page by default. Manual selection of a search library will override 
-                       it. One recommendation is to set the search library to the highest point you would normally 
-                       want to search.</p>
-              <div class="input-group">
+    <div class="row">
+        <div class="col-md-6">
+            <h3>Default Advanced Search Pane</h3>
+            <p>Advanced search has secondary panes for Numeric and MARC Expert searching. You
+            can change which one is loaded by default when opening a new catalog window here.</p>
+            <div class="input-group">
                 <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">
-                        {{getOrgLabel(org.shortname)}}
-                    </option>
-                                 </select>
-                </div><!-- /btn-group -->
-              </div><!-- /input-group -->
+                    <select class="btn btn-default dropdown-toggle">
+                        <option>[% l('Select Pane') %]</option>
+                        </select>
+                    </div><!-- /btn-group -->
+                </div><!-- /input-group -->
             </div><!-- col -->
+        </div><!-- row -->
+
+    <br>
+    <div>
         <button class="btn btn-default" ng-click="setDefaultLibs() ">
         [% l('Save') %]
         </button>
-
-          </div><!-- row --><div class="row" ng-hide="isTestView">
-            <div class="col-md-6">
-                               <h3>Preferred Library</h3>
-                               <p>The preferred library is used to show copies and URIs regardless of the library 
-                               searched. One recommendation is to set this to your workstation library so that local 
-                               copies show up first in search results.</p>
-              <div class="input-group">
-                <div class="input-group-btn" dropdown>
-                  <select class="btn btn-default dropdown-toggle" ng-model="selectedPrefOrg">
-                    <option ng-repeat="org in orgList" value="{{org}}"
-                    ng-selected="org.shortname == selectedPrefOrg">
-                        {{getPrefOrgLabel(org.shortname)}}
-                    </option>
-                                 </select>
-                </div><!-- /btn-group -->
-              </div><!-- /input-group -->
-            </div><!-- col -->
-
-          </div><!-- row -->
-                       <div class="row" ng-hide="isTestView">
-                               <div class="col-md-6">
-                                       <h3>Default Advanced Search Pane</h3>
-                                       <p>Advanced search has secondary panes for Numeric and MARC Expert searching. You 
-                                       can change which one is loaded by default when opening a new catalog window here.</p>
-                                       <div class="input-group">
-                                               <div class="input-group-btn" dropdown>
-                                                       <select class="btn btn-default dropdown-toggle">
-                                                               <option>[% l('Select Pane') %]</option>
-                                                       </select>
-                                               </div><!-- /btn-group -->
-                                       </div><!-- /input-group -->
-                               </div><!-- col -->
-                       </div><!-- row -->
+    </div>
 </div><!-- container -->
 
index 5b38f19..9a2c48d 100644 (file)
@@ -193,19 +193,15 @@ function($scope , $window , $location, egCore, egOrg, egConfirmDialog, egAuth) {
     });
 
     egCore.hatch.getItem('eg.pref.lib.default')
-    .then(function(def) {
-        if (def == undefined) {
+    .then(function(prefDef) {
+        if (prefDef == undefined) {
            egCore.hatch.setItem(
             'eg.pref.lib.default', $scope.orgList[0]);
-            def =  $scope.orgList[0].shortname;
+            prefDef =  $scope.orgList[0].shortname;
         }
         //This lets our dropdown auto-select our default preferred lib.
-        $scope.selectedPrefOrg = def;
-        angular.forEach($scope.orgList, function(val, key) {
-            if(JSON.stringify(def.shortname) == JSON.stringify(val.shortname)){
-            $scope.selectedPrefOrg = val.shortname;
-            }
-        });
+        $scope.selectedPrefOrg =  prefDef;
+        $scope.getPrefDefaultSelectedName = getSelectedName($scope.selectedPrefOrg.shortname);
     });
 
     egCore.hatch.getItem('eg.search.lib.default')
@@ -217,38 +213,52 @@ function($scope , $window , $location, egCore, egOrg, egConfirmDialog, egAuth) {
         }
         //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.getDefaultSelectedName = getSelectedName($scope.selectedOrg.shortname);
     });
 
-    $scope.getOrgLabel = function(org) {
-        return org == $scope.defaultSearchLib?
-            egCore.strings.$replace(egCore.strings.DEFAULT_ORG_LABEL, {org:org}) :org;
+    $scope.orgDefaultChanged = function(org) {
+        $scope.selectedOrg = org;
+        $scope.getDefaultSelectedName =  $scope.selectedOrg.shortname;
+        if ($scope.onchange) $scope.onchange($scope.getDefaultSelectedName);
+    }
+
+    $scope.prefOrgDefaultChanged = function(org) {
+        $scope.selectedPrefOrg = org;
+        $scope.getPrefDefaultSelectedName = getSelectedName($scope.selectedPrefOrg.shortname);
+        if ($scope.onchange) $scope.onchange($scope.getPrefDefaultSelectedName);
     }
 
-    $scope.getPrefOrgLabel = function(org) {
-        return org == $scope.defaultPrefLib?
-            egCore.strings.$replace(egCore.strings.DEFAULT_PREF_ORG_LABEL, {pref:org}) :org;
+    var getSelectedName = function(prefOrg) {
+        if (prefOrg) {
+            return prefOrg
+        } else {
+           return $scope.orgList[0].shortname;
+        }
     }
 
     $scope.setDefaultLibs = function() {
-        setDefaultSearchLib();
-        setDefaultPrefLib();
+        if($scope.selectedOrg.shortname){
+            setDefaultSearchLib();
+        }
+        if($scope.selectedPrefOrg.shortname ){
+            setDefaultPrefLib();
+        }
     }
 
     function setDefaultSearchLib() {
-        egCore.hatch.setItem(
-            'eg.search.lib.default', JSON.parse($scope.selectedOrg))
-        .then(function() { $scope.defaultSearchLib = $scope.selectedOrg });
+        if($scope.selectedOrg){
+            egCore.hatch.setItem(
+                'eg.search.lib.default', ($scope.selectedOrg))
+            //.then(function() { $scope.defaultSearchLib = $scope.selected.Org });
+       }
     }
 
     function setDefaultPrefLib() {
-        egCore.hatch.setItem(
-            'eg.pref.lib.default',  JSON.parse($scope.selectedPrefOrg))
-        .then(function() { $scope.defaultPrefLib = $scope.selectedPrefOrg });
+        if($scope.selectedPrefOrg ) {
+            egCore.hatch.setItem(
+                'eg.pref.lib.default',  $scope.selectedPrefOrg)
+            //.then(function() { $scope.defaultPrefLib = $scope.selectedPrefOrg });
+        }
     }
 
     // ---------------------
index 0f356b5..b327adc 100644 (file)
@@ -261,8 +261,8 @@ function($scope , $routeParams , $location , $q , egCore , egHolds,
         // The URL is otherwise generated through user navigation.
         if ($scope.catalog_url) return; 
 
-        var default_search_library = egCore.hatch.getLocalItem('eg.search.lib.default');
         var url = $location.absUrl().replace(/\/staff.*/, '/opac/advanced');
+        var default_search_library = egCore.hatch.getLocalItem('eg.search.lib.default');
         var preferred_search_library = egCore.hatch.getLocalItem('eg.pref.lib.default');
 
         if (default_search_library.id) {