diff --git a/grails-app/assets/javascripts/services.js b/grails-app/assets/javascripts/services.js index bba0faa7b..9f3efcc71 100644 --- a/grails-app/assets/javascripts/services.js +++ b/grails-app/assets/javascripts/services.js @@ -72,7 +72,7 @@ function OrganisationServicesViewModel(serviceIds, allServices, outputTargets, p target.serviceId = ko.observable(service ? service.id : null); target.scoreId = ko.observable(score ? score.scoreId : null); - var decimalPlaces = _.isNumber(score.decimalPlaces) ? score.decimalPlaces : 2; + var decimalPlaces = _.isNumber(score && score.decimalPlaces) ? score.decimalPlaces : 2; target.target = ko.observable().extend({numericString: decimalPlaces}); target.targetDate = ko.observable().extend({simpleDate:false}); @@ -210,6 +210,11 @@ function OrganisationServicesViewModel(serviceIds, allServices, outputTargets, p }); target.scoreId.subscribe(function () { + var score = target.scoreId() ? target.score() : null; + if (score) { + var decimalPlaces = _.isNumber(score && score.decimalPlaces) ? score.decimalPlaces : 2; + target.target = ko.observable().extend({numericString: decimalPlaces}); + } target.updateTargets(); }); diff --git a/grails-app/controllers/au/org/ala/merit/OrganisationController.groovy b/grails-app/controllers/au/org/ala/merit/OrganisationController.groovy index 03bbb1302..4ab021f5b 100644 --- a/grails-app/controllers/au/org/ala/merit/OrganisationController.groovy +++ b/grails-app/controllers/au/org/ala/merit/OrganisationController.groovy @@ -74,11 +74,14 @@ class OrganisationController { Map availableReportCategories = null List services = null List targetPeriods = null + List dashboardData = null if (adminVisible) { dashboardReports += [name:'announcements', label:'Announcements'] availableReportCategories = settingService.getJson(SettingPageType.ORGANISATION_REPORT_CONFIG) services = organisationService.findApplicableServices(organisation, metadataService.getProjectServices()) targetPeriods = organisationService.generateTargetPeriods(organisation) + List scores = services.collect{it.scores}.flatten() + dashboardData = organisationService.scoresForOrganisation(organisation, scores?.collect{it.scoreId}, !hasEditorAccess) } boolean showTargets = userService.userIsSiteAdmin() && services && targetPeriods @@ -110,7 +113,7 @@ class OrganisationController { [about : [label: 'About', visible: true, stopBinding: false, type:'tab', default:!reportingVisible, displayedPrograms:projectGroups.displayedPrograms, servicesDashboard:[visible:true]], 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], sites : [label: 'Sites', visible: reportingVisible, type: 'tab', stopBinding:true, projectCount:organisation.projects?.size()?:0, showShapefileDownload:adminVisible], - dashboard : [label: 'Dashboard', visible: reportingVisible, stopBinding:true, type: 'tab', template:'/shared/dashboard', reports:dashboardReports], + dashboard : [label: 'Dashboard', visible: reportingVisible, stopBinding:true, type: 'tab', template:'dashboard', reports:dashboardReports, dashboardData:dashboardData], admin : [label: 'Admin', visible: adminVisible, type: 'tab', template:'admin', showEditAnnoucements:showEditAnnoucements, availableReportCategories:availableReportCategories, targetPeriods:targetPeriods, services: services, showTargets:showTargets]] } @@ -200,7 +203,7 @@ class OrganisationController { } List existingLinks = links?.findResults { it.documentId } - List toDeleteLinks = originalOrganisation?.links?.findAll { !existingLinks.contains(it.documentId) } + List toDeleteLinks = originalOrganisation?.links?.findAll { !existingLinks?.contains(it.documentId) } // delete any links that were removed. if (toDeleteLinks && !result.error) { toDeleteLinks.each { link -> diff --git a/grails-app/services/au/org/ala/merit/OrganisationService.groovy b/grails-app/services/au/org/ala/merit/OrganisationService.groovy index 4d1e6140e..4d30720a0 100644 --- a/grails-app/services/au/org/ala/merit/OrganisationService.groovy +++ b/grails-app/services/au/org/ala/merit/OrganisationService.groovy @@ -352,6 +352,23 @@ class OrganisationService { scoreIds.collectEntries{ String scoreId ->[(scoreId):result.results?.find{it.scoreId == scoreId}?.result?.result ?: 0]} } + List scoresForOrganisation(Map organisation, List scoreIds, boolean approvedOnly = true) { + + String url = grailsApplication.config.getProperty('ecodata.baseUrl')+"organisation/organisationMetrics/"+organisation.organisationId + Map params = [approvedOnly: approvedOnly, scoreIds: scoreIds] + + Map result = webService.doPost(url, params) + + List scores = result?.resp?.collect { Map score -> + Map target = organisation?.custom?.details?.services?.targets?.find { it.scoreId == score.scoreId } + score.target = target?.target + score + } + + scores + + } + /** * Filter services to those supported by organisation. diff --git a/grails-app/views/organisation/_dashboard.gsp b/grails-app/views/organisation/_dashboard.gsp new file mode 100644 index 000000000..dec0d574c --- /dev/null +++ b/grails-app/views/organisation/_dashboard.gsp @@ -0,0 +1,10 @@ + +
+

Indigenous workforce and procurement

+ + + +
+
+ + \ No newline at end of file