From 6540b2f3f0aa020633b90cd0688290fd0438c90c Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 23 Apr 2018 08:42:53 +0200 Subject: [PATCH 1/6] Fix the minDate and maxDate initialization in the datepicker option object --- src/directives/datepicker.js | 8 ++++---- src/directives/partials/datepicker.html | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/directives/datepicker.js b/src/directives/datepicker.js index 2770d185ec7..fe8a3bdaa3a 100644 --- a/src/directives/datepicker.js +++ b/src/directives/datepicker.js @@ -46,6 +46,8 @@ ngeo.DatePicker = function(ngeoDatePickerTemplateUrl, $timeout) { $['datepicker']['setDefaults']($['datepicker']['regional'][lang]); ctrl.sdateOptions = angular.extend({}, ctrl.sdateOptions, { + 'minDate': ctrl.initialMinDate, + 'maxDate': ctrl.initialMaxDate, 'onClose': function(selectedDate) { if (selectedDate) { $(element[0]).find('input[name="edate"]').datepicker('option', 'minDate', selectedDate); @@ -54,6 +56,8 @@ ngeo.DatePicker = function(ngeoDatePickerTemplateUrl, $timeout) { }); ctrl.edateOptions = angular.extend({}, ctrl.edateOptions, { + 'minDate': ctrl.initialMinDate, + 'maxDate': ctrl.initialMaxDate, 'onClose': function(selectedDate) { if (selectedDate) { $(element[0]).find('input[name="sdate"]').datepicker('option', 'maxDate', selectedDate); @@ -149,8 +153,6 @@ ngeo.DatePickerController = function($scope, $injector, ngeoTime, gettextCatalog * @export */ this.edateOptions = { - 'minDate': this.initialMinDate, - 'maxDate': this.initialMaxDate, 'changeMonth': true, 'changeYear': true }; @@ -161,8 +163,6 @@ ngeo.DatePickerController = function($scope, $injector, ngeoTime, gettextCatalog * @export */ this.sdateOptions = { - 'minDate': this.initialMinDate, - 'maxDate': this.initialMaxDate, 'changeMonth': true, 'changeYear': true }; diff --git a/src/directives/partials/datepicker.html b/src/directives/partials/datepicker.html index ed1ce86f26b..008a969ed6a 100644 --- a/src/directives/partials/datepicker.html +++ b/src/directives/partials/datepicker.html @@ -3,7 +3,7 @@
From: - Date: + Date:
Date: Mon, 23 Apr 2018 14:50:40 +0200 Subject: [PATCH 2/6] Fix rules operator translation --- src/directives/partials/rule.html | 4 ++-- src/directives/rule.js | 17 +++++++++++++++++ src/rule/rule.js | 8 ++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/directives/partials/rule.html b/src/directives/partials/rule.html index 6909c382c9a..7389d466d4d 100644 --- a/src/directives/partials/rule.html +++ b/src/directives/partials/rule.html @@ -244,7 +244,7 @@ {{ ruleCtrl.timeToDate(ruleCtrl.rule.upperBoundary) }}
- {{ ruleCtrl.rule.operator }} + {{ ruleCtrl.operatorsShortFormat[ruleCtrl.rule.operator] }} {{ ruleCtrl.timeToDate(ruleCtrl.rule.getExpression()) }}
@@ -291,7 +291,7 @@ {{ ruleCtrl.rule.upperBoundary }}
- {{ ruleCtrl.rule.operator }} + {{ ruleCtrl.operatorsShortFormat[ruleCtrl.rule.operator] }} {{ ruleCtrl.rule.getExpression() }}
diff --git a/src/directives/rule.js b/src/directives/rule.js index 81853248e2f..1a313882f7b 100644 --- a/src/directives/rule.js +++ b/src/directives/rule.js @@ -154,6 +154,23 @@ ngeo.RuleController = class { [tot.EQUALS]: gettextCatalog.getString('Is equal to') }; + /** + * @type {Object.} + * @export + */ + this.operatorsShortFormat = { + [ot.EQUAL_TO]: '=', + [ot.GREATER_THAN]: '>', + [ot.GREATER_THAN_OR_EQUAL_TO]: '>=', + [ot.LESSER_THAN]: '<', + [ot.LESSER_THAN_OR_EQUAL_TO]: '<=', + [ot.NOT_EQUAL_TO]: '!=', + [ot.LIKE]: '~', + [tot.BEGINS]: '>=', + [tot.ENDS]: '<=', + [tot.EQUALS]: '=' + }; + /** * Time property used when the rule is of type 'date|datetime' and uses * a range of date. diff --git a/src/rule/rule.js b/src/rule/rule.js index c1fc4bb35a6..8832c0440a1 100644 --- a/src/rule/rule.js +++ b/src/rule/rule.js @@ -362,8 +362,8 @@ ngeo.rule.Rule.SpatialOperatorType = { * @enum {string} */ ngeo.rule.Rule.TemporalOperatorType = { - BEGINS: '>=', - DURING: '..', - ENDS: '<=', - EQUALS: '=' + BEGINS: 'time_start', + DURING: 'time_during', + ENDS: 'time_end', + EQUALS: 'time_equal' }; From c0197dcb67295ef769e62c817464023f679af8d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Mon, 23 Apr 2018 13:27:54 +0200 Subject: [PATCH 3/6] Translate the disclaimer --- contribs/gmf/src/directives/disclaimer.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/contribs/gmf/src/directives/disclaimer.js b/contribs/gmf/src/directives/disclaimer.js index 06e02a007fd..feaf50edef8 100644 --- a/contribs/gmf/src/directives/disclaimer.js +++ b/contribs/gmf/src/directives/disclaimer.js @@ -78,6 +78,7 @@ gmf.module.component('gmfDisclaimer', gmf.disclaimerComponent); * @param {!angular.Scope} $scope Angular scope. * @param {!angular.$sce} $sce Angular sce service. * @param {!angular.$timeout} $timeout Angular timeout service. + * @param {!angularGettext.Catalog} gettextCatalog Gettext catalog. * @param {!ngeo.CreatePopup} ngeoCreatePopup Popup service. * @param {!ngeo.Disclaimer} ngeoDisclaimer Ngeo Disclaimer service. * @param {!ngeo.EventHelper} ngeoEventHelper Ngeo Event Helper. @@ -88,7 +89,7 @@ gmf.module.component('gmfDisclaimer', gmf.disclaimerComponent); * @ngname GmfDisclaimerController */ gmf.DisclaimerController = function($element, $scope, $sce, $timeout, - ngeoCreatePopup, ngeoDisclaimer, ngeoEventHelper, ngeoLayerHelper) { + gettextCatalog, ngeoCreatePopup, ngeoDisclaimer, ngeoEventHelper, ngeoLayerHelper) { /** * @type {?ol.Map} @@ -140,6 +141,12 @@ gmf.DisclaimerController = function($element, $scope, $sce, $timeout, */ this.timeout_ = $timeout; + /** + * @type {!angularGettext.Catalog} + * @private + */ + this.gettextCatalog_ = gettextCatalog; + /** * @type {!angular.JQLite} * @private @@ -299,6 +306,7 @@ gmf.DisclaimerController.prototype.$onDestroy = function() { * @private */ gmf.DisclaimerController.prototype.showDisclaimerMessage_ = function(msg) { + msg = this.gettextCatalog_.getString(msg); if (this.external) { if (this.msgs_.indexOf(msg) < 0) { this.msgs_.push(msg); @@ -321,6 +329,7 @@ gmf.DisclaimerController.prototype.showDisclaimerMessage_ = function(msg) { * @private */ gmf.DisclaimerController.prototype.closeDisclaimerMessage_ = function(msg) { + msg = this.gettextCatalog_.getString(msg); if (this.external) { this.visibility = false; this.msgs_.length = 0; From 381e959354a02f54cb8ae09e55933ddce88de73c Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 24 Apr 2018 08:30:55 +0200 Subject: [PATCH 4/6] Better 'no result' display in search --- contribs/gmf/less/search.less | 3 +++ contribs/gmf/src/directives/search.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/contribs/gmf/less/search.less b/contribs/gmf/less/search.less index b1d643a3681..9f2051e1ef9 100644 --- a/contribs/gmf/less/search.less +++ b/contribs/gmf/less/search.less @@ -108,6 +108,9 @@ gmf-search { } } } + .tt-menu.tt-open.gmf-search-no-results { + display: block !important; + } } // Overrides for small browser widths only diff --git a/contribs/gmf/src/directives/search.js b/contribs/gmf/src/directives/search.js index e09807a1c02..f76ac79503b 100644 --- a/contribs/gmf/src/directives/search.js +++ b/contribs/gmf/src/directives/search.js @@ -970,8 +970,9 @@ gmf.SearchController.datasetsempty_ = function(event, query, empty) { } if (empty) { message.show(); - menu.show(); + menu.addClass('gmf-search-no-results'); } else { + menu.removeClass('gmf-search-no-results'); message.hide(); } From a3b3d8aec76e58ded067f1da97156aff3490d418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 24 Apr 2018 13:59:11 +0200 Subject: [PATCH 5/6] Add missing double support --- src/ol-ext/format/xsdattribute.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol-ext/format/xsdattribute.js b/src/ol-ext/format/xsdattribute.js index a962eae2811..d913d20a422 100644 --- a/src/ol-ext/format/xsdattribute.js +++ b/src/ol-ext/format/xsdattribute.js @@ -170,7 +170,7 @@ ngeo.format.XSDAttribute.prototype.setAttributeByXsdType_ = function( attribute.type = ngeo.AttributeType.DATETIME; } else if (type === 'xsd:time') { attribute.type = ngeo.AttributeType.TIME; - } else if (type === 'xsd:decimal') { + } else if (type === 'xsd:decimal' || type === 'xsd:double') { attribute.type = ngeo.AttributeType.NUMBER; attribute.numType = ngeo.NumberType.FLOAT; } else if (type === 'xsd:integer') { From aa8d2b70400b259f9b1b3a1ed13bf6aa3717d144 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 24 Apr 2018 13:12:26 +0200 Subject: [PATCH 6/6] Use jQuery to synchronize rotation inputs --- .../gmf/src/directives/partials/print.html | 12 ++--- contribs/gmf/src/directives/print.js | 54 ++++++++++--------- .../controllers/gmfprintcontroller.spec.js | 11 ++-- 3 files changed, 43 insertions(+), 34 deletions(-) diff --git a/contribs/gmf/src/directives/partials/print.html b/contribs/gmf/src/directives/partials/print.html index fddaadbc94a..b3dccf13016 100644 --- a/contribs/gmf/src/directives/partials/print.html +++ b/contribs/gmf/src/directives/partials/print.html @@ -156,10 +156,9 @@
+ min="-180" + max="180" + value="0">
diff --git a/contribs/gmf/src/directives/print.js b/contribs/gmf/src/directives/print.js index 211e952de47..11d8e4d3d69 100644 --- a/contribs/gmf/src/directives/print.js +++ b/contribs/gmf/src/directives/print.js @@ -149,6 +149,7 @@ gmf.module.directive('gmfPrint', gmf.printDirective); /** + * @param {angular.JQLite} $element Element. * @param {angular.Scope} $rootScope Angular root scope. * @param {angular.Scope} $scope Angular scope. * @param {angular.$timeout} $timeout Angular timeout service. @@ -172,7 +173,7 @@ gmf.module.directive('gmfPrint', gmf.printDirective); * @ngdoc controller * @ngname GmfPrintController */ -gmf.PrintController = function($rootScope, $scope, $timeout, $q, $injector, +gmf.PrintController = function($element, $rootScope, $scope, $timeout, $q, $injector, gettextCatalog, ngeoLayerHelper, ngeoFeatureOverlayMgr, ngeoPrintUtils, ngeoCreatePrint, gmfPrintUrl, gmfAuthentication, ngeoQueryResult, $filter, gmfPrintState, gmfThemes) { @@ -376,6 +377,19 @@ gmf.PrintController = function($rootScope, $scope, $timeout, $q, $injector, */ this.scaleManuallySelected_ = false; + /** + * @type {angular.JQLite} + * @export + */ + this.rotationInput_ = $element.find('.gmf-print-rotation-input'); + + this.rotationInput_.on('input', (event) => { + const rotation = $(event.target).val(); + if (rotation !== '') { + this.setRotation(/** @type {number} */ (rotation)); + } + }); + /** * @return {ol.Size} Size in dots of the map to print. */ @@ -493,7 +507,7 @@ gmf.PrintController.prototype.togglePrintPanel_ = function(active) { ol.Observable.unByKey(this.postComposeListenerKey_); ol.Observable.unByKey(this.pointerDragListenerKey_); ol.Observable.unByKey(this.mapViewResolutionChangeKey_); - this.getSetRotation(0); + this.setRotation(0); this.map.render(); // Redraw (remove) post compose mask; } }; @@ -661,32 +675,22 @@ gmf.PrintController.prototype.isAttributeInCurrentLayout_ = function(name) { /** - * Getter setter to update or get the current rotation value. Param and result - * are in degree. Updating the rotation will redraw the mask or rorate the - * map (depending on the configuration); - * @param {number=} opt_rotation The optional new rotation value. - * @return {number} The new value of rotation; - * @export + * Set the current rotation value. + * Updating the rotation will redraw the mask or rotate the map (depending on the configuration). + * @param {number} rotation The optional new rotation value in degrees. */ -gmf.PrintController.prototype.getSetRotation = function(opt_rotation) { - if (opt_rotation !== undefined) { - let rotation = parseInt(opt_rotation, 10); - if (rotation > 180) { - rotation = -180; - } else if (rotation < -180) { - rotation = 180; - } - this.rotation = rotation; +gmf.PrintController.prototype.setRotation = function(rotation) { + this.rotation = ol.math.clamp(rotation, -180, 180); - // Render the map to update the postcompose mask or rotate the map. - if (this.rotateMask_) { - this.map.render(); - } else { - this.map.getView().setRotation(ol.math.toRadians(this.rotation)); - } + // sync all the inputs + this.rotationInput_.val(this.rotation.toString()); + // Render the map to update the postcompose mask or rotate the map. + if (this.rotateMask_) { + this.map.render(); + } else { + this.map.getView().setRotation(ol.math.toRadians(this.rotation)); } - return this.rotation; }; @@ -722,7 +726,7 @@ gmf.PrintController.prototype.onPointerDrag_ = function(e) { const increment = Math.round(ol.math.toDegrees(angle) * boost); // Set rotation then update the view. - this.getSetRotation(this.rotation + increment); + this.setRotation(this.rotation + increment); this.$scope_.$digest(); } // Prepare the removal of this session of drags events diff --git a/contribs/gmf/test/spec/controllers/gmfprintcontroller.spec.js b/contribs/gmf/test/spec/controllers/gmfprintcontroller.spec.js index 0ff42d49da2..0ac2546b1e0 100644 --- a/contribs/gmf/test/spec/controllers/gmfprintcontroller.spec.js +++ b/contribs/gmf/test/spec/controllers/gmfprintcontroller.spec.js @@ -11,8 +11,10 @@ describe('GmfPrintController', () => { $controller = _$controller_; $rootScope = _$rootScope_; $scope = $rootScope.$new(); + const $element = angular.element('
'); gmfPrintCtrl = $controller('GmfPrintController', { + $element, $scope, gmfPrintUrl: '' } @@ -27,11 +29,14 @@ describe('GmfPrintController', () => { gmfPrintCtrl.parseCapabilities_({data: printCapabilities}); })); - it('Get Set rotation', () => { + it('Set rotation', () => { expect(gmfPrintCtrl.rotation).toBe(0); - gmfPrintCtrl.getSetRotation(25); - expect(gmfPrintCtrl.rotation).toBe(gmfPrintCtrl.getSetRotation()); + gmfPrintCtrl.setRotation(25); expect(gmfPrintCtrl.rotation).toBe(25); + gmfPrintCtrl.setRotation(190); + expect(gmfPrintCtrl.rotation).toBe(180); + gmfPrintCtrl.setRotation(-1000); + expect(gmfPrintCtrl.rotation).toBe(-180); }); it('Set layout and test depending layout informations changes', () => {