Skip to content

Commit

Permalink
Dataset summary WIP #2957
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Sep 4, 2023
1 parent 2f81cc6 commit c030ff5
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 79 deletions.
24 changes: 18 additions & 6 deletions grails-app/assets/javascripts/dataSets.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var DataSetViewModel = function(dataSet, projectService, options) {

dataSet = dataSet || {};
self.dataSetId = dataSet.dataSetId;
self.surveyId = dataSet.surveyId; // Data set summaries created by a submission from the Monitor app will have a surveyId
self.name = ko.observable(dataSet.name );
self.grantId = dataSet.grantId;
self.projectName = dataSet.projectName;
Expand All @@ -79,12 +80,23 @@ var DataSetViewModel = function(dataSet, projectService, options) {
});

self.type = ko.observable(dataSet.type);
self.otherDataSetType = ko.observable(dataSet.otherDataSetType);
self.term = ko.observable(dataSet.term);

self.serviceAndOutcomes = ko.observable(_.find(options.projectOutcomes || [], function(outcome) {
return outcome.serviceId == dataSet.serviceId && _.isEqual(outcome.outcomes, dataSet.projectOutcomes);
}));
self.projectOutcomeList = ko.observableArray(options.projectOutcomes);
self.serviceId = ko.computed(function() {
return self.serviceAndOutcomes() && self.serviceAndOutcomes().serviceId;
});
self.projectOutcomes = ko.computed(function() {
return self.serviceAndOutcomes() && self.serviceAndOutcomes().outcomes;
});
if (dataSet.measurementTypes && !_.isArray(dataSet.measurementTypes)) {
dataSet.measurementTypes = [dataSet.measurementTypes];
}
self.measurementTypes = ko.observableArray(dataSet.measurementTypes);
self.otherMeasurementType = ko.observable(dataSet.otherMeasurementType);
self.methods = ko.observableArray(dataSet.methods);
self.methodDescription = ko.observable(dataSet.methodDescription);
self.collectionApp = ko.observable(dataSet.collectionApp);
Expand All @@ -101,16 +113,14 @@ var DataSetViewModel = function(dataSet, projectService, options) {
});
self.addition = ko.observable(dataSet.addition);
self.threatenedSpeciesIndex = ko.observable(dataSet.threatenedSpeciesIndex);
self.collectorType = ko.observable(dataSet.collectorType);
self.qa = ko.observable(dataSet.qa);
self.published = ko.observable(dataSet.published);
self.storageType = ko.observable(dataSet.storageType);
self.threatenedSpeciesIndexUploadDate = ko.observable(dataSet.threatenedSpeciesIndexUploadDate).extend({simpleDate:false});
self.publicationUrl = ko.observable(dataSet.publicationUrl);
self.format = ko.observable(dataSet.format);
if (dataSet.sensitivities && !_.isArray(dataSet.sensitivities)) {
dataSet.sensitivities = [dataSet.sensitivities];
}
self.sensitivities = ko.observableArray(dataSet.sensitivities);
self.otherSensitivity = ko.observableArray(dataSet.otherSensitivity);
self.owner = ko.observable(dataSet.owner);
self.custodian = ko.observable(dataSet.custodian);
self.progress = ko.observable(dataSet.progress);
Expand All @@ -126,6 +136,8 @@ var DataSetViewModel = function(dataSet, projectService, options) {
}
});

self.isAutoCreated = dataSet.surveyId != null;

self.validate = function() {
return $(config.validationContainerSelector).validationEngine('validate');
}
Expand All @@ -135,7 +147,7 @@ var DataSetViewModel = function(dataSet, projectService, options) {

if (valid) {
var dataSet = ko.mapping.toJS(self,
{ignore: ['grantId', 'projectName', 'programName', 'validate', 'save', 'cancel', 'investmentOtherSelected', 'siteUrl']});
{ignore: ['grantId', 'projectName', 'programName', 'validate', 'save', 'cancel', 'investmentOtherSelected', 'siteUrl', 'isAutoCreated', 'serviceAndOutcomes']});
projectService.saveDataSet(dataSet).done(function() {
// return to project
window.location.href = config.returnToUrl;
Expand Down
4 changes: 2 additions & 2 deletions grails-app/assets/stylesheets/dataSets.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ table td.dataset-name, table th.dataset-name {
table td.report-start, table th.report-start {
width:15%;
}
div.otherPriority {
margin-top: 10px;
div.otherPriority, div.other {
margin-top: 5px;
}
table td.dataset-progress, table th.dataset-progress {
width:10em;
Expand Down
21 changes: 18 additions & 3 deletions grails-app/controllers/au/org/ala/merit/DataSetController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,26 @@ class DataSetController {
if (!priorities) {
priorities = ['n/a']
}
if (priorities){
priorities << 'Other'


List outcomeGroups = []
List projectServices = projectService.getProjectServices(project)
project.outputTargets?.each { Map outputTarget ->
if (outputTarget.outcomeTargets) {
Map service = projectServices.find{it.scores?.find{score -> score.scoreId == outputTarget.scoreId}}
outputTarget.outcomeTargets.each {
outcomeGroups << [
scoreId:outputTarget.scoreId,
serviceId: service.id,
service: service.name,
outcomes:it.relatedOutcomes,
label:service.name+" "+it.relatedOutcomes
]
}
}
}

[projectId:projectId, programName:programName, priorities:priorities, outcomes: outcomes, project:project]
[projectId:projectId, programName:programName, priorities:priorities, outcomes: outcomes, project:project, projectOutcomes:outcomeGroups]
}

// Note that authorization is done against a project, so the project id must be supplied to the method.
Expand Down
113 changes: 45 additions & 68 deletions grails-app/views/dataSet/_editDataSet.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
<label for="investmentPriority" class="col-sm-5 col-form-label required">6. What primary or secondary investment priorities or assets does this dataset relate to?</label>
<div class="col-sm-7">
<g:select multiple="multiple" from="${priorities}" name="investmentPriority" class="form-control" id="investmentPriority" data-validation-engine="validate[required]" data-bind="selectedOptions:investmentPriorities"/>
<div class="otherPriority">
<textarea type="text" class="form-control otherPriorityTextArea" placeholder="Note: This Other Priorities box only enable if other is selected" data-bind="enable: investmentOtherSelected(), value: otherInvestmentPriority"></textarea> </div>
</div>

</div>
%{-- Support for legacy data set summaries --}%
<!-- ko if:term() -->
<div class="form-group row">
<label for="term" class="col-sm-5 col-form-label">7. Is this data being collected for reporting against short or medium term outcome statements?</label>
<div class="col-sm-7">
Expand All @@ -61,6 +61,18 @@
</select>
</div>
</div>
<!-- /ko -->

<!-- ko if:!term() -->
<div class="form-group row">
<label for="projectOutcomes" class="col-sm-5 col-form-label">7. Which project service and outcome/s does this data set support? </label>
<div class="col-sm-7">
<select id="projectOutcomes" class="form-control" data-bind="options:projectOutcomeList, optionsText:'label', optionsCaption:'Please select...', value:serviceAndOutcomes"></select>

</div>
</div>
<!-- /ko -->

<div class="form-group row">
<label for="type" class="col-sm-5 col-form-label required">8. Is this (a) a baseline dataset associated with a project outcome i.e. against which, change will be measured, (b) a project progress dataset that is tracking change against an established project baseline dataset or (c) a standalone, foundational dataset to inform future management interventions?</label>
<div class="col-sm-7">
Expand All @@ -71,12 +83,17 @@
<option>Standalone, foundational dataset to inform future management interventions</option>
<option>Other</option>
</select>
<div class="otherDataSetType other">
<textarea type="text" class="form-control otherPriorityTextArea" placeholder="Note: This field will only enable if Other is selected" data-bind="enable: type() == 'Other', value: otherDataSetType"></textarea>
</div>

</div>
</div>

<div class="form-group row">
<label for="measurementTypes" class="col-sm-5 col-form-label required">9. What types of measurements or observations does the dataset include? <br/>To select more than one answer, hold down the ‘CTRL’ button whilst selecting an option from the drop-down list</label>
<div class="col-sm-7">
<select multiple="multiple" type="text" class="form-control" id="measurementTypes" data-validation-engine="validate[required]" data-bind="selectedOptions:measurementTypes">
<select multiple="multiple" type="text" class="form-control" id="measurementTypes" data-validation-engine="validate[required]" data-bind="multiSelect2:{value:measurementTypes}">
<option>Abundance</option>
<option>Adoption - climate and market demands</option>
<option>Adoption - land resource management practices</option>
Expand Down Expand Up @@ -105,6 +122,9 @@
<option>Targeted - weeds</option>
<option>Water quality
</select>
<div class="otherMeasurementType other">
<textarea type="text" class="form-control otherPriorityTextArea" placeholder="Note: This field will only enable if Other is selected" data-bind="enable: measurementTypes() && measurementTypes().indexOf('Other') >= 0, value: otherMeasurementType"></textarea>
</div>
</div>
</div>

Expand Down Expand Up @@ -153,14 +173,14 @@
</div>
</div>
<div class="form-group row">
<label for="collectionApp" class="col-sm-5 col-form-label">12. Identify any apps used during data collection.</label>
<label for="collectionApp" class="col-sm-5 col-form-label">12. Identify any apps used during data collection. <p>Where the 'Monitor' app has not been used, please provide details</p></label>
<div class="col-sm-7">
<input type="text" class="form-control" id="collectionApp" placeholder="" data-bind="value:collectionApp">
</div>
</div>
<div class="form-group row">
<label for="location" class="col-sm-5 col-form-label">13. Provide a coordinate centroid for the area surveyed.
(For biophysical/ecological surveys where an app was not used, and where there are no sensitivities in providing a location).
(For biophysical/ecological surveys where an app was not used, and where there are no sensitivities in providing a location). <p>For biophysical/ecological surveys where an app was not used, and where there are no sensitivities in providing a location</p>
</label>
<div class="col-sm-7">
<!-- ko if:!siteId() -->
Expand All @@ -183,7 +203,7 @@
<label for="endDate" class="col-sm-5 col-form-label">15. Last collection date.</label>
<div class="col-sm-3">
<div class="input-group input-append">
<fc:datePicker type="text" bs4="true" class="form-control" id="endDate" placeholder="" data-validation-engine="validate[future[startDate]" targetField="endDate.date"/>
<fc:datePicker type="text" bs4="true" class="form-control" id="endDate" placeholder="" data-validation-engine="validate[future[startDate]]" targetField="endDate.date"/>

</div>
</div>
Expand All @@ -207,7 +227,7 @@
</div>

<div class="form-group row">
<label for="threatenedSpeciesIndex" class="col-sm-5 col-form-label">16a. Has your data been included in the Threatened Species Index?</label>
<label for="threatenedSpeciesIndex" class="col-sm-5 col-form-label">16a. Has your data been uploaded to the Threatened Species Index?</label>
<div class="col-sm-7">
<select class="form-control" id="threatenedSpeciesIndex" data-bind="value:threatenedSpeciesIndex">
<option></option>
Expand All @@ -218,69 +238,22 @@
</div>
</div>

<div class="row form-subheading">
<div class="col-12">
Dataset accessibility
</div>
</div>
<div class="form-group row">
<label for="collectorType" class="col-sm-5 col-form-label required">17. Who developed the dataset?</label>
<div class="col-sm-7">
<select type="text" class="form-control" id="collectorType" data-validation-engine="validate[required]" data-bind="value:collectorType">
<option></option>
<option>University researcher</option>
<option>Specialist consultant</option>
<option>Service Provider staff</option>
<option>State Government agency staff</option>
<option>Community member/volunteer</option>
<option>Other</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="qa" class="col-sm-5 col-form-label required">18. Has a quality assurance check been undertaken on the data?</label>
<div class="col-sm-7">
<select class="form-control" id="qa" data-validation-engine="validate[required]" data-bind="value:qa">
<option></option>
<option>Yes</option>
<option>No</option>
<option>Don't know</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="published" class="col-sm-5 col-form-label required">19. Has the data contributed to a publication?</label>
<div class="col-sm-7">
<select class="form-control" id="published" data-validation-engine="validate[required]" data-bind="value:published">
<option></option>
<option>Yes</option>
<option>No</option>
<option>Don't know</option>
</select>
<label for="threatenedSpeciesIndex" class="col-sm-5 col-form-label required">16b. Date of upload, if you answered 'Yes' to 16a above.</label>
<div class="col-sm-3">
<div class="input-group input-append">
<fc:datePicker type="text" bs4="true" class="form-control" id="threatenedSpeciesIndexUploadDate" placeholder="" data-validation-engine="validate[required]" data-bind="datepicker:threatenedSpeciesIndexUploadDate.date, enable: threatenedSpeciesIndex() == 'Yes'" targetField="" required="true"/>
</div>
</div>
</div>
<div class="form-group row">
<label for="storageType" class="col-sm-5 col-form-label required">20. Where is the data held?</label>
<div class="col-sm-7">
<select class="form-control" id="storageType" data-validation-engine="validate[required]" data-bind="value:storageType">
<option></option>
<option>Aurion</option>
<option>Cloud</option>
<option>CM9</option>
<option>External Hard Drive</option>
<option>Oracle Database</option>
<option>Other Database</option>
<option>Protected Enclave</option>
<option>Shared Drive</option>
<option>Sharepoint</option>
<option>SPIRE</option>
<option>Unknown</option>
<option>Stored internally</option>
</select>

<div class="row form-subheading">
<div class="col-12">
Dataset accessibility
</div>
</div>
<div class="form-group row">
<label for="publicationUrl" class="col-sm-5 col-form-label">21. For all public datasets, please provide the published location. If stored internally by your organisation, write ‘stored internally’.</label>
<label for="publicationUrl" class="col-sm-5 col-form-label">21. Please provide the location/system of where the dataset is held. If possible, provide a URL of the published location. If stored internally by your organisation, write ‘stored internally’.</label>
<div class="col-sm-7">
<input type="text" class="form-control" id="publicationUrl" placeholder="" data-bind="value:publicationUrl">
</div>
Expand Down Expand Up @@ -316,13 +289,17 @@
<option>Legally sensitive</option>
<option>Other</option>
</select>
<div class="otherSensitivity other">
<textarea type="text" class="form-control otherSensitivityTextArea" placeholder="Note: This field will only enable if Other is selected" data-bind="enable: sensitivities() && sensitivities().indexOf('Other') >= 0, value: otherSensitivity"></textarea>
</div>
</div>

</div>

<div class="form-group row">
<div class="col-sm-5">
<label for="owner" class="col-form-label required">24. Primary source of data (organisation or individual that owns or maintains the dataset)</label>
<p>Please include the contact name, physical address, email address and phone number where possible</p>
<label for="owner" class="col-form-label required">24. Primary source of data (organisation that owns or maintains the dataset)</label>
<p>Please include the organisation name, physical address, email address and phone number where possible. Do not include any details of individual officers</p>
</div>


Expand All @@ -333,8 +310,8 @@

<div class="form-group row">
<div class="col-sm-5 col-form-label">
<label for="custodian" class="required">25. Dataset custodian (name of contact to obtain access to dataset)</label>
<p>Please include the contact name, physical address, email address and phone number where possible</p>
<label for="custodian" class="required">25. Dataset custodian (name of organisation to obtain access to dataset)</label>
<p>Please include the organisation name, physical address, email address and phone number where possible. Do not include any details of individual officers.</p>
</div>
<div class="col-sm-7">
<textarea rows="2" class="form-control" id="custodian" placeholder="" data-validation-engine="validate[required,maxSize[300]]" data-bind="value:custodian"></textarea>
Expand Down
4 changes: 4 additions & 0 deletions grails-app/views/dataSet/create.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
};
</script>
<asset:stylesheet src="common-bs4.css"/>
<asset:stylesheet src="select2/4.0.3/css/select2.css"/>
<asset:stylesheet src="dataSets.css"/>

</head>
Expand Down Expand Up @@ -43,11 +44,14 @@

<asset:javascript src="common-bs4.js"/>
<asset:javascript src="projectService.js"/>
<asset:javascript src="select2/js/select2.full.js"/>
<asset:javascript src="forms-knockout-bindings.js"/>
<asset:javascript src="dataSets.js"/>
<script>
var project = {};
var projectService = new ProjectService(project, fcConfig);
var config = _.extend(fcConfig, {endDateSelector:"#endDate"});
config.projectOutcomes = <fc:modelAsJavascript model="${projectOutcomes}"/>;
var viewModel = new DataSetViewModel({}, projectService, config);
ko.applyBindings(viewModel);
</script>
Expand Down
4 changes: 4 additions & 0 deletions grails-app/views/dataSet/edit.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
};
</script>
<asset:stylesheet src="common-bs4.css"/>
<asset:stylesheet src="select2/4.0.3/css/select2.css"/>
<asset:stylesheet src="dataSets.css"/>

</head>
Expand Down Expand Up @@ -43,12 +44,15 @@

<asset:javascript src="common-bs4.js"/>
<asset:javascript src="projectService.js"/>
<asset:javascript src="select2/js/select2.full.js"/>
<asset:javascript src="forms-knockout-bindings.js"/>
<asset:javascript src="dataSets.js"/>
<script>
var project = {};
var dataSet = <fc:modelAsJavascript model="${dataSet}"/>;
var projectService = new ProjectService(project, fcConfig);
var config = _.extend(fcConfig, {endDateSelector:"#endDate"});
config.projectOutcomes = <fc:modelAsJavascript model="${projectOutcomes}"/>;
var viewModel = new DataSetViewModel(dataSet, projectService, fcConfig);
ko.applyBindings(viewModel);
</script>
Expand Down
Loading

0 comments on commit c030ff5

Please sign in to comment.