<commit_before>'use strict';

angular.module('project').config (
	['$locationProvider', '$stateProvider', '$urlRouterProvider', '_',
	function ($locationProvider, $stateProvider, $urlRouterProvider, _) {

	$stateProvider
	.state('p', {
		url: '/p/:projectid',
		abstract: true,
		templateUrl: 'modules/projects/client/views/project.abstract.html',
		resolve: {
			project: function ($stateParams, ProjectModel) {
				// console.log ('loading project');
				if ($stateParams.projectid === 'new') {
					return ProjectModel.getNew ();
				} else {
					return ProjectModel.byCode ($stateParams.projectid);
				}
			},
			eaoAdmin: function (project) {
				return project.adminRole;
			},
			proponentAdmin: function (project) {
				return project.proponentAdminRole;
			}
		},
		controller: function ($scope, $stateParams, project, ENV, $rootScope, ProjectModel, Menus, MenuControl) {
			$scope.project = project;
			$scope.environment = ENV;
			$scope.isNew = ($stateParams.projectid === 'new');

			ProjectModel.setModel(project);

			$scope.intakeQuestions = ProjectModel.getProjectIntakeQuestions();

			//
			// Clear out the project side menu... and add them on the fly
			// we need the project context to properly show the menus, or else we get 403 on the routes...
			//
			Menus.removeMenuItem('projectTopMenu', 'p.edit');
			Menus.removeMenuItem('projectTopMenu', 'p.schedule');
			Menus.removeMenuItem('projectTopMenu', 'p.enforcements');

			Menus.addMenuItem('projectTopMenu', {
				title: 'Edit Project',
				state: 'p.edit',
				roles: MenuControl.menuRolesBuilder (undefined, project.code, '*', ['responsible-epd','project-admin', 'project-lead','project-team','project-intake', 'assistant-dm', 'associate-dm', 'qa-officer', 'ce-lead', 'ce-officer', 'pro:admin', 'pro:member'])
			});

			// Specific to EAO.
			if (ENV === 'EAO') {
				Menus.addMenuItem('projectTopMenu', {
					title: 'Schedule',
					state: "p.schedule",
					roles: MenuControl.menuRolesBuilder (undefined, project.code, '*', ['responsible-epd','project-admin', 'project-lead','project-team','project-intake', 'assistant-dm', 'associate-dm', 'minister-office', 'qa-officer', 'ce-lead', 'ce-officer', 'wg', 'ceaa', 'pro:admin', 'pro:member', 'sub'])
				});
				Menus.addMenuItem('projectTopMenu', {
					title: 'Compliance Oversight',
					state: "p.enforcements",
					roles: MenuControl.menuRolesBuilder (['user'], project.code, '*', '*')
				});
				Menus.addMenuItem('projectTopMenu', {
					title: 'Public Comment Period',
					state: "p.comments",
					roles: MenuControl.menuRolesBuilder (['user'], project.code, '*', '*')
				});
			}

			Menus.removeMenuItem('projectMenu', 'p.documents');
			Menus.removeMenuItem('projectMenu', 'p.invitations');
			Menus.removeMenuItem('projectMenu', 'p.commentperiod.list');
			Menus.removeMenuItem('projectMenu', 'p.complaint.list');
			Menus.removeMenuItem('projectMenu', 'p.projectcondition.list');
			Menus.removeMenuItem('projectMenu', 'p.ir.list');
			Menus.removeMenuItem('projectMenu', 'p.roles.list');
			Menus.removeMenuItem('projectMenu', 'p.vc.list');

			Menus.addMenuItem('projectMenu', {
				title: 'Documents',
				state: 'p.documents',
				roles: MenuControl.menuRolesBuilder (['admin','user','public'], project.code, '*', ['eao:admin', 'eao:member', 'responsible-epd','project-admin', 'project-lead','project-team','project-intake', 'assistant-dm', 'associate-dm', 'pro:admin', 'pro:member', 'sub'])
			});
			if (ENV === 'EAO') {
				Menus.addMenuItem('projectMenu', {
					title: 'Project Invitations',
					state: 'p.invitations',
					roles: MenuControl.menuRolesBuilder (undefined, project.code, '*', ['eao:admin', 'responsible-epd','project-admin', 'project-lead','project-intake', 'pro:admin', 'pro:member'])
				});
				Menus.addMenuItem('projectMenu', {
					title: 'Comment Periods',
					state: 'p.commentperiod.list',
					roles: MenuControl.menuRoles ('admin', project.code, '*', '*')
				});
				Menus.addMenuItem('projectMenu', {
					title: 'Complaints',
					state: 'p.complaint.list',
					roles: MenuControl.menuRolesBuilder (undefined, project.code, '*', ['ce-lead', 'ce-officer'])
				});
				Menus.addMenuItem('projectMenu', {
					title: 'Conditions',
					state: 'p.projectcondition.list',
					roles: MenuControl.menuRolesBuilder (undefined, project.code, '*', ['eao:admin', 'eao:member', 'responsible-epd','project-admin', 'project-lead','project-team','project-intake', 'assistant-dm', 'associate-dm', 'qa-officer', 'ce-lead', 'ce-officer'])
				});
				Menus.addMenuItem('projectMenu', {
					title: 'Inspection Reports',<commit_msg>Fixing bug where Public Comment Periods were showing up after any action you took inside ESM.  Re-order some clearing logic.<commit_after>'use strict';

angular.module('project').config (
	['$locationProvider', '$stateProvider', '$urlRouterProvider', '_',
	function ($locationProvider, $stateProvider, $urlRouterProvider, _) {

	$stateProvider
	.state('p', {
		url: '/p/:projectid',
		abstract: true,
		templateUrl: 'modules/projects/client/views/project.abstract.html',
		resolve: {
			project: function ($stateParams, ProjectModel) {
				// console.log ('loading project');
				if ($stateParams.projectid === 'new') {
					return ProjectModel.getNew ();
				} else {
					return ProjectModel.byCode ($stateParams.projectid);
				}
			},
			eaoAdmin: function (project) {
				return project.adminRole;
			},
			proponentAdmin: function (project) {
				return project.proponentAdminRole;
			}
		},
		controller: function ($scope, $stateParams, project, ENV, $rootScope, ProjectModel, Menus, MenuControl) {
			$scope.project = project;
			$scope.environment = ENV;
			$scope.isNew = ($stateParams.projectid === 'new');

			ProjectModel.setModel(project);

			$scope.intakeQuestions = ProjectModel.getProjectIntakeQuestions();

			//
			// Clear out the project side menu... and add them on the fly
			// we need the project context to properly show the menus, or else we get 403 on the routes...
			//
			Menus.removeMenuItem('projectTopMenu', 'p.edit');
			Menus.removeMenuItem('projectTopMenu', 'p.schedule');
			Menus.removeMenuItem('projectTopMenu', 'p.comments');
			Menus.removeMenuItem('projectTopMenu', 'p.enforcements');
			Menus.removeMenuItem('projectMenu', 'p.documents');
			Menus.removeMenuItem('projectMenu', 'p.invitations');
			Menus.removeMenuItem('projectMenu', 'p.commentperiod.list');
			Menus.removeMenuItem('projectMenu', 'p.complaint.list');
			Menus.removeMenuItem('projectMenu', 'p.projectcondition.list');
			Menus.removeMenuItem('projectMenu', 'p.ir.list');
			Menus.removeMenuItem('projectMenu', 'p.roles.list');
			Menus.removeMenuItem('projectMenu', 'p.vc.list');

			Menus.addMenuItem('projectTopMenu', {
				title: 'Edit Project',
				state: 'p.edit',
				roles: MenuControl.menuRolesBuilder (undefined, project.code, '*', ['responsible-epd','project-admin', 'project-lead','project-team','project-intake', 'assistant-dm', 'associate-dm', 'qa-officer', 'ce-lead', 'ce-officer', 'pro:admin', 'pro:member'])
			});

			// Specific to EAO.
			if (ENV === 'EAO') {
				Menus.addMenuItem('projectTopMenu', {
					title: 'Schedule',
					state: "p.schedule",
					roles: MenuControl.menuRolesBuilder (undefined, project.code, '*', ['responsible-epd','project-admin', 'project-lead','project-team','project-intake', 'assistant-dm', 'associate-dm', 'minister-office', 'qa-officer', 'ce-lead', 'ce-officer', 'wg', 'ceaa', 'pro:admin', 'pro:member', 'sub'])
				});
				Menus.addMenuItem('projectTopMenu', {
					title: 'Compliance Oversight',
					state: "p.enforcements",
					roles: MenuControl.menuRolesBuilder (['user'], project.code, '*', '*')
				});
				Menus.addMenuItem('projectTopMenu', {
					title: 'Public Comment Period',
					state: "p.comments",
					roles: MenuControl.menuRolesBuilder (['user'], project.code, '*', '*')
				});
			}

			Menus.addMenuItem('projectMenu', {
				title: 'Documents',
				state: 'p.documents',
				roles: MenuControl.menuRolesBuilder (['admin','user','public'], project.code, '*', ['eao:admin', 'eao:member', 'responsible-epd','project-admin', 'project-lead','project-team','project-intake', 'assistant-dm', 'associate-dm', 'pro:admin', 'pro:member', 'sub'])
			});
			if (ENV === 'EAO') {
				Menus.addMenuItem('projectMenu', {
					title: 'Project Invitations',
					state: 'p.invitations',
					roles: MenuControl.menuRolesBuilder (undefined, project.code, '*', ['eao:admin', 'responsible-epd','project-admin', 'project-lead','project-intake', 'pro:admin', 'pro:member'])
				});
				Menus.addMenuItem('projectMenu', {
					title: 'Comment Periods',
					state: 'p.commentperiod.list',
					roles: MenuControl.menuRoles ('admin', project.code, '*', '*')
				});
				Menus.addMenuItem('projectMenu', {
					title: 'Complaints',
					state: 'p.complaint.list',
					roles: MenuControl.menuRolesBuilder (undefined, project.code, '*', ['ce-lead', 'ce-officer'])
				});
				Menus.addMenuItem('projectMenu', {
					title: 'Conditions',
					state: 'p.projectcondition.list',
					roles: MenuControl.menuRolesBuilder (undefined, project.code, '*', ['eao:admin', 'eao:member', 'responsible-epd','project-admin', 'project-lead','project-team','project-intake', 'assistant-dm', 'associate-dm', 'qa-officer', 'ce-lead', 'ce-officer'])
				});
				Menus.addMenuItem('projectMenu', {
					title: 'Inspection Reports',
{'fraction_non_alphanumeric': 0.18632150846915949, 'fraction_numerical': 0.0006391818472355385, 'mean_word_length': 4.483644859813084, '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': '2271684', 'n_tokens_mistral': 3549, 'n_tokens_neox': 2945, 'n_words': 548}