Commit 42f300feb26ec62d63ff746ef0149f1385ca8245
1 parent
59cec6c6
Exists in
master
and in
2 other branches
Adding city filter
Showing
2 changed files
with
39 additions
and
7 deletions
Show diff stats
ConfJuvApp/www/html/_right_sidebar.html
... | ... | @@ -4,18 +4,23 @@ |
4 | 4 | <span>Filtros</span> |
5 | 5 | <button menu-toggle="right" class="button button-icon icon ion-close-circled" hide-when="large"></button> |
6 | 6 | </h2> |
7 | - <!-- Uncomment when backend is ready | |
8 | - <h3> | |
7 | + <h3 ng-show="user.region"> | |
9 | 8 | Mostrar apenas propostas de {{user.region.full_name}} |
10 | 9 | <label class="checkbox my-city-cbox checkbox-balanced"> |
11 | 10 | <input type="checkbox" ng-click="loadProposalsOfMyCity()" /> |
12 | 11 | </label> |
13 | 12 | </h3> |
14 | - <h3 ng-show="!user.region" class="choose-city"> | |
15 | - <a ng-click="loadStates()">Escolha a sua cidade</a> | |
16 | - <ng-include ng-show="states.length != 0" src="'html/_select_state.html'"></ng-include> | |
17 | - </h3> | |
18 | - --> | |
13 | + <form ng-submit="updateProfile(data)"> | |
14 | + <h3 ng-show="!user.region" class="choose-city"> | |
15 | + <a ng-click="loadStates()">Escolha a sua cidade</a> | |
16 | + <ng-include ng-show="states.length != 0" src="'html/_select_state.html'"></ng-include> | |
17 | + </h3> | |
18 | + | |
19 | + <p class="text-center" style="clear: both;" ng-show="!user.region && (cities.length != 0)"> | |
20 | + <button class="button" type="submit">Save</button> | |
21 | + </p> | |
22 | + | |
23 | + </form> | |
19 | 24 | <h3>Mostrar apenas propostas do eixo:</h3> |
20 | 25 | <ion-radio class="radio-balanced" ng-value="'all'" ng-model="topicFilter.value" ng-click="$parent.reloadProposals()">Todos</ion-radio> |
21 | 26 | <label ng-repeat="topic in topics"> | ... | ... |
ConfJuvApp/www/js/controllers.js
... | ... | @@ -283,6 +283,33 @@ angular.module('confjuvapp.controllers', []) |
283 | 283 | }); |
284 | 284 | }; |
285 | 285 | |
286 | + // Submit the profile | |
287 | + $scope.updateProfile = function(data) { | |
288 | + $scope.loading = true; | |
289 | + var config = { | |
290 | + headers: { | |
291 | + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | |
292 | + }, | |
293 | + timeout: 10000 | |
294 | + }; | |
295 | + var params = { | |
296 | + 'private_token': $scope.token, | |
297 | + 'person[region_id]': data.city.id | |
298 | + }; | |
299 | + | |
300 | + $http.post(ConfJuvAppUtils.pathTo('people/' + $scope.user.id), jQuery.param(params), config) | |
301 | + .then(function(resp) { | |
302 | + $scope.user = resp.data.person; | |
303 | + var popup = $ionicPopup.alert({ title: 'Atualizar Usuário', template: 'Usuário atualizado com sucesso!' }); | |
304 | + popup.then(function() { | |
305 | + $scope.loading = false; | |
306 | + }); | |
307 | + }, function(err) { | |
308 | + var popup = $ionicPopup.alert({ title: 'Atualizar Usuário', template: 'Erro ao atualizar usuário!' }); | |
309 | + $scope.loading = false; | |
310 | + }); | |
311 | + }; | |
312 | + | |
286 | 313 | $scope.backToLoginHome = function() { |
287 | 314 | $scope.registerFormDisplayed = false; |
288 | 315 | $scope.loginFormDisplayed = false; | ... | ... |