<commit_before>﻿"use strict";

module OrganizationRegister
{
    export class MainNavigationController extends Affecto.Login.LoginDrivenController
    {
        public static $inject = ["$scope", "$location", "busyIndicationService", "userService", "organizationService", "authenticationService", "useExternalLogin"];

        public currentSection: CurrentNavigationSection;
        public organizations: Array<OrganizationName>;
        public selectedOrganizationId: string;
        
        constructor($scope: Affecto.Base.IViewScope, private $location: angular.ILocationService, private busyIndicationService: Affecto.BusyIndication.IBusyIndicationService,
            public userService: UserService, private organizationService: OrganizationService, authenticationService: Affecto.Login.IAuthenticationService,
            private useExternalLogin: boolean)
        {
            super($scope, authenticationService);
            $scope.controller = this;

            this.currentSection = CurrentNavigationSection.Organizations;
        }

        public logOut()
        {
            this.authenticationService.logOut();
            if (this.useExternalLogin)
            {
                this.$location.path(Route.logout);
            }
            else
            {
                this.$location.path(Route.login);
            }
        }

        public areUsersActive(): boolean
        {
            return this.currentSection === CurrentNavigationSection.Users;
        }

        public areOrganizationsActive(): boolean
        {
            return this.currentSection === CurrentNavigationSection.Organizations;
        }

        public changeToOrganizations(): void
        {
            this.currentSection = CurrentNavigationSection.Organizations;
        }

        public changeToUsers(): void
        {
            this.currentSection = CurrentNavigationSection.Users;
        }

        protected onUserLoggedIn(): void
        {
            this.currentSection = CurrentNavigationSection.Organizations;
        }<commit_msg>Fix current section initialization in page header.<commit_after>﻿"use strict";

module OrganizationRegister
{
    export class MainNavigationController extends Affecto.Login.LoginDrivenController
    {
        public static $inject = ["$scope", "$location", "busyIndicationService", "userService", "organizationService", "authenticationService", "useExternalLogin"];

        public currentSection: CurrentNavigationSection;
        public organizations: Array<OrganizationName>;
        public selectedOrganizationId: string;
        
        constructor($scope: Affecto.Base.IViewScope, private $location: angular.ILocationService, private busyIndicationService: Affecto.BusyIndication.IBusyIndicationService,
            public userService: UserService, private organizationService: OrganizationService, authenticationService: Affecto.Login.IAuthenticationService,
            private useExternalLogin: boolean)
        {
            super($scope, authenticationService);
            $scope.controller = this;
            this.setCurrentSection();
        }

        public logOut()
        {
            this.authenticationService.logOut();
            if (this.useExternalLogin)
            {
                this.$location.path(Route.logout);
            }
            else
            {
                this.$location.path(Route.login);
            }
        }

        public areUsersActive(): boolean
        {
            return this.currentSection === CurrentNavigationSection.Users;
        }

        public areOrganizationsActive(): boolean
        {
            return this.currentSection === CurrentNavigationSection.Organizations;
        }

        public changeToOrganizations(): void
        {
            this.currentSection = CurrentNavigationSection.Organizations;
        }

        public changeToUsers(): void
        {
            this.currentSection = CurrentNavigationSection.Users;
        }

        protected onUserLoggedIn(): void
        {
            this.currentSection = CurrentNavigationSection.Organizations;
        }

        private isInUserPage(): boolean
        {
            return this.$location.path().indexOf("User") !== -1;
        }

        private setCurrentSection(): void
        {
            if (this.isInUserPage())
            {
                this.currentSection = CurrentNavigationSection.Users;
            }
            else
            {
                this.currentSection = CurrentNavigationSection.Organizations;
            }            
        }
{'fraction_non_alphanumeric': 0.08112836212551935, 'fraction_numerical': 0.00021867483052700635, 'mean_word_length': 2.189679218967922, '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': '5832521', 'n_tokens_mistral': 1034, 'n_tokens_neox': 1011, 'n_words': 197}