Skip to content

Commit

Permalink
commit WIP #2980
Browse files Browse the repository at this point in the history
  • Loading branch information
salomon-j committed Sep 11, 2023
1 parent c174ca8 commit 1e0dc89
Show file tree
Hide file tree
Showing 51 changed files with 1,768 additions and 10 deletions.
323 changes: 322 additions & 1 deletion grails-app/assets/javascripts/meriplan.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions grails-app/assets/javascripts/projectService.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ function ProjectService(project, options) {
approvedPlans.push(
{
openMeriPlanUrl: config.viewHistoricalMeriPlanUrl+"?documentId="+meriPlan.documentId,
openMeriPlanChangesUrl: config.viewMeriPlanChangesUrl+"?documentId="+meriPlan.documentId,
userDisplayName:meriPlan.userDisplayName,
dateApproved:convertToSimpleDate(meriPlan.date, true),
reason:meriPlan.reason,
Expand Down
3 changes: 3 additions & 0 deletions grails-app/assets/javascripts/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
//= require projectService
//= require components.js
//= require_self
//= require prettytextdiff/jquery.pretty-text-diff.min.js
//= require prettytextdiff/diff_match_patch.js
//= require htmldiff.js

/*
Utilities for managing project representations.
Expand Down
1 change: 1 addition & 0 deletions grails-app/assets/stylesheets/project.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*= require blog
*= require dataSets
*= require activity.css
*= require prettytextdiff/pretty_text_diff_basic.css
*= require_self
*/

Expand Down
19 changes: 19 additions & 0 deletions grails-app/controllers/au/org/ala/merit/ProjectController.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package au.org.ala.merit

import au.org.ala.merit.command.MeriPlanChangesReportCommand
import au.org.ala.merit.command.MeriPlanReportCommand
import au.org.ala.merit.command.ProjectSummaryReportCommand
import au.org.ala.merit.command.ReportCommand
Expand Down Expand Up @@ -1077,6 +1078,24 @@ class ProjectController {
}
}

@PreAuthorise(accessLevel = 'admin')
def viewMeriPlanChanges(MeriPlanChangesReportCommand meriPlanChangesReportCommand) {
Map model
// Only grant/project managers can view historical MERI plans.
if (meriPlanChangesReportCommand.documentId && !userService.userIsSiteAdmin()) {
render status:HttpStatus.SC_UNAUTHORIZED
}
else {
model = meriPlanChangesReportCommand.meriPlanChangesReportModel()
if (!model.error) {
render view:'/project/meriPlanChangesReport', model:model
}
else {
render status: HttpStatus.SC_NOT_FOUND
}
}
}

/**
* This method returns the investment priorities listed in the primary and secondary outcome sections of the
* RLP MERI plan into a single list for the purposes of pre-populating one of the RLP outcomes reporting forms.
Expand Down
35 changes: 35 additions & 0 deletions grails-app/taglib/au/org/ala/merit/FCTagLib.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,41 @@ class FCTagLib {
out << '<span class="diff"></span>'
}

def renderComparisonNewVersion = { attrs ->

List original = attrs.original
List changed = attrs.changed
int i = attrs.i
if (attrs.property) {
String property = attrs.property

out << '<span class="original hide">'
if (original && original.size() > i) {
out << original[i][property]
}
out << '</span>'
out << '<span class="changed hide">'
if (changed && changed.size() > i) {
out << changed[i][property]
}
out << '</span>'
out << '<span class="diff"></span>'
} else {
out << '<span class="original hide">'
if (original && original.size() > i) {
out << original[i]
}
out << '</span>'
out << '<span class="changed hide">'
if (changed && changed.size() > i) {
out << changed[i]
}
out << '</span>'
out << '<span class="diff"></span>'
}

}

def status = { attrs ->
String statusClass
switch (attrs.status?.toLowerCase()) {
Expand Down
13 changes: 13 additions & 0 deletions grails-app/views/project/_configurableMeriPlanChangesView.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div id="meriplan-changes" class="meri-plan space-after" data-bind="let:{details:meriPlan(), detailsChanged:meriPlanChanged()}">
MERI-PLAN CHANGES TESTING
<g:each var="content" in="${config?.meriPlanContents}">
<div class="row">
<div class="col-sm-12 p-3">
<g:if test="${!(mode in content.excludedModes?:[])}">
<g:render template="/project/meriPlanChanges/${content.template}" model="${content.model}"/>
</g:if>
</div>
</div>
</g:each>

</div>
14 changes: 14 additions & 0 deletions grails-app/views/project/_configurableMeriPlanOriginalView.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div id="meriplan-original" class="meri-plan space-after" data-bind="let:{details:meriPlan(), detailsChanged:meriPlanChanged()}">
MERI-PLAN ORIGINAL TESTING
<g:each var="content" in="${config?.meriPlanContents}">
<div class="row">
<div class="col-sm-12 p-3">
<g:if test="${!(mode in content.excludedModes?:[])}">
<g:render template="/project/meriPlanChanges/${content.template}" model="${content.model}"/>
</g:if>
</div>
</div>
</g:each>

</div>

19 changes: 11 additions & 8 deletions grails-app/views/project/_editMeriPlan.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@
<th class="ref">Change Order Numbers</th>
<th class="comments">Comments</th>
<th class="approver">Approved by</th>
<th class="open">Open</th>
<g:if test="${fc.userIsAlaOrFcAdmin()}">
<th class="delete-approval">Delete</th>
</g:if>
<th class="report-actions">Actions</th>
</tr>
</thead>
<tbody data-bind="foreach:approvedPlans">
Expand All @@ -113,10 +110,15 @@
<td class="ref" data-bind="text:referenceDocument"></td>
<td class="comments" data-bind="text:reason"></td>
<td class="approver"><span data-bind="text:userDisplayName"></span></td>
<td class="open"><a target="_meriPlan" data-bind="attr:{href:openMeriPlanUrl}"><i class="fa fa-external-link"></i></a></td>
<g:if test="${fc.userIsAlaOrFcAdmin()}">
<td class="delete-approval"><i class="fa fa-remove" data-bind="click:$parent.deleteApproval"></i></td>
</g:if>
<td class="report-actions">
<a target="_meriPlan" data-bind="attr:{href:openMeriPlanUrl}"><i class="fa fa-external-link" title="Open"></i></a>
<a target="_meriPlan" data-bind="attr:{href:openMeriPlanChangesUrl}"><i class="fa fa fa-code-fork" title="View Changes"></i></a>
<g:if test="${fc.userIsAlaOrFcAdmin()}">
<a class="btn btn-container btn-sm pull-right" href="javascript:void(0)" title="Delete"
data-bind="click:$parent.deleteApproval"><i class="fa fa-remove" style="color:red;"></i>
</a>
</g:if>
</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -154,6 +156,7 @@
<button type="button" data-bind="click: saveProjectDetails, disable: isProjectDetailsLocked()" class="btn btn-sm btn-primary">Save changes</button>
<button type="button" class="btn btn-sm btn-danger" data-bind="click: cancelProjectDetailsEdits">Cancel</button>
<button type="button" class="btn btn-sm btn-info" data-bind="click: meriPlanPDF">Display Printable MERI Plan</button>
<button type="button" class="btn btn-sm btn-info" data-bind="click: meriPlanChanges">Display MERI Plan Changes</button>

<!-- Admin - submit to approval. -->
<g:if test="${user?.isAdmin}">
Expand Down
4 changes: 4 additions & 0 deletions grails-app/views/project/index.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
projectReportUrl: "${createLink(controller:'project', action:'projectReport', id:project.projectId)}",
projectReportPDFUrl: "${createLink(controller:'project', action:'projectReportPDF', id:project.projectId)}",
meriPlanPDFUrl: "${createLink(controller:'project', action:'viewMeriPlan', id:project.projectId)}",
meriPlanChangesUrl: "${createLink(controller:'project', action:'viewMeriPlanChanges', id:project.projectId)}",
viewMeriPlanChangesUrl: "${createLink(controller:'project', action:"viewMeriPlanChanges", id:project.projectId)}",
sitesPhotoPointsUrl: "${createLink(controller:'project', action:'projectSitePhotos', id:project.projectId)}",
organisationSearchUrl: "${createLink(controller: 'organisation', action: 'search')}",
submitReportUrl: "${createLink(controller: 'project', action: 'ajaxSubmitReport', id:project.projectId)}/",
Expand Down Expand Up @@ -259,6 +261,8 @@

var config = {
meriPlanPDFUrl: fcConfig.meriPlanPDFUrl,
meriPlanChangesUrl: fcConfig.meriPlanChangesUrl,
viewMeriPlanChangesUrl: fcConfig.viewMeriPlanChangesUrl,
saveTargetsUrl: fcConfig.projectUpdateUrl,
documentUpdateUrl: fcConfig.documentUpdateUrl,
projectUpdateUrl: fcConfig.projectUpdateUrl,
Expand Down
14 changes: 14 additions & 0 deletions grails-app/views/project/meriPlanChanges/_activities.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div id="activity-list-view">
<g:if test="${title}">
<h4>${title}</h4>
</g:if>

<ul data-bind="visible:details.activities.activities().length > 0 || details.activities.activities.otherChecked()">
<!-- ko foreach:details.activities.activities -->
<li class="activity" data-bind="text:$data"></li>
<!-- /ko -->
<li class="activity" data-bind="visible:details.activities.activities.otherChecked(), text:details.activities.activities.otherValue()"></li>
</ul>

<span class="activity" data-bind="visible:details.activities.activities().length == 0 && !details.activities.activities.otherChecked()">${noneSelectedMessage}</span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="adaptive-management-view">
<g:if test="${title}">
<h4>${title}</h4>
</g:if>
<p>Methods and processes that will enable adaptive management during the lifetime of this project</p>
<span data-bind="text:details.adaptiveManagement"></span>
</div>
29 changes: 29 additions & 0 deletions grails-app/views/project/meriPlanChanges/_additionalOutcomes.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<h4>Additional benefits</h4>
<table class="table secondary-outcome">
<thead>
<tr>
<th class="outcome-priority">Secondary outcome(s)</th>
<th class="priority">${ priority ?:"Secondary Investment Priorities"}</th>
</tr>
</thead>
<tbody>
<tr>
<td class="outcome-priority" id="secondaryOutcomes">
<span>
<g:set var="max" value="${Math.max(project.custom.details.outcomes?.secondaryOutcomes?.size(), changed.custom.details.outcomes?.secondaryOutcomes?.size()?:0)}"/>
<g:each in="${(0..<max)}" var="i">
<span><fc:renderComparison changed="${changed.custom.details.outcomes.secondaryOutcomes ?: []}" i="${i}" original="${project.custom.details.outcomes.secondaryOutcomes ?: []}" property="description"/></span>
</g:each>
</span>
</td>
<td>
<span id="secondaryAssets">
<g:set var="max" value="${Math.max(project.custom.details.outcomes?.secondaryOutcomes?.assets?.size(), changed.custom.details.outcomes?.secondaryOutcomes?.assets?.size()?:0)}"/>
<g:each in="${(0..<max)}" var="i">
<span><fc:renderComparison changed="${changed.custom.details.outcomes.secondaryOutcomes ?: []}" i="${i}" original="${project.custom.details.outcomes.secondaryOutcomes ?: []}" property="assets"/></span>
</g:each>
</span>
</td>
</tr>
</tbody>
</table>
37 changes: 37 additions & 0 deletions grails-app/views/project/meriPlanChanges/_assets.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<h4>Project assets</h4>
<g:if test="${viewExplanation}">
${viewExplanation ?: "Species, ecological community or environmental asset(s) the project is targeting"}
</g:if>
<g:set var="assetClass" value="${useCategorySelection || autoSelectCategory ? 'asset-detail': 'asset'} "/>
<table class="table assets-view">
<thead>
<tr>
<th class="index"></th>
<g:if test="${fromPriorities && useCategorySelection}">
<th class="asset-category">Asset Type</th>
</g:if>
<th class="${assetClass}">${assetHeading ?: "Species, ecological community or environmental asset(s) the project is targeting"}</th>
<g:if test="${fromPriorities && autoSelectCategory}">
<th class="asset-category">Asset Type</th>
</g:if>
</tr>
</thead>
<tbody data-bind="foreach:details.assets">
<tr>
<td class="index" data-bind="text:$index()+1"></td>
<g:if test="${fromPriorities && useCategorySelection}">
<td class="asset-category">
<span data-bind="text:category"></span>
</td>
</g:if>
<td class="${assetClass}">
<span data-bind="text:description"></span>
</td>
<g:if test="${fromPriorities && autoSelectCategory}">
<td class="asset-category">
<span data-bind="text:category"></span>
</td>
</g:if>
</tr>
</tbody>
</table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h4>${heading}</h4>
<p>${attachmentText}</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h4>${title}</h4>

<div class="community-engagement-view row">
<span class="col-sm-12" data-bind="text:details.communityEngagement"></span>
</div>
5 changes: 5 additions & 0 deletions grails-app/views/project/meriPlanChanges/_consultation.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h4>${title}</h4>

<div class="consultation-view row">
<span class="col-sm-12" data-bind="text:details.consultation"></span>
</div>
17 changes: 17 additions & 0 deletions grails-app/views/project/meriPlanChanges/_controlApproach.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<g:if test="${title}">
<h4>${title}</h4>
</g:if>
<table class="table">
<thead>
<tr>
<th class="approach-current">Could this control approach pose a threat to Native Animals/Plants or Biodiversity?</th>
<th class="approach-details">Details</th>
</tr>
</thead>
<tbody data-bind="foreach : details.threatToNativeSpecies.rows">
<tr>
<td class="approach-current"><span data-bind="text:couldBethreatToSpecies"></span></td>
<td class="approach-details"><span data-bind="text:details"></span></td>
</tr>
</tbody>
</table>
23 changes: 23 additions & 0 deletions grails-app/views/project/meriPlanChanges/_controlMethod.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<g:if test="${title}">
<h4>${title}</h4>
</g:if>
<table class="table">
<thead>
<tr>
<th class="index"></th>
<th class="method-current">Are there any current control methods for this pest?</th>
<th class="method-success">Has it been successful?</th>
<th class="method-type">Type of method</th>
<th class="method-details">Details</th>
</tr>
</thead>
<tbody data-bind="foreach : details.threatControlMethod.rows">
<tr>
<td class="index"><span data-bind="text: $index()+1"></span></td>
<td class="method-current"><span data-bind="text:currentControlMethod"></span></td>
<td class="method-success"><span data-bind="text:hasBeenSuccessful"></span></td>
<td class="method-type"><span data-bind="text:methodType"></span></td>
<td class="method-details"><span data-bind="text:details"></span></td>
</tr>
</tbody>
</table>
23 changes: 23 additions & 0 deletions grails-app/views/project/meriPlanChanges/_description.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<g:if test="${tableFormatting}">
<table class="table">
<thead>
<tr>
<th>Project description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="display:none" class="original" data-bind="text:details.description"></td>
<td style="display:none" class="changed" data-bind="text:detailsChanged.description"></td>
<td wrap class="diff1"></td>
</tr>
</tbody>
</table>
</g:if>
<g:else>
<h4>Project description</h4>
<td style="display:none" class="original" data-bind="text:details.description"></td>
<td style="display:none" class="changed" data-bind="text:detailsChanged.description"></td>
<td wrap class="diff1"></td>
</g:else>

Loading

0 comments on commit 1e0dc89

Please sign in to comment.