Skip to content

Commit

Permalink
Merge pull request #2192 from AtlasOfLivingAustralia/feature/#2160
Browse files Browse the repository at this point in the history
Feature/#2160
  • Loading branch information
chrisala authored Mar 5, 2021
2 parents d3a61f3 + ed6ccf1 commit 2137601
Show file tree
Hide file tree
Showing 15 changed files with 193 additions and 35 deletions.
10 changes: 7 additions & 3 deletions grails-app/assets/javascripts/meriplan.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function MERIPlan(project, projectService, config) {

self.meriGrantManagerActionsTemplate = ko.pureComputed(function () {
var template = 'editablePlanTmpl';
if (projectService.isCompleted()) {
if (projectService.isCompletedOrTerminated()) {
template = projectService.isUnlockedForDataCorrection() ? 'unlockedProjectTmpl' : 'completedProjectTmpl';
} else {
if (projectService.isApproved()) {
Expand Down Expand Up @@ -520,11 +520,15 @@ function ReadOnlyMeriPlan(project, projectService, config) {
text: 'This plan is not yet approved',
badgeClass: 'badge-warning'
};
if (projectService.isCompleted()) {
if (projectService.isCompletedOrTerminated()) {
if (projectService.isUnlockedForDataCorrection()) {
result = {text: 'The plan has been unlocked for data correction', badgeClass: 'badge-warning'};
} else {
result = {text: 'This project is complete', badgeClass: 'badge-info'};
if (projectService.isTerminated()){
result = {text: 'This project is ' + project.status.toLowerCase(), badgeClass: 'badge-danger'};
}else{
result = {text: 'This project is ' + project.status.toLowerCase(), badgeClass: 'badge-info'};
}
}
} else {
if (projectService.isApproved()) {
Expand Down
16 changes: 10 additions & 6 deletions grails-app/assets/javascripts/projectService.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,16 @@ function ProjectService(project, options) {
self.isSubmittedOrApproved = function() {
return (project.planStatus == PlanStatus.APPROVED || project.planStatus == PlanStatus.SUBMITTED);
};
self.isTerminated = function(){
return project.status.toLowerCase() === 'terminated';
};

self.isCompletedOrTerminated = function() {
return project.status && (project.status.toLowerCase() === 'completed' || self.isTerminated());
};

self.isProjectDetailsLocked = ko.computed(function () {
return self.isSubmittedOrApproved();
return self.isCompletedOrTerminated() || self.isSubmittedOrApproved();
});

self.isApproved = function() {
Expand All @@ -233,14 +240,11 @@ function ProjectService(project, options) {
return project.planStatus == PlanStatus.SUBMITTED;
};


self.isUnlockedForDataCorrection = function() {
return project.planStatus == PlanStatus.UNLOCKED;
};

self.isCompleted = function() {
return project.status && project.status.toLowerCase() == 'completed';
};

self.canApproveMeriPlan = function() {
return project.internalOrderId ? true: false
};
Expand Down Expand Up @@ -307,4 +311,4 @@ function ProjectService(project, options) {
var url = config.documentDeleteUrl+'/'+documentId;
return $.post(url);
};
};
};
13 changes: 12 additions & 1 deletion grails-app/assets/javascripts/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,17 @@ function ProjectViewModel(project, isUserEditor, organisations) {
projectDefault = project.status;
}
self.status = ko.observable(projectDefault.toLowerCase());
self.projectStatus = [{id: 'application', name:'Application'}, {id: 'active', name:'Active'},{id:'completed',name:'Completed'},{id:'deleted', name:'Deleted'}];
self.projectStatus = [{id: 'application', name:'Application'}, {id: 'active', name:'Active'},{id:'completed',name:'Completed'},{id:'deleted', name:'Deleted'}, {id:"terminated", name: "Terminated"}];

self.terminationReason = ko.observable(project.terminationReason);

self.status.subscribe(function (terminated) {
if (terminated === "terminated"){
bootbox.prompt("Reason For Termination", self.terminationReason)
}else{
self.terminationReason(undefined)
}
});

self.organisationId = ko.observable(project.organisationId);
self.transients.organisation = ko.observable(organisationsMap[self.organisationId()]);
Expand Down Expand Up @@ -887,6 +897,7 @@ function ProjectPageViewModel(project, sites, activities, organisations, userRol
programId: self.programId(),
funding: new Number(self.funding()),
status: self.status(),
terminationReason: self.terminationReason(),
tags: self.tags(),
promoteOnHomepage: self.promoteOnHomepage(),
options: {
Expand Down
4 changes: 4 additions & 0 deletions grails-app/assets/stylesheets/meriplan.css
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,7 @@ a.meri-history-toggle {
font-size: 14px;
content: "\f059";
}
.control-group .badge-danger {
background-color: #dc3545;
}

16 changes: 16 additions & 0 deletions grails-app/assets/stylesheets/project.css
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,19 @@
margin-right:10px;

}
.row-fluid .span8 .badge-danger {
background-color: #dc3545;
color: #fff;
}
.clearfix .span3 .badge-danger {
background-color: #dc3545;
color: #fff;
}

.projectStatus {
text-transform:uppercase;
font-size: 13px;
}
.terminationReasonSection {
padding-bottom: 20px;
}
13 changes: 12 additions & 1 deletion grails-app/views/project/_overview.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@
Project Status:
<span style="text-transform:uppercase;" data-bind="text:status" class="badge badge-info" style="font-size: 13px;"></span>
</span>

<span data-bind="if: status().toLowerCase() == 'terminated'">
Project Status:
<span style="text-transform:uppercase;" data-bind="text:status" class="badge badge-danger" style="font-size: 13px;"></span>
</span>
</div>
<div class="span3" data-bind="visible:grantId" style="margin-bottom: 0">
Grant Id:
Expand All @@ -69,6 +72,14 @@
</div>

</div>
<g:if test="${fc.userIsAlaOrFcAdmin()}">
<span data-bind="if: status().toLowerCase() == 'terminated'">
<div class="row-fluid">
<div class="terminationReasonSection"><strong>Termination Reason: </strong><span class="terminationReason" data-bind="text: terminationReason"></span></div>
</div>
</span>
</g:if>
<strong>Project Description</strong>
<div data-bind="visible:description()">
<p class="well well-small more" data-bind="text:description"></p>
</div>
Expand Down
18 changes: 16 additions & 2 deletions grails-app/views/project/_rlpOverview.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,24 @@
<div class="span4 header-label">Project status</div>

<div class="span8 value">
<span style="text-transform:uppercase;" data-bind="text:status" class="badge badge-info"
style="font-size: 13px;"></span>
<span data-bind="if: status().toLowerCase() == 'terminated'">
<span style="text-transform:uppercase;" data-bind="text:status" class="badge badge-danger projectStatus"></span>
</span>
<span data-bind="if: status().toLowerCase() != 'terminated'">
<span data-bind="text:status" class="badge badge-info projectStatus"></span>
</span>
</div>
</div>
<g:if test="${fc.userIsAlaOrFcAdmin()}">
<span data-bind="if: status().toLowerCase() == 'terminated'">
<div class="row-fluid">
<div class="span4 header-label">Termination Reason</div>
<div class="span8 value">
<span class="terminationReason" data-bind="text: terminationReason"></span>
</div>
</div>
</span>
</g:if>

</div>
</div></div>
Expand Down
1 change: 0 additions & 1 deletion grails-app/views/project/index.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@
<div class="tab-content" style="overflow:visible;display:none">
<fc:tabContent tabs="${projectContent}"/>
</div>

<g:render template="/shared/timeoutMessage" model="${[url:grailsApplication.config.security.cas.loginUrl+'?service='+createLink(action:'index', id:project.projectId, absolute: true)]}"/>
<g:render template="/shared/unsavedChanges" model="${[id:'meriPlanUnsavedChanges', unsavedData:'MERI Plan']}"/>
<g:render template="/shared/unsavedChanges" model="${[id:'risksUnsavedChanges', unsavedData:'Risks & Threats']}"/>
Expand Down
6 changes: 3 additions & 3 deletions test/functional/au/org/ala/fieldcapture/MeriPlanSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class MeriPlanSpec extends StubbedCasSpec {
overviewTab.click()

then:
overview.projectStatus.text() == 'ACTIVE'
overview.projectStatus[1].text() == 'ACTIVE'
}

def "Approve MERI plan of a project with the active status and internal order Id"() {
Expand Down Expand Up @@ -475,6 +475,6 @@ class MeriPlanSpec extends StubbedCasSpec {
overviewTab.click()

then:
overview.projectStatus.text() == 'ACTIVE'
overview.projectStatus[1].text() == 'ACTIVE'
}
}
}
20 changes: 20 additions & 0 deletions test/functional/au/org/ala/fieldcapture/ProjectIndexSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,25 @@ class ProjectIndexSpec extends StubbedCasSpec {
waitFor { admin.projectSettingsTab.click() }
!admin.projectSettings.projectState.@disabled
}

def "Project Status is Terminated"() {
setup:
login([userId:'1', role:"ROLE_FC_ADMIN", email:'[email protected]', firstName: "FC", lastName:'Admin'], browser)

when:
to ProjectIndex, 'project_terminated'

then:
at ProjectIndex

when:
overviewTab.click()

then:
overview.projectStatus[1].text() == 'TERMINATED'
overview.terminationReason.text() == "Termination Reason"

}

}

1 change: 1 addition & 0 deletions test/functional/pages/ProjectIndex.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class OverviewTab extends Module {
programName {$(".programName")}
managementUnit {$(".managementUnitName")}
projectStatus {$('span[data-bind*=status]')}
terminationReason {$('.terminationReason')}
}
}

Expand Down
6 changes: 4 additions & 2 deletions test/functional/resources/dataset_project/loadDataSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ load('../data_common/loadMeritHub.js');
load('../data_common/insertData.js');

createProject({name:'project 1', projectId:"project_1", programId:'program_1',managementUnitId:"mu_1", grantId:"RLP-Test-Program-Project-1" })

createProgram({name:'Regional Land Partnerships', programId:'program_1' })
createMu({name:'test mu', managementUnitId:"mu_1"});

Expand Down Expand Up @@ -85,7 +84,10 @@ db.document.insert(document1);
createProject({name:'project active', projectId:"project_active", managementUnitId:"mu_1", grantId:"RLP-Test-Program-Project-1", status:"active", programId:'program_1' })
createProject({name:'project application', projectId:"project_application", managementUnitId:"mu_1", grantId:"RLP-Test-Program-Project-1", status:"application", programId:'program_1' })
createProject({name:'project completed', projectId:"project_completed", managementUnitId:"mu_1", grantId:"RLP-Test-Program-Project-1", status:"completed", programId:'program_1' })
createProject({name:'project Terminated', projectId:"project_terminated", programId:'program_1',managementUnitId:"mu_1", grantId:"RLP-Test-Program-Project-1", status: 'terminated', terminationReason: "Termination Reason" })

db.userPermission.insert({entityType:'au.org.ala.ecodata.Project', entityId:'project_active', userId:'1', accessLevel:'admin'});
db.userPermission.insert({entityType:'au.org.ala.ecodata.Project', entityId:'project_application', userId:'1', accessLevel:'admin'});
db.userPermission.insert({entityType:'au.org.ala.ecodata.Project', entityId:'project_completed', userId:'1', accessLevel:'admin'});
db.userPermission.insert({entityType:'au.org.ala.ecodata.Project', entityId:'project_completed', userId:'1', accessLevel:'admin'});
db.userPermission.insert({entityType:'au.org.ala.ecodata.Project', entityId:'project_terminated', userId:'1', accessLevel:'admin'});

18 changes: 18 additions & 0 deletions test/js/spec/MeriPlanSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,4 +747,22 @@ describe("Loading the MERI plan is handled correctly", function () {

});

it('should check if the project is terminated', function () {
let project = {
status: "terminated"
}
let projectService = new ProjectService(project, {})
let readOnlyMeriPlan = new ReadOnlyMeriPlan(project, projectService, {useRlpTemplate:true, healthCheckUrl:'testing'} )
expect(readOnlyMeriPlan.meriPlanStatus().text).toEqual("This project is terminated")
});

it('should check if the project is completed', function () {
let project = {
status: "completed"
}
let projectService = new ProjectService(project, {})
let readOnlyMeriPlan = new ReadOnlyMeriPlan(project, projectService, {useRlpTemplate:true, healthCheckUrl:'testing'} )
expect(readOnlyMeriPlan.meriPlanStatus().text).toEqual("This project is completed")
});

});
Loading

0 comments on commit 2137601

Please sign in to comment.