replace item barcode
authorBill Erickson <berick@esilibrary.com>
Fri, 6 Jun 2014 21:01:46 +0000 (17:01 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 6 Jun 2014 21:01:46 +0000 (17:01 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/cat/item/replace_barcode/index.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/navbar.tt2
Open-ILS/web/js/ui/default/staff/cat/item/replace_barcode/app.js [new file with mode: 0644]

diff --git a/Open-ILS/src/templates/staff/cat/item/replace_barcode/index.tt2 b/Open-ILS/src/templates/staff/cat/item/replace_barcode/index.tt2
new file mode 100644 (file)
index 0000000..6472a48
--- /dev/null
@@ -0,0 +1,49 @@
+[%
+  WRAPPER "staff/base.tt2";
+  ctx.page_title = l("Replace Item Barcode"); 
+  ctx.page_app = "egItemReplaceBarcode";
+  ctx.page_ctrl = "ReplaceItemBarcodeCtrl";
+%]
+
+[% BLOCK APP_JS %]
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/ui.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/item/replace_barcode/app.js"></script>
+[% END %]
+
+<h2>[% l('Replace Item Barcode') %]</h2>
+
+<div class="row">
+  <div class="col-md-6 pad-vert">
+    <form role="form" ng-submit="updateBarcode()">
+      <div class="form-group">
+        <label for="barcode1">[% l('Enter Original Barcode for Item') %]</label>
+        <input type="text" class="form-control" id="barcode1" required
+          ng-model="barcode1"
+          placeholder="[% l('Original Barcode...') %]" select-me="focusBarcode">
+      </div>
+      <div class="form-group">
+        <label for="barcode2">[% l('Enter New Barcode for Item') %]</label>
+        <input type="text" class="form-control" id="barcode2" 
+          ng-model="barcode2"
+          required placeholder="[% l('New Barcode...') %]">
+      </div>
+      <button type="submit" class="btn btn-default">[% l('Submit') %]</button>
+    </form>
+  </div>
+</div>
+
+<div class="row pad-vert">
+  <div class="col-md-6">
+    <div class="alert alert-danger" ng-if="copyNotFound">
+      [% l('Copy Not Found') %]
+    </div>
+    <div class="alert alert-success" ng-if="updateOK">
+      <span>[% l('Copy Updated') %]</span>
+      <span class="horiz-pad" ng-if="copyId">
+        <a href="./cat/item/{{copyId}}/summary" target="_self">
+          [% l('View Item Details') %]
+        </a>
+    </div>
+  </div>
+</div>
+[% END %]
index d2a668b..ffe08f6 100644 (file)
               <span>[% l('Record In-House Use') %]</span>
             </a>
           </li>
+          <li class="divider"></li>
+          <li>
+            <a href="./cat/item/replace_barcode/index" target="_self">
+              <span class="glyphicon glyphicon-barcode"></span>
+              <span>[% l('Replace Barcode') %]</span>
+            </a>
+          </li>
         </ul>
       </li>
 
        </ul>
       </li>
 
-      <!-- cataloging -->
+      <!-- admin -->
       <li class="dropdown">
         <a href="javascript:;" class="dropdown-toggle" 
           data-toggle="dropdown">[% l('Administration') %]
diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/replace_barcode/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/replace_barcode/app.js
new file mode 100644 (file)
index 0000000..33d1cb6
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+ * Item Display
+ */
+
+angular.module('egItemReplaceBarcode', 
+    ['ngRoute', 'ui.bootstrap', 'egCoreMod','egUiMod'])
+
+.controller('ReplaceItemBarcodeCtrl',
+       ['$scope','egCore',
+function($scope , egCore) {
+    egCore.startup.go();
+
+    $scope.focusBarcode = true;
+
+    $scope.updateBarcode = function() {
+        $scope.copyNotFound = false;
+        $scope.updateOK = false;
+
+        egCore.pcrud.search('acp', 
+            {deleted : 'f', barcode : $scope.barcode1})
+        .then(function(copy) {
+
+            if (!copy) {
+                $scope.focusBarcode = true;
+                $scope.copyNotFound = true;
+                return;
+            }
+
+            $scope.copyId = copy.id();
+            copy.barcode($scope.barcode2);
+
+            egCore.pcrud.update(copy).then(function(stat) {
+                $scope.updateOK = stat;
+                $scope.focusBarcode = true;
+            });
+        });
+    }
+}]);
+