diff --git a/modules/opportunities/client/config/OpportunityRouter.ts b/modules/opportunities/client/config/OpportunityRouter.ts index 7da694285..283ba4b16 100644 --- a/modules/opportunities/client/config/OpportunityRouter.ts +++ b/modules/opportunities/client/config/OpportunityRouter.ts @@ -12,7 +12,6 @@ import { IAuthenticationService } from '../../../users/client/services/Authentic import { IOpportunitiesService, IOpportunityResource } from '../services/OpportunitiesService'; export default class OpportunityRouter { - public static $inject = ['$stateProvider']; private rootState: Ng1StateDeclaration = { abstract: true, @@ -50,11 +49,7 @@ export default class OpportunityRouter { opportunity: [ '$stateParams', 'OpportunitiesService', - async ($stateParams: StateParams, OpportunitiesService: IOpportunitiesService): Promise => { - return await OpportunitiesService.get({ - opportunityId: $stateParams.opportunityId - }).$promise; - } + this.resolveOpportunity ], myproposal: [ '$stateParams', @@ -89,11 +84,7 @@ export default class OpportunityRouter { opportunity: [ '$stateParams', 'OpportunitiesService', - async ($stateParams: StateParams, OpportunitiesService: IOpportunitiesService): Promise => { - return await OpportunitiesService.get({ - opportunityId: $stateParams.opportunityId - }).$promise; - } + this.resolveOpportunity ], org: [ 'AuthenticationService', @@ -169,11 +160,7 @@ export default class OpportunityRouter { opportunity: [ '$stateParams', 'OpportunitiesService', - async ($stateParams: StateParams, OpportunitiesService: IOpportunitiesService): Promise => { - return await OpportunitiesService.get({ - opportunityId: $stateParams.opportunityId - }).$promise; - } + this.resolveOpportunity ] } }; @@ -316,6 +303,12 @@ export default class OpportunityRouter { this.$stateProvider.state('createswu', this.createSWUState); this.$stateProvider.state('oppcreatelanding', this.createLandingState); } + + private async resolveOpportunity($stateParams: StateParams, OpportunitiesService: IOpportunitiesService): Promise { + return await OpportunitiesService.get({ + opportunityId: $stateParams.opportunityId + }).$promise; + } } angular.module('opportunities.routes').config(['$stateProvider', ($stateProvider: StateProvider) => new OpportunityRouter($stateProvider)]); diff --git a/modules/opportunities/client/directives/OpportunityEvaluationDirective.ts b/modules/opportunities/client/directives/OpportunityEvaluationDirective.ts index e52259487..bd973d054 100644 --- a/modules/opportunities/client/directives/OpportunityEvaluationDirective.ts +++ b/modules/opportunities/client/directives/OpportunityEvaluationDirective.ts @@ -1,6 +1,6 @@ 'use strict'; -import angular, { IController, IScope, uiNotification } from 'angular'; +import angular, { IController, IScope, ui, uiNotification } from 'angular'; import _ from 'lodash'; import { ICapabilitySkill } from '../../../capabilities/shared/ICapabilitySkillDTO'; import { IProposalResource, IProposalService } from '../../../proposals/client/services/ProposalService'; @@ -14,6 +14,13 @@ interface IEvaluationScope extends IScope { opportunity: IOpportunityResource; } +interface IEvalModalScope { + proposals: IProposalResource[]; + maxPoints: number; + cancel(): void; + save(): Promise; +} + enum Stages { NEW = 0, REVIEW, @@ -321,13 +328,6 @@ export class OpportunityEvaluationDirectiveController implements IController { } public async openCodeChallengeModal(): Promise { - interface ICodeChallengeModalScope { - proposals: IProposalResource[]; - maxCodeChallengePoints: number; - cancel(): void; - save(): Promise; - } - const modalResponse = await this.modalService.showModal( { size: 'sm', @@ -336,23 +336,16 @@ export class OpportunityEvaluationDirectiveController implements IController { controller: [ '$scope', '$uibModalInstance', - ($scope: ICodeChallengeModalScope, $uibModalInstance: ng.ui.bootstrap.IModalInstanceService) => { + ($scope: IEvalModalScope, $uibModalInstance: ng.ui.bootstrap.IModalInstanceService) => { $scope.proposals = angular.copy(this.proposals); - $scope.maxCodeChallengePoints = this.opportunity.weights.codechallenge * this.maximumScore; + $scope.maxPoints = this.opportunity.weights.codechallenge * this.maximumScore; $scope.cancel = (): void => { $uibModalInstance.close({}); }; $scope.save = async (): Promise => { - const message = 'Are you sure you wish to commit the code challenge scores as entered?'; - const choice = await this.ask.yesNo(message); - if (choice) { - $uibModalInstance.close({ - action: 'save', - proposalsToSave: $scope.proposals - }); - } + this.confirmModalSave('Are you sure you wish to commit the code challenge scores as entered?', $uibModalInstance, $scope); }; } ] @@ -393,13 +386,6 @@ export class OpportunityEvaluationDirectiveController implements IController { * Validates based on interview weighting and max points */ public async openInterviewModal(): Promise { - interface IInterviewModalScope { - proposals: IProposalResource[]; - maxInterviewPoints: number; - cancel(): void; - save(): Promise; - } - const modalResponse = await this.modalService.showModal( { size: 'sm', @@ -408,23 +394,16 @@ export class OpportunityEvaluationDirectiveController implements IController { controller: [ '$scope', '$uibModalInstance', - ($scope: IInterviewModalScope, $uibModalInstance: ng.ui.bootstrap.IModalInstanceService) => { + ($scope: IEvalModalScope, $uibModalInstance: ng.ui.bootstrap.IModalInstanceService) => { $scope.proposals = angular.copy(this.proposals); - $scope.maxInterviewPoints = this.opportunity.weights.interview * this.maximumScore; + $scope.maxPoints = this.opportunity.weights.interview * this.maximumScore; $scope.cancel = (): void => { $uibModalInstance.close({}); }; - $scope.save = async (): Promise => { - const message = 'Are you sure you wish to commit the team scenario scores as entered?'; - const choice = await this.ask.yesNo(message); - if (choice) { - $uibModalInstance.close({ - action: 'save', - proposalsToSave: $scope.proposals - }); - } + $scope.save = async () => { + this.confirmModalSave('Are you sure you wish to commit the team scenario scores as entered?', $uibModalInstance, $scope); }; } ] @@ -752,8 +731,18 @@ export class OpportunityEvaluationDirectiveController implements IController { } } + private async confirmModalSave(message: string, modalInstance: ui.bootstrap.IModalServiceInstance, scope: IEvalModalScope): Promise { + const choice = await this.ask.yesNo(message); + if (choice) { + modalInstance.close({ + action: 'save', + proposalsToSave: scope.proposals + }); + } + } + private handleError(error: any): void { - const errorMessage = (error as any).data ? (error as any).data.message : error.message; + const errorMessage = error.data ? error.data.message : error.message; this.Notification.error({ title: 'Error', message: ` ${errorMessage}` diff --git a/modules/opportunities/client/views/swu-opportunity-modal-code-challenge.html b/modules/opportunities/client/views/swu-opportunity-modal-code-challenge.html index 17b9f8569..137cd6fe6 100644 --- a/modules/opportunities/client/views/swu-opportunity-modal-code-challenge.html +++ b/modules/opportunities/client/views/swu-opportunity-modal-code-challenge.html @@ -10,7 +10,7 @@
Code Challenge Scores
- +
{{proposal.businessName | limitTo: 20 }}{{ proposal.businessName.length > 20 ? '...' : '' }} @@ -21,7 +21,7 @@
Code Challenge Scores
-
Scores must be a number between 0 and {{ maxCodeChallengePoints }}
+
Scores must be a number between 0 and {{ maxPoints }}
diff --git a/modules/opportunities/client/views/swu-opportunity-modal-interview.html b/modules/opportunities/client/views/swu-opportunity-modal-interview.html index fa578427c..29f333950 100644 --- a/modules/opportunities/client/views/swu-opportunity-modal-interview.html +++ b/modules/opportunities/client/views/swu-opportunity-modal-interview.html @@ -7,7 +7,7 @@
Interview Scores
- +
{{proposal.businessName | limitTo: 20 }}{{ proposal.businessName.length > 20 ? '...' : '' }} @@ -17,7 +17,7 @@
Interview Scores
-
Scores must be a number between 0 and {{ maxInterviewPoints }}
+
Scores must be a number between 0 and {{ maxPoints }}