Skip to content
This repository has been archived by the owner on Sep 3, 2020. It is now read-only.

Code Challenge - Workflow for ADM Notification #236 #272

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright {yyyy} {name of copyright owner}
Copyright 2018 Shengzong He

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 4 additions & 1 deletion modules/core/server/controllers/core.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ exports.renderIndex = function (req, res) {
isPublicProfile : req.user.isPublicProfile,
isAutoAdd : req.user.isAutoAdd,
capabilityDetails : req.user.capabilityDetails,
capabilitySkills : req.user.capabilitySkills
capabilitySkills : req.user.capabilitySkills,
admEmail : validator.escape(req.user.ADMEmail),
dfsEmail : validator.escape(req.user.DFSEmail),
bfsEmail : validator.escape(req.user.BFSEmail)
};
}
var features = config.features.split ('-');
Expand Down
37 changes: 37 additions & 0 deletions modules/opportunities/client/config/opportunities.client.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,43 @@
})
// -------------------------------------------------------------------------
//
// submit a opportunity
//
// -------------------------------------------------------------------------
.state('opportunityadmin.submitcwu', {
url: '/:opportunityId/submitcwu',
params: {
programId: null,
projectId: null
},
templateUrl: '/modules/opportunities/client/views/cwu-opportunity-submit.html',
controller: 'OpportunitySubmitController',
controllerAs: 'vm',
resolve: {
opportunity: function ($stateParams, OpportunitiesService) {
return OpportunitiesService.get({
opportunityId: $stateParams.opportunityId
}).$promise;
},
programs: function (ProgramsService) {
return ProgramsService.myadmin ().$promise;
},
projects: function (ProjectsService) {
return ProjectsService.myadmin ().$promise;
},
editing: function () { return true; }
},
data: {
roles: ['admin', 'gov'],
pageTitle: 'Opportunity: {{ opportunity.name }}'
},
ncyBreadcrumb: {
label: 'Submit Opportunity',
parent: 'opportunities.list'
}
})
// -------------------------------------------------------------------------
//
// edit a opportunity
//
// -------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,74 @@
var isAdmin = isUser && !!~Authentication.user.roles.indexOf ('admin');
var isGov = isUser && !!~Authentication.user.roles.indexOf ('gov');
vm.userCanAdd = (isAdmin || isGov);
})
// =========================================================================
//
// Controller the view of the opportunity page
//
// =========================================================================
.controller('OpportunitySubmitController', function ($scope, $state, $stateParams, $timeout ,$window, $sce, opportunity, editing, projects, Authentication, Notification, dataService, modalService, $q, ask, OpportunitiesService) {
var vm = this;
vm.opportunity = opportunity;
vm.features = window.features;

var copiedUser = angular.copy(Authentication.user);

$scope.data = {
admEmail: copiedUser.admEmail,
dfsEmail: copiedUser.dfsEmail,
bfsEmail: copiedUser.bfsEmail
};

var checkEmails = function(emails) {
if (emails && _.isArray(emails)) {
for (var i = 0; i < emails.length; i++) {
var email = emails[i];
if (email.length === 0) {
// The condition you want to check the email for
return true;
}
}
}
return false;
}
// Email Update Callbacks
function onRequestEmailUpdateError(response) {
// Show user error message and clear form
vm.credentials = null;
Notification.error({ message: response.data.message, title: '<i class="glyphicon glyphicon-remove"></i> Failed to send email and update profile!', delay: 4000 });
}
// -------------------------------------------------------------------------
//
// Submit Modal
//
// -------------------------------------------------------------------------
vm.submit = function (data) {
OpportunitiesService.sendEmailToADM({opportunityId: opportunity._id},{ emails: data, opportunity: vm.opportunity}).$promise
.then(function(response) {
vm.credentials = null;
Notification.success({ message: response.message, title: '<i class="glyphicon glyphicon-ok"></i> Email was sent successfully! Profile updated' });
// Manually update user profile
Authentication.user.admEmail = data.admEmail
Authentication.user.bfsEmail = data.bfsEmail
Authentication.user.dfsEmail = data.dfsEmail
vm.opportunityForm.$setPristine();

$timeout(function() {
$state.go('opportunities.viewcwu', {opportunityId:vm.opportunity.code})
},250)
})
.catch(onRequestEmailUpdateError);
}
})
// =========================================================================
//
// Controller the view of the opportunity page
//
// =========================================================================
.controller('OpportunityViewController', function ($scope, $state, $stateParams, $sce, opportunity, Authentication, OpportunitiesService, ProposalsService, Notification, modalService, $q, ask, subscriptions, myproposal, dataService, NotificationsService, OpportunitiesCommon) {
.controller('OpportunityViewController', function ($scope, $state, $stateParams, $sce, opportunity, Authentication, OpportunitiesService, ProposalsService, Notification, modalService, $q, ask, subscriptions, myproposal, dataService, NotificationsService, OpportunitiesCommon, AdminService) {
var vm = this;
vm.features = window.features;
// console.log ('virtuals', opportunity.isOpen);
//
// set the notification code for updates to this opp, and set the vm flag to current state
//
Expand Down Expand Up @@ -74,6 +132,7 @@
vm.loggedIn = isUser;
vm.canRequestMembership = isGov && !isMemberOrWaiting;
vm.canEdit = isAdmin || opportunity.userIs.admin;
vm.canSubmit = isAdmin || opportunity.userIs.admin;
vm.isMember = opportunity.userIs.member;
vm.isSprintWithUs = (vm.opportunity.opportunityTypeCd === 'sprint-with-us');
vm.showProposals = vm.canEdit && vm.opportunity.isPublished;
Expand Down Expand Up @@ -214,6 +273,13 @@
vm.responses[0][0].rank = 999;
});
}
else {
// -------------------------------------------------------------------------
//
// stuff for cwu evaluation
//
// -------------------------------------------------------------------------
}
// -------------------------------------------------------------------------
//
// Questions Modal
Expand Down Expand Up @@ -362,6 +428,7 @@
proposal.isAssigned = true;
vm.saveProposal (proposal);
};

// -------------------------------------------------------------------------
//
// publish or un publish the opportunity
Expand Down Expand Up @@ -481,6 +548,11 @@
});
}
};

vm.submit = function() {
vm.opportunity.status = 'Pending';
$state.go('opportunityadmin.submitcwu' , {opportunityId:vm.opportunity.code});
}
})
// =========================================================================
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@
denyMember: {
method: 'GET',
url : '/api/opportunities/requests/deny/:opportunityId/:userId'
}
},
sendEmailToADM: {
method: 'POST',
url: '/api/opportunities/email/:opportunityId'
}
});
angular.extend (Opportunity.prototype, {
createOrUpdate: function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<div class="modal-header">
<h3>Email</h3>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
<div class="cols-md-12">
<p>Email Modal, to be determined (Assistant Deputy Minister)</p>
</div>
</div>
<div class="row">
<form-input
class="col-sm-3"
ng-model="data.admEmail"
x-options='{
"title": "Assistant Deputy Minister&#39;s email address",
"id":"email-ADM",
"name":"email-ADM",
"placeholder":"Email"
}'>
</form-input>
</div>
<div class="row">
<form-input
class="col-sm-3"
ng-model="data.dfsEmail"
x-options='{
"title":"Divisional Financial Staff&#39;s email address",
"id":"email-DFS",
"name":"email-DFS",
"placeholder":"Email"
}'>
</form-input>
</div>
<div class="row">
<form-input
class="col-sm-3"
ng-model="data.bfsEmail"
x-options='{
"title":" Branch Financial Staff&#39;s email address",
"id":"email-BFS",
"name":"email-BFS",
"placeholder":"Email"
}'>
</form-input>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-ng-click="close()">Cancel</button>
<button ng-disabled="checkEmails(data.email)" class="btn btn-primary" data-ng-click="ok()">Submit</button>
</div>
61 changes: 61 additions & 0 deletions modules/opportunities/client/views/cwu-opportunity-submit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<section class="edit-form-background" role="main">

<form id="opportunityForm" warn-on-exit name="vm.opportunityForm" class="form" ng-submit="vm.submit(data)" novalidate>
<div class="container edit-form">

<div class="edit-form-header">
<span ng-if="vm.editing">
<span class="light small">Submit:</span>
{{vm.opportunity.name}}
</span>
<span ng-if="!vm.editing">
New Opportunity {{vm.opportunity.name}}
</span>
<a ui-sref="opportunities.viewcwu({opportunityId:vm.opportunity.code})" ng-if="vm.opportunity._id" class="btn btn-text-only pull-right" title="Close"><i class="fa fa-2x fa-times"></i></a>
<a ui-sref="opportunities.list()" ng-if="!vm.opportunity._id" class="btn btn-text-only pull-right"><i class="fa fa-2x fa-times" title="Close"></i></a>
</div>
<div class="edit-form-tab-content">
<fieldset>
<form-input
class="col-sm-3"
ng-model="data.admEmail"
x-options='{
"title": "Assistant Deputy Minister&#39;s email address",
"id":"email-ADM",
"name":"email-ADM",
"placeholder":"Email"
}'>
</form-input>

<form-input
class="col-sm-3"
ng-model="data.dfsEmail"
x-options='{
"title":"Divisional Financial Staff&#39;s email address",
"id":"email-DFS",
"name":"email-DFS",
"placeholder":"Email"
}'>
</form-input>
<form-input
class="col-sm-3"
ng-model="data.bfsEmail"
x-options='{
"title":" Branch Financial Staff&#39;s email address",
"id":"email-BFS",
"name":"email-BFS",
"placeholder":"Email"
}'>
</form-input>
</fieldset>
</div>
<div class="edit-form-footer">
<div class="row">
<div class="col-xs-12">
<button type="submit" href="javascript:void(0);" class="btn btn-primary pull-right"><i class="fa fa-save"></i> Submit</button>
</div>
</div>
</div>
</div>
</form>
</section>
2 changes: 2 additions & 0 deletions modules/opportunities/client/views/cwu-opportunity-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ <h4 class="opp-detail" class="card-title" style="font-size: 17px; padding-top: 6
<div class="col-xs-12">
<div class="pull-right" role="group">
<button type="button" class="btn btn-sm btn-text-only" ng-if="vm.canEdit" ui-sref="opportunityadmin.editcwu({opportunityId:vm.opportunity.code})"><i class="fa fa-pencil"></i> EDIT</button>
<button type="button" class="btn btn-sm btn-text-only" ng-if="vm.canSubmit" ng-click="vm.submit()"><i class="fa fa-arrow-circle-right"></i> SUBMIT</button>
<a href="javascript:void(0);" ng-if="vm.canPublish && vm.opportunity.project.isPublished && vm.canEdit && !vm.opportunity.isPublished" class="btn btn-sm btn-primary" ng-click="vm.publish(vm.opportunity, true)"><i class="fa fa-bullhorn"></i> PUBLISH</a>
</div>
</div>
Expand Down Expand Up @@ -225,6 +226,7 @@ <h4 class="opp-detail">Proposal Evaluation Criteria</h4>
<div>
<h4 class="opp-detail"><i class="fa fa-comments fa-lg"></i>&nbsp; Questions?&nbsp;&nbsp;<a href="{{vm.opportunity.issueUrl}}" rel="nofollow" target="_blank">Visit the GitHub issue for this opportunity</a> and post a comment.</h4>
</div>

</div>
</div>
</div>
Expand Down
Loading