Skip to content

Commit

Permalink
Merge pull request #150 from FabiApfelkern/dataset_manager
Browse files Browse the repository at this point in the history
Bug Fix: Crash with multiple Dimensions
  • Loading branch information
fabiankirstein committed Aug 21, 2015
2 parents 8d9c0f5 + a8fe5bb commit 20c69ae
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 28 deletions.
39 changes: 33 additions & 6 deletions app/modules/datasets/controllers/datasetControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,23 +233,27 @@ angular.module('pcApp.datasets.controllers.dataset', [
} else {
$scope.individualSelection = [];
}

if(creationService.data.extraMetadata) {
$scope.extraMetadata = [];
angular.forEach(creationService.data.extraMetadata, function (em) {

$scope.extraMetadata.push({
classInput: em.classOutput,
classInput: angular.copy(em.classOutput),
classOutput: [],
indInput: em.indOutput,
indOutput: []
indInput: angular.copy(em.indOutput),
indOutput: [],
sub: true,
class_id: em.classOutput[0]
});
})
} else {
$scope.extraMetadata = [{
classInput: [],
classOutput: [],
indInput: [],
indOutput: []
indOutput: [],
sub: false,
class_id: null
}];
}
creationService.data.classSelection = [];
Expand All @@ -270,10 +274,33 @@ angular.module('pcApp.datasets.controllers.dataset', [
classInput: [],
classOutput: [],
indInput: [],
indOutput: []
indOutput: [],
sub: false,
class_id: null
});
};

$scope.removeExtraMetadata = function (em) {
$scope.extraMetadata = _.without($scope.extraMetadata, em)


};

$scope.$watch('extraMetadata', function (newValue) {

angular.forEach($scope.extraMetadata, function (em) {
if(em.classOutput[0]) {
em.sub = true;
em.class_id = em.classOutput[0];
} else {
em.sub = false;
em.indOutput = [];
}

});

}, true);

$scope.clearAll = function () {
$scope.individualSelection = [];
};
Expand Down
33 changes: 16 additions & 17 deletions app/modules/datasets/partials/step2.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,23 @@ <h5>Dimension Type:</h5>
</div>

<div class="well">
<h4>Further Dimension Restrictions</h4>

<div class="dataset-filters-bottom">
<div class="dataset-filter clearfix" ng-repeat="em in extraMetadata">
<h5>Dimension {{$index+1}} </h5>
<div class="reference-selection" resource="Class" selection-mode="single" output="em.classOutput" input="em.classInput"></div>
<div ng-if="em.classOutput"
class="reference-selection"
resource="Individual"
selection-mode="single"
output="em.indOutput"
input="em.indInput"
parameters="{ class: em.classOutput[0] }">

<h4>Further Dimension Restrictions</h4><a class="btn btn-add btn-validate" ng-click="addExtraMetadata()">Add a Dimension</a>
<div class="dataset-filters-bottom">
<div class="dataset-filter clearfix" ng-repeat="em in extraMetadata">
<h5>Dimension {{$index+1}} </h5>
<div class="reference-selection" resource="Class" selection-mode="single" output="em.classOutput" input="em.classInput"></div>
<div ng-show="em.sub"
class="reference-selection"
resource="Individual"
selection-mode="single"
output="em.indOutput"
input="em.indInput"
parameters="{ class: em.class_id }">
</div>
<a class="btn btn-clear" ng-click="removeExtraMetadata(em)">Remove</a>
</div>
<a ng-if="em.indOutput" class="btn btn-add btn-validate" ng-click="addExtraMetadata()">Add a Dimension</a>

</div>
</div>
</div>

</div>
</dataset-create-wrapper>
10 changes: 5 additions & 5 deletions app/modules/references/directives/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ angular.module('pcApp.references.directives.forms', [
link: function ($scope, $element, $attrs) {
var params = {};
if($scope.parameters != undefined) {
params = $scope.parameters;

$scope.$watch('parameters', function (newValue) {
params = $scope.parameters;
$scope.$watch('parameters', function (newValue) {;
params = newValue;
getData();
});
Expand Down Expand Up @@ -205,21 +205,20 @@ angular.module('pcApp.references.directives.forms', [

getData();
$scope.outputData = {};

if($attrs.selectionMode != 'undefined' && $attrs.selectionMode == 'single') {
$scope.selectionMode = 'single';
} else {
$scope.selectionMode = 'multiple';
}

$scope.$watch('outputData', function (newValue, oldValue) {
$scope.$watchCollection('outputData', function (newValue, oldValue) {
$scope.output = [];
angular.forEach(newValue, function (value) {
$scope.output.push(value.id);
})
});

$scope.$watch('input', function (newValue) {
$scope.$watchCollection('input', function (newValue) {
angular.forEach($scope.selection, function (s) {
if(_.contains(newValue, s.id)){
s.ticked = true;
Expand All @@ -228,6 +227,7 @@ angular.module('pcApp.references.directives.forms', [
}
})
});

},
template: '<div class="dataset-select" ' +
'isteven-multi-select ' +
Expand Down

0 comments on commit 20c69ae

Please sign in to comment.