Sha256: 95810919fab0dbe98ca3d19033ec2f3a661fb67504269214ba8326011535bb79

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

/**
 * Copyright 2014 Red Hat, Inc.
 *
 * This software is licensed to you under the GNU General Public
 * License as published by the Free Software Foundation; either version
 * 2 of the License (GPLv2) or (at your option) any later version.
 * There is NO WARRANTY for this software, express or implied,
 * including the implied warranties of MERCHANTABILITY,
 * NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
 * have received a copy of GPLv2 along with this software; if not, see
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*/

/**
 * @ngdoc object
 * @name  Bastion.host-collections.controller:HostCollectionFormController
 *
 * @requires $scope
 * @requires $q
 * @requires HostCollection
 * @requires CurrentOrganization
 *
 * @description
 *   Provides the functionality specific to HostCollections for creating a new host collection
 */
angular.module('Bastion.host-collections').controller('HostCollectionFormController',
    ['$scope', '$q', 'HostCollection', 'CurrentOrganization',
    function ($scope, $q, HostCollection, CurrentOrganization) {

        $scope.hostCollection = $scope.hostCollection || new HostCollection();
        $scope.hostCollection['unlimited_content_hosts'] = true;

        $scope.save = function (hostCollection) {
            hostCollection['organization_id'] = CurrentOrganization;
            hostCollection.$save(success, error);
        };

        function success(response) {
            $scope.table.addRow(response);
            $scope.transitionTo('host-collections.details.info', {hostCollectionId: $scope.hostCollection.id});
        }

        function error(response) {
            $scope.working = false;
            angular.forEach(response.data.errors, function (errors, field) {
                $scope.hostCollectionForm[field].$setValidity('', false);
                $scope.hostCollectionForm[field].$error.messages = errors;
            });
        }

    }]
);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katello-2.2.2 engines/bastion_katello/app/assets/javascripts/bastion_katello/host-collections/new/host-collection-form.controller.js