Commit 5fb9be745eb84907e1672da971eac05a45bc5888
1 parent
4a23d376
Exists in
master
and in
2 other branches
adding state and cities selection
Showing
4 changed files
with
79 additions
and
0 deletions
Show diff stats
ConfJuvApp/www/html/_login.html
@@ -73,6 +73,7 @@ | @@ -73,6 +73,7 @@ | ||
73 | 73 | ||
74 | <label class="item item-input"><input type="text" placeholder="E-mail" ng-model="data.email" required></label> | 74 | <label class="item item-input"><input type="text" placeholder="E-mail" ng-model="data.email" required></label> |
75 | <label class="item item-input"><input type="text" placeholder="Nome de usuário" ng-model="data.login" required></label> | 75 | <label class="item item-input"><input type="text" placeholder="Nome de usuário" ng-model="data.login" required></label> |
76 | + <ng-include src="'html/_select_state.html'"></ng-include> | ||
76 | <label class="item item-input"><input type="password" placeholder="Senha" ng-model="data.password" required></label> | 77 | <label class="item item-input"><input type="password" placeholder="Senha" ng-model="data.password" required></label> |
77 | <label class="item item-input"><input type="password" placeholder="Confirmar senha" ng-model="data.password_confirmation" required></label> | 78 | <label class="item item-input"><input type="password" placeholder="Confirmar senha" ng-model="data.password_confirmation" required></label> |
78 | 79 |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +<div class="list" ng-show="shouldDisplayCities"> | ||
2 | + | ||
3 | + <label class="item item-input item-select"> | ||
4 | + <div class="input-label"> | ||
5 | + Cidade | ||
6 | + </div> | ||
7 | + <select ng-model="cityChoosed" ng-options="city.name for city in cities"> | ||
8 | + <option value="">Selecione uma cidade...</option> | ||
9 | + </select> | ||
10 | + </label> | ||
11 | + | ||
12 | +</div> |
@@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
1 | +<div class="list"> | ||
2 | + | ||
3 | + <label class="item item-input item-select"> | ||
4 | + <div class="input-label"> | ||
5 | + Estado | ||
6 | + </div> | ||
7 | + <select ng-model="stateChoosed" ng-change="loadCitiesByState(stateChoosed.id)" ng-options="state.name for state in states"> | ||
8 | + <option value="">Selecione um estado...</option> | ||
9 | + </select> | ||
10 | + </label> | ||
11 | + | ||
12 | +</div> | ||
13 | + | ||
14 | +<ng-include src="'html/_select_city.html'"></ng-include> | ||
15 | + |
ConfJuvApp/www/js/controllers.js
@@ -115,13 +115,17 @@ angular.module('confjuvapp.controllers', []) | @@ -115,13 +115,17 @@ angular.module('confjuvapp.controllers', []) | ||
115 | $scope.registerFormDisplayed = false; | 115 | $scope.registerFormDisplayed = false; |
116 | 116 | ||
117 | $scope.displayRegisterForm = function() { | 117 | $scope.displayRegisterForm = function() { |
118 | + $scope.loadStates(); | ||
118 | $scope.registerFormDisplayed = true; | 119 | $scope.registerFormDisplayed = true; |
119 | $scope.loginFormDisplayed = false; | 120 | $scope.loginFormDisplayed = false; |
121 | + $scope.loading = false; | ||
120 | }; | 122 | }; |
121 | 123 | ||
122 | // Function to register | 124 | // Function to register |
123 | $scope.Register = function(data) { | 125 | $scope.Register = function(data) { |
126 | +alert('no registro') | ||
124 | if (!data || !data.login || !data.email || !data.password || !data.password_confirmation) { | 127 | if (!data || !data.login || !data.email || !data.password || !data.password_confirmation) { |
128 | +alert('teste'); | ||
125 | $ionicPopup.alert({ title: 'Registrar', template: 'Por favor preencha todos os campos' }); | 129 | $ionicPopup.alert({ title: 'Registrar', template: 'Por favor preencha todos os campos' }); |
126 | return; | 130 | return; |
127 | } | 131 | } |
@@ -168,6 +172,53 @@ angular.module('confjuvapp.controllers', []) | @@ -168,6 +172,53 @@ angular.module('confjuvapp.controllers', []) | ||
168 | }; | 172 | }; |
169 | 173 | ||
170 | /****************************************************************************** | 174 | /****************************************************************************** |
175 | + States > Cities | ||
176 | + ******************************************************************************/ | ||
177 | + | ||
178 | + $scope.states = []; | ||
179 | + $scope.stateChoosed = null; | ||
180 | + $scope.cities = []; | ||
181 | + $scope.cityChoosed = null; | ||
182 | + $scope.shouldDisplayCities = false; | ||
183 | + | ||
184 | + // Load States | ||
185 | + $scope.loadStates = function() { | ||
186 | + $scope.loading = true; | ||
187 | + $scope.shouldDisplayCities = false; | ||
188 | + $scope.stateChoosed = null; | ||
189 | + $scope.cityChoosed = null; | ||
190 | + | ||
191 | + var path = 'states'; | ||
192 | + | ||
193 | + $http.get(ConfJuvAppUtils.pathTo(path)) | ||
194 | + .then(function(resp) { | ||
195 | + $scope.states = resp.data; | ||
196 | + $scope.loading = false; | ||
197 | + }, function(err) { | ||
198 | + $ionicPopup.alert({ title: 'Estados', template: 'Não foi possível carregar os estados' }); | ||
199 | + $scope.loading = false; | ||
200 | + }); | ||
201 | + }; | ||
202 | + | ||
203 | + // Load Cities | ||
204 | + $scope.loadCitiesByState = function(state) { | ||
205 | + $scope.loading = true; | ||
206 | + | ||
207 | + var path = 'states/' + state + '/cities'; | ||
208 | + | ||
209 | + $http.get(ConfJuvAppUtils.pathTo(path)) | ||
210 | + .then(function(resp) { | ||
211 | + $scope.loading = false; | ||
212 | + $scope.cities = resp.data; | ||
213 | + $scope.shouldDisplayCities = true; | ||
214 | + $scope.loading = false; | ||
215 | + }, function(err) { | ||
216 | + $ionicPopup.alert({ title: 'Estados', template: 'Não foi possível carregar as cidades' }); | ||
217 | + $scope.loading = false; | ||
218 | + }); | ||
219 | + }; | ||
220 | + | ||
221 | + /****************************************************************************** | ||
171 | D I S C U S S I O N S > T O P I C S > P R O P O S A L S | 222 | D I S C U S S I O N S > T O P I C S > P R O P O S A L S |
172 | ******************************************************************************/ | 223 | ******************************************************************************/ |
173 | 224 |