From 8a86e640d8d7204a0a18299341e4065030293d52 Mon Sep 17 00:00:00 2001 From: Thomas Parisot Date: Thu, 28 Feb 2019 17:12:38 +0100 Subject: [PATCH] Add filters and sorting in dataset_list.html --- frontend/dataset_list.html | 32 ++++++++++++++++--- .../js/angular/controller_dataset_list.js | 24 ++++++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/frontend/dataset_list.html b/frontend/dataset_list.html index a79dff51..3c9c6944 100644 --- a/frontend/dataset_list.html +++ b/frontend/dataset_list.html @@ -123,14 +123,24 @@

{{objCountry[0].name}}

-
+ + +
+
+ + +
+
+
+
+
@@ -138,9 +148,23 @@

{{objCountry[0].name}}

+ + + + - +
Dataset Open data criteria
+
+ + +
+
+
+ + +
+
{{item.name}} {{item.name}} @@ -168,7 +192,7 @@

{{objCountry[0].name}}

- +
{{dataset.title || dataset.name}} {{dataset.institution}} diff --git a/frontend/js/angular/controller_dataset_list.js b/frontend/js/angular/controller_dataset_list.js index e947278b..f47e8fe3 100644 --- a/frontend/js/angular/controller_dataset_list.js +++ b/frontend/js/angular/controller_dataset_list.js @@ -25,6 +25,7 @@ RodiApp.controller('RodiCtrlDatasetList', ['$scope', 'RodiSrv', '$location', '$w $scope.idCountry = $location.search().idcountry; $scope.idDatasetCat = $location.search().idcategory || 0; $scope.bLoading = true; + $scope.datasetSearchFilter = ""; $scope.bNoDataset = false; $scope.bPopUpDetails = false; $scope.datasetsByCategory = []; @@ -36,6 +37,9 @@ RodiApp.controller('RodiCtrlDatasetList', ['$scope', 'RodiSrv', '$location', '$w $scope.datasets_restricted_count = 0; $scope.datasets_closed_count = 0; $scope.datasets_unknown_count = 0; + $scope.sortField = "-openness"; + $scope.sortPredicate = ['-openness', 'name']; + $scope.questions = RodiSrv.getQuestions(); @@ -163,6 +167,26 @@ RodiApp.controller('RodiCtrlDatasetList', ['$scope', 'RodiSrv', '$location', '$w } + $scope.sortBy = function(property, alias) { + $scope.sortField = alias || property; + $scope.sortPredicate = property; + } + + $scope.byDatasetTitle = function (item) { + if (!$scope.datasetSearchFilter.trim()) { + return true; + } + + var term = $scope.datasetSearchFilter.toLowerCase(); + var titles = [item.title, item.name].concat((item.datasets || []).map(function(item){ + return item.title || item.name; + })).filter(function(title){ return title }); + + return titles.some(function(title) { + return Boolean(title.toLowerCase().match(term)); + }); + }; + $scope.setFilterMode = function($event, type) { $event.preventDefault(); $scope.filterMode = type;