<commit_before>angular.module('app.preferences').config(accountConfig);

accountConfig.$inject = ['$stateProvider'];
function accountConfig($stateProvider) {
    $stateProvider.state('base.preferences.emailaccounts.create', {
        url: '/create',
        views: {
            '@base.preferences': {
                templateUrl: 'preferences/email/controllers/emailaccount_form.html',
                controller: EmailAccountUpdateController,
                controllerAs: 'vm',
            },
        },
        ncyBreadcrumb: {
            label: 'Create',
        },
        resolve: {
            emailAccount: function() {
                return {};
            },
            sharedWithUsers: function() {
                return [];
            },
        },
    });

    $stateProvider.state('base.preferences.emailaccounts.setup.create', {
        url: '/:id',
        views: {
            '@': {
                templateUrl: 'preferences/email/controllers/emailaccount_form.html',
                controller: EmailAccountUpdateController,
                controllerAs: 'vm',
            },
        },
        ncyBreadcrumb: {
            label: 'Setup',
        },
        resolve: {
            emailAccount: ['EmailAccount', '$stateParams', function(EmailAccount, $stateParams) {
                return EmailAccount.get({id: $stateParams.id}).$promise;
            }],
            sharedWithUsers: function() {
                return [];
            },
        },
    });

    $stateProvider.state('base.preferences.emailaccounts.edit', {
        url: '/edit/{id:[0-9]{1,}}',
        views: {
            '@base.preferences': {
                templateUrl: 'preferences/email/controllers/emailaccount_form.html',
                controller: EmailAccountUpdateController,
                controllerAs: 'vm',
            },
        },
        ncyBreadcrumb: {
            label: 'Edit',
        },
        resolve: {
            emailAccount: ['EmailAccount', '$stateParams', function(EmailAccount, $stateParams) {
                return EmailAccount.get({id: $stateParams.id}).$promise;
            }],
            sharedWithUsers: ['User', 'emailAccount', function(User, emailAccount) {
                var i;
                var filterquery = '';
                var configs = emailAccount.shared_email_configs;

                if (configs.length) {
                    for (i = 0; i < configs.length; i++) {
                        if (i > 0) {
                            filterquery += ' OR ';
                        }

                        filterquery += 'id: ' + configs[i].user;
                    }

                    return User.search({filterquery: filterquery}).$promise;
                }

                return [];
            }],
        },
    });
}

angular.module('app.preferences').controller('EmailAccountCreateController', EmailAccountUpdateController);

EmailAccountUpdateController.$inject = ['$scope', '$state', '$stateParams', '$timeout', 'HLForms', 'HLSearch',
    'EmailAccount', 'emailAccount', 'User', 'sharedWithUsers'];
function EmailAccountUpdateController($scope, $state, $stateParams, $timeout, HLForms, HLSearch,
    EmailAccount, emailAccount, User, sharedWithUsers) {
    var vm = this;

    vm.emailAccount = emailAccount;<commit_msg>LILY-2598: Fixed user search query for email account form<commit_after>angular.module('app.preferences').config(accountConfig);

accountConfig.$inject = ['$stateProvider'];
function accountConfig($stateProvider) {
    $stateProvider.state('base.preferences.emailaccounts.create', {
        url: '/create',
        views: {
            '@base.preferences': {
                templateUrl: 'preferences/email/controllers/emailaccount_form.html',
                controller: EmailAccountUpdateController,
                controllerAs: 'vm',
            },
        },
        ncyBreadcrumb: {
            label: 'Create',
        },
        resolve: {
            emailAccount: function() {
                return {};
            },
            sharedWithUsers: function() {
                return [];
            },
        },
    });

    $stateProvider.state('base.preferences.emailaccounts.setup.create', {
        url: '/:id',
        views: {
            '@': {
                templateUrl: 'preferences/email/controllers/emailaccount_form.html',
                controller: EmailAccountUpdateController,
                controllerAs: 'vm',
            },
        },
        ncyBreadcrumb: {
            label: 'Setup',
        },
        resolve: {
            emailAccount: ['EmailAccount', '$stateParams', function(EmailAccount, $stateParams) {
                return EmailAccount.get({id: $stateParams.id}).$promise;
            }],
            sharedWithUsers: function() {
                return [];
            },
        },
    });

    $stateProvider.state('base.preferences.emailaccounts.edit', {
        url: '/edit/{id:[0-9]{1,}}',
        views: {
            '@base.preferences': {
                templateUrl: 'preferences/email/controllers/emailaccount_form.html',
                controller: EmailAccountUpdateController,
                controllerAs: 'vm',
            },
        },
        ncyBreadcrumb: {
            label: 'Edit',
        },
        resolve: {
            emailAccount: ['EmailAccount', '$stateParams', function(EmailAccount, $stateParams) {
                return EmailAccount.get({id: $stateParams.id}).$promise;
            }],
            sharedWithUsers: ['User', 'emailAccount', function(User, emailAccount) {
                var i;
                var filterquery = '';
                var configs = emailAccount.shared_email_configs;

                if (configs.length) {
                    for (i = 0; i < configs.length; i++) {
                        if (i > 0) {
                            filterquery += ' OR ';
                        }

                        filterquery += 'id: ' + configs[i].user;
                    }

                    return User.search({filterquery: filterquery, size: 100}).$promise;
                }

                return [];
            }],
        },
    });
}

angular.module('app.preferences').controller('EmailAccountCreateController', EmailAccountUpdateController);

EmailAccountUpdateController.$inject = ['$scope', '$state', '$stateParams', '$timeout', 'HLForms', 'HLSearch',
    'EmailAccount', 'emailAccount', 'User', 'sharedWithUsers'];
function EmailAccountUpdateController($scope, $state, $stateParams, $timeout, HLForms, HLSearch,
    EmailAccount, emailAccount, User, sharedWithUsers) {
    var vm = this;

    vm.emailAccount = emailAccount;
{'fraction_non_alphanumeric': 0.13100436681222707, 'fraction_numerical': 0.0025598554434573106, 'mean_word_length': 1.7333333333333334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2894112', 'n_tokens_mistral': 1741, 'n_tokens_neox': 1664, 'n_words': 279}