Skip to content

Commit

Permalink
Only display current org relationships on Overview tab #2880
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Sep 18, 2024
1 parent 1fd29e6 commit f571c03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 53 deletions.
58 changes: 6 additions & 52 deletions grails-app/assets/javascripts/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,59 +376,13 @@ function ProjectViewModel(project) {
});

self.transients.projectId = project.projectId;
self.transients.currentAssociatedOrgs = ko.pureComputed(function() {
return _.filter(self.associatedOrgs(), function(org) {
var toDate = ko.utils.unwrapObservable(org.toDate);
var fromDate = ko.utils.unwrapObservable(org.fromDate);
return (!toDate || toDate >= new Date().toISOStringNoMillis()) && (!fromDate || fromDate <= new Date().toISOStringNoMillis());

self.transients.dataSharingLicenses = [
{lic:'CC BY', name:'Creative Commons Attribution'},
{lic:'CC BY-NC', name:'Creative Commons Attribution-NonCommercial'},
{lic:'CC BY-SA', name:'Creative Commons Attribution-ShareAlike'},
{lic:'CC BY-NC-SA', name:'Creative Commons Attribution-NonCommercial-ShareAlike'}
];

self.transients.difficultyLevels = [ "Easy", "Medium", "Hard" ];

var scienceTypesList = [
{name:'Biodiversity', value:'biodiversity'},
{name:'Ecology', value:'ecology'},
{name:'Natural resource management', value:'nrm'}
];
self.transients.availableScienceTypes = scienceTypesList;
self.transients.scienceTypeDisplay = ko.pureComputed(function () {
for (var st = self.scienceType(), i = 0; i < scienceTypesList.length; i++)
if (st === scienceTypesList[i].value)
return scienceTypesList[i].name;
});

var availableProjectTypes = [
{name:'Citizen Science Project', display:'Citizen\nScience', value:'citizenScience'},
{name:'Ecological or biological survey / assessment (not citizen science)', display:'Biological\nScience', value:'survey'},
{name:'Natural resource management works project', display:'Works\nProject', value:'works'}
];
self.transients.availableProjectTypes = availableProjectTypes;
self.transients.kindOfProjectDisplay = ko.pureComputed(function () {
for (var pt = self.transients.kindOfProject(), i = 0; i < availableProjectTypes.length; i++)
if (pt === availableProjectTypes[i].value)
return availableProjectTypes[i].display;
});
/** Map between the available selection of project types and how the data is stored */
self.transients.kindOfProject = ko.pureComputed({
read: function() {
if (self.isCitizenScience()) {
return 'citizenScience';
}
if (self.projectType()) {
return self.projectType() == 'survey' ? 'survey' : 'works';
}
},
write: function(value) {
if (value === 'citizenScience') {
self.isCitizenScience(true);
self.projectType('survey');
}
else {
self.isCitizenScience(false);
self.projectType(value);
}
}
});
});

self.loadPrograms = function (programsModel) {
Expand Down
2 changes: 1 addition & 1 deletion grails-app/views/project/_overview.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
id="${project.managementUnitId}">${project.managementUnitName?.encodeAsHTML()}</g:link></div>
</div>
</g:if>
<!-- ko foreach:associatedOrgs() -->
<!-- ko foreach:transients.currentAssociatedOrgs() -->
<div class="row mb-2">
<div class="col-sm-4 header-label" data-bind="text:$data.description"></div>

Expand Down

0 comments on commit f571c03

Please sign in to comment.