diff --git a/contribs/gmf/examples/xsdattributes.js b/contribs/gmf/examples/xsdattributes.js index 757aa300474..3e8888bdfae 100644 --- a/contribs/gmf/examples/xsdattributes.js +++ b/contribs/gmf/examples/xsdattributes.js @@ -3,7 +3,7 @@ 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'); @@ -11,6 +11,7 @@ goog.require('ol.Feature'); gmfapp.module = angular.module('gmfapp', [ gmf.module.name, gmf.theme.Themes.module.name, + ngeo.editing.attributesComponent.name, ]); diff --git a/contribs/gmf/src/directives/drawfeature.js b/contribs/gmf/src/directives/drawfeature.js index 08a4ab6c670..a15aa42beb0 100644 --- a/contribs/gmf/src/directives/drawfeature.js +++ b/contribs/gmf/src/directives/drawfeature.js @@ -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'); @@ -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 /** diff --git a/contribs/gmf/src/directives/editfeature.js b/contribs/gmf/src/directives/editfeature.js index a80ff9e1ac3..c020153d574 100644 --- a/contribs/gmf/src/directives/editfeature.js +++ b/contribs/gmf/src/directives/editfeature.js @@ -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'); diff --git a/contribs/gmf/src/directives/objecteditingtools.js b/contribs/gmf/src/directives/objecteditingtools.js index c0920d70a7d..fced5a10c34 100644 --- a/contribs/gmf/src/directives/objecteditingtools.js +++ b/contribs/gmf/src/directives/objecteditingtools.js @@ -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} */ diff --git a/examples/attributes.js b/examples/attributes.js index 940861cc9e0..3eea5cc5a6f 100644 --- a/examples/attributes.js +++ b/examples/attributes.js @@ -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'); @@ -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, ]); diff --git a/examples/createfeature.js b/examples/createfeature.js index 90143b54977..960ca77b33e 100644 --- a/examples/createfeature.js +++ b/examples/createfeature.js @@ -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'); @@ -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, ]); diff --git a/src/editing/.eslintrc.yaml b/src/editing/.eslintrc.yaml new file mode 100644 index 00000000000..718b11a9fd5 --- /dev/null +++ b/src/editing/.eslintrc.yaml @@ -0,0 +1,2 @@ +extends: + - ../.eslintrc-googshift.yaml diff --git a/src/directives/partials/attributes.html b/src/editing/attributescomponent.html similarity index 100% rename from src/directives/partials/attributes.html rename to src/editing/attributescomponent.html diff --git a/src/directives/attributes.js b/src/editing/attributescomponent.js similarity index 78% rename from src/directives/attributes.js rename to src/editing/attributescomponent.js index b961f70820d..3bed486cff8 100644 --- a/src/directives/attributes.js +++ b/src/editing/attributescomponent.js @@ -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. @@ -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', @@ -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_); /** @@ -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. @@ -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 @@ -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); @@ -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); }; @@ -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; } @@ -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_); diff --git a/src/directives/createfeature.js b/src/editing/createfeaturecomponent.js similarity index 88% rename from src/directives/createfeature.js rename to src/editing/createfeaturecomponent.js index 02913db470d..4099ab04a02 100644 --- a/src/directives/createfeature.js +++ b/src/editing/createfeaturecomponent.js @@ -1,4 +1,4 @@ -goog.provide('ngeo.createfeatureDirective'); +goog.provide('ngeo.editing.createfeatureComponent'); goog.require('ngeo'); /** @suppress {extraRequire} */ @@ -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); /** @@ -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', @@ -66,7 +72,7 @@ ngeo.createfeatureDirective = function() { }; }; -ngeo.module.directive('ngeoCreatefeature', ngeo.createfeatureDirective); +ngeo.editing.createfeatureComponent.directive('ngeoCreatefeature', ngeo.editing.createfeatureComponent.directive_); /** @@ -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) { /** @@ -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_; @@ -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 @@ -283,7 +289,7 @@ 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); @@ -291,3 +297,5 @@ ngeo.CreatefeatureController.prototype.$onDestroy = function() { this.map.removeInteraction(this.interaction_); }, 0); }; + +ngeo.editing.createfeatureComponent.controller('ngeoCreatefeatureController', ngeo.editing.createfeatureComponent.Controller_); diff --git a/src/directives/createregularpolygonfromclick.js b/src/editing/createregularpolygonfromclickcomponent.js similarity index 80% rename from src/directives/createregularpolygonfromclick.js rename to src/editing/createregularpolygonfromclickcomponent.js index 11fcd351ce9..e8afeb5b6c8 100644 --- a/src/directives/createregularpolygonfromclick.js +++ b/src/editing/createregularpolygonfromclickcomponent.js @@ -1,4 +1,4 @@ -goog.provide('ngeo.createregularpolygonfromclickDirective'); +goog.provide('ngeo.editing.createregularpolygonfromclickComponent'); goog.require('ngeo'); goog.require('ngeo.interaction.DrawRegularPolygonFromClick'); @@ -6,6 +6,12 @@ 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 @@ -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', @@ -66,9 +72,10 @@ ngeo.createregularpolygonfromclickDirective = function() { }; }; -ngeo.module.directive( +ngeo.editing.createregularpolygonfromclickComponent.directive( 'ngeoCreateregularpolygonfromclick', - ngeo.createregularpolygonfromclickDirective); + ngeo.editing.createregularpolygonfromclickComponent.directive_ +); /** @@ -80,7 +87,7 @@ ngeo.module.directive( * @ngdoc controller * @ngname ngeoCreateregularpolygonfromclickController */ -ngeo.CreateregularpolygonfromclickController = function($scope) { +ngeo.editing.createregularpolygonfromclickComponent.Controller_ = function($scope) { // == Scope properties == @@ -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, @@ -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); }; @@ -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_ +); diff --git a/src/directives/exportfeatures.js b/src/editing/exportfeaturescomponent.js similarity index 83% rename from src/directives/exportfeatures.js rename to src/editing/exportfeaturescomponent.js index 33e9569e3ac..2c62ca094f8 100644 --- a/src/directives/exportfeatures.js +++ b/src/editing/exportfeaturescomponent.js @@ -1,9 +1,16 @@ -goog.provide('ngeo.exportfeaturesDirective'); +goog.provide('ngeo.editing.exportfeaturesComponent'); goog.require('ngeo'); goog.require('ngeo.misc.FeatureHelper'); +goog.require('ol'); +goog.require('ol.geom.Point'); +goog.require('ol.geom.LineString'); -// FIXME add ngeo.misc.FeatureHelper as module dependency +ngeo.editing.exportfeaturesComponent = angular.module('ngeoExportfeatures', [ + ngeo.misc.FeatureHelper.module.name +]); + +ngeo.module.requires.push(ngeo.editing.exportfeaturesComponent.name); /** * Directive used to export vector features in different types of format. @@ -29,7 +36,7 @@ goog.require('ngeo.misc.FeatureHelper'); * @ngdoc directive * @ngname ngeoExportfeatures */ -ngeo.exportfeaturesDirective = function() { +ngeo.editing.exportfeaturesComponent.directive_ = function() { return { controller: 'ngeoExportfeaturesController as efCtrl', scope: true, @@ -40,7 +47,7 @@ ngeo.exportfeaturesDirective = function() { }; -ngeo.module.directive('ngeoExportfeatures', ngeo.exportfeaturesDirective); +ngeo.module.directive('ngeoExportfeatures', ngeo.editing.exportfeaturesComponent.directive_); /** @@ -55,7 +62,7 @@ ngeo.module.directive('ngeoExportfeatures', ngeo.exportfeaturesDirective); * @ngdoc controller * @ngname ngeoExportfeaturesController */ -ngeo.ExportfeaturesController = function($element, $injector, $scope, +ngeo.editing.exportfeaturesComponent.Controller_ = function($element, $injector, $scope, ngeoFeatureHelper) { /** @@ -154,7 +161,7 @@ ngeo.ExportfeaturesController = function($element, $injector, $scope, * that doesn't support the type of geometry. * @private */ -ngeo.ExportfeaturesController.prototype.handleElementClick_ = function() { +ngeo.editing.exportfeaturesComponent.Controller_.prototype.handleElementClick_ = function() { const features = this.features.getArray(); @@ -186,7 +193,7 @@ ngeo.ExportfeaturesController.prototype.handleElementClick_ = function() { * @param {jQuery.Event} event Event. * @private */ -ngeo.ExportfeaturesController.prototype.handleMenuItemClick_ = function(format, event) { +ngeo.editing.exportfeaturesComponent.Controller_.prototype.handleMenuItemClick_ = function(format, event) { if (!$(event.target.parentElement).hasClass('disabled')) { const features = this.features.getArray(); this.featureHelper_.export(features, format); @@ -198,7 +205,7 @@ ngeo.ExportfeaturesController.prototype.handleMenuItemClick_ = function(format, * Cleanup event listeners and remove the menu from DOM, if any. * @private */ -ngeo.ExportfeaturesController.prototype.handleDestroy_ = function() { +ngeo.editing.exportfeaturesComponent.Controller_.prototype.handleDestroy_ = function() { const id = this.id_; this.element_.off(['click', id].join('.')); @@ -214,5 +221,5 @@ ngeo.ExportfeaturesController.prototype.handleDestroy_ = function() { }; -ngeo.module.controller( - 'ngeoExportfeaturesController', ngeo.ExportfeaturesController); +ngeo.editing.exportfeaturesComponent.controller( + 'ngeoExportfeaturesController', ngeo.editing.exportfeaturesComponent.Controller_); diff --git a/src/editing/extraModule.js b/src/editing/extraModule.js new file mode 100644 index 00000000000..9884d1be81c --- /dev/null +++ b/src/editing/extraModule.js @@ -0,0 +1,12 @@ +goog.provide('ngeo.editing.extraModule'); + +goog.require('ngeo'); +goog.require('ngeo.editing.exportfeaturesComponent'); + +/** + * @type {angular.Module} + */ +ngeo.editing.extraModule = angular.module('ngeoEditingExtraModule', [ + ngeo.module.name, // Change me when all dependencies are in a module. + ngeo.editing.exportfeaturesComponent.name, +]); diff --git a/src/editing/module.js b/src/editing/module.js new file mode 100644 index 00000000000..afd851ec7b7 --- /dev/null +++ b/src/editing/module.js @@ -0,0 +1,16 @@ +goog.provide('ngeo.editing.module'); + +goog.require('ngeo'); +goog.require('ngeo.editing.attributesComponent'); +goog.require('ngeo.editing.createfeatureComponent'); +goog.require('ngeo.editing.createregularpolygonfromclickComponent'); + +/** + * @type {!angular.Module} + */ +ngeo.editing.module = angular.module('ngeoEditingModule', [ + ngeo.module.name, // Change me when all dependencies are in a module. + ngeo.editing.attributesComponent.name, + ngeo.editing.createfeatureComponent.name, + ngeo.editing.createregularpolygonfromclickComponent.name, +]);