Commit 50d191bc434488e45fdd75997590bd2651d40bf7
1 parent
4df97dc0
Exists in
master
and in
2 other branches
refactoring profile load and edit
Showing
10 changed files
with
122 additions
and
125 deletions
Show diff stats
www/html/_edit_profile.html
| 1 | 1 | <div id="profile" class="modal"> |
| 2 | 2 | <ion-content> |
| 3 | - <form ng-submit="updateProfile(data)" novalidate> | |
| 3 | + <form ng-submit="updateProfile(profile)" novalidate> | |
| 4 | 4 | <h1 class="title"> |
| 5 | 5 | <span>Editar Perfil</span> |
| 6 | 6 | <a class="back icon-left ion-reply" ng-click="closeEditProfile()">Voltar</a> |
| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | <div class="list"> |
| 10 | 10 | <div class="list list-inset"> |
| 11 | 11 | <label class="item item-input"> |
| 12 | - <input type="text" placeholder="Nome" ng-model="data.name" /> | |
| 12 | + <input type="text" placeholder="Nome" ng-model="profile.name" /> | |
| 13 | 13 | </label> |
| 14 | 14 | |
| 15 | 15 | <ng-include src="'html/_signup_person_fields.html'"></ng-include> | ... | ... |
www/html/_login.html
| ... | ... | @@ -31,7 +31,7 @@ |
| 31 | 31 | |
| 32 | 32 | <!-- Login form --> |
| 33 | 33 | |
| 34 | - <form ng-submit="Login(data)" ng-show="loginFormDisplayed" id="login-form"> | |
| 34 | + <form ng-submit="Login(profile)" ng-show="loginFormDisplayed" id="login-form"> | |
| 35 | 35 | <h1 class="title"> |
| 36 | 36 | <span>Entrar</span> |
| 37 | 37 | <a class="back icon-left ion-reply" ng-click="backToLoginHome()">Voltar</a> |
| ... | ... | @@ -41,11 +41,11 @@ |
| 41 | 41 | <div class="list list-inset"> |
| 42 | 42 | |
| 43 | 43 | <label class="item item-input"> |
| 44 | - <input type="text" placeholder="Usuário" ng-model="data.login"> | |
| 44 | + <input type="text" placeholder="Usuário" ng-model="profile.login"> | |
| 45 | 45 | </label> |
| 46 | 46 | |
| 47 | 47 | <label class="item item-input"> |
| 48 | - <input type="password" placeholder="Senha" ng-model="data.password"> | |
| 48 | + <input type="password" placeholder="Senha" ng-model="profile.password"> | |
| 49 | 49 | </label> |
| 50 | 50 | |
| 51 | 51 | </div> |
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | </p> |
| 55 | 55 | |
| 56 | 56 | <div class="login-actions"> |
| 57 | - <a ng-click="forgotPassword(data.login)">Esqueceu a senha?</a> | |
| 57 | + <a ng-click="forgotPassword(profile.login)">Esqueceu a senha?</a> | |
| 58 | 58 | <a ng-click="displayRegisterForm('user')">Criar conta</a></p> |
| 59 | 59 | </div> |
| 60 | 60 | </div> |
| ... | ... | @@ -62,7 +62,7 @@ |
| 62 | 62 | |
| 63 | 63 | <!-- Register form --> |
| 64 | 64 | |
| 65 | - <form ng-submit="Register(data)" ng-show="registerFormDisplayed" class="register-form" novalidate id="register-form"> | |
| 65 | + <form ng-submit="Register(profile)" ng-show="registerFormDisplayed" class="register-form" novalidate id="register-form"> | |
| 66 | 66 | <h1 class="title"> |
| 67 | 67 | <span>Registrar</span> |
| 68 | 68 | <a class="back icon-left ion-reply" ng-click="backToLoginHome()">Voltar</a> |
| ... | ... | @@ -72,12 +72,12 @@ |
| 72 | 72 | <div class="list list-inset"> |
| 73 | 73 | |
| 74 | 74 | <label class="item item-input"> |
| 75 | - <input type="text" placeholder="E-mail" ng-model="data.email" required ng-blur="setLoginBasedOnEmail()" | |
| 75 | + <input type="text" placeholder="E-mail" ng-model="profile.email" required ng-blur="setLoginBasedOnEmail()" | |
| 76 | 76 | onblur="var $l=document.getElementById('lf'); if ($l.value == '') $l.value=ConfJuvAppUtils.normalizeLogin(this.value);"> |
| 77 | 77 | </label> |
| 78 | 78 | |
| 79 | 79 | <label class="item item-input"> |
| 80 | - <input type="text" id="lf" placeholder="Nome de usuário" required ng-model="data.login" | |
| 80 | + <input type="text" id="lf" placeholder="Nome de usuário" required ng-model="profile.login" | |
| 81 | 81 | onchange="this.value=ConfJuvAppUtils.normalizeLogin(this.value)"> |
| 82 | 82 | </label> |
| 83 | 83 | <p><small>Espaços, letras maiúsculas ou acentos <b>não</b> são permitidos</small></p> |
| ... | ... | @@ -88,8 +88,8 @@ |
| 88 | 88 | |
| 89 | 89 | <p class="disclaimer">Ao se cadastrar, você concorda com os <span onclick="window.open(ConfJuvAppConfig.noosferoApiHost + '/site/terms', '_system')">Termos de Uso do Juventude.gov.br</span> e com o <span onclick="window.open(ConfJuvAppConfig.noosferoApiHost + '/' + ConfJuvAppConfig.noosferoStatutePath, '_system')">Regimento da Conferência</span></p> |
| 90 | 90 | |
| 91 | - <label class="item item-input"><input type="password" placeholder="Senha" ng-model="data.password"></label> | |
| 92 | - <label class="item item-input"><input type="password" placeholder="Confirmar senha" ng-model="data.password_confirmation"></label> | |
| 91 | + <label class="item item-input"><input type="password" placeholder="Senha" ng-model="profile.password"></label> | |
| 92 | + <label class="item item-input"><input type="password" placeholder="Confirmar senha" ng-model="profile.password_confirmation"></label> | |
| 93 | 93 | |
| 94 | 94 | </div> |
| 95 | 95 | ... | ... |
www/html/_profile.html
| ... | ... | @@ -13,5 +13,17 @@ |
| 13 | 13 | |
| 14 | 14 | <h2>Região</h2> |
| 15 | 15 | <p>{{profile.region.full_name}}</p> |
| 16 | + | |
| 17 | + <h2>Orientação Sexual</h2> | |
| 18 | + <p>{{profile.orientacao_sexual | orientacaoSexualFilter }}</p> | |
| 19 | + | |
| 20 | + <h2>Identidade de Gênero</h2> | |
| 21 | + <p>{{profile.identidade_genero | generoFilter }}</p> | |
| 22 | + | |
| 23 | + <h2>Etnia</h2> | |
| 24 | + <p>{{profile.etnia | etniaFilter}}</p> | |
| 25 | + | |
| 26 | + <h2><span ng-show="profile.transgenero == 'false'">Não</span> Sou transgênero</h2> | |
| 27 | + | |
| 16 | 28 | </ion-content> |
| 17 | 29 | </div> | ... | ... |
www/html/_right_sidebar.html
| ... | ... | @@ -4,19 +4,19 @@ |
| 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 | - <h3 ng-show="user.region"> | |
| 8 | - Mostrar apenas propostas de {{user.region.full_name}} | |
| 7 | + <h3 ng-show="profile.region"> | |
| 8 | + Mostrar apenas propostas de {{profile.region.full_name}} | |
| 9 | 9 | <label class="checkbox my-city-cbox checkbox-balanced"> |
| 10 | 10 | <input type="checkbox" ng-click="loadProposalsOfMyCity()" /> |
| 11 | 11 | </label> |
| 12 | 12 | </h3> |
| 13 | - <form ng-submit="updateProfile(data)"> | |
| 14 | - <h3 ng-show="!user.region" class="choose-city"> | |
| 13 | + <form ng-submit="updateProfile(profile)"> | |
| 14 | + <h3 ng-show="!profile.region" class="choose-city"> | |
| 15 | 15 | <a ng-click="loadStates()">Escolha a sua cidade</a> |
| 16 | 16 | <ng-include ng-show="states.length != 0" src="'html/_select_state.html'"></ng-include> |
| 17 | 17 | </h3> |
| 18 | 18 | |
| 19 | - <p class="text-center" style="clear: both;" ng-show="!user.region && (cities.length != 0)"> | |
| 19 | + <p class="text-center" style="clear: both;" ng-show="!profile.region && (cities.length != 0)"> | |
| 20 | 20 | <button class="button" type="submit">Salvar</button> |
| 21 | 21 | </p> |
| 22 | 22 | ... | ... |
www/html/_select_city.html
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | <div class="input-label"> |
| 3 | 3 | Cidade |
| 4 | 4 | </div> |
| 5 | - <select ng-model="data.city" ng-value="city.id" ng-options="city.name for city in cities track by city.id" class="item"> | |
| 5 | + <select ng-model="profile.city" ng-value="profile.city.id" ng-options="city.name for city in cities track by city.id" class="item"> | |
| 6 | 6 | <option value="">Escolha a cidade...</option> |
| 7 | 7 | </select> |
| 8 | 8 | </label> | ... | ... |
www/html/_select_state.html
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | <div class="input-label"> |
| 3 | 3 | Estado |
| 4 | 4 | </div> |
| 5 | - <select ng-model="data.state" ng-value="state.id" ng-change="loadCitiesByState(data.state.id)" ng-options="state.name for state in states track by state.id" class="item"> | |
| 5 | + <select ng-model="profile.state" ng-value="state" ng-change="loadCitiesByState(profile.state.id)" ng-options="state.name for state in states track by state.id" class="item"> | |
| 6 | 6 | <option value="">Escolha o estado...</option> |
| 7 | 7 | </select> |
| 8 | 8 | </label> | ... | ... |
www/html/_signup_person_fields.html
| ... | ... | @@ -2,12 +2,12 @@ |
| 2 | 2 | <div> |
| 3 | 3 | <label> |
| 4 | 4 | <div class="input-label"> |
| 5 | - Identidade de Gênero | |
| 5 | + Identidade de Gênero | |
| 6 | 6 | </div> |
| 7 | - <select ng-model="data.identidade_genero" required class="item"> | |
| 7 | + <select ng-model="profile.identidade_genero" required class="item"> | |
| 8 | 8 | <option value="">Identidade de Gênero</option> |
| 9 | - <option value="1">Masculino</option> | |
| 10 | - <option value="2">Feminino</option> | |
| 9 | + <option value="1">{{ 1 | generoFilter }}</option> | |
| 10 | + <option value="2">{{ 2 | generoFilter }}</option> | |
| 11 | 11 | </select> |
| 12 | 12 | </label> |
| 13 | 13 | </div> |
| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | <ul class="list" id="transgender"> |
| 17 | 17 | <li class="item item-checkbox"> |
| 18 | 18 | <label class="checkbox"> |
| 19 | - <input type="checkbox" ng-model="data.transgenero" class="ckbox"> | |
| 19 | + <input type="checkbox" ng-model="profile.transgenero" ng-true-value="'true'" class="ckbox"> | |
| 20 | 20 | </label> |
| 21 | 21 | Sou transgênero |
| 22 | 22 | </li> |
| ... | ... | @@ -28,13 +28,13 @@ |
| 28 | 28 | <div class="input-label"> |
| 29 | 29 | Raça/Etnia |
| 30 | 30 | </div> |
| 31 | - <select ng-model="data.etnia" required class="item"> | |
| 31 | + <select ng-model="profile.etnia" required class="item" > | |
| 32 | 32 | <option value="">Raça / Etnia</option> |
| 33 | - <option value="1">Pardo</option> | |
| 34 | - <option value="2">Preto</option> | |
| 35 | - <option value="3">Branco</option> | |
| 36 | - <option value="4">Indígena</option> | |
| 37 | - <option value="5">Amarelo</option> | |
| 33 | + <option value="1">{{ 1 | etniaFilter}}</option> | |
| 34 | + <option value="2">{{ 2 | etniaFilter}}</option> | |
| 35 | + <option value="3">{{ 3 | etniaFilter}}</option> | |
| 36 | + <option value="4">{{ 4 | etniaFilter}}</option> | |
| 37 | + <option value="5">{{ 5 | etniaFilter}}</option> | |
| 38 | 38 | </select> |
| 39 | 39 | </label> |
| 40 | 40 | </div> |
| ... | ... | @@ -44,12 +44,12 @@ |
| 44 | 44 | <div class="input-label"> |
| 45 | 45 | Orientação Sexual |
| 46 | 46 | </div> |
| 47 | - <select ng-model="data.orientacao_sexual" required class="item"> | |
| 47 | + <select ng-model="profile.orientacao_sexual" required class="item"> | |
| 48 | 48 | <option value="">Orientação Sexual</option> |
| 49 | - <option value="1">Homosexual</option> | |
| 50 | - <option value="2">Heterosexual</option> | |
| 51 | - <option value="3">Bisexual</option> | |
| 52 | - <option value="4">Assexual</option> | |
| 49 | + <option value="1">{{ 1 | orientacaoSexualFilter}}</option> | |
| 50 | + <option value="2">{{ 2 | orientacaoSexualFilter}}</option> | |
| 51 | + <option value="3">{{ 3 | orientacaoSexualFilter}}</option> | |
| 52 | + <option value="4">{{ 4 | orientacaoSexualFilter}}</option> | |
| 53 | 53 | </select> |
| 54 | 54 | </label> |
| 55 | 55 | </div> | ... | ... |
www/index.html
| ... | ... | @@ -48,7 +48,7 @@ |
| 48 | 48 | </ion-side-menu-content> |
| 49 | 49 | |
| 50 | 50 | <ion-side-menu side="right" aside-expose-right="large"> |
| 51 | - <ng-include src="'html/_right_sidebar.html?10'"></ng-include> | |
| 51 | + <ng-include src="'html/_right_sidebar.html?11'"></ng-include> | |
| 52 | 52 | </ion-side-menu> |
| 53 | 53 | </ion-side-menus> |
| 54 | 54 | ... | ... |
www/js/controllers.js
| ... | ... | @@ -34,7 +34,7 @@ angular.module('confjuvapp.controllers', []) |
| 34 | 34 | // Function to open the modal |
| 35 | 35 | $scope.openModal = function() { |
| 36 | 36 | if (ConfJuvAppUtils.getPrivateToken()) { |
| 37 | - $scope.loadMe(); | |
| 37 | + $scope.loadProfile(); | |
| 38 | 38 | } else if ($scope.modal) { |
| 39 | 39 | $scope.modal.show(); |
| 40 | 40 | } else { |
| ... | ... | @@ -88,6 +88,7 @@ angular.module('confjuvapp.controllers', []) |
| 88 | 88 | // Function to logout |
| 89 | 89 | $scope.logout = function() { |
| 90 | 90 | ConfJuvAppUtils.setPrivateToken(null); |
| 91 | + $scope.profile = null; | |
| 91 | 92 | $scope.openModal(); |
| 92 | 93 | }; |
| 93 | 94 | |
| ... | ... | @@ -120,7 +121,7 @@ angular.module('confjuvapp.controllers', []) |
| 120 | 121 | .then(function(resp) { |
| 121 | 122 | $scope.closeModal(); |
| 122 | 123 | var popup = $ionicPopup.alert({ title: 'Login', template: 'Login efetuado com sucesso!' }); |
| 123 | - $scope.user = resp.data.person; | |
| 124 | + $scope.profile = resp.data.person; | |
| 124 | 125 | popup.then(function() { |
| 125 | 126 | $scope.loginCallback(resp.data.private_token); |
| 126 | 127 | }); |
| ... | ... | @@ -219,7 +220,6 @@ angular.module('confjuvapp.controllers', []) |
| 219 | 220 | }, |
| 220 | 221 | timeout: 10000 |
| 221 | 222 | } |
| 222 | - | |
| 223 | 223 | var params = { |
| 224 | 224 | 'email': data.email, |
| 225 | 225 | 'login': data.login, |
| ... | ... | @@ -273,56 +273,6 @@ angular.module('confjuvapp.controllers', []) |
| 273 | 273 | }); |
| 274 | 274 | }; |
| 275 | 275 | |
| 276 | - // Load Me | |
| 277 | - $scope.loadMe = function() { | |
| 278 | - $scope.loading = true; | |
| 279 | - | |
| 280 | - var params = '?private_token=' + ConfJuvAppUtils.getPrivateToken(), | |
| 281 | - path = 'people/me/' + params; | |
| 282 | - | |
| 283 | - $http.get(ConfJuvAppUtils.pathTo(path)) | |
| 284 | - .then(function(resp) { | |
| 285 | - $scope.user = resp.data.person; | |
| 286 | - $scope.loginCallback(ConfJuvAppUtils.getPrivateToken()); | |
| 287 | - $scope.loading = false; | |
| 288 | - }, function(err) { | |
| 289 | - $scope.token = ConfJuvAppUtils.setPrivateToken(null); | |
| 290 | - $scope.loggedIn = false; | |
| 291 | - var popup = $ionicPopup.alert({ title: 'Usuário', template: 'Sessão expirada. Por favor faça login novamente.' }); | |
| 292 | - popup.then(function() { | |
| 293 | - $scope.openModal(); | |
| 294 | - }); | |
| 295 | - $scope.loading = false; | |
| 296 | - }); | |
| 297 | - }; | |
| 298 | - | |
| 299 | - // Submit the profile | |
| 300 | - $scope.updateProfile = function(data) { | |
| 301 | - $scope.loading = true; | |
| 302 | - var config = { | |
| 303 | - headers: { | |
| 304 | - 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | |
| 305 | - }, | |
| 306 | - timeout: 10000 | |
| 307 | - }; | |
| 308 | - var params = { | |
| 309 | - 'private_token': $scope.token, | |
| 310 | - 'person[region_id]': data.city.id | |
| 311 | - }; | |
| 312 | - | |
| 313 | - $http.post(ConfJuvAppUtils.pathTo('people/' + $scope.user.id), jQuery.param(params), config) | |
| 314 | - .then(function(resp) { | |
| 315 | - $scope.user = resp.data.person; | |
| 316 | - var popup = $ionicPopup.alert({ title: 'Atualizar Usuário', template: 'Usuário atualizado com sucesso!' }); | |
| 317 | - popup.then(function() { | |
| 318 | - $scope.loading = false; | |
| 319 | - }); | |
| 320 | - }, function(err) { | |
| 321 | - var popup = $ionicPopup.alert({ title: 'Atualizar Usuário', template: 'Erro ao atualizar usuário!' }); | |
| 322 | - $scope.loading = false; | |
| 323 | - }); | |
| 324 | - }; | |
| 325 | - | |
| 326 | 276 | $scope.backToLoginHome = function() { |
| 327 | 277 | $scope.registerFormDisplayed = false; |
| 328 | 278 | $scope.loginFormDisplayed = false; |
| ... | ... | @@ -346,6 +296,9 @@ angular.module('confjuvapp.controllers', []) |
| 346 | 296 | $http.get(ConfJuvAppUtils.pathTo(path)) |
| 347 | 297 | .then(function(resp) { |
| 348 | 298 | $scope.states = resp.data; |
| 299 | + if($scope.profile && $scope.profile.state){ | |
| 300 | + $scope.loadCitiesByState($scope.profile.state.id) | |
| 301 | + } | |
| 349 | 302 | $scope.loading = false; |
| 350 | 303 | }, function(err) { |
| 351 | 304 | $ionicPopup.alert({ title: 'Estados', template: 'Não foi possível carregar os estados' }); |
| ... | ... | @@ -356,7 +309,6 @@ angular.module('confjuvapp.controllers', []) |
| 356 | 309 | // Load Cities |
| 357 | 310 | $scope.loadCitiesByState = function(state_id) { |
| 358 | 311 | $scope.loading = true; |
| 359 | - | |
| 360 | 312 | var path = 'states/' + state_id + '/cities'; |
| 361 | 313 | |
| 362 | 314 | $http.get(ConfJuvAppUtils.pathTo(path)) |
| ... | ... | @@ -430,7 +382,7 @@ angular.module('confjuvapp.controllers', []) |
| 430 | 382 | $scope.loadProposalsOfMyCity = function() { |
| 431 | 383 | $scope.loading = true; |
| 432 | 384 | if($scope.proposalsFilter == ''){ |
| 433 | - $scope.proposalsFilter = '&categories_ids=' + $scope.user.region.id; | |
| 385 | + $scope.proposalsFilter = '&categories_ids=' + $scope.profile.region.id; | |
| 434 | 386 | }else{ |
| 435 | 387 | $scope.proposalsFilter = ''; |
| 436 | 388 | } |
| ... | ... | @@ -647,7 +599,7 @@ angular.module('confjuvapp.controllers', []) |
| 647 | 599 | body: data.description, |
| 648 | 600 | topic: topic, |
| 649 | 601 | categories: [data.city, data.state], |
| 650 | - author: { name: $scope.user.name, id: $scope.user.id } | |
| 602 | + author: { name: $scope.profile.name, id: $scope.profile.id } | |
| 651 | 603 | }; |
| 652 | 604 | $scope.cards.push(proposal); |
| 653 | 605 | $scope.myProposals.push(proposal); |
| ... | ... | @@ -741,7 +693,7 @@ angular.module('confjuvapp.controllers', []) |
| 741 | 693 | if (!$scope.proposal.comments) { |
| 742 | 694 | $scope.proposal.comments = []; |
| 743 | 695 | } |
| 744 | - $scope.proposal.comments.unshift({ body: params.body, author: { name: $scope.user.name }}); | |
| 696 | + $scope.proposal.comments.unshift({ body: params.body, author: { name: $scope.profile.name }}); | |
| 745 | 697 | $scope.commentStatus = ''; |
| 746 | 698 | popup.then(function() { |
| 747 | 699 | $scope.loading = false; |
| ... | ... | @@ -1199,19 +1151,25 @@ angular.module('confjuvapp.controllers', []) |
| 1199 | 1151 | |
| 1200 | 1152 | $scope.profile = null; |
| 1201 | 1153 | |
| 1154 | + // Load Profile | |
| 1202 | 1155 | $scope.loadProfile = function() { |
| 1203 | 1156 | $scope.loading = true; |
| 1204 | 1157 | |
| 1205 | - var path = 'people/me?private_token=' + ConfJuvAppUtils.getPrivateToken(); | |
| 1158 | + var params = '?private_token=' + ConfJuvAppUtils.getPrivateToken(), | |
| 1159 | + path = 'people/me/' + params; | |
| 1206 | 1160 | |
| 1207 | 1161 | $http.get(ConfJuvAppUtils.pathTo(path)) |
| 1208 | 1162 | .then(function(resp) { |
| 1209 | 1163 | $scope.profile = resp.data.person; |
| 1210 | - if ($scope.data == null) $scope.data = {}; | |
| 1211 | - $scope.data.name = $scope.profile.name; | |
| 1164 | + $scope.loginCallback(ConfJuvAppUtils.getPrivateToken()); | |
| 1212 | 1165 | $scope.loading = false; |
| 1213 | 1166 | }, function(err) { |
| 1214 | - $ionicPopup.alert({ title: 'Perfil', template: 'Não foi possível carregar o perfil' }); | |
| 1167 | + $scope.token = ConfJuvAppUtils.setPrivateToken(null); | |
| 1168 | + $scope.loggedIn = false; | |
| 1169 | + var popup = $ionicPopup.alert({ title: 'Usuário', template: 'Sessão expirada. Por favor faça login novamente.' }); | |
| 1170 | + popup.then(function() { | |
| 1171 | + $scope.openModal(); | |
| 1172 | + }); | |
| 1215 | 1173 | $scope.loading = false; |
| 1216 | 1174 | }); |
| 1217 | 1175 | }; |
| ... | ... | @@ -1274,7 +1232,7 @@ angular.module('confjuvapp.controllers', []) |
| 1274 | 1232 | $scope.editProfileModal.remove(); |
| 1275 | 1233 | }); |
| 1276 | 1234 | |
| 1277 | - $scope.updateProfile = function(data) { | |
| 1235 | + $scope.updateProfile = function(profile) { | |
| 1278 | 1236 | $scope.loading = true; |
| 1279 | 1237 | |
| 1280 | 1238 | var config = { |
| ... | ... | @@ -1282,22 +1240,25 @@ angular.module('confjuvapp.controllers', []) |
| 1282 | 1240 | 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', |
| 1283 | 1241 | }, |
| 1284 | 1242 | timeout: 10000 |
| 1285 | - } | |
| 1243 | + }; | |
| 1286 | 1244 | |
| 1287 | 1245 | var params = { |
| 1288 | 1246 | 'private_token': $scope.token, |
| 1289 | - 'person[name]': data.name, | |
| 1290 | - 'person[orientacao_sexual]': data.orientacao_sexual, | |
| 1291 | - 'person[identidade_genero]': data.identidade_genero, | |
| 1292 | - 'person[transgenero]': data.transgenero, | |
| 1293 | - 'person[etnia]': data.etnia, | |
| 1294 | - 'person[city]': data.city.id | |
| 1247 | + 'person[name]': profile.name, | |
| 1248 | + 'person[orientacao_sexual]': profile.orientacao_sexual, | |
| 1249 | + 'person[identidade_genero]': profile.identidade_genero, | |
| 1250 | + 'person[transgenero]': profile.transgenero, | |
| 1251 | + 'person[etnia]': profile.etnia, | |
| 1252 | + 'person[city]': profile.city.id | |
| 1295 | 1253 | }; |
| 1296 | 1254 | |
| 1297 | - $http.post(ConfJuvAppUtils.pathTo('people'), jQuery.param(params), config) | |
| 1255 | + $http.post(ConfJuvAppUtils.pathTo('people/' + $scope.profile.id), jQuery.param(params), config) | |
| 1298 | 1256 | .then(function(resp) { |
| 1299 | - $scope.profile = { name: data.name }; | |
| 1300 | - $ionicPopup.alert({ title: 'Perfil', template: 'Perfil atualizado com sucesso' }); | |
| 1257 | + $scope.profile = resp.data.person; | |
| 1258 | + var popup = $ionicPopup.alert({ title: 'Perfil', template: 'Perfil atualizado com sucesso' }); | |
| 1259 | + popup.then(function() { | |
| 1260 | + $scope.loading = false; | |
| 1261 | + }); | |
| 1301 | 1262 | $scope.loading = false; |
| 1302 | 1263 | }, function(err) { |
| 1303 | 1264 | $ionicPopup.alert({ title: 'Perfil', template: 'Erro ao atualizar perfil' }); |
| ... | ... | @@ -1322,26 +1283,21 @@ angular.module('confjuvapp.controllers', []) |
| 1322 | 1283 | timeout: 10000 |
| 1323 | 1284 | }; |
| 1324 | 1285 | |
| 1325 | - var path = 'articles?private_token=' + $scope.token + '&fields=title,image,body,abstract,id,tag_list,categories,created_by&content_type=ProposalsDiscussionPlugin::Proposal&_=' + (new Date().getTime()) + '&parent_id='; | |
| 1286 | + var path = 'articles?private_token=' + $scope.token + '&fields=title,image,body,abstract,id,tag_list,categories,created_by&content_type=ProposalsDiscussionPlugin::Proposal&_=' + (new Date().getTime()) + '&author_id=' + $scope.profile.id + '&parent_id[]='; | |
| 1326 | 1287 | |
| 1327 | 1288 | for (var i = 0; i < $scope.topics.length; i++) { |
| 1328 | - $scope.loading = true; | |
| 1329 | - | |
| 1330 | - $http.get(ConfJuvAppUtils.pathTo(path + $scope.topics[i].id), config) | |
| 1331 | - .then(function(resp) { | |
| 1332 | - var articles = resp.data.articles; | |
| 1333 | - for (var j = 0; j < articles.length; j++) { | |
| 1334 | - var article = articles[j]; | |
| 1335 | - if (article.author.id === $scope.user.id) { | |
| 1336 | - $scope.myProposals.push(article); | |
| 1337 | - $scope.cards = $scope.myProposals.slice(); | |
| 1338 | - } | |
| 1339 | - } | |
| 1340 | - $scope.loading = false; | |
| 1341 | - }, function(err) { | |
| 1342 | - $scope.loading = false; | |
| 1343 | - }); | |
| 1344 | - } | |
| 1289 | + path += '&parent_id[]=' + $scope.topics[i].id; | |
| 1290 | + } | |
| 1291 | + $scope.loading = true; | |
| 1292 | + | |
| 1293 | + $http.get(ConfJuvAppUtils.pathTo(path), config) | |
| 1294 | + .then(function(resp) { | |
| 1295 | + $scope.myProposals = resp.data.articles; | |
| 1296 | + $scope.cards = $scope.myProposals.slice(); | |
| 1297 | + $scope.loading = false; | |
| 1298 | + }, function(err) { | |
| 1299 | + $scope.loading = false; | |
| 1300 | + }); | |
| 1345 | 1301 | } |
| 1346 | 1302 | else { |
| 1347 | 1303 | $scope.cards = $scope.myProposals.slice(); | ... | ... |
www/js/filters.js
| ... | ... | @@ -17,4 +17,33 @@ filter('tagFilter', function() { |
| 17 | 17 | return function(text) { |
| 18 | 18 | return String(text).replace(/#/gm, ''); |
| 19 | 19 | }; |
| 20 | +}). | |
| 21 | +filter('etniaFilter', function() { | |
| 22 | + return function(type) { | |
| 23 | + var etnia = {}; | |
| 24 | + etnia[1] = 'Pardo'; | |
| 25 | + etnia[2] = 'Preto'; | |
| 26 | + etnia[3] = 'Branco'; | |
| 27 | + etnia[4] = 'Indígena'; | |
| 28 | + etnia[5] = 'Amarelo'; | |
| 29 | + return etnia[type]; | |
| 30 | + }; | |
| 31 | +}). | |
| 32 | +filter('orientacaoSexualFilter', function() { | |
| 33 | + return function(type) { | |
| 34 | + var orientacao = {}; | |
| 35 | + orientacao[1] = 'Homosexual'; | |
| 36 | + orientacao[2] = 'Heterosexual'; | |
| 37 | + orientacao[3] = 'Bisexual'; | |
| 38 | + orientacao[4] = 'Assexual'; | |
| 39 | + return orientacao[type]; | |
| 40 | + }; | |
| 41 | +}). | |
| 42 | +filter('generoFilter', function() { | |
| 43 | + return function(type) { | |
| 44 | + var genero = {}; | |
| 45 | + genero[1] = 'Masculino'; | |
| 46 | + genero[2] = 'Feminino'; | |
| 47 | + return genero[type]; | |
| 48 | + }; | |
| 20 | 49 | }); | ... | ... |