Skip to content

Commit

Permalink
fix keyword coords management & improve template
Browse files Browse the repository at this point in the history
  • Loading branch information
jahow authored and fgravin committed Sep 20, 2017
1 parent 43c52c8 commit bbb7449
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
24 changes: 17 additions & 7 deletions web-ui/src/main/resources/catalog/js/admin/ThesaurusController.js
Expand Up @@ -418,6 +418,15 @@
$scope.editKeyword = function(k) {
$scope.keywordSelected = angular.copy(k);
$scope.keywordSelected.oldId = $scope.keywordSelected.uri;

// create geo object (if not already there)
$scope.keywordSelected.geo = $scope.keywordSelected.geo || {
east: k.coordEast,
north: k.coordNorth,
south: k.coordSouth,
west: k.coordWest
};

creatingKeyword = false;
$('#keywordModal').modal();
searchRelation($scope.keywordSelected);
Expand All @@ -442,10 +451,10 @@
};
if ($scope.isPlaceType()) {
$scope.keywordSelected.geo = {
west: '',
south: '',
east: '',
north: ''
west: '0',
south: '0',
east: '0',
north: '0'
};
}
$('#keywordModal').modal();
Expand All @@ -454,7 +463,7 @@
/**
* Build keyword POST body message
*/
buildKeyword = function(keywordObject) {
buildKeywordXML = function(keywordObject) {
var geoxml = $scope.isPlaceType() ?
'<west>' + keywordObject.geo.west + '</west>' +
'<south>' + keywordObject.geo.south + '</south>' +
Expand Down Expand Up @@ -488,6 +497,7 @@
(keywordObject.oldId || keywordObject.uri) + '</oldid>' +
localizedValues +
localizedDefinitions +
geoxml +
'</request>';

return xml;
Expand All @@ -499,7 +509,7 @@
$scope.createKeyword = function() {
$http.post(
'thesaurus.keyword.add?_content_type=json',
buildKeyword($scope.keywordSelected),
buildKeywordXML($scope.keywordSelected),
{ headers: {'Content-type': 'application/xml'} }
)
.success(function(data) {
Expand Down Expand Up @@ -533,7 +543,7 @@
*/
$scope.updateKeyword = function() {
$http.post('thesaurus.keyword.update',
buildKeyword($scope.keywordSelected),
buildKeywordXML($scope.keywordSelected),
{ headers: {'Content-type': 'application/xml'} }
)
.success(function(data) {
Expand Down
Expand Up @@ -450,14 +450,14 @@ <h4 class="modal-title" translate ng-show="isNewKeyword()">

<!-- Only displayed for thesaurus of type place -->
<fieldset data-ng-show="isPlaceType()">
<legend data-translate="">keywordCoordinates</legend>

<legend translate>keywordCoordinates</legend>
<div data-ng-repeat="(key, value) in keywordSelected.geo track by $index">
<label class="control-label" data-translate="">{{key | translate}}</label>
<!-- TODO: use type="number" min="-180" max="180" but there is
some issue in Angular - maybe https://github.com/angular/angular.js/issues/2144-->
<input name="{{key}}" class="form-control" type="text"
data-ng-disabled="isExternal()" data-ng-model="keywordSelected.geo[key]"/>
<div class="input-group">
<span class="input-group-addon width-33 text-right" translate>{{key}}</span>
<input name="{{key}}" class="form-control" type="text"
data-ng-disabled="isExternal()" data-ng-model="keywordSelected.geo[key]"/>
</div>
<br>
</div>
</fieldset>

Expand Down

0 comments on commit bbb7449

Please sign in to comment.