child node creation
authorJason Etheridge <jason@esilibrary.com>
Mon, 11 Jul 2016 18:52:53 +0000 (14:52 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 18 Aug 2016 19:34:22 +0000 (15:34 -0400)
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/src/templates/staff/admin/actor/org_unit/t_main_tab.tt2
Open-ILS/web/js/ui/default/staff/admin/actor/org_unit/app.js

index 1d2e805..ebb6e20 100644 (file)
             <input type="checkbox" ng-model="i_am_sure" ng-disabled="!org"/>
         </div>
     </div>
+    <div class="row">
+        <div class="col-md-2">
+            <button class="form-control" ng-click="new_child()">[% l('New Child') %]</button>
+        </div>
+        <div class="col-md-9">
+                [% l('NOTE: The new org unit will not exist in the database until Update Org is applied.') %]
+        </div>
+    </div>
 
 </form>
 
index c5b34a7..f27f671 100644 (file)
@@ -31,8 +31,8 @@ angular.module('egOrgUnitApp',
 })
 
 .controller('OrgUnitCtrl',
-       ['$scope','$q','$routeParams','$window','egCore','egOrg','ngToast',
-function($scope , $q , $routeParams , $window , egCore , egOrg , ngToast ) {
+       ['$scope','$q','$routeParams','$window','egCore','egIDL','egOrg','ngToast',
+function($scope , $q , $routeParams , $window , egCore , egIDL , egOrg , ngToast ) {
 
     $scope.reset = function() {
         $scope.org = angular.copy($scope.selectedNode);
@@ -92,12 +92,15 @@ function($scope , $q , $routeParams , $window , egCore , egOrg , ngToast ) {
     // main tab behavior
 
     $scope.update = function() {
-        var new_org = egOrg.get($scope.org.id);
+        var new_org = $scope.org.id == -1 ? new egIDL.aou() : egOrg.get($scope.org.id);
+        new_org.id( $scope.org.id );
+        new_org.parent_ou( $scope.org.parent_ou );
         new_org.name( $scope.org.name );
         new_org.shortname( $scope.org.shortname );
         new_org.email( $scope.org.email );
         new_org.phone( $scope.org.phone );
-        egCore.pcrud.update(new_org).then(
+        new_org.ou_type( 2 ); // FIXME
+        egCore.pcrud[$scope.org.id == -1 ? 'create' : 'update'](new_org).then(
             function(res) { // success
                 window.sessionStorage.removeItem('eg.env.aou.tree');
                 egCore.env.load();
@@ -129,5 +132,12 @@ function($scope , $q , $routeParams , $window , egCore , egOrg , ngToast ) {
         );
     };
 
+    $scope.new_child = function() {
+        $scope.org.parent_ou = $scope.org.id;
+        $scope.org.id = -1;
+        $scope.org.name = '';
+        $scope.org.shortname = '';
+    };
+
 }])