<commit_before>﻿(function (ng, app) {
    app.config(['$stateProvider', function ($stateProvider) {
        $stateProvider.state('edit-it-project.risk', {
            url: '/risk',
            templateUrl: 'partials/it-project/tab-risk.html',
            controller: 'project.EditRiskCtrl',
            resolve: {
                risks: ['$http', 'itProject', function ($http, itProject) {
                        return $http.get('api/risk/?getByProject&projectId=' + itProject.id)
                            .then(function (result) {
                                return result.data.response;
                            });
                    }]
            }
        });
    }]);

    app.controller('project.EditRiskCtrl', ['$scope', '$http', '$stateParams', 'notify', 'risks',
        function($scope, $http, $stateParams, notify, risks) {

            var projectId = $stateParams.id;

            $scope.risks = [];

            function watchUser(risk) {

                function getUserId() {
                    return risk.userForSelect.id;
                }

                $scope.$watch(getUserId, function (newVal, oldVal) {

                    if (!newVal || newVal === oldVal) return;

                    $http({
                        method: 'PATCH',
                        url: risk.updateUrl,
                        data: {
                            'responsibleUserId': newVal
                        }
                    }).success(function() {
                        risk.responsibleUserId = risk.userForSelect.id;
                        risk.responsibleUser = risk.userForSelect.user;

                        notify.addSuccessMessage("Feltet er opdateret.");
                    }).error(function () {
                        notify.addErrorMessage("Fejl! Feltet kunne ikke ændres!");
                    });

                });


            }

            function pushRisk(risk) {
                risk.show = true;
                risk.userForSelect = {
                    id: risk.responsibleUserId,
                    text: risk.responsibleUser.name
                };
<commit_msg>Added check for null user on risk<commit_after>﻿(function (ng, app) {
    app.config(['$stateProvider', function ($stateProvider) {
        $stateProvider.state('edit-it-project.risk', {
            url: '/risk',
            templateUrl: 'partials/it-project/tab-risk.html',
            controller: 'project.EditRiskCtrl',
            resolve: {
                risks: ['$http', 'itProject', function ($http, itProject) {
                        return $http.get('api/risk/?getByProject&projectId=' + itProject.id)
                            .then(function (result) {
                                return result.data.response;
                            });
                    }]
            }
        });
    }]);

    app.controller('project.EditRiskCtrl', ['$scope', '$http', '$stateParams', 'notify', 'risks',
        function($scope, $http, $stateParams, notify, risks) {

            var projectId = $stateParams.id;

            $scope.risks = [];

            function watchUser(risk) {

                function getUserId() {
                    if (risk.userForSelect) return risk.userForSelect.id;

                    return null;
                }

                $scope.$watch(getUserId, function (newVal, oldVal) {

                    if (!newVal || newVal === oldVal) return;

                    $http({
                        method: 'PATCH',
                        url: risk.updateUrl,
                        data: {
                            'responsibleUserId': newVal
                        }
                    }).success(function() {
                        risk.responsibleUserId = risk.userForSelect.id;
                        risk.responsibleUser = risk.userForSelect.user;

                        notify.addSuccessMessage("Feltet er opdateret.");
                    }).error(function () {
                        notify.addErrorMessage("Fejl! Feltet kunne ikke ændres!");
                    });

                });


            }

            function pushRisk(risk) {
                risk.show = true;
                risk.userForSelect = risk.responsibleUserId ? {
                    id: risk.responsibleUserId,
                    text: risk.responsibleUser.name
                } : null;

{'fraction_non_alphanumeric': 0.11642268984446477, 'fraction_numerical': 0.0, 'mean_word_length': 1.195281124497992, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3954450', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1018, 'n_words': 188}