Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt angular ngeo.editing #3308

Merged
merged 6 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion contribs/gmf/examples/xsdattributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ goog.provide('gmfapp.xsdattributes');
goog.require('gmf.theme.Themes');
goog.require('gmf.XSDAttributes');
/** @suppress {extraRequire} */
goog.require('ngeo.attributesComponent');
goog.require('ngeo.editing.attributesComponent');
goog.require('ol.Feature');


/** @type {!angular.Module} **/
gmfapp.module = angular.module('gmfapp', [
gmf.module.name,
gmf.theme.Themes.module.name,
ngeo.editing.attributesComponent.name,
]);


Expand Down
3 changes: 2 additions & 1 deletion contribs/gmf/src/directives/drawfeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ goog.require('ngeo.Menu');
/** @suppress {extraRequire} */
goog.require('ngeo.misc.btnComponent');
/** @suppress {extraRequire} */
goog.require('ngeo.exportfeaturesDirective');
goog.require('ngeo.editing.exportfeaturesComponent');
/** @suppress {extraRequire} */
goog.require('ngeo.draw.component');
goog.require('ngeo.interaction.Modify');
Expand All @@ -30,6 +30,7 @@ goog.require('ol.style.Text');
// - ngeo.interaction.Rotate.module.name
// - ngeo.interaction.Translate.module.name
// - ngeo.misc.FeatureHelper.module.name
// - ngeo.editing.exportfeaturesComponent.name


/**
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/directives/editfeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ goog.require('gmf.Snapping');
goog.require('gmf.SyncLayertreeMap');
goog.require('gmf.XSDAttributes');
/** @suppress {extraRequire} */
goog.require('ngeo.attributesComponent');
goog.require('ngeo.editing.attributesComponent');
/** @suppress {extraRequire} */
goog.require('ngeo.createfeatureDirective');
goog.require('ngeo.editing.createfeatureComponent');
goog.require('ngeo.interaction.Rotate');
goog.require('ngeo.interaction.Translate');
goog.require('ngeo.map.LayerHelper');
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/directives/objecteditingtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ goog.provide('gmf.objecteditingtoolsDirective');
/** @suppress {extraRequire} */
goog.require('gmf.objecteditinggetwmsfeatureDirective');
/** @suppress {extraRequire} */
goog.require('ngeo.createfeatureDirective');
goog.require('ngeo.editing.createfeatureComponent');
/** @suppress {extraRequire} */
goog.require('ngeo.createregularpolygonfromclickDirective');
goog.require('ngeo.editing.createregularpolygonfromclickComponent');
/** @suppress {extraRequire} */
goog.require('ngeo.misc.btnComponent');
/** @suppress {extraRequire} */
Expand Down
5 changes: 3 additions & 2 deletions examples/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ goog.provide('app.attributes');

goog.require('ngeo.format.XSDAttribute');
/** @suppress {extraRequire} */
goog.require('ngeo.attributesComponent');
goog.require('ngeo.editing.attributesComponent');
goog.require('ol.Feature');

goog.require('ngeo.map.module');
Expand All @@ -11,7 +11,8 @@ goog.require('ngeo.map.module');
/** @type {!angular.Module} */
app.module = angular.module('app', [
ngeo.module.name,
ngeo.map.module.name
ngeo.map.module.name,
ngeo.editing.attributesComponent.name,
]);


Expand Down
3 changes: 2 additions & 1 deletion examples/createfeature.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
goog.provide('app.createfeature');

/** @suppress {extraRequire} */
goog.require('ngeo.createfeatureDirective');
goog.require('ngeo.editing.createfeatureComponent');
/** @suppress {extraRequire} */
goog.require('ngeo.misc.btnComponent');
goog.require('ngeo.misc.ToolActivate');
Expand All @@ -23,6 +23,7 @@ app.module = angular.module('app', [
ngeo.map.module.name,
ngeo.misc.btnComponent.name,
ngeo.misc.ToolActivateMgr.module.name,
ngeo.editing.createfeatureComponent.name,
]);


Expand Down
2 changes: 2 additions & 0 deletions src/editing/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extends:
- ../.eslintrc-googshift.yaml
27 changes: 16 additions & 11 deletions src/directives/attributes.js → src/editing/attributescomponent.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
goog.provide('ngeo.attributesComponent');
goog.provide('ngeo.editing.attributesComponent');

goog.require('ol');
goog.require('ol.events');
goog.require('ngeo');
goog.require('ngeo.misc.EventHelper');

// FIXME Dont' forget to add ngeo.misc.EventHelper to the module

ngeo.editing.attributesComponent = angular.module('ngeoAttributes', [
ngeo.misc.EventHelper.module.name,
]);

ngeo.module.requires.push(ngeo.editing.attributesComponent.name);

/**
* Component used to render the attributes of a feature into a form.
Expand All @@ -26,7 +31,7 @@ goog.require('ngeo.misc.EventHelper');
* @ngdoc component
* @ngname ngeoAttributes
*/
ngeo.attributesComponent = {
ngeo.editing.attributesComponent.component_ = {
controller: 'ngeoAttributesController as attrCtrl',
bindings: {
'attributes': '=ngeoAttributesAttributes',
Expand All @@ -36,10 +41,10 @@ ngeo.attributesComponent = {
require: {
'form': '^'
},
templateUrl: () => `${ngeo.baseTemplateUrl}/attributes.html`
templateUrl: () => `${ngeo.baseModuleTemplateUrl}/editing/attributescomponent.html`
};

ngeo.module.component('ngeoAttributes', ngeo.attributesComponent);
ngeo.editing.attributesComponent.component('ngeoAttributes', ngeo.editing.attributesComponent.component_);


/**
Expand All @@ -53,7 +58,7 @@ ngeo.module.component('ngeoAttributes', ngeo.attributesComponent);
* @ngdoc controller
* @ngname ngeoAttributesController
*/
ngeo.AttributesController = function($scope, ngeoEventHelper, gettextCatalog) {
ngeo.editing.attributesComponent.Controller_ = function($scope, ngeoEventHelper, gettextCatalog) {

/**
* The list of attributes to create the form with.
Expand Down Expand Up @@ -130,7 +135,7 @@ ngeo.AttributesController = function($scope, ngeoEventHelper, gettextCatalog) {
/**
* Initialise the component.
*/
ngeo.AttributesController.prototype.$onInit = function() {
ngeo.editing.attributesComponent.Controller_.prototype.$onInit = function() {
this.properties = this.feature.getProperties();

// Listen to the feature inner properties change and apply them to the form
Expand All @@ -150,7 +155,7 @@ ngeo.AttributesController.prototype.$onInit = function() {
* @param {string} name Attribute name
* @export
*/
ngeo.AttributesController.prototype.handleInputChange = function(name) {
ngeo.editing.attributesComponent.Controller_.prototype.handleInputChange = function(name) {
this.updating_ = true;
const value = this.properties[name];
this.feature.set(name, value);
Expand All @@ -161,7 +166,7 @@ ngeo.AttributesController.prototype.handleInputChange = function(name) {
/**
* Cleanup event listeners.
*/
ngeo.AttributesController.prototype.$onDestroy = function() {
ngeo.editing.attributesComponent.Controller_.prototype.$onDestroy = function() {
const uid = ol.getUid(this);
this.ngeoEventHelper_.clearListenerKey(uid);
};
Expand All @@ -171,7 +176,7 @@ ngeo.AttributesController.prototype.$onDestroy = function() {
* @param {ol.Object.Event} evt Event.
* @private
*/
ngeo.AttributesController.prototype.handleFeaturePropertyChange_ = function(evt) {
ngeo.editing.attributesComponent.Controller_.prototype.handleFeaturePropertyChange_ = function(evt) {
if (this.updating_) {
return;
}
Expand All @@ -180,4 +185,4 @@ ngeo.AttributesController.prototype.handleFeaturePropertyChange_ = function(evt)
};


ngeo.module.controller('ngeoAttributesController', ngeo.AttributesController);
ngeo.editing.attributesComponent.controller('ngeoAttributesController', ngeo.editing.attributesComponent.Controller_);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
goog.provide('ngeo.createfeatureDirective');
goog.provide('ngeo.editing.createfeatureComponent');

goog.require('ngeo');
/** @suppress {extraRequire} */
Expand All @@ -7,12 +7,18 @@ goog.require('ngeo.interaction.MeasureArea');
goog.require('ngeo.interaction.MeasureLength');
goog.require('ngeo.misc.EventHelper');
goog.require('ngeo.utils');
goog.require('ol');
goog.require('ol.events');
goog.require('ol.Feature');
goog.require('ol.interaction.Draw');
goog.require('ol.style.Style');

// Don't forget to add module dependencies

ngeo.editing.createfeatureComponent = angular.module('ngeoCreatefeature', [
ngeo.misc.EventHelper.module.name
]);

ngeo.module.requires.push(ngeo.editing.createfeatureComponent.name);


/**
Expand Down Expand Up @@ -53,9 +59,9 @@ goog.require('ol.style.Style');
* @ngdoc directive
* @ngname ngeoCreatefeature
*/
ngeo.createfeatureDirective = function() {
ngeo.editing.createfeatureComponent.directive_ = function() {
return {
controller: ngeo.CreatefeatureController,
controller: 'ngeoCreatefeatureController',
bindToController: true,
scope: {
'active': '=ngeoCreatefeatureActive',
Expand All @@ -66,7 +72,7 @@ ngeo.createfeatureDirective = function() {
};
};

ngeo.module.directive('ngeoCreatefeature', ngeo.createfeatureDirective);
ngeo.editing.createfeatureComponent.directive('ngeoCreatefeature', ngeo.editing.createfeatureComponent.directive_);


/**
Expand All @@ -83,7 +89,7 @@ ngeo.module.directive('ngeoCreatefeature', ngeo.createfeatureDirective);
* @ngdoc controller
* @ngname ngeoCreatefeatureController
*/
ngeo.CreatefeatureController = function(gettextCatalog, $compile, $filter, $scope,
ngeo.editing.createfeatureComponent.Controller_ = function(gettextCatalog, $compile, $filter, $scope,
$timeout, ngeoEventHelper) {

/**
Expand Down Expand Up @@ -168,7 +174,7 @@ ngeo.CreatefeatureController = function(gettextCatalog, $compile, $filter, $scop
/**
* Initialize the directive.
*/
ngeo.CreatefeatureController.prototype.$onInit = function() {
ngeo.editing.createfeatureComponent.Controller_.prototype.$onInit = function() {
this.active = this.active === true;
const gettextCatalog = this.gettextCatalog_;

Expand Down Expand Up @@ -254,7 +260,7 @@ ngeo.CreatefeatureController.prototype.$onInit = function() {
* @param {ol.interaction.Draw.Event|ngeox.MeasureEvent} event Event.
* @export
*/
ngeo.CreatefeatureController.prototype.handleDrawEnd_ = function(event) {
ngeo.editing.createfeatureComponent.Controller_.prototype.handleDrawEnd_ = function(event) {
let sketch;
if (event.feature) {
// ol.interaction.Draw.Event
Expand Down Expand Up @@ -283,11 +289,13 @@ ngeo.CreatefeatureController.prototype.handleDrawEnd_ = function(event) {
/**
* Cleanup event listeners and remove the interaction from the map.
*/
ngeo.CreatefeatureController.prototype.$onDestroy = function() {
ngeo.editing.createfeatureComponent.Controller_.prototype.$onDestroy = function() {
this.timeout_(() => {
const uid = ol.getUid(this);
this.ngeoEventHelper_.clearListenerKey(uid);
this.interaction_.setActive(false);
this.map.removeInteraction(this.interaction_);
}, 0);
};

ngeo.editing.createfeatureComponent.controller('ngeoCreatefeatureController', ngeo.editing.createfeatureComponent.Controller_);
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
goog.provide('ngeo.createregularpolygonfromclickDirective');
goog.provide('ngeo.editing.createregularpolygonfromclickComponent');

goog.require('ngeo');
goog.require('ngeo.interaction.DrawRegularPolygonFromClick');
goog.require('ol.events');
goog.require('ol.Feature');


ngeo.editing.createregularpolygonfromclickComponent = angular.module('ngeoCreateregularpolygonfromclick', [
]);

ngeo.module.requires.push(ngeo.editing.createregularpolygonfromclickComponent.name);


/**
* A directive used to draw vector features of a single geometry type using
* either a 'draw' or 'measure' interaction. Once a feature is finished being
Expand Down Expand Up @@ -51,9 +57,9 @@ goog.require('ol.Feature');
* @ngdoc directive
* @ngname ngeoCreateregularpolygonfromclick
*/
ngeo.createregularpolygonfromclickDirective = function() {
ngeo.editing.createregularpolygonfromclickComponent.directive_ = function() {
return {
controller: ngeo.CreateregularpolygonfromclickController,
controller: 'ngeoCreateregularpolygonfromclickController',
bindToController: true,
scope: {
'active': '=ngeoCreateregularpolygonfromclickActive',
Expand All @@ -66,9 +72,10 @@ ngeo.createregularpolygonfromclickDirective = function() {
};
};

ngeo.module.directive(
ngeo.editing.createregularpolygonfromclickComponent.directive(
'ngeoCreateregularpolygonfromclick',
ngeo.createregularpolygonfromclickDirective);
ngeo.editing.createregularpolygonfromclickComponent.directive_
);


/**
Expand All @@ -80,7 +87,7 @@ ngeo.module.directive(
* @ngdoc controller
* @ngname ngeoCreateregularpolygonfromclickController
*/
ngeo.CreateregularpolygonfromclickController = function($scope) {
ngeo.editing.createregularpolygonfromclickComponent.Controller_ = function($scope) {

// == Scope properties ==

Expand Down Expand Up @@ -149,7 +156,7 @@ ngeo.CreateregularpolygonfromclickController = function($scope) {
/**
* Initialize the directive.
*/
ngeo.CreateregularpolygonfromclickController.prototype.$onInit = function() {
ngeo.editing.createregularpolygonfromclickComponent.Controller_.prototype.$onInit = function() {

this.interaction_ = new ngeo.interaction.DrawRegularPolygonFromClick({
angle: this.angle,
Expand All @@ -175,7 +182,7 @@ ngeo.CreateregularpolygonfromclickController.prototype.$onInit = function() {
* @param {ol.interaction.Draw.Event} evt Event.
* @private
*/
ngeo.CreateregularpolygonfromclickController.prototype.handleDrawEnd_ = function(evt) {
ngeo.editing.createregularpolygonfromclickComponent.Controller_.prototype.handleDrawEnd_ = function(evt) {
const feature = new ol.Feature(evt.feature.getGeometry());
this.features.push(feature);
};
Expand All @@ -185,8 +192,14 @@ ngeo.CreateregularpolygonfromclickController.prototype.handleDrawEnd_ = function
* Cleanup event listeners and remove the interaction from the map.
* @private
*/
ngeo.CreateregularpolygonfromclickController.prototype.handleDestroy_ = function() {
ngeo.editing.createregularpolygonfromclickComponent.Controller_.prototype.handleDestroy_ = function() {
ol.events.unlistenByKey(this.interactionListenerKey_);
this.interaction_.setActive(false);
this.map.removeInteraction(this.interaction_);
};


ngeo.editing.createregularpolygonfromclickComponent.controller(
'ngeoCreateregularpolygonfromclickController',
ngeo.editing.createregularpolygonfromclickComponent.Controller_
);
Loading