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

BA-1131- Implement design changes to CWU proposal #587

Open
wants to merge 26 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7e75319
BA-1131 - Move CWU create/edit to modal
sutherlanda Mar 26, 2019
c8f0df1
BA-1131 - Proposals autosave on creation to
sutherlanda Mar 27, 2019
4eff49e
BA-1152 // Remove tabs from CWU proposal
mark-a-wilson May 15, 2019
32c412e
BA-1156 // Remove 'Withdraw' option from CWU proposal
mark-a-wilson May 16, 2019
a66a3f3
BA-1157 // Restyle 'Delete proposal' button
mark-a-wilson May 16, 2019
dd594a8
BA-1161 // Remove icons from buttons with text in the CWU proposal
mark-a-wilson May 16, 2019
036f321
BA-1158 // Add way to access CWU proposal after closing deadline
mark-a-wilson May 16, 2019
07aa552
BA-1158: Enable users to view their CWU proposal
kvangorp Jun 10, 2019
4ca3526
BA-1159: Enable download of uploaded attachments
kvangorp Jun 10, 2019
362435e
BA-1160: Save CWU proposal as a draft when closing modal
kvangorp Jun 11, 2019
3939b52
BA-1131 // reinstate border on btn-sm
mark-a-wilson Jun 13, 2019
acb1830
BA-1131 // Style cwu proposal modal
mark-a-wilson Jun 13, 2019
9936ade
BA-1131 // Style cwu proposal attachments section
mark-a-wilson Jun 13, 2019
fd7e16d
BA-1131 // Style cwu proposal terms section
mark-a-wilson Jun 13, 2019
cde02c9
BA-1131 // Minimize and tweak alert messages that appear at top of op…
mark-a-wilson Jun 13, 2019
68a32e9
Merge develop into feature/BA-1131
sutherlanda Jun 18, 2019
bf7504c
BA-1131 - Remove extraneous apply directive
sutherlanda Jun 18, 2019
2b6fbc6
BA-1131 // Further modal styling for cwu proposal edit views
mark-a-wilson Jun 18, 2019
84cd2d6
BA-1131: Ensure accept terms checkbox remains checked
kvangorp Jun 19, 2019
11a82b3
BA-1131: Remove submit button from draft proposals
kvangorp Jun 19, 2019
1434614
BA-1131 // use md rather than lg modal for cwu proposal
mark-a-wilson Jun 19, 2019
63b9439
BA-1131 // nest upload button inside call to action
mark-a-wilson Jun 19, 2019
1c56eac
BA-1131 // hide CTA to accept terms if deadline has passed and tweak …
mark-a-wilson Jun 19, 2019
f16a563
BA-1131 // style modal-cta
mark-a-wilson Jun 19, 2019
31a79aa
BA-1131 // tweaks to appearance of cwu-proposal-edit view
mark-a-wilson Jun 19, 2019
2f58e6a
BA-1131 // hide CTA to upload proposal if no attachments and proposal…
mark-a-wilson Jun 19, 2019
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
11 changes: 2 additions & 9 deletions modules/opportunities/client/views/cwu-opportunity-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@
</div>

<!-- // Proposal Application Directive // -->
<div class="row" ng-if="!vm.isClosed()">
<div class="row">
<div class="col">
<proposal-apply opportunity="vm.opportunity" proposal="vm.myproposal"></proposal-apply>
<proposal-apply opportunity="vm.opportunity" isclosed="vm.isClosed()" proposal="vm.myproposal"></proposal-apply>
</div>

</div>
Expand Down Expand Up @@ -318,13 +318,6 @@ <h4>Got Questions?</h4>
<h3 class="opp-detail">Proposal Evaluation Criteria</h3>
<p>Your Proposal will be scored by this criteria:</p>
<p ng-bind-html="vm.opportunity.evaluation"></p>

<!-- // Proposal Application Directive // -->
<div class="row" ng-if="!vm.isClosed()">
<div class="col">
<proposal-apply opportunity="vm.opportunity" proposal="vm.myproposal"></proposal-apply>
</div>
</div>
</div>
</div>
</div>
Expand Down
110 changes: 66 additions & 44 deletions modules/proposals/client/controllers/ProposalEditCWUController.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
'use strict';

import { StateService } from '@uirouter/core';
import angular, { angularFileUpload, IFormController, IRootScopeService, uiNotification } from 'angular';
import angular, { angularFileUpload, IFormController, IRootScopeService, ui, uiNotification } from 'angular';
import moment from 'moment-timezone';
import { Settings } from 'tinymce';
import { IOpportunitiesService, IOpportunityResource } from '../../../opportunities/client/services/OpportunitiesService';
import { IOrgResource } from '../../../orgs/client/services/OrgService';
import { IAuthenticationService } from '../../../users/client/services/AuthenticationService';
import { IUserService } from '../../../users/client/services/UsersService';
import { IUser } from '../../../users/shared/IUserDTO';
import { ProposalModalActions } from '../directives/ProposalApplyDirective';
import { IProposalResource, IProposalService } from '../services/ProposalService';

export default class ProposalEditCWUController {
public static $inject = [
'editing',
'$scope',
'ask',
'Upload',
'$state',
'proposal',
'opportunity',
'AuthenticationService',
Expand All @@ -26,21 +25,22 @@ export default class ProposalEditCWUController {
'UsersService',
'Notification',
'org',
'TinyMceConfiguration'
'TinyMceConfiguration',
'$uibModalInstance'
];

public members: any[];
public title: string;
public proposalForm: IFormController;

private user: IUser;
private isclosed: boolean;
private hasAttachments: boolean;

constructor(
public editing: boolean,
private $scope: IRootScopeService,
private ask,
private Upload: angularFileUpload.IUploadService,
private $state: StateService,
public proposal: IProposalResource,
public opportunity: IOpportunityResource,
private AuthenticationService: IAuthenticationService,
Expand All @@ -49,17 +49,20 @@ export default class ProposalEditCWUController {
private UsersService: IUserService,
private Notification: uiNotification.INotificationService,
public org: IOrgResource,
public TinyMceConfiguration: Settings
public TinyMceConfiguration: Settings,
private $uibModalInstance: ui.bootstrap.IModalServiceInstance
) {
// if not editing (i.e. creating), ensure that the current user doesn't already have a proposal started for this opp
// if they do, transition to edit view for that proposal
this.checkForExisting();

// refresh the view based on passed in proposal
this.refreshProposal(this.proposal);

// set the user
this.user = this.AuthenticationService.user;

this.init();
}

private async init(){
this.isclosed = await this.isClosed();
}

// Format dates to always be in PST (America/Vancouver timezone)
Expand Down Expand Up @@ -92,31 +95,39 @@ export default class ProposalEditCWUController {

// Save the proposal
this.copyUserInfo();
let updatedProposal: IProposalResource;
if (this.editing) {
updatedProposal = await this.ProposalService.update(this.proposal).$promise;
} else {
updatedProposal = await this.ProposalService.create(this.proposal).$promise;
if (this.proposal.status === 'New') {
this.proposal.status = 'Draft';
}
const updatedProposal = await this.ProposalService.update(this.proposal).$promise;

this.refreshProposal(updatedProposal);
this.Notification.success({
message: `<i class="fas fa-check-circle"></i> ${successMessage}`
});
this.proposalForm.$setPristine();

// if this is a newly created proposal, transition to edit view
if (!this.editing) {
this.$state.go('proposaladmin.editcwu', { proposalId: this.proposal._id, opportunityId: this.opportunity.code });
}
// close the modal and include the proposal in the response
this.$uibModalInstance.close({
action: ProposalModalActions.SAVED,
proposal: updatedProposal
});
} catch (error) {
this.handleError(error);
}
}

// Leave the edit view
public close(): void {
this.$state.go('opportunities.viewcwu', { opportunityId: this.opportunity.code });
// Leave the edit view and save any changes made if needed
public async close(): Promise<void> {

// If looking at a proposal for a closed opportunity, simply close the modal
if(this.isclosed) {
this.$uibModalInstance.close({
action: ProposalModalActions.SAVED,
proposal: this.proposal
});

// If looking at a proposal for an open opportunity, save any changes made
} else {
this.save(true);
}
}

// Delete a proposal
Expand All @@ -128,10 +139,12 @@ export default class ProposalEditCWUController {
try {
await this.proposal.$remove();
this.proposalForm.$setPristine();
this.$state.go('opportunities.viewcwu', { opportunityId: this.opportunity.code });
this.Notification.success({
message: '<i class="fas fa-check-circle"></i> Proposal Deleted'
});
this.$uibModalInstance.close({
action: ProposalModalActions.DELETED
});
} catch (error) {
this.handleError(error);
}
Expand Down Expand Up @@ -162,11 +175,15 @@ export default class ProposalEditCWUController {
// Submit the proposal
this.copyUserInfo();

await this.ProposalService.submit(this.proposal).$promise;
const submittedProposal = await this.ProposalService.submit(this.proposal).$promise;
this.Notification.success({
message: '<i class="fas fa-check-circle"></i> Your proposal has been submitted'
});
this.close();

this.$uibModalInstance.close({
action: ProposalModalActions.SAVED,
proposal: submittedProposal
});
} catch (error) {
this.handleError(error);
}
Expand Down Expand Up @@ -202,7 +219,7 @@ export default class ProposalEditCWUController {
message: '<i class="fas fa-check-circle"></i> Attachment Uploaded'
});

const updatedProposal = response.data as IProposalResource;
const updatedProposal = new this.ProposalService(response.data);
this.refreshProposal(updatedProposal);
} catch (error) {
this.handleError(error);
Expand Down Expand Up @@ -249,6 +266,24 @@ export default class ProposalEditCWUController {
}
}

// Set the terms to accepted and update the proposal
public async acceptTerms(): Promise<void>{
try{
this.proposal.isAcceptedTerms = true;
const updatedProposal = await this.ProposalService.update(this.proposal).$promise;
this.refreshProposal(updatedProposal);
}catch(error){
this.handleError(error);
}
}

// Determine whether the deadline for the opportunity has passed
public async isClosed(){
const response = await this.OpportunitiesService.getDeadlineStatus({ opportunityId: this.opportunity._id }).$promise;
return response.deadlineStatus === 'CLOSED';
}

// Determine whether the deadline for the opportunity has passed and send an error if it has
private async checkDeadline(): Promise<boolean> {
// Check with server to ensure deadline hasn't passed
const response = await this.OpportunitiesService.getDeadlineStatus({ opportunityId: this.opportunity._id }).$promise;
Expand All @@ -263,16 +298,6 @@ export default class ProposalEditCWUController {
}
}

private async checkForExisting(): Promise<void> {
if (!this.editing) {
const myProposal = await this.ProposalService.getMyProposal({ opportunityId: this.opportunity.code }).$promise;

if (myProposal && myProposal._id) {
this.$state.go('proposaladmin.editcwu', { proposalId: myProposal._id, opportunityId: this.opportunity.code });
}
}
}

private refreshProposal(newProposal: IProposalResource): void {
this.proposal = newProposal;

Expand All @@ -282,15 +307,12 @@ export default class ProposalEditCWUController {
this.members = this.org.members.concat(this.org.admins);
}

this.title = this.editing ? 'Edit' : 'Create';
this.title = 'Edit';
if (!this.proposal.team) {
this.proposal.team = [];
}

// ensure status set accordingly
if (!this.editing) {
this.proposal.status = 'New';
}
this.hasAttachments = this.proposal.attachments.length>0;
}

// Copy over user and org information to the proposal
Expand Down
Loading