Skip to content

Commit

Permalink
#2 accept objects and arrary for criteria function and decision strat…
Browse files Browse the repository at this point in the history
…egy JSON files
  • Loading branch information
p-a-s-c-a-l committed Nov 7, 2018
1 parent 9ddeee9 commit 16b59b6
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,12 @@ angular.module(

onloadIccObjects = function (file) {
return function (e) {
console.log('load icc file: ' + file.name);

var fileObj;
try {
fileObj = JSON.parse(e.target.result);
loadIndicatorObjects(fileObj);

loadIndicatorObject(fileObj);
$scope.$apply();
} catch (err) {
console.log(err.toString());
Expand Down Expand Up @@ -310,7 +311,11 @@ angular.module(
var criteriaFunctionArray;
try {
criteriaFunctionArray = JSON.parse(e.target.result);
loadCriteriaFunctions(criteriaFunctionArray);
if (Object.prototype.toString.call(criteriaFunctionArray) !== '[object Array]') {
loadCriteriaFunctions([criteriaFunctionArray]);
} else {
loadCriteriaFunctions(criteriaFunctionArray);
}
$scope.loadedCfFile = theFile.name;
$scope.$apply();
} catch (err) {
Expand Down Expand Up @@ -345,7 +350,7 @@ angular.module(
if (criteriaFunctionContainer.name) {
$scope.loadedCfFile = criteriaFunctionContainer.name;
} else {
$scope.loadedCfFile = ' '
$scope.loadedCfFile = ' ';
}

for (j = 0; j < criteriaFunctionContainer.criteriaFunctions.length; j++) {
Expand Down Expand Up @@ -381,7 +386,7 @@ angular.module(

} else {
msg = 'criteria function object is not an array or empty';
console.log(msg + ': ' + criteriaFunctionArray.ToString());
console.log(msg + ': ' + criteriaFunctionArray.toString());
$scope.showCfFileLoadingError('msg');
}
};
Expand All @@ -391,6 +396,9 @@ angular.module(
var decisionStrategyArray;
try {
decisionStrategyArray = JSON.parse(e.target.result);
if (Object.prototype.toString.call(decisionStrategyArray) !== '[object Array]') {
decisionStrategyArray = [decisionStrategyArray];
}
loadDecisionStrategies(decisionStrategyArray);
$scope.loadedDsfFile = theFile.name;
$scope.$apply();
Expand Down Expand Up @@ -464,7 +472,7 @@ angular.module(
console.log(decisionStrategyArray.length + 'decision strategies loaded');
} else {
msg = 'decision strategy object is not an array or empty';
console.log(msg + ': ' + decisionStrategyArray.ToString());
console.log(msg + ': ' + decisionStrategyArray.toString());
$scope.showCfFileLoadingError('msg');
}
};
Expand Down

0 comments on commit 16b59b6

Please sign in to comment.