diff --git a/src/module_vmap/module/javascript/app/vmap/tools/insert.js b/src/module_vmap/module/javascript/app/vmap/tools/insert.js index b4b7e11aabe4ec7145ccb781d40db4ae9276cd5f..fc10d75e41bbb2cd629965bc201ed54d8a8eddc8 100644 --- a/src/module_vmap/module/javascript/app/vmap/tools/insert.js +++ b/src/module_vmap/module/javascript/app/vmap/tools/insert.js @@ -298,11 +298,22 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController = function ($scope, // Supprime la feature lors de la sélection sur l'interaction this.delete_ this.delete_.on('select', function () { + + // Supprime la partie selectionnée var aSelectedFeatures = this.delete_.getFeatures().getArray(); for (var i = 0; i < aSelectedFeatures.length; i++) { this.oOverlayLayer_.getSource().removeFeature(aSelectedFeatures[i]); } this.delete_.getFeatures().clear(); + + // Arrête la suppression si il ne reste plus de parties + if (goog.isDefAndNotNull(this.oOverlayLayer_.getSource().getFeatures().length)) { + if (this.oOverlayLayer_.getSource().getFeatures().length === 0) { + oVmap.getMap().removeActionsOnMap(); + oVmap.getMap().getMapTooltip().hide(); + } + } + }, this); /** @@ -389,6 +400,7 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController = function ($scope, this_.updateInsertForm(null, function(){ this_.selectCurrentBoForSnapping(); this_.loadAvoidSuperpositionBos(); + this_.autoSelectDrawPart(); }); }); @@ -456,7 +468,6 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.selectCurr this.checkEditionScale(); }; - /** * Load this.aAvoidSuperpositionsBOs * @@ -550,6 +561,59 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.checkEditi } }; +/** + * Commence automatiquement le dessin si le type de feature est connu + */ +nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.autoSelectDrawPart = function () { + oVmap.log('nsVmap.nsToolsManager.Insert.inserttoolController.autoSelectDrawPart'); + + // Supprime les interractions + oVmap.getMap().removeActionsOnMap(); + + // Cache la tooltip + oVmap.getMap().getMapTooltip().hide(); + + // Supprime le snapping + this.oSnapOverlayLayer_.getSource().clear(); + oVmap.getMap().getOLMap().removeInteraction(this.snap_); + + // Lance automatiquement la saisie + if (this['addPartGeomType'] !== '') { + this['startInsertion']('insert' + this['addPartGeomType'], this['currentAction'] === 'basicTools-insert-insert' + this['addPartGeomType']) + } +} + +/** + * Affiche automatiquement le formulaire après un dessin si besoin + */ +nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.autoShowForm = function () { + oVmap.log('nsVmap.nsToolsManager.Insert.inserttoolController.autoShowForm'); + + // Type de geom en base + var sGeomType = this.$scope_['oInsertObject']['sGeomType']; + + // Si il ne s'agit pas d'une géométrie multiple + if (goog.isDefAndNotNull(sGeomType)) { + if (sGeomType.substr(0, 5) !== 'MULTI' && sGeomType !== 'GEOMETRYCOLLECTION') { + + // Affiche le formulaire + this.displayEditFrom(); + } + } +} + +/** + * Affiche / cache le selecteur de type de géométrie + * @export + */ +nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.showDrawTypeSelectDropdown = function () { + oVmap.log('nsVmap.nsToolsManager.Insert.inserttoolController.showDrawTypeSelectDropdown'); + + setTimeout(function () { + $('#vmap-insert-select-type-dropdown').dropdown('toggle'); + }); +} + // Opérations sur les couches @@ -600,6 +664,17 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.displayEdi var $scope = this.$scope_; + // Supprime les interractions + oVmap.getMap().removeActionsOnMap(); + + // Cache la tooltip + oVmap.getMap().getMapTooltip().hide(); + + // Supprime le snapping + this.oSnapOverlayLayer_.getSource().clear(); + oVmap.getMap().getOLMap().removeInteraction(this.snap_); + + // Affiche le formulaire oVmap.getToolsManager().getBasicTools().showTool($('#basic-tools-dropdown-insert-btn')); $('#basictools-insert-form-reader-modal').modal('show'); @@ -655,7 +730,6 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.validateFo $scope.isFormValid_ = false; setTimeout(function () { -// oVmap.simuleClick("basictools-insert-form-reader-submit-btn"); var oFormReaderScope = this_.getEditFormReaderScope(); oFormReaderScope['sendForm'](); setTimeout(function () { @@ -777,7 +851,8 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.updateInse return null; } - // Vide les variables oInsertObject + // Vide les variables + this['addPartGeomType'] = ''; $scope['oInsertObject']['oResult'] = {}; $scope['oInsertObject']['sGeomColumn'] = null; $scope['oInsertObject']['sGeomType'] = null; @@ -916,6 +991,32 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.getEditFor return angular.element($('#basictools-insert-form-reader').children()).scope(); }; +/** + * Ferme le formulaire et retourne à l'édition de la géométrie + * @export + */ +nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.closeFormToEditGeom = function () { + oVmap.log('nsVmap.nsToolsManager.Insert.inserttoolController.validateForm'); + + var this_ = this; + var $scope = this.$scope_; + + // Récupère les valeurs sous un format propice à l'insertion (sans "selectedOption") + if (goog.isDefAndNotNull($scope['oInsertObject']['oResult'][$scope['oInsertObject']['sGeomColumn']])) { + var EWKTGeometry = angular.copy($scope['oInsertObject']['oResult'][$scope['oInsertObject']['sGeomColumn']]); + } + $scope['oInsertObject']['oResult'] = this_.getBOValuesFromFormValues($scope['oInsertObject']['oFormValues']); + if (!goog.isDefAndNotNull($scope['oInsertObject']['oResult'][$scope['oInsertObject']['sGeomColumn']])) { + $scope['oInsertObject']['oResult'][$scope['oInsertObject']['sGeomColumn']] = EWKTGeometry; + } + $('#basictools-insert-form-reader-modal').modal('hide'); + + // Lance automatiquement la saisie + if (this['addPartGeomType'] !== '') { + this['startInsertion']('insert' + this['addPartGeomType'], this['currentAction'] === 'basicTools-insert-insert' + this['addPartGeomType']) + } +} + // Edition de la géométrie @@ -965,7 +1066,7 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.startInser } else if (type === 'deleteFeature') { //Ajoute la tooltip - oVmap.getMap().getMapTooltip().displayMessage('Cliquez sur un dessin pour le supprimer'); + oVmap.getMap().getMapTooltip().displayMessage('Cliquez sur une partie pour la supprimer'); // Ajoute l'interraction oVmap.getMap().setInteraction(this.delete_, 'basicTools-insert-' + type); @@ -1130,6 +1231,8 @@ nsVmap.nsToolsManager.Insert.prototype.inserttoolController.prototype.startDrawi feature = this_.updateCircleGeoms(feature); // Évite les superpositions avec les autres couches si besoin this_.avoidSuperpositions(feature); + // Affiche le formulaire automatiquement + this_.autoShowForm(); }, this); diff --git a/src/module_vmap/module/template/tools/insert.html b/src/module_vmap/module/template/tools/insert.html index b0dfbd89e68cf40d6b6373df445450705f2fbe73..b8941d1f57a92157e337e7c796e864a031660939 100644 --- a/src/module_vmap/module/template/tools/insert.html +++ b/src/module_vmap/module/template/tools/insert.html @@ -30,22 +30,26 @@ class="btn btn-sm btn-info" style="width: 80%" ng-class="{'white color-gray': ctrl.currentAction === 'basicTools-insert-insertPoint' || ctrl.currentAction === 'basicTools-insert-insertLineString' || ctrl.currentAction === 'basicTools-insert-insertPolygon' || ctrl.currentAction === 'basicTools-insert-insertCircle'}" - ng-click="ctrl.addPartGeomType !== '' ? ctrl.startInsertion('insert' + ctrl.addPartGeomType, ctrl.currentAction === 'basicTools-insert-insert' + ctrl.addPartGeomType) : angular.noop"> + ng-click="ctrl.addPartGeomType !== '' ? ctrl.startInsertion('insert' + ctrl.addPartGeomType, ctrl.currentAction === 'basicTools-insert-insert' + ctrl.addPartGeomType) : ctrl.showDrawTypeSelectDropdown()"> {{ 'VMAP_INSERT_ADD_PART' | translate }} </button> <button type="button" + id="vmap-insert-select-type-dropdown-trigger" class="btn btn-sm btn-default dropdown-toggle" style="width: 20%" data-toggle="dropdown" aria-haspopup="true" - aria-expanded="false"> + aria-expanded="false" + ng-click="(oInsertObject.sGeomType !== 'GEOMETRYCOLLECTION' && oInsertObject.sGeomType !== 'GEOMETRY') ? ctrl.startInsertion('insert' + ctrl.addPartGeomType, ctrl.currentAction === 'basicTools-insert-insert' + ctrl.addPartGeomType) : angular.noop"> <span class="caret" ng-show="oInsertObject.sGeomType === 'GEOMETRYCOLLECTION' || oInsertObject.sGeomType === 'GEOMETRY' && ctrl.addPartGeomType === ''"></span> <span class="icon-point" ng-show="ctrl.addPartGeomType === 'Point'"></span> <span class="icon-line" ng-show="ctrl.addPartGeomType === 'LineString'"></span> <span class="icon-polygon" ng-show="ctrl.addPartGeomType === 'Polygon'"></span> <span class="icon-circle" ng-show="ctrl.addPartGeomType === 'Circle'"></span> </button> - <ul class="dropdown-menu"> + <ul ng-show="oInsertObject.sGeomType === 'GEOMETRYCOLLECTION' || oInsertObject.sGeomType === 'GEOMETRY'" + id="vmap-insert-select-type-dropdown" + class="dropdown-menu"> <li><a href="javascript:void(0)" ng-show="oInsertObject.sGeomType === 'GEOMETRYCOLLECTION' || oInsertObject.sGeomType === 'GEOMETRY' || oInsertObject.sGeomType === 'POINT' || oInsertObject.sGeomType === 'MULTIPOINT'" ng-click="ctrl.addPartGeomType = 'Point'; ctrl.startInsertion('insertPoint', false)"> @@ -125,7 +129,7 @@ <div class="hr-gray margin-10"></div> <!--Snapping--> <div> - <div class="basic-tools-dropdown-btn vmap-insert-snapping-collapse-button " + <div class="basic-tools-dropdown-btn vmap-insert-snapping-collapse-button pointer" ng-click="ctrl.isSnapMenuCollapse = !ctrl.isSnapMenuCollapse"> <span class ="glyphicon glyphicon-magnet" ></span> <span class="margin-sides-10"> {{ 'VMAP_INSERT_VECTOR_SNAPPING' | translate }} </span> @@ -220,7 +224,7 @@ </div> <div class="modal-footer modal-footer-sm text-left"> <button class="btn btn-info" - ng-click="ctrl.validateForm()"> + ng-click="ctrl.closeFormToEditGeom()"> {{ 'VMAP_INSERT_MODIFY_GEOM' | translate }} </button> <button type="submit" class="btn btn-primary" form="basictools-insert-form-reader-form"