From ece68bc0c6169f5d4413c1fdbe315dbb0a2c3b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Fri, 5 Jul 2019 10:20:05 +0200 Subject: [PATCH] Fix and simplify floors injections --- contribs/gmf/apps/appmodule.js | 17 -------------- contribs/gmf/apps/desktop_alt/Controller.js | 14 ++++------- contribs/gmf/apps/desktop_alt/index.html.ejs | 3 +-- .../gmf/src/floor/floorselectorComponent.js | 23 ++++++++----------- 4 files changed, 15 insertions(+), 42 deletions(-) diff --git a/contribs/gmf/apps/appmodule.js b/contribs/gmf/apps/appmodule.js index 33579c1fe991..e653929c65e0 100644 --- a/contribs/gmf/apps/appmodule.js +++ b/contribs/gmf/apps/appmodule.js @@ -20,22 +20,5 @@ module.config(['$compileProvider', function($compileProvider) { } }]); -/** - * @type {Array.>} - */ -const appFloors = [ - {value: '10', label: '10'}, - {value: '9', label: '9'}, - {value: '8', label: '8'}, - {value: '7', label: '7'}, - {value: '6', label: '6'}, - {value: '5', label: '5'}, - {value: '4', label: '4'}, - {value: '3', label: '3'}, - {value: '2', label: '2'}, - {value: 'NULL', label: 'N'}, - {value: '*', label: '*'} -]; -module.constant('appFloors', appFloors); export default module; diff --git a/contribs/gmf/apps/desktop_alt/Controller.js b/contribs/gmf/apps/desktop_alt/Controller.js index b7cb4a1bf62a..fe9b3e54f207 100644 --- a/contribs/gmf/apps/desktop_alt/Controller.js +++ b/contribs/gmf/apps/desktop_alt/Controller.js @@ -41,10 +41,9 @@ class Controller extends AbstractDesktopController { /** * @param {angular.IScope} $scope Scope. * @param {angular.auto.IInjectorService} $injector Main injector. - * @param {Array.>} appFloors Floor dimension values and labels. * @ngInject */ - constructor($scope, $injector, appFloors) { + constructor($scope, $injector) { super({ srid: 21781, mapViewConfig: { @@ -54,17 +53,12 @@ class Controller extends AbstractDesktopController { } }, $scope, $injector); - /** - * @type {Array.>} - */ - this.floors = appFloors; - - if (this.dimensions['FLOOR'] == undefined) { - this.dimensions['FLOOR'] = '*'; + if (this.dimensions.FLOOR == undefined) { + this.dimensions.FLOOR = '*'; } /** - * @type {Array.} + * @type {Array} */ this.searchCoordinatesProjections = [EPSG21781, EPSG2056, 'EPSG:4326']; diff --git a/contribs/gmf/apps/desktop_alt/index.html.ejs b/contribs/gmf/apps/desktop_alt/index.html.ejs index 8aecd7a461b0..cfe1942c7b5f 100644 --- a/contribs/gmf/apps/desktop_alt/index.html.ejs +++ b/contribs/gmf/apps/desktop_alt/index.html.ejs @@ -306,8 +306,7 @@ + value="mainCtrl.dimensions.FLOOR"> diff --git a/contribs/gmf/src/floor/floorselectorComponent.js b/contribs/gmf/src/floor/floorselectorComponent.js index f4ae7cb4ee2d..d79f07570227 100644 --- a/contribs/gmf/src/floor/floorselectorComponent.js +++ b/contribs/gmf/src/floor/floorselectorComponent.js @@ -20,7 +20,7 @@ module.value('gmfFloorselectorTemplateUrl', * @return {string} The template url. */ ($attrs) => { - const templateUrl = $attrs['gmfFloorselectorTemplateUrl']; + const templateUrl = $attrs.gmfFloorselectorTemplateUrl; return templateUrl !== undefined ? templateUrl : 'gmf/floor/floorselectorcomponent'; }); @@ -46,19 +46,20 @@ function gmfFloorselectorTemplateUrl($attrs, gmfFloorselectorTemplateUrl) { class Controller { /** - * @param {!angular.IScope} $scope Angular scope. - * @param {!JQuery} $element Element. + * @param {angular.IScope} $scope Angular scope. + * @param {JQuery} $element Element. + * @param {Array>} gmfFloors Floor dimension values and labels. * @private * @ngInject * @ngdoc controller * @ngname GmfFilterselectorController */ - constructor($scope, $element) { + constructor($scope, $element, gmfFloors) { /** - * @type {Array.>} + * @type {Array>} */ - this.items; + this.items = gmfFloors; /** * @type {number} @@ -160,21 +161,18 @@ class Controller { * Example: * * + * value="mainCtrl.dimensions.FLOOR"> * * - * With: + * With the injected value `gmfFloors` with: * - * mainCtrl.floors = [ + * [ * {value: 'value1', label: 'label1'}, * {value: 'value2', label: 'label2'}, * ... * ]; * * @htmlAttribute {string} value Current floor value. - * @htmlAttribute {Array.>} items List of objects with "value" and - * "label" properties. * * @ngdoc component * @ngname gmfFloorselector @@ -182,7 +180,6 @@ class Controller { const floorSelectorComponent = { bindings: { value: '=', - items: '<' }, controller: Controller, templateUrl: gmfFloorselectorTemplateUrl