Sha256: 864aa58ab7fe70e17d3f1dfd02a380cc348057f6ce748015acd65ca0c1142225

Contents?: true

Size: 1.97 KB

Versions: 9

Compression:

Stored size: 1.97 KB

Contents

/**
 * @ngdoc object
 * @name  Bastion.products.controller:ProductsBulkActionController
 *
 * @requires $scope
 * @requires translate
 * @requires ProductBulkAction
 * @requires CurrentOrganization
 *
 * @description
 *   A controller for providing bulk action functionality to the products page.
 */
angular.module('Bastion.products').controller('ProductsBulkActionController',
    ['$scope', 'translate', 'ProductBulkAction', 'CurrentOrganization',
    function ($scope, translate, ProductBulkAction, CurrentOrganization) {

        $scope.successMessages = [];
        $scope.errorMessages = [];

        $scope.removeProducts = {
            confirm: false,
            workingMode: false
        };

        $scope.actionParams = {
            ids: [],
            'organization_id': CurrentOrganization
        };

        $scope.getSelectedProductIds = function () {
            var rows = $scope.productTable.getSelected();
            return _.pluck(rows, 'id');
        };

        $scope.removeProducts = function () {
            var success, error;

            $scope.removingProducts = true;
            $scope.actionParams.ids = $scope.getSelectedProductIds();

            success = function (data) {
                $scope.productsNutupane.refresh();
                $scope.table.selectAll(false);

                $scope.$parent.successMessages = data.displayMessages.success;
                $scope.$parent.errorMessages = data.displayMessages.error;
                $scope.removingProducts = false;
                $scope.transitionTo('products.index');
            };

            error = function (response) {
                angular.forEach(response.data.errors, function (errorMessage) {
                    $scope.errorMessages.push(translate("An error occurred removing the Products: ") + errorMessage);
                });
                $scope.removingProducts = false;
            };

            ProductBulkAction.removeProducts($scope.actionParams, success, error);
        };
    }]
);

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
katello-2.4.5 engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/products-bulk-action.controller.js
katello-2.4.4 engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/products-bulk-action.controller.js
katello-2.4.3 engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/products-bulk-action.controller.js
katello-2.4.2 engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/products-bulk-action.controller.js
katello-2.4.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/products-bulk-action.controller.js
katello-2.4.0 engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/products-bulk-action.controller.js
katello-2.4.0.rc3 engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/products-bulk-action.controller.js
katello-2.4.0.rc2 engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/products-bulk-action.controller.js
katello-2.4.0.rc1 engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/products-bulk-action.controller.js