Skip to content

Commit adebb29

Browse files
committed
Merge remote-tracking branch 'origin/dev' into feature/issue3421
2 parents effab43 + 05d3386 commit adebb29

16 files changed

+112
-61
lines changed

forms/other/regionalCapacityServicesReportV3.json

+15-29
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@
1818
{
1919
"target": "targetIndigenousParticipationPercentage",
2020
"source-path": "periodTargets.targetIndigenousParticipationPercentage"
21+
},
22+
{
23+
"target": "reportedFundingExcludingThisReport",
24+
"source-path": "reportedFundingExcludingThisReport"
2125
}
2226
],
2327
"merge": {
2428
"targetIndigenousParticipationPercentage": {
2529
"replaceExisting": true
30+
},
31+
"reportedFundingExcludingThisReport": {
32+
"replaceExisting": true
2633
}
2734
}
2835
},
@@ -60,6 +67,10 @@
6067
}
6168
],
6269
"dataModel": [
70+
{
71+
"name": "reportedFundingExcludingThisReport",
72+
"dataType": "number"
73+
},
6374
{
6475
"name": "governanceAndFinancialFrameworksOnTrack",
6576
"dataType": "text",
@@ -242,7 +253,7 @@
242253
},
243254
{
244255
"param": {
245-
"expression": "organisationPanelProjectValue",
256+
"expression": "organisationPanelProjectValue-reportedFundingExcludingThisReport",
246257
"type": "computed"
247258
},
248259
"rule": "max",
@@ -639,18 +650,6 @@
639650
}
640651
]
641652
},
642-
{
643-
"type": "row",
644-
"items": [
645-
{
646-
"css": "span7",
647-
"preLabel": "Target Workforce Performance % this reporting period",
648-
"source": "targetIndigenousParticipationPercentage",
649-
"type": "number",
650-
"readonly": true
651-
}
652-
]
653-
},
654653
{
655654
"type": "row",
656655
"items": [
@@ -679,25 +678,12 @@
679678
"items": [
680679
{
681680
"css": "span7",
682-
"preLabel": "Supply Chain Performance to date",
683-
"source": "supplyChainPerformancePercentage",
684-
"type": "number",
685-
"helpText": "Supply chain performance to date (note this is a cumulative measure over the life of the contract consistent with the approach used by NIAA measuring indigenous participation. Performance to date should meet or exceed target performance by the end of the Deed period)"
686-
}
687-
]
688-
},
689-
{
690-
"type": "row",
691-
"items": [
692-
{
693-
"css": "span7",
694-
"preLabel": "Target supply chain performance at end of Deed period",
695-
"source": "targetIndigenousProcurementPercentage",
696-
"type": "number",
697-
"readonly": true
681+
"source": "To check how your performance to date against the agreed targets, please click on the dashboard tab after closing the report",
682+
"type": "literal"
698683
}
699684
]
700685
},
686+
701687
{
702688
"type": "row",
703689
"items": [

grails-app/assets/javascripts/organisation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ EditOrganisationViewModel = function(props, options) {
466466
OrganisationPageViewModel = function (props, options) {
467467
var self = this;
468468
_.extend(self, new OrganisationViewModel(props, options));
469-
469+
self.areTargetsAndFundingEditable = options.areTargetsAndFundingEditable;
470470
var tabs = {
471471
'about': {
472472
initialiser: function() {

grails-app/assets/javascripts/services.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ function OrganisationDetailsViewModel(o, organisation, budgetHeaders, allService
33
var period = budgetHeaders,
44
serviceIds = o.services && o.services.serviceIds || [],
55
targets = o.services && o.services.targets || [];
6-
self.services = new OrganisationServicesViewModel(serviceIds, config.services, targets, budgetHeaders);
6+
self.areTargetsAndFundingEditable = config.areTargetsAndFundingEditable;
7+
self.services = new OrganisationServicesViewModel(serviceIds, config.services, targets, budgetHeaders, {areTargetsEditable:config.areTargetsAndFundingEditable});
78
self.funding = new BudgetViewModel(o.funding, budgetHeaders);
9+
self.funding.isEditable = config.areTargetsAndFundingEditable;
10+
811
function clearHiddenFields(jsData) {
912

1013
};
@@ -34,13 +37,13 @@ function OrganisationDetailsViewModel(o, organisation, budgetHeaders, allService
3437
* @param outputTargets The current organisation targets
3538
* @param periods An array of periods, each of which require a target to be set
3639
*/
37-
function OrganisationServicesViewModel(serviceIds, allServices, outputTargets, periods) {
40+
function OrganisationServicesViewModel(serviceIds, allServices, outputTargets, periods, options) {
3841
var self = this,
3942
OPERATION_SUM = "SUM",
4043
OPERATION_AVG = "AVG",
4144
operation = OPERATION_AVG;
4245

43-
self.isProjectDetailsLocked = ko.observable(false);
46+
self.areTargetsEditable = options.areTargetsEditable;
4447

4548
allServices = _.sortBy(allServices || [], function (service) {
4649
return service.name

grails-app/controllers/au/org/ala/merit/OrganisationController.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class OrganisationController {
8484
dashboardData = organisationService.scoresForOrganisation(organisation, scores?.collect{it.scoreId}, !hasEditorAccess)
8585
}
8686
boolean showTargets = userService.userIsSiteAdmin() && services && targetPeriods
87-
87+
boolean targetsEditable = userService.userIsAlaOrFcAdmin()
8888
List reportOrder = null
8989
if (reportingVisible) {
9090
// TODO change me to use the configuration once it's been decided how that
@@ -114,7 +114,7 @@ class OrganisationController {
114114
projects : [label: 'Reporting', template:"/shared/projectListByProgram", visible: reportingVisible, stopBinding:true, default:reportingVisible, type: 'tab', reports:organisation.reports, adHocReportTypes:adHocReportTypes, reportOrder:reportOrder, hideDueDate:true, displayedPrograms:projectGroups.displayedPrograms, reportsFirst:true, declarationType:SettingPageType.RDP_REPORT_DECLARATION],
115115
sites : [label: 'Sites', visible: reportingVisible, type: 'tab', stopBinding:true, projectCount:organisation.projects?.size()?:0, showShapefileDownload:adminVisible],
116116
dashboard : [label: 'Dashboard', visible: reportingVisible, stopBinding:true, type: 'tab', template:'dashboard', reports:dashboardReports, dashboardData:dashboardData],
117-
admin : [label: 'Admin', visible: adminVisible, type: 'tab', template:'admin', showEditAnnoucements:showEditAnnoucements, availableReportCategories:availableReportCategories, targetPeriods:targetPeriods, services: services, showTargets:showTargets]]
117+
admin : [label: 'Admin', visible: adminVisible, type: 'tab', template:'admin', showEditAnnoucements:showEditAnnoucements, availableReportCategories:availableReportCategories, targetPeriods:targetPeriods, services: services, showTargets:showTargets, targetsEditable:targetsEditable]]
118118

119119
}
120120

grails-app/controllers/au/org/ala/merit/ProjectController.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ class ProjectController {
925925
}
926926

927927
model.context = new HashMap(project)
928-
model.context.putAll(reportData.getContextData(project, model.report))
928+
model.context.putAll(reportData.getContextData(project, model.report, model.activity))
929929
model.returnTo = g.createLink(action:'exitReport', id:projectId, params:[reportId:reportId])
930930
model.contextViewUrl = g.createLink(action:'index', id:projectId)
931931
model.reportHeaderTemplate = '/project/rlpProjectReportHeader'

grails-app/services/au/org/ala/merit/MetadataService.groovy

+10
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,16 @@ class MetadataService {
277277
})
278278
}
279279

280+
/**
281+
* Returns a Map cantaining the properties of a Score identified by a supplied name.
282+
* A score name is a unique identifier that is human readable and stable between test/staging/production
283+
* environments.
284+
* @param name The name of the Score of interest.
285+
*/
286+
Map findScoreByName(String name) {
287+
getScores(false).find { it.name == name }
288+
}
289+
280290
List<Map> getScores(boolean includeConfig) {
281291
cacheService.get("scores-${includeConfig}", {
282292
String url = grailsApplication.config.getProperty('ecodata.baseUrl') + "metadata/scores"

grails-app/views/organisation/_funding.gsp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<tr>
1919
<!-- ko foreach: costs -->
2020
<td class="budget-amount">
21-
<input type="number" class="form-control form-control-sm" data-bind="value: dollar, numeric: $root.number, disable: $root.isProjectDetailsLocked()" data-validation-engine="validate[custom[number],min[0]"/>
21+
<input type="number" class="form-control form-control-sm" data-bind="value: dollar, numeric: $root.number, enable: $parents[1].isEditable" data-validation-engine="validate[custom[number],min[0]"/>
2222
</td>
2323
<!-- /ko -->
2424
</tr>

grails-app/views/organisation/_serviceTargets.gsp

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
<tr>
3131
<td class="index"><span data-bind="text:$index()+1"></span></td>
3232
<td class="service">
33-
<select class="form-control form-control-sm" data-bind="options: selectableServices, optionsText:'name', optionsValue:'id', value:serviceId, disable: $root.isProjectDetailsLocked()"
33+
<select class="form-control form-control-sm" data-bind="options: selectableServices, optionsText:'name', optionsValue:'id', value:serviceId, enable: $parent.areTargetsEditable"
3434
data-validation-engine="validate[required]"></select>
3535
</td>
3636
<td class="score">
37-
<select class="form-control form-control-sm" data-bind="options: selectableScores, optionsText:'label', optionsValue:'scoreId', value:scoreId, disable: $root.isProjectDetailsLocked()"
37+
<select class="form-control form-control-sm" data-bind="options: selectableScores, optionsText:'label', optionsValue:'scoreId', value:scoreId, enable: $parent.areTargetsEditable"
3838
data-validation-engine="validate[required]"></select>
3939
</td>
4040
<td class="budget-cell">
@@ -45,7 +45,7 @@
4545
<g:if test="${showTargetDate}">
4646
<td class="target-date">
4747
<div class="input-group">
48-
<input class="form-control form-control-sm" data-bind="datepicker:targetDate.date, disable: $root.isProjectDetailsLocked()" type="text" size="16" data-validation-engine="validate[required]">
48+
<input class="form-control form-control-sm" data-bind="datepicker:targetDate.date, enable: $parent.areTargetsEditable" type="text" size="16" data-validation-engine="validate[required]">
4949
<div class="input-group-append open-datepicker">
5050
<span class="input-group-text">
5151
<i class="fa fa-th ">&nbsp;</i>
@@ -58,7 +58,7 @@
5858
<!-- ko foreach: periodTargets -->
5959
<td class="budget-cell">
6060
<input class="form-control form-control-sm" type="number"
61-
data-bind="value: target, disable: $root.isProjectDetailsLocked()"
61+
data-bind="value: target, enable: $parents[1].areTargetsEditable"
6262
data-validation-engine="validate[custom[number],min[0]]"/>
6363
</td>
6464
<!-- /ko -->
@@ -68,4 +68,4 @@
6868
</table>
6969
<!-- /ko -->
7070
<!-- /ko -->
71-
<button class="btn btn-sm btn-primary" data-bind="click: saveCustomFields">Save changes</button>
71+
<button class="btn btn-sm btn-primary" data-bind="click: saveCustomFields, enable:areTargetsAndFundingEditable">Save changes</button>

grails-app/views/organisation/index.gsp

+2
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@
8282
var availableReportCategories = <fc:modelAsJavascript model="${content.admin?.availableReportCategories}"/>;
8383
var services = <fc:modelAsJavascript model="${content.admin?.services}"/>;
8484
var targetPeriods = <fc:modelAsJavascript model="${content.admin?.targetPeriods}"/>;
85+
var areTargetsAndFundingEditable = ${Boolean.valueOf(content.admin?.targetsEditable)};
8586
var config = _.extend({
8687
reportingConfigSelector:'#reporting-config form',
8788
availableReportCategories:availableReportCategories,
8889
targetPeriods: targetPeriods,
8990
services: services,
9091
organisationDetailsSelector: '#organisation-details',
92+
areTargetsAndFundingEditable: areTargetsAndFundingEditable
9193

9294
}, fcConfig);
9395

grails-app/views/project/meriPlan/_additionalOutcomes.gsp

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<tr>
5151
<td colspan="3">
5252
<button type="button" class="btn btn-sm"
53-
data-bind="disable: details.outcomes.secondaryOutcomes().length >= ${maxAdditonalOutcomes ?: 15} || isProjectDetailsLocked(), click: addSecondaryOutcome">
53+
data-bind="disable: details.outcomes.secondaryOutcomes().length >= ${maxAdditonalOutcomes ?: 35} || isProjectDetailsLocked(), click: addSecondaryOutcome">
5454
<i class="fa fa-plus"></i> Add a row</button></td>
5555
</tr>
5656
</tfoot>

src/main/groovy/au/org/ala/merit/command/EditOrViewReportCommand.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ abstract class EditOrViewReportCommand implements Validateable {
4444

4545
ReportLifecycleListener listener = reportService.reportLifeCycleListener(model.report)
4646
if (listener) {
47-
model.context.putAll(listener.getContextData(entity, model.report))
47+
model.context.putAll(listener.getContextData(entity, model.report, model.activity))
4848
}
4949
}
5050
}

src/main/groovy/au/org/ala/merit/reports/NHTOutputReportLifecycleListener.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class NHTOutputReportLifecycleListener extends ReportLifecycleListener {
2525
boolean containsEntityReferences() {
2626
true
2727
}
28-
Map getContextData(Map project, Map report) {
28+
Map getContextData(Map project, Map report, Map activity) {
2929
// Side effect - filter data sets.
3030
List eligibleDataSets = project.custom?.dataSets?.findAll {
3131
// This is a side effect and a workaround for the problem that selected outcomes

src/main/groovy/au/org/ala/merit/reports/RegionalCapacityServicesReportLifecycleListener.groovy

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package au.org.ala.merit.reports
22

3+
import au.org.ala.merit.MetadataService
34
import au.org.ala.merit.OrganisationService
45
import groovy.util.logging.Slf4j
56
import org.springframework.beans.factory.annotation.Autowired
@@ -10,11 +11,17 @@ class RegionalCapacityServicesReportLifecycleListener extends ReportLifecycleLis
1011
@Autowired
1112
OrganisationService organisationService
1213

13-
Map getContextData(Map organisation, Map report) {
14+
@Autowired
15+
MetadataService metadataService
16+
17+
private static String TOTAL_REPORTED_VALUE_SCORE_NAME = 'totalValueServicesContractedToFirstNations'
18+
19+
Map getContextData(Map organisation, Map report, Map activity) {
1420
List outputTargets = organisation.custom?.details?.services?.targets
1521
Map periodTargets = getTargetsForReportPeriod(report, outputTargets)
1622
def funding = getFundingForPeriod(organisation, report)
17-
[periodTargets:periodTargets, totalContractValue:funding]
23+
def reportedFundingExcludingThisReport = getReportedFundingToDate(organisation, activity)
24+
[periodTargets:periodTargets, totalContractValue:funding, reportedFundingExcludingThisReport:reportedFundingExcludingThisReport]
1825
}
1926

2027
private static def getFundingForPeriod(Map organisation, Map report) {
@@ -29,4 +36,24 @@ class RegionalCapacityServicesReportLifecycleListener extends ReportLifecycleLis
2936
index >= 0 ? organisation.custom?.details?.funding?.rows[0].costs[index].dollar : 0
3037

3138
}
39+
40+
private double getReportedFundingToDate(Map organisation, Map activity) {
41+
Map score = metadataService.findScoreByName(TOTAL_REPORTED_VALUE_SCORE_NAME)
42+
if (!score) {
43+
log.error("No score found for organisation ${organisation.id} and score name ${TOTAL_REPORTED_VALUE_SCORE_NAME}")
44+
return 0
45+
}
46+
List scoreData = organisationService.scoresForOrganisation(organisation, [score.scoreId], false)
47+
48+
double firstNationsServicesTotal = 0
49+
Map firstNationsServicesScore = scoreData[0]
50+
if (firstNationsServicesScore) {
51+
firstNationsServicesTotal = firstNationsServicesScore.result?.result ?: 0
52+
String amountReportedThisPeriod = activity?.outputs?[0]?.data?.servicesContractedValueFirstNations
53+
double reportedAmountThisReport = amountReportedThisPeriod ? Double.valueOf(amountReportedThisPeriod) : 0
54+
55+
firstNationsServicesTotal -= reportedAmountThisReport
56+
}
57+
return firstNationsServicesTotal
58+
}
3259
}

src/main/groovy/au/org/ala/merit/reports/ReportLifecycleListener.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ReportLifecycleListener {
1717
@Autowired
1818
MetadataService metadataService
1919

20-
Map getContextData(Map context, Map report) { [:] }
20+
Map getContextData(Map context, Map report, Map activity) { [:] }
2121
Map getOutputData(Map context, Map outputConfig, Map report) { [:] }
2222
Map reportSaved(Map report, Map activityData) { [:] }
2323
Map reportSubmitted(Map report, List reportActivityIds, Map reportOwner) { [:] }

0 commit comments

Comments
 (0)