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

Fix and simplify floors injections #4994

Merged
merged 1 commit into from
Jul 11, 2019
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
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 @@ -41,10 +41,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 @@ -54,17 +53,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">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to know here how to configure floors list.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, fixed :-)

* </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