Skip to content

Commit

Permalink
Refactor feature-filter module
Browse files Browse the repository at this point in the history
refs #217
  • Loading branch information
raitisbe committed Jul 17, 2019
1 parent 161f8b7 commit 63d8403
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 281 deletions.
42 changes: 42 additions & 0 deletions components/feature-filter/feature-filter-element.directive.js
@@ -0,0 +1,42 @@
export default ['config', '$compile', function (config, $compile) {
// console.log($state);
return {
// templateUrl: `${config.hsl_path}components/feature-filter/partials/${$state.type}${config.design || ''}.html`,
template: '<ng-include src="getTemplateUrl()"/>',
scope: {
filter: "="
},
// link: function(scope, element, attrs) {
// element.html(`${hsl_path}components/feature-filter/partials/${scope.filter.type}${config.design || ''}.html`).show();
// $compile(element.contents())(scope);
// },
controller: function ($scope) {
$scope.getTemplateUrl = function () {
if (config.design == 'md') {
switch ($scope.filter.type) {
case 'fieldset':
return `components/feature-filter/partials/fieldsetmd.html`;
case 'slider':
return `components/feature-filter/partials/slidermd.html`;
}

} else {
switch ($scope.filter.type) {
case 'fieldset':
return `components/feature-filter/partials/fieldset.html`;
case 'slider':
return `components/feature-filter/partials/slider.html`;
}
}

};
},
// templateUrl: function(el, attrs) {
// return `${config.hsl_path}components/feature-filter/partials/${attrs.filter.type}md.html`
// },
// link: function(scope, element, attrs) {
// scope.filter = scope.$eval(attrs.filter);
// },
// template: require('components/feature-filter/partials/{{filter.type}}md.html'),
};
}]
60 changes: 60 additions & 0 deletions components/feature-filter/feature-filter.controller.js
@@ -0,0 +1,60 @@
export default ['$scope', 'hs.map.service', 'Core', 'hs.featureFilter.service', 'hs.layermanager.service', 'config',
function ($scope, OlMap, Core, service, LayMan, config) {
var map = OlMap.map;

$scope.map = OlMap.map;
$scope.LayMan = LayMan;

$scope.applyFilters = service.applyFilters;

$scope.allSelected = function (filter) {
return filter.selected ? filter.selected.length === filter.values.length : false;
};

$scope.isIndeterminate = function (filter) {
return filter.selected ? (filter.selected.length !== 0 && filter.selected.length !== filter.values.length) : false;
};

$scope.exists = function (item, list) {
return list.indexOf(item) > -1;
};

$scope.toggle = function (value, selected) {
var idx = selected.indexOf(value);
if (idx > -1) {
selected.splice(idx, 1);
} else {
selected.push(value);
}
};

$scope.toggleAll = function (filter) {
if (filter.selected.length === filter.values.length) {
filter.selected = [];
} else {
filter.selected = filter.values.slice(0);
}
};

$scope.$emit('scope_loaded', "featureFilter");



// $rootScope.$on('layermanager.layer_added', function (e, layer) {
// service.prepLayerFilter(layer);

// if (layer.layer instanceof VectorLayer) {
// var source = layer.layer.getSource();
// console.log(source.getState());
// var listenerKey = source.on('change', function (e) {
// if (source.getState() === 'ready') {
// console.log(source.getState());
// Observable.unByKey(listenerKey);
// service.prepLayerFilter(layer);
// $scope.applyFilters(layer);
// }
// });
// }
// });
}
]
8 changes: 8 additions & 0 deletions components/feature-filter/feature-filter.directive.js
@@ -0,0 +1,8 @@
export default ['config', function (config) {
return {
template: require(`components/feature-filter/partials/feature-filter-md.html`),
link: function (scope, element) {

}
};
}]

0 comments on commit 63d8403

Please sign in to comment.