Skip to content

Commit

Permalink
Merge pull request #4994 from camptocamp/fixFloorsInjections
Browse files Browse the repository at this point in the history
Fix and simplify floors injections
  • Loading branch information
sbrunner committed Jul 11, 2019
2 parents 54c1112 + ece68bc commit c82f056
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 42 deletions.
17 changes: 0 additions & 17 deletions contribs/gmf/apps/appmodule.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,5 @@ module.config(['$compileProvider', function($compileProvider) {
}
}]);

/**
* @type {Array.<Object.<string, string>>}
*/
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;
14 changes: 4 additions & 10 deletions contribs/gmf/apps/desktop_alt/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ class Controller extends AbstractDesktopController {
/**
* @param {angular.IScope} $scope Scope.
* @param {angular.auto.IInjectorService} $injector Main injector.
* @param {Array.<Object.<string, string>>} appFloors Floor dimension values and labels.
* @ngInject
*/
constructor($scope, $injector, appFloors) {
constructor($scope, $injector) {
super({
srid: 21781,
mapViewConfig: {
Expand All @@ -58,17 +57,12 @@ class Controller extends AbstractDesktopController {
}
}, $scope, $injector);

/**
* @type {Array.<Object.<string, string>>}
*/
this.floors = appFloors;

if (this.dimensions['FLOOR'] == undefined) {
this.dimensions['FLOOR'] = '*';
if (this.dimensions.FLOOR == undefined) {
this.dimensions.FLOOR = '*';
}

/**
* @type {Array.<string>}
* @type {Array<string>}
*/
this.searchCoordinatesProjections = [EPSG21781, EPSG2056, 'EPSG:4326'];

Expand Down
3 changes: 1 addition & 2 deletions contribs/gmf/apps/desktop_alt/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@
</gmf-map>

<gmf-floorselector class="gmf-floorselector ol-unselectable ol-control"
value="mainCtrl.dimensions.FLOOR"
items="::mainCtrl.floors">
value="mainCtrl.dimensions.FLOOR">
</gmf-floorselector>

<!--infobar-->
Expand Down
23 changes: 10 additions & 13 deletions contribs/gmf/src/floor/floorselectorComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
});
Expand All @@ -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<Object<string, string>>} gmfFloors Floor dimension values and labels.
* @private
* @ngInject
* @ngdoc controller
* @ngname GmfFilterselectorController
*/
constructor($scope, $element) {
constructor($scope, $element, gmfFloors) {

/**
* @type {Array.<Object.<string, string>>}
* @type {Array<Object<string, string>>}
*/
this.items;
this.items = gmfFloors;

/**
* @type {number}
Expand Down Expand Up @@ -160,29 +161,25 @@ class Controller {
* Example:
*
* <gmf-floorselector class="gmf-floorselector ol-unselectable ol-control"
* value="mainCtrl.dimensions.FLOOR"
* items="::mainCtrl.floors">
* value="mainCtrl.dimensions.FLOOR">
* </gmf-floorselector>
*
* 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.<Object.<string, string>>} items List of objects with "value" and
* "label" properties.
*
* @ngdoc component
* @ngname gmfFloorselector
*/
const floorSelectorComponent = {
bindings: {
value: '=',
items: '<'
},
controller: Controller,
templateUrl: gmfFloorselectorTemplateUrl
Expand Down

0 comments on commit c82f056

Please sign in to comment.