-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/R3-3-String-Properties' into develop
Conflicts: app/js/services/translatorToSPARQL.js
- Loading branch information
Showing
8 changed files
with
187 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
'use strict'; | ||
|
||
/** | ||
* PropertyInstanceCtrl | ||
* Controller for a single property. | ||
*/ | ||
|
||
angular.module('GSB.controllers.propertyType.string', ['GSB.config']) | ||
//Inject $scope, $http, $log and globalConfig (see @ js/config.js) into controller | ||
.controller('StringPropertyCtrl', ['$scope', '$http', '$log', 'globalConfig', function($scope, $http, $log, globalConfig) { | ||
|
||
$scope.allowedStringComparisons = [ | ||
{ | ||
label: "contains", | ||
f : 'regex(%after_arithmetic%, "%input%", "i")' | ||
}, | ||
{ | ||
label: "equals", | ||
f : '%after_arithmetic%^^xsd:string="%input%"^^xsd:string' | ||
}, | ||
{ | ||
label: "equals not", | ||
f : '%after_arithmetic%^^xsd:string!="%input%"^^xsd:string' | ||
}, | ||
{ | ||
label: "starts with", | ||
f : 'regex(%after_arithmetic%, "^%input%", "i")' | ||
}, | ||
{ | ||
label: "ends with", | ||
f : 'regex(%after_arithmetic%, "%input%$", "i")' | ||
}, | ||
{ | ||
label: "REGEX", | ||
f : 'regex(%after_arithmetic%, "%input%", "%flags%")' | ||
} | ||
]; | ||
|
||
$scope.allowedLanguages = globalConfig['allowedLanguages']; | ||
|
||
$scope.stringComparison = null; | ||
|
||
$scope.$watch('stringComparison',function (newValue){ | ||
renderComparison(newValue.f,$scope.comparisonInput,$scope.comparisonRegexFlags); | ||
}); | ||
|
||
$scope.comparisonInput = ""; | ||
|
||
$scope.$watch('comparisonInput',function (newValue){ | ||
renderComparison($scope.stringComparison.f,newValue,$scope.comparisonRegexFlags) | ||
}); | ||
|
||
$scope.comparisonRegexFlags = ""; | ||
|
||
$scope.$watch('comparisonRegexFlags',function (newValue){ | ||
renderComparison($scope.stringComparison.f,$scope.comparisonInput,newValue) | ||
}); | ||
|
||
function renderComparison(f,input,flags) | ||
{ | ||
if(input === null || input=== undefined || input === '' ||f === undefined || f === null){ | ||
$scope.compare = null | ||
renderLangCompare(); | ||
return; | ||
} | ||
$scope.compare = f.replace(/%input%/,input).replace(/%flags%/,flags); | ||
renderLangCompare(); | ||
} | ||
|
||
$scope.selectedLanguage = null; | ||
|
||
$scope.$watch('selectedLanguage',function (newValue){ | ||
renderLangCompare(); | ||
}); | ||
|
||
function renderLangCompare(){ | ||
if($scope.selectedLanguage === null || $scope.selectedLanguage === undefined ||$scope.selectedLanguage === ''){ | ||
$scope.propertyInst.compare = $scope.compare; | ||
} else if($scope.compare===null){ | ||
$scope.propertyInst.compare = 'langMatches(lang(%after_arithmetic%), "'+$scope.selectedLanguage+'")' | ||
} else { | ||
$scope.propertyInst.compare = 'langMatches(lang(%after_arithmetic%), "' + $scope.selectedLanguage + '") && ' + $scope.compare; | ||
} | ||
} | ||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Property directive | ||
* Creates the possibility to use a <property> element, | ||
* which will be replaced with the contents of template/property.html | ||
*/ | ||
|
||
angular.module('GSB.directives.propertyType.string', []) | ||
.directive('stringPropertyDir', function () { | ||
return { | ||
restrict: "A", | ||
replace: true, | ||
controller: 'StringPropertyCtrl', | ||
templateUrl: 'template/propertyType/string.html' | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div > | ||
<!-- if a property is selected, it will be linked with the subject --> | ||
<select ng-model="selectedLanguage" | ||
ng-options="x as x for x in allowedLanguages" | ||
title="Select"> | ||
<option value="">LANG</option> | ||
</select> | ||
<select ng-model="stringComparison" | ||
ng-options="x as x.label for x in allowedStringComparisons" | ||
title="Compare this string"> | ||
<option value="">exists</option> | ||
</select> | ||
<input ng-show="stringComparison" ng-model="comparisonInput"> | ||
<input ng-show="stringComparison && stringComparison.label === 'REGEX'" ng-model="comparisonRegexFlags"> | ||
</div> |