Skip to content

Commit

Permalink
add a new configuration option called closeaftersave in the editFeatu…
Browse files Browse the repository at this point in the history
…re components to allow to directly close the feature drawing panel after the use clic on the save button.
  • Loading branch information
ochriste committed Apr 9, 2019
1 parent cef0685 commit bdae2f1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
14 changes: 13 additions & 1 deletion contribs/gmf/src/editing/editFeatureComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ exports.run(/* @ngInject */ ($templateCache) => {
* buffer in pixels to use when making queries to get the features.
* @htmlAttribute {ol.layer.Vector} gmf-editfeature-vector The vector layer in
* which to draw the vector features.
* @htmlAttribute {boolean} gmf-editfeatureselector-closeaftersave If true,
* immediatly return to the main edit panel after save. Default is false.
* @return {angular.Directive} The directive specs.
* @ngdoc directive
* @ngname gmfEditfeature
Expand All @@ -128,7 +130,8 @@ exports.component_ = function() {
'map': '<gmfEditfeatureMap',
'state': '=gmfEditfeatureState',
'tolerance': '<?gmfEditfeatureTolerance',
'vectorLayer': '<gmfEditfeatureVector'
'vectorLayer': '<gmfEditfeatureVector',
'closeaftersave': '=?gmfEditfeatureCloseaftersave'
},
bindToController: true,
templateUrl: 'gmf/editing/editFeatureComponent'
Expand Down Expand Up @@ -207,6 +210,11 @@ exports.Controller_ = function($element, $q, $scope, $timeout,
*/
this.vectorLayer;

/**
* @type {boolean}
* @export
*/
this.closeaftersave;

// === Injected properties ===

Expand Down Expand Up @@ -483,6 +491,7 @@ exports.Controller_.prototype.$onInit = function() {
this.editableTreeCtrl.node);
this.features = this.vectorLayer.getSource().getFeaturesCollection();
this.tolerance = this.tolerance !== undefined ? this.tolerance : 10;
this.closeaftersave = this.closeaftersave !== undefined ? this.closeaftersave : false;

// (1.1) Set editable WMS layer
const layer = gmfLayertreeSyncLayertreeMap.getLayer(this.editableTreeCtrl);
Expand Down Expand Up @@ -654,6 +663,9 @@ exports.Controller_.prototype.save = function() {
this.pending = false;
this.handleEditFeature_(response);
this.gmfSnapping_.refresh();
if (this.closeaftersave) {
this.cancel();
}
},
(response) => {
this.showServerError = true;
Expand Down
3 changes: 2 additions & 1 deletion contribs/gmf/src/editing/editFeatureSelectorComponent.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
gmf-editfeature-map="::efsCtrl.map"
gmf-editfeature-state="efsCtrl.state"
gmf-editfeature-tolerance="::efsCtrl.tolerance"
gmf-editfeature-vector="::efsCtrl.vectorLayer">
gmf-editfeature-vector="::efsCtrl.vectorLayer"
gmf-editfeature-closeaftersave="::efsCtrl.closeaftersave">
</gmf-editfeature>

</div>
Expand Down
14 changes: 12 additions & 2 deletions contribs/gmf/src/editing/editFeatureSelectorComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ exports.run(/* @ngInject */ ($templateCache) => {
* gmf-editfeatureselector-active="ctrl.editFeatureSelectorActive"
* gmf-editfeatureselector-map="::ctrl.map"
* gmf-editfeatureselector-tolerance="::ctrl.tolerance"
* gmf-editfeatureselector-vector="::ctrl.vectorLayer">
* gmf-editfeatureselector-vector="::ctrl.vectorLayer"
* gmf-editfeatureselector-tree="ctrl.selectedEditableTreeCtrl"
* gmf-editfeatureselector-closeaftersave="::true">
* </gmf-editfeatureselector>
*
* @htmlAttribute {boolean} gmf-editfeatureselector-active Whether the
Expand All @@ -48,6 +50,8 @@ exports.run(/* @ngInject */ ($templateCache) => {
* layer where the selected or created features are drawn.
* @htmlAttribute {ngeo.layertree.Controller} gmf-editfeatureselector-tree The
* layertree controller handling the selectable editable layers list.
* @htmlAttribute {boolean} gmf-editfeatureselector-closeaftersave If true,
* immediatly return to the main edit panel after save. Default is false.
* @return {angular.Directive} The directive specs.
* @ngdoc directive
* @ngname gmfEditfeatureselector
Expand All @@ -60,7 +64,8 @@ exports.component_ = function() {
'map': '<gmfEditfeatureselectorMap',
'tolerance': '<?gmfEditfeatureselectorTolerance',
'vectorLayer': '<gmfEditfeatureselectorVector',
'selectedEditableTreeCtrl': '=?gmfEditfeatureselectorTree'
'selectedEditableTreeCtrl': '=?gmfEditfeatureselectorTree',
'closeaftersave': '=?gmfEditfeatureselectorCloseaftersave'
},
bindToController: true,
templateUrl: 'gmf/editing/editFeatureSelectorComponent'
Expand Down Expand Up @@ -115,6 +120,11 @@ exports.Controller_ = function($scope, $timeout, gmfThemes, gmfTreeManager) {
*/
this.vectorLayer;

/**
* @type {boolean}
* @export
*/
this.closeaftersave;

// === Injected services ===

Expand Down

0 comments on commit bdae2f1

Please sign in to comment.