Skip to content
Snippets Groups Projects
Commit 0248d779 authored by Eduardo L. Buratti's avatar Eduardo L. Buratti
Browse files

web: Change attendance.search to pull data from server (no fake data)

parent b8a37045
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<ul ng-repeat="filter in filters"> <ul ng-repeat="filter in filters">
<li class="header">{{ filter.title }}:</li> <li class="header">{{ filter.title }}:</li>
<li class="checkbox" ng-repeat="opt in filter.options"> <li class="checkbox" ng-repeat="opt in filter.options">
<label><input type="checkbox" ng-model="opt.value"> {{ opt.title }}</label> <label><input type="checkbox" ng-model="opt.value" ng-click="reload()"> {{ opt.title }}</label>
</li> </li>
<li class="checkbox" ng-show="filter.more"><a href="">outros...</a></li> <li class="checkbox" ng-show="filter.more"><a href="">outros...</a></li>
</ul> </ul>
...@@ -14,16 +14,16 @@ ...@@ -14,16 +14,16 @@
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th style="width: 60%;" ng-click="ordering = 'name'; reverse=!reverse">Nome</th> <th style="width: 60%;" ng-click="setSorting('name')">Nome</th>
<th style="width: 20%;" ng-click="ordering = 'location'; reverse=!reverse">Localização</th> <th style="width: 20%;" ng-click="setSorting('location')">Localização</th>
<th style="width: 20%;" ng-click="ordering = 'project'; reverse=!reverse">Projeto</th> <th style="width: 20%;" ng-click="setSorting('project')">Projeto</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="res in results | filterResults:this | orderBy:ordering:reverse "> <tr ng-repeat="point in points">
<td><a href="">{{ res.name }}</a></td> <td><a href="">{{ point.name }}</a></td>
<td>{{ res.location }}</a></td> <td>{{ point.location }}</a></td>
<td>{{ res.project | projectStr }} </a></td> <td>{{ point.project }} </a></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
...@@ -59,31 +59,22 @@ angular.module('datasid.attendance.search', []). ...@@ -59,31 +59,22 @@ angular.module('datasid.attendance.search', []).
}; };
}). }).
factory('ResultFactory', function($q, $rootScope) { factory('PointsFactory', function($resource) {
return { return $resource('/api/points', {}, {
get: function () { list: {method: 'POST', isArray: true}
var deferred = $q.defer(); });
setTimeout(function () {
$rootScope.$apply(function() {
deferred.resolve(FakeSchools);
});
}, 1);
return deferred.promise;
}
};
}). }).
controller('SearchCtrl', function ($scope, $rootScope, ResultFactory) { controller('SearchCtrl', function ($scope, $rootScope, PointsFactory) {
$scope.filters = [ $scope.filters = [
{ {
key: 'project', key: 'project',
title: 'Projeto', title: 'Projeto',
options: [ options: [
{ key: 0, title: 'Telecentros BR', value: true }, { key: 'TLBR', title: 'TLBR', value: true },
{ key: 1, title: 'GESAC', value: true }, { key: 'TLBR/GESAC', title: 'TLBR/GESAC', value: true },
{ key: 2, title: 'Cidades Digitais', value: true } { key: 'GESAC', title: 'GESAC', value: true },
{ key: 'Cidades Digitais', title: 'Cidades Digitais', value: true }
], ],
more: false more: false
}, },
...@@ -99,8 +90,37 @@ angular.module('datasid.attendance.search', []). ...@@ -99,8 +90,37 @@ angular.module('datasid.attendance.search', []).
} }
]; ];
$scope.results = ResultFactory.get(); $scope.points = [];
$scope.ordering = 'name'; $scope.sorting = 'name';
$scope.reverse = false;
}); $scope.reload = function () {
\ No newline at end of file var filters = {};
for (var i=0; i < $scope.filters.length; i++) {
var filter = $scope.filters[i];
filters[filter.key] = [];
for (var j=0; j < filter.options.length; j++) {
if (filter.options[j].value)
filters[filter.key].push(filter.options[j].key);
}
}
$scope.points = PointsFactory.list({
sorting: $scope.sorting,
page: 0,
filters: filters
});
};
$scope.reload();
$scope.setSorting = function (column) {
if ($scope.sorting === column)
$scope.sorting = '-' + column;
else
$scope.sorting = column;
$scope.reload();
};
});;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment