LP#1832897: add miscellaneous carousels functionality to staff interface
[Evergreen.git] / Open-ILS / web / js / ui / default / staff / cat / bucket / record / app.js
index 14ebe42..29d64cc 100644 (file)
@@ -401,6 +401,34 @@ function($scope,  $location,  $q,  $timeout,  $uibModal,
         });
     }
 
+    // allows user to create a carousel from the selected bucket
+    $scope.openCreateCarouselDialog = function() {
+        if (!bucketSvc.currentBucket || !bucketSvc.currentBucket.id()) {
+            return;
+        }
+        $uibModal.open({
+            templateUrl: './cat/bucket/record/t_create_carousel',
+            backdrop: 'static',
+            controller :
+                ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) {
+                $scope.focusMe = true;
+                $scope.ok = function(args) {
+                    if (args && args.name) {
+                        return egCore.net.request(
+                            'open-ils.actor',
+                            'open-ils.actor.carousel.create.from_bucket',
+                            egCore.auth.token(), args.name, bucketSvc.currentBucket.id()
+                        ).then(function(carouselId) { $uibModalInstance.close(carouselId) });
+                    }
+                }
+                $scope.cancel = function() { $uibModalInstance.dismiss() }
+            }]
+        }).result.then(function(carouselId) {
+            // bouncing outside of AngularJS
+            $window.location.href = '/eg2/en-US/staff/admin/server/container/carousel';
+        });
+    }
+
     // opens the record export dialog
     $scope.openExportBucketDialog = function() {
         $uibModal.open({