Skip to content

Commit

Permalink
Merge pull request #820 from IntegratedBreedingPlatform/IBP-3094-IBP-…
Browse files Browse the repository at this point in the history
…3095-AddEnvironmentAndIterateDesign

IBP-3094 IBP-3095 Add Environment and Iterate Design
  • Loading branch information
darla-leafnode authored Nov 13, 2019
2 parents fff939c + 91972e5 commit f80766c
Show file tree
Hide file tree
Showing 23 changed files with 403 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@

public class ExpDesignParameterUi implements Serializable, TabInfoBean {

/**
*
*/
private static final long serialVersionUID = -3081300491744812262L;
private Integer noOfEnvironments;
private Integer noOfEnvironmentsToAdd;
private List<Integer> trialInstancesForDesignGeneration;
private Integer designType;
private Integer replicationsCount;
private Boolean useLatenized;
Expand Down Expand Up @@ -42,12 +38,8 @@ public class ExpDesignParameterUi implements Serializable, TabInfoBean {
*/
private Integer replicationsArrangement;

public Integer getNoOfEnvironments() {
return this.noOfEnvironments;
}

public void setNoOfEnvironments(final Integer noOfEnvironments) {
this.noOfEnvironments = noOfEnvironments;
public List<Integer> getTrialInstancesForDesignGeneration() {
return this.trialInstancesForDesignGeneration;
}

public Integer getDesignType() {
Expand Down Expand Up @@ -162,14 +154,6 @@ public void setReplicationsArrangement(final Integer replicationsArrangement) {
this.replicationsArrangement = replicationsArrangement;
}

public Integer getNoOfEnvironmentsToAdd() {
return this.noOfEnvironmentsToAdd;
}

public void setNoOfEnvironmentsToAdd(final Integer noOfEnvironmentsToAdd) {
this.noOfEnvironmentsToAdd = noOfEnvironmentsToAdd;
}

public boolean isHasMeasurementData() {
return this.hasMeasurementData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ <h1 class="page-header col-xs-12 edit-trial-page-identifier">
<script type="text/javascript" th:src="@{/static/js/trialmanager/trialSettings.js}"></script>
<script type="text/javascript" th:src="@{/static/js/trialmanager/germplasm.js}"></script>
<script type="text/javascript" th:src="@{/static/js/trialmanager/treatment.js}"></script>
<script type="text/javascript" th:src="@{/static/js/trialmanager/environmentService.js}"></script>
<script type="text/javascript" th:src="@{/static/js/trialmanager/studyInstanceService.js}"></script>
<script type="text/javascript" th:src="@{/static/js/trialmanager/environments.js}"></script>
<script type="text/javascript" th:src="@{/static/js/trialmanager/experimentalDesign.js}"></script>
<script type="text/javascript" th:src="@{/static/js/trialmanager/subobservations/subObservationTab.js}"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,21 @@

<div class="form-horizontal">
<div class="form-group form-group-sm">
<label class="control-label label-bold add_top_padding col-xs-8" style="text-align: left" th:text="#{study.managesettings.environment.specify.level.no}">Specify the number of environments for this study:</label>
<label class="control-label label-bold add_top_padding col-xs-7" style="text-align: left" th:text="#{study.managesettings.environment.specify.level.no}">Specify the number of environments for this study:</label>
<div class="col-xs-4">
<div class="input-group">
<input maxlength="3" valid-number="" class="form-control input-sm" ng-model="temp.noOfEnvironments" ng-disabled="shouldDisableEnvironmentCountUpdate()"/>

<input maxlength="3" valid-number="" class="form-control input-sm" ng-model="temp.noOfEnvironments" ng-disabled="isDesignAlreadyGenerated()"/>
<span class="input-group-btn">
<input ng-click="updateEnvironmentCount()" ng-hide="shouldDisableEnvironmentCountUpdate()" class="btn btn-info btn-sm" style="padding: 6px 10px 5px; font-size: 11px;" type="button" value="Ok"/>
<input ng-click="updateEnvironmentCount()" ng-hide="isDesignAlreadyGenerated()" class="btn btn-info btn-sm"
style="padding: 6px 10px 5px; font-size: 11px;" type="button" value="Ok"/>
</span>

</div><!-- /input-group -->
</div>
<div class="col-xs-offset-0">
<div class="input-group">
<span ng-show="isDesignAlreadyGenerated()" class="glyphicon glyphicon-plus-sign fbk-add-sign" ng-click="(isDisableAddEnvironment) || addEnvironment()"></span>
</div>
</div>
</div>

</div>
Expand Down Expand Up @@ -72,7 +76,7 @@
<tbody>
<tr ng-repeat="environment in data.environments track by $index" ng-class="{even : $even, odd : $odd}">
<td class="fbk-delete-link fbk-table-delete-link">
<span ng-click="deleteEnvironment($index)" ng-show="data.noOfEnvironments > 1 &amp;&amp; !shouldDisableEnvironmentCountUpdate()"
<span ng-click="deleteEnvironment($index)" ng-show="data.noOfEnvironments > 1 &amp;&amp; !isDesignAlreadyGenerated()"
class="glyphicon glyphicon-minus-sign fbk-delete-sign" ng-model-options="{ debounce: 500 }">&nbsp;</span>
</td>
<td>{{environment.managementDetailValues[TRIAL_INSTANCE_NO_INDEX]}}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
</div>
<div ng-show="toggleDesignView()">
<div class="col-md-8">
<div class="add-bottom-padding"
ng-show="data.noOfEnvironments &gt;= 0">
<div class="add-bottom-padding">
<div ng-hide="currentDesignType.templateName =='Default Design'">
<b th:text="#{review.study.design.source}"></b>
<span>{{currentDesignType.templateName}}</span>
Expand All @@ -54,8 +53,7 @@
ng-click="deleteDesign()"/>
</a>
</span>
<div class="add-bottom-padding"
ng-show="data.noOfEnvironments &gt;= 0">
<div class="add-bottom-padding">
<b th:text="#{review.study.design.type}"></b>
<span ng-hide="currentDesignType.templateName =='Default Design'">{{currentDesignType.name}}</span>
<span ng-show="currentDesignType.templateName =='Default Design'">Default Design</span>
Expand All @@ -68,7 +66,7 @@
<section-container heading="SPECIFY PLOT NUMBERING" ng-hide="isImportedDesign()" ng-disabled="toggleDesignView()">
<div name="content">
<label class="control-label control-label-bold" id="startingPlotNumber" th:text="#{germplasm.list.specify.starting.plot.number}">Specify Starting Plot Number</label>
<input class="inputForNumberingAndChecks" id="txtStartingPlotNo" style="width:70px;" onchange="validateAndSetPlotNo()" ng-model="data.startingPlotNo" ng-disabled="measurementDetails.hasMeasurement"/>
<input class="inputForNumberingAndChecks" id="txtStartingPlotNo" style="width:70px;" ng-model="data.startingPlotNo" ng-disabled="measurementDetails.hasMeasurement"/>
</div>
</section-container>
</div>
Expand All @@ -85,29 +83,3 @@
</div>

</form>

<script type="text/javascript" th:inline="javascript">
var plotNoShouldBeInRange = /*[[#{plot.number.should.be.in.range}]]*/ '';

function validateAndSetPlotNo() {
var customMessage = '';
var plotNo = $.trim($("#txtStartingPlotNo").val());
if (!validatePlotNo(plotNo)) {
customMessage = plotNoShouldBeInRange;
}

if (customMessage !== '') {
showInvalidInputMessage(customMessage);
} else {
showAlertMessage('', 'These changes have not yet been applied to the Observations table. ' +
'To update the Observations table, please save the Study', 10000);
}

}

function validatePlotNo(inputNo) {
var validNo = '^(?=.*[1-9].*)[0-9]{1,8}$';
return !!inputNo.match(validNo);

}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
</div>
<div class="add_top_padding add-bottom-padding">
<!-- TODO Localise Label -->
<input type="submit" class="btn btn-info" value="Generate Design"
ng-disabled="disableGenerateDesign()"/>
<input type="submit" class="btn btn-info" value="Generate Design" onclick="this.blur();"/>
</div>
<div class="add_top_padding add-bottom-padding">
<input type="button" class="btn btn-info" value="Delete Design" ng-disabled="isDeleteDesignDisable()"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<table datatable="ng" dt-options="dtOptions" class="table table-curved table-condensed" width="100%">
<thead>
<tr>
<th><input type="checkbox" ng-model="ctrl.isSelectAll" ng-click="toggleSelect(ctrl.isSelectAll)"></th>
<th>TRIAL_INSTANCE</th>
<th>LOCATION_NAME</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="instance in instances | filter: { canBeDeleted: true }">
<td><input type="checkbox" ng-click="select(instance[instanceNumber])" ng-model="selectedInstances[instance[instanceNumber]]"/></td>
<td>{{::instance.instanceNumber}}</td>
<td>{{::instance.locationName}} - ({{::instance.locationAbbreviation}})</td>
</tr>
</tbody>
</table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<div class="modal-body">
<div class="row form-group">
<div class="col-xs-11 col-md-11">
<label class="modal-title fbk-modal-title" id="heading-modal">Generate Design</label>
</div>
<div class="col-xs-1 col-md-1">
<button ng-click="cancel()" type="button" class="close pull-right glyphicon glyphicon-remove"></button>
</div>
</div>
<div class="separator"></div>
<br/>
<div class="row form-group">
<div class="col-xs-12 col-md-12">
<label class=""><em> <span class="required">*</span> indicates a mandatory field</em></label>
</div>
</div>

<div class="row form-group">
<div class="col-xs-12 col-md-12">&nbsp;</div>
<div class="col-xs-12 col-md-12">
<label class="control-label h4 label-bold">STUDY ENVIRONMENT</label>
</div>
<div class="col-xs-12 col-md-12">&nbsp;</div>
<div class="col-xs-12 col-md-12">
<label class="control-label label-bold">Choose the study environment you would like to generate the design: <span class="required">*</span></label>
</div>
<div class="col-xs-12 col-md-12">&nbsp;</div>
<div class="col-xs-12 col-md-12">
<generate-design-instances-table instances="instances" selected-instances="selectedInstances" has-experimental-design="hasExperimentalDesign"
can-be-deleted="canBeDeleted" instance-number="instanceNumber"
is-empty-selection="isEmptySelection" ></generate-design-instances-table>
</div>

</div>
</div>
<div class="modal-footer">
<button class="btn btn-default" ng-click="cancel()">Cancel</button>
<button class="btn btn-primary" ng-disabled="isEmptySelection" ng-click="validateSelectedEnvironments()">Generate</button>
</div>
6 changes: 6 additions & 0 deletions src/main/webapp/WEB-INF/static/css/fieldbook.css
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ table.dataTable thead .sorting_desc {
width: 25px;
}

.fbk-add-sign {
cursor: pointer;
color: green;
font-size: 25px;
}

.fbk-table-delete-link {
width: 25px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Measurement Controller', function () {
studyContext: studyContext,
datasetService: datasetServiceMock,
TrialManagerDataService: trialManagerServiceMock,
environmentService: {},
studyInstanceService: {},
LOCATION_ID: 1
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Location', function () {
studyContext: studyContext,
derivedVariableService: derivedVariableService,
TrialManagerDataService: trialDataManagerService,
environmentService: {},
studyInstanceService: {},
LOCATION_ID: 1
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ describe('SubObservationSetCtrl', function () {
dTColumnBuilderMock = {},
$httpMock = {},
$compileMock = {},
environmentServiceMock = {},
studyInstanceServiceMock = {},
datasetServiceMock = jasmine.createSpyObj('datasetService', [
'getDataset',
'getColumns',
Expand Down Expand Up @@ -922,7 +922,7 @@ describe('SubObservationSetCtrl', function () {
dTColumnBuilder: dTColumnBuilderMock,
$http: $httpMock,
$compile: $compileMock,
environmentService: environmentServiceMock,
studyInstanceService: studyInstanceServiceMock,
datasetService: datasetServiceMock,
$timeout: $timeout,
$uibModal: $uibModal
Expand Down
61 changes: 60 additions & 1 deletion src/main/webapp/WEB-INF/static/js/angular/fieldbook-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,66 @@
},
controllerAs: 'ctrl'
};
}]).factory('formUtilities', function() {
}]).directive('generateDesignInstancesTable', ['DTOptionsBuilder', 'DTColumnBuilder', function (DTOptionsBuilder, DTColumnBuilder) {

return {
restrict: 'E',
require: '?ngModel',
scope: {
instances: '=',
selectedInstances: '=',
isEmptySelection: '=',
canBeDeleted: '@',
hasExperimentalDesign: '@',
instanceNumber: '@',
},
templateUrl: '/Fieldbook/static/angular-templates/generateDesign/generateDesignInstancesTable.html',
controller: function ($scope) {

var ctrl = this;
ctrl.isSelectAll = true;
$scope.dtOptions = DTOptionsBuilder.newOptions().withDOM('<\'row\'<\'col-sm-6\'l><\'col-sm-6\'f>>' +
'<\'row\'<\'col-sm-12\'tr>>' +
'<\'row\'<\'col-sm-5\'i><\'col-sm-7\'>>' +
'<\'row\'<\'col-sm-12\'p>>');

$scope.$watch('instances', function (newValue, oldValue, scope) {
if (newValue.length !== 0) {
$.each($scope.instances, function (key, value) {
$scope.selectedInstances[value[$scope.instanceNumber]] = !value[$scope.hasExperimentalDesign];
});
$scope.selectionChanged();
}
});

$scope.toggleSelect = function (checked) {
$.each($scope.instances, function (key, value) {
$scope.selectedInstances[value[$scope.instanceNumber]] = checked;
});
$scope.selectionChanged();
};

$scope.select = function (itemId) {
if (!$scope.selectedInstances[itemId]) {
ctrl.isSelectAll = false;
}
$scope.selectionChanged();
};

$scope.selectionChanged = function() {
// Returns true if all instances are not selected
$scope.isEmptySelection = Object.values($scope.selectedInstances).every(function (value) {
return value === false;
});
ctrl.isSelectAll = Object.values($scope.selectedInstances).every(function (value) {
return value === true;
});
};

},
controllerAs: 'ctrl'
};
}]).factory('formUtilities', function() {

var formUtilities = {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
'use strict';

var manageTrialApp = angular.module('manageTrialApp');
manageTrialApp.controller('SubObservationUnitDatasetBuildCtrl', ['$scope', 'environmentService', '$http', 'formUtilities',
manageTrialApp.controller('SubObservationUnitDatasetBuildCtrl', ['$scope', 'studyInstanceService', '$http', 'formUtilities',
'MAXIMUM_NUMBER_OF_SUB_OBSERVATION_SETS', 'MAXIMUM_NUMBER_FOR_EACH_PARENT_UNIT', 'variableService', 'studyContext',
'DATASET_TYPES', 'datasetService', '$timeout', function ($scope, environmentService, $http, formUtilities, MAXIMUM_NUMBER_OF_SUB_OBSERVATION_SETS,
'DATASET_TYPES', 'datasetService', '$timeout', function ($scope, studyInstanceService, $http, formUtilities, MAXIMUM_NUMBER_OF_SUB_OBSERVATION_SETS,
MAXIMUM_NUMBER_FOR_EACH_PARENT_UNIT, variableService, studyContext, DATASET_TYPES, datasetService, $timeout) {

$scope.instances = [];
Expand Down Expand Up @@ -84,8 +84,8 @@
$scope.numberOfSubObservationUnits = '';
$scope.selectedVariable = undefined;

environmentService.getEnvironments().then(function (environmentDetails) {
$scope.instances = environmentDetails;
datasetService.getDatasetInstances(studyContext.measurementDatasetId).then(function (datasetInstances) {
$scope.instances = datasetInstances;

variableService.getVariablesByFilter({
methodIds: 4040,
Expand Down
Loading

0 comments on commit f80766c

Please sign in to comment.