web staff : locale selector
authorBill Erickson <berick@esilibrary.com>
Fri, 6 Dec 2013 15:16:15 +0000 (10:16 -0500)
committerBill Erickson <berick@esilibrary.com>
Fri, 6 Dec 2013 15:16:18 +0000 (10:16 -0500)
leverage the existing set_eg_locale URL parameter for applying the
selected locale.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/t_navbar.tt2
Open-ILS/web/js/ui/default/staff/navbar.js

index f00855d..2f8caf5 100644 (file)
       <li>
         <a ng-cloak ng-show="username" 
           ng-init="workstation = '[% l('<no workstation>') %]'">
-          [% l('{{username}} @ {{workstation}}') %]
+            [% l('{{username}} @ {{workstation}}') %]
         </a>
       </li>
+
+      <!-- locale selector -->
+      <li class="dropdown">
+        <a href='' class="dropdown-toggle" data-toggle="dropdown">
+            [% lcl = ctx.locale;  ctx.locales.$lcl %]
+            <span class="glyphicon glyphicon-flag"></span>
+        </a>
+        <ul class="dropdown-menu">
+        [% FOR locale IN ctx.locales.keys.sort %]
+          <li 
+            ng-class="{disabled : '[% ctx.locale %]'=='[% locale %]'}">
+            <a href="" ng-click="applyLocale('[% locale %]')">
+                [% ctx.locales.$locale %]
+            </a>
+          </li>
+        [% END %]
+        </ul>
+      </li>
+
       <li class="dropdown" ng-show="username">
         <a href='' class="dropdown-toggle glyphicon glyphicon-list" 
           data-toggle="dropdown"></a>
         <ul class="dropdown-menu">
-          <li class="disabled"><a href="" ng-click="" target="_self">
-            <span class="glyphicon glyphicon-random"></span>
-            [% l('Change Operator') %]</a></li>
+          <li class="disabled">
+            <a href="" ng-click="" target="_self">
+              <span class="glyphicon glyphicon-random"></span>
+              [% l('Change Operator') %]
+            </a>
+          </li>
           <li>
             <a href="./login" ng-click="logout()" target="_self">
               <span class="glyphicon glyphicon-log-out"></span>
index 7e53529..b54975c 100644 (file)
@@ -1,7 +1,13 @@
 /**
  * Free-floating controller which can be used by any app.
  */
-function NavCtrl($scope, egStartup, egAuth, egEnv) {
+function NavCtrl($scope, $window, $location, egStartup, egAuth, egEnv) {
+
+    $scope.applyLocale = function(locale) {
+        // EGWeb.pm can change the locale for us w/ the right param
+        $window.location.href = 
+            $location.search('set_eg_locale', locale).absUrl();
+    }
 
     // tied to logout link
     $scope.logout = function() {
@@ -42,4 +48,5 @@ function NavCtrl($scope, egStartup, egAuth, egEnv) {
 }
 
 // minify-safe dependency injection
-NavCtrl.$inject = ['$scope', 'egStartup', 'egAuth', 'egEnv'];
+NavCtrl.$inject = ['$scope', '$window', 
+    '$location', 'egStartup', 'egAuth', 'egEnv'];