<commit_before>/**
 * group-edit-form.directive.js
 * Created by anonymous on 23/01/16 8:08.
 */

(function() {
    'use strict';

    angular
        .module('jwtAuth')
        .directive('groupEditForm', groupEditForm);

    groupEditForm.$inject = [];

    /* @ngInject */
    function groupEditForm() {
        var directive = {
            bindToController: true,
            controller      : GroupEditFormController,
            controllerAs    : 'ctrl',
            link            : link,
            restrict        : 'EA',
            scope           : {
                id: '=id'
            },
            templateUrl     : function(elem, attr) {
                return attr.template;
            }
        };
        return directive;

        function link(scope, element, attrs) {

        }
    }

    GroupEditFormController.$inject = ['$state', 'Groups', 'ToastService'];

    /* @ngInject */
    function GroupEditFormController($state, Groups, ToastService) {
        var vm    = this;
        vm.update = update;

        activate();

        ////////////////

        function activate() {
            var id;
            if (_.isString(vm.id)) {
                id = parseInt(vm.id);
            } else {
                id = vm.id;
            }

            Groups.get(id).then(function(response) {
                vm.list = response.data;
            });
        }

        function update(id) {
            Groups.getList().then(function(response) {
                vm.records     = response;
                var listWithId = _.find(vm.records, function(list) {
                    return list.id === id;
                });

                listWithId.name = '';
                listWithId.put();

                /*
                 // Alternatively delete the element from the list when finished
                 listWithId.remove().then(function() {
                 // Updating the list and removing the user after the response is OK.
                 // vm.records = _.without(vm.records, listWithId);
                 var index = vm.records.indexOf(listWithId);
                 if (index > -1) {
                 vm.records.splice(index, 1);
                 }
                 vm.selected = [];
                 //$state.go('dashboard.groups');
                 ToastService.show('Group deleted.');
                 });*/

            });

        }
<commit_msg>Modified group-edit-form.directive<commit_after>/**
 * group-edit-form.directive.js
 * Created by anonymous on 23/01/16 8:08.
 */

(function() {
    'use strict';

    angular
        .module('jwtAuth')
        .directive('groupEditForm', groupEditForm);

    groupEditForm.$inject = [];

    /* @ngInject */
    function groupEditForm() {
        var directive = {
            bindToController: true,
            controller      : GroupEditFormController,
            controllerAs    : 'ctrl',
            link            : link,
            restrict        : 'EA',
            scope           : {
                id: '=id'
            },
            templateUrl     : function(elem, attr) {
                return attr.template;
            }
        };
        return directive;

        function link(scope, element, attrs) {

        }
    }

    GroupEditFormController.$inject = ['$state', 'Groups', 'ToastService'];

    /* @ngInject */
    function GroupEditFormController($state, Groups, ToastService) {
        var vm    = this;
        vm.update = update;

        activate();

        ////////////////

        function activate() {
            var id;
            if (_.isString(vm.id)) {
                id = parseInt(vm.id);
            } else {
                id = vm.id;
            }

            Groups.get(id).then(function(response) {
                vm.list = response.data;
            });
        }

        function update(id) {
            Groups.getList().then(function(response) {
                vm.lists = response;

                var listWithId = _.find(vm.lists, function(list) {
                    return list.id === id;
                });

                listWithId.username = vm.list[0].username;
                listWithId.email    = vm.list[0].email;
                listWithId.put();

                $state.go('dashboard.users');
                ToastService.show('User updated.');

            });

        }

{'fraction_non_alphanumeric': 0.1251435132032147, 'fraction_numerical': 0.005051664753157291, 'mean_word_length': 1.2179226069246436, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3227726', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1101, 'n_words': 220}