Skip to content

Commit

Permalink
Merge pull request #174 from BillionOysterProject/BOP-1031
Browse files Browse the repository at this point in the history
Bop 1031
  • Loading branch information
thetif authored Aug 15, 2016
2 parents 90399b4 + 76746a2 commit 0047c36
Show file tree
Hide file tree
Showing 16 changed files with 546 additions and 264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
}, function(data) {
vm.members = data;
vm.memberLists.members = angular.copy(data);
vm.memberLists.members.push(angular.copy(vm.team.teamLead));
vm.member = null;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@
vm.isAdmin = checkRole('admin');

// Check if the user is allows to write to the given protocol
vm.checkWrite = function(teamList) {
if (checkRole('team lead') || checkRole('admin')) {
vm.checkWrite = function(teamList, protocol) {
if (checkRole('admin') && !checkRole('team lead') && !checkRole('team member')) {
return true;
} else {
var teamListIndex = lodash.findIndex(teamList, function(m) {
return m.username === vm.user.username;
});
return (teamListIndex > -1) ? true : false;
if (checkRole('team lead') && (protocol.status !== 'incomplete' && protocol.status !== 'returned')) {
return true;
} else {
var teamListIndex = lodash.findIndex(teamList, function(m) {
return m.username === vm.user.username;
});
return (teamListIndex > -1) ? true : false;
}
}
};

Expand All @@ -86,7 +90,7 @@
// Set up Site Condition protocol variables
if (!vm.checkDisabled(vm.expedition.protocols.siteCondition)) {
$scope.siteCondition = vm.expedition.protocols.siteCondition;
vm.viewSiteCondition = vm.checkWrite(vm.expedition.teamLists.siteCondition);
vm.viewSiteCondition = vm.checkWrite(vm.expedition.teamLists.siteCondition, $scope.siteCondition);
vm.disabledSiteCondition = false;
} else {
$scope.siteCondition = null;
Expand All @@ -97,7 +101,7 @@
// Set up Oyster Measurement protocol variables
if (!vm.checkDisabled(vm.expedition.protocols.oysterMeasurement)) {
$scope.oysterMeasurement = vm.expedition.protocols.oysterMeasurement;
vm.viewOysterMeasurement = vm.checkWrite(vm.expedition.teamLists.oysterMeasurement);
vm.viewOysterMeasurement = vm.checkWrite(vm.expedition.teamLists.oysterMeasurement, $scope.oysterMeasurement);
vm.disabledOysterMeasurement = false;
} else {
$scope.oysterMeasurement = null;
Expand All @@ -108,7 +112,7 @@
// Set up Mobile Trap protocol variables
if (!vm.checkDisabled(vm.expedition.protocols.mobileTrap)) {
$scope.mobileTrap = vm.expedition.protocols.mobileTrap;
vm.viewMobileTrap = vm.checkWrite(vm.expedition.teamLists.mobileTrap);
vm.viewMobileTrap = vm.checkWrite(vm.expedition.teamLists.mobileTrap, $scope.mobileTrap);
vm.disabledMobileTrap = false;
} else {
$scope.mobileTrap = null;
Expand All @@ -119,7 +123,7 @@
// Set up Settlement Tiles protocol variables
if (!vm.checkDisabled(vm.expedition.protocols.settlementTiles)) {
$scope.settlementTiles = vm.expedition.protocols.settlementTiles;
vm.viewSettlementTiles = vm.checkWrite(vm.expedition.teamLists.settlementTiles);
vm.viewSettlementTiles = vm.checkWrite(vm.expedition.teamLists.settlementTiles, $scope.settlementTiles);
vm.disabledSettlementTiles = false;
} else {
$scope.settlementTiles = null;
Expand All @@ -130,7 +134,7 @@
// Set up Water Quality protocol variables
if (!vm.checkDisabled(vm.expedition.protocols.waterQuality)) {
$scope.waterQuality = vm.expedition.protocols.waterQuality;
vm.viewWaterQuality = vm.checkWrite(vm.expedition.teamLists.waterQuality);
vm.viewWaterQuality = vm.checkWrite(vm.expedition.teamLists.waterQuality, $scope.waterQuality);
vm.disabledWaterQuality = false;
} else {
$scope.waterQuality = null;
Expand Down Expand Up @@ -332,11 +336,9 @@

if(vm.viewOysterMeasurement && $scope.oysterMeasurement) {
$scope.saveOysterMeasurement(function() {
console.log('returned successful');
vm.tabs.protocol2.saveSuccessful = true;
allDone();
}, function() {
console.log('returned failure');
vm.tabs.protocol2.saveSuccessful = false;
allDone();
});
Expand Down Expand Up @@ -479,11 +481,8 @@

// Return the Expedition
vm.return = function() {
console.log('returning');
vm.returning = true;

//if (vm.protocolsLoaded()) {
console.log('protocols loaded');
var protocols = {};
if(vm.viewSiteCondition && $scope.siteCondition) protocols.siteCondition = $scope.siteCondition;
if(vm.viewOysterMeasurement && $scope.oysterMeasurement) protocols.oysterMeasurement = $scope.oysterMeasurement;
Expand Down Expand Up @@ -522,9 +521,6 @@
}
vm.returning = false;
});
// } else {
// vm.returning = false;
// }
};

// Unpublish the Expedition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ <h6 class="navbar-text"><i class="glyphicon glyphicon-map-marker"></i> {{vm.expe
<!-- If never submitted (Status: Incomplete) --->
<!-- Show if team member: -->
<button class="btn btn-success navbar-btn" ng-click="vm.submitTeamMember()"
ng-show="vm.checkStatusIncomplete() && vm.isTeamMember" id="submit-exp-incomplete">Submit</button>
ng-show="vm.checkStatusIncomplete() && (vm.isTeamMember || vm.isTeamLead)" id="submit-exp-incomplete">Submit</button>

<!--If submitted by team member (Status: Under Review) -->
<!-- Show if team lead: -->
<button class="btn btn-danger navbar-btn" ng-click="vm.return()"
ng-show="vm.checkStatusPending() && (vm.isTeamLead || vm.isAdmin)">Return</button>
<!-- Show if team lead: -->
<button class="btn btn-success navbar-btn" ng-click="vm.publish()"
ng-show="(vm.checkStatusIncomplete() || vm.checkStatusPending() || vm.checkStatusReturned()) &&
(vm.isTeamLead || vm.isAdmin)">Publish</button>
ng-show="(vm.checkStatusPending() || vm.checkStatusReturned()) &&
(vm.isTeamLead || vm.isAdmin)">Publish</button><!-- vm.checkStatusIncomplete() || -->

<!-- If returned by team lead (Status: Returned) -->
<!-- Show if team member: -->
<button class="btn btn-success navbar-btn" ng-click="vm.submitTeamMember()"
ng-show="vm.checkStatusReturned() && vm.isTeamMember" id="submit-exp-returned">Submit</button>
ng-show="vm.checkStatusReturned() && (vm.isTeamMember || vm.isTeamLead)" id="submit-exp-returned">Submit</button>

<!-- If published by team lead (Status: Published) -->
<!-- Show if team lead: -->
Expand Down
Loading

0 comments on commit 0047c36

Please sign in to comment.