Commit 61267f5d911a45ad4d6e7f4d3b0fd8d912dcd14d

Authored by Caio Almeida
1 parent e0b7f461

Ticket #58: Fixing edit proposal

www/html/_edit_proposal.html
... ... @@ -9,17 +9,8 @@
9 9 <label class="item item-input"><input type="text" placeholder="Título" ng-model="data.title" maxlength="40"></label>
10 10 <label class="item item-input"><textarea placeholder="Descrição" ng-model="data.description"></textarea></label>
11 11  
12   - <ng-include src="'html/_select_state.html'"></ng-include>
  12 + <ng-include src="'html/_select_proposal_state.html'"></ng-include>
13 13  
14   - <label id="proposal-topic">
15   - <div class="input-label">
16   - Eixo
17   - </div>
18   - <select ng-model="data.topic_id" id="select-topic" ng-value="topic.id" ng-options="topic.title for topic in topics track by topic.id">
19   - <option value="">Escolha o eixo...</option>
20   - </select>
21   - </label>
22   -
23 14 <label class="checkbox free-conference-cbox">
24 15 <input type="checkbox" ng-model="data.free_conference" >
25 16 </label>
... ...
www/html/_left_sidebar.html
1 1 <div id="left-sidebar" class="sidebar" menu-toggle="left">
2 2 <ion-content>
3 3 <h2>
4   - <span>{{user.name}}</span>
  4 + <span>{{profile.login}}</span>
5 5 <button menu-toggle="left" class="button button-icon icon ion-close-circled"></button>
6 6 </h2>
7 7 <ul class="list" ng-show="loggedIn">
... ...
www/html/_proposal.html
... ... @@ -12,16 +12,16 @@
12 12 <span id="proposal-id" style="display: none;">{{proposal.id}}</span>
13 13  
14 14 <p class="proposal-buttons">
15   - <button class="button tag" ng-click="openTagForm()" ng-show="proposal.author.id == user.id">
  15 + <button class="button tag" ng-click="openTagForm()" ng-show="proposal.author.id == profile.id">
16 16 <i class="icon ion-pricetags"></i> <span>Adicionar Tag</span>
17 17 </button>
18   - <button class="button edit" ng-click="openEditProposalForm()" ng-show="proposal.author.id == user.id">
  18 + <button class="button edit" ng-click="openEditProposalForm()" ng-show="proposal.author.id == profile.id">
19 19 <i class="icon ion-edit"></i> <span>Editar</span>
20 20 </button>
21 21 <button class="button comment" ng-click="openCommentForm()">
22 22 <i class="icon ion-chatbox-working"></i> <span>Comentar</span>
23 23 </button>
24   - <button class="button follow" ng-click="follow(proposal)" ng-hide="isFollowing(proposal) || proposal.author.id == user.id">
  24 + <button class="button follow" ng-click="follow(proposal)" ng-hide="isFollowing(proposal) || proposal.author.id == profile.id">
25 25 <i class="icon ion-eye"></i> <span>Seguir</span>
26 26 </button>
27 27 <br />
... ...
www/html/_proposal_list.html
... ... @@ -52,7 +52,7 @@
52 52 </div>
53 53 <div class="card-footer">
54 54 <a ng-click="openProposal(proposal)" class="icon-left ion-android-open"> Leia Mais</a>
55   - <a ng-click="follow(proposal)" class="icon-left ion-eye" ng-hide="isFollowing(proposal) || proposal.author.id == user.id"> Seguir</a>
  55 + <a ng-click="follow(proposal)" class="icon-left ion-eye" ng-hide="isFollowing(proposal) || proposal.author.id == profile.id"> Seguir</a>
56 56 </div>
57 57 </div>
58 58 </td-card>
... ...
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="profile.city" ng-value="profile.city.id" ng-options="city.name for city in cities track by city.id" class="item">
  5 + <select ng-model="profile.city" ng-value="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_proposal_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="data.city.id" ng-options="city.name for city in cities track by city.id" class="item">
  5 + <select ng-model="data.city" ng-value="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_proposal_state.html
... ... @@ -8,4 +8,3 @@
8 8 </label>
9 9  
10 10 <ng-include src="'html/_select_proposal_city.html'"></ng-include>
11   -
... ...
www/index.html
... ... @@ -35,14 +35,14 @@
35 35  
36 36 <ion-side-menus id="body" ng-show="!introDisplayed">
37 37 <ion-side-menu side="left">
38   - <ng-include src="'html/_left_sidebar.html'"></ng-include>
  38 + <ng-include src="'html/_left_sidebar.html?1'"></ng-include>
39 39 </ion-side-menu>
40 40  
41 41 <ion-side-menu-content>
42 42 <ng-include src="'html/_header.html?2'"></ng-include>
43 43 <ion-pane>
44 44 <ion-content id="proposals-container" no-scroll="">
45   - <ng-include src="'html/_proposal_list.html?9'"></ng-include>
  45 + <ng-include src="'html/_proposal_list.html?10'"></ng-include>
46 46 </ion-content>
47 47 </ion-pane>
48 48 </ion-side-menu-content>
... ...
www/js/controllers.js
... ... @@ -288,7 +288,7 @@ angular.module(&#39;confjuvapp.controllers&#39;, [])
288 288 $scope.shouldDisplayCities = false;
289 289  
290 290 // Load States
291   - $scope.loadStates = function() {
  291 + $scope.loadStates = function(selected) {
292 292 $scope.loading = true;
293 293 $scope.shouldDisplayCities = false;
294 294  
... ... @@ -297,8 +297,11 @@ angular.module(&#39;confjuvapp.controllers&#39;, [])
297 297 $http.get(ConfJuvAppUtils.pathTo(path))
298 298 .then(function(resp) {
299 299 $scope.states = resp.data;
300   - if($scope.profile && $scope.profile.state){
301   - $scope.loadCitiesByState($scope.profile.state.id)
  300 + if (selected) {
  301 + $scope.loadCitiesByState(selected);
  302 + }
  303 + else if ($scope.profile && $scope.profile.state && !selected) {
  304 + $scope.loadCitiesByState($scope.profile.state.id);
302 305 }
303 306 $scope.loading = false;
304 307 }, function(err) {
... ... @@ -450,7 +453,7 @@ angular.module(&#39;confjuvapp.controllers&#39;, [])
450 453 perPage = 11;
451 454 }
452 455  
453   - var params = '?private_token=' + token + '&fields=title,image,body,abstract,id,tag_list,categories,created_by&content_type=ProposalsDiscussionPlugin::Proposal&per_page=' + perPage + '&oldest=younger_than&reference_id=' + topic.lastProposalId + $scope.proposalsFilter;
  456 + var params = '?t=' + (new Date().getTime()) + '&private_token=' + token + '&fields=title,image,body,abstract,id,tag_list,categories,created_by&content_type=ProposalsDiscussionPlugin::Proposal&per_page=' + perPage + '&oldest=younger_than&reference_id=' + topic.lastProposalId + $scope.proposalsFilter;
454 457  
455 458 var path = 'articles/' + topic.id + '/children' + params;
456 459  
... ... @@ -535,7 +538,7 @@ angular.module(&#39;confjuvapp.controllers&#39;, [])
535 538 }
536 539 else {
537 540 // Initiate the modal
538   - $ionicModal.fromTemplateUrl('html/_proposal.html?16', {
  541 + $ionicModal.fromTemplateUrl('html/_proposal.html?17', {
539 542 scope: $scope,
540 543 animation: 'slide-in-up'
541 544 }).then(function(modal) {
... ... @@ -1028,8 +1031,7 @@ angular.module(&#39;confjuvapp.controllers&#39;, [])
1028 1031 $scope.loadCitiesByState($scope.data.state.id);
1029 1032 }
1030 1033 else {
1031   - $scope.loadStates();
1032   - $scope.loadCitiesByState($scope.data.state.id);
  1034 + $scope.loadStates($scope.data.state.id);
1033 1035 // Initiate the modal
1034 1036 $ionicModal.fromTemplateUrl('html/_edit_proposal.html', {
1035 1037 scope: $scope,
... ... @@ -1056,7 +1058,7 @@ angular.module(&#39;confjuvapp.controllers&#39;, [])
1056 1058  
1057 1059 // Submit the updated proposal
1058 1060 $scope.updateProposal = function(data) {
1059   - if (!data || !data.title || !data.description || !data.topic_id) {
  1061 + if (!data || !data.title || !data.description) {
1060 1062 $scope.closeEditProposalModal();
1061 1063 var popup = $ionicPopup.alert({ title: 'Alterar proposta', template: 'Por favor preencha todos os campos!' });
1062 1064 popup.then(function() {
... ... @@ -1100,24 +1102,16 @@ angular.module(&#39;confjuvapp.controllers&#39;, [])
1100 1102  
1101 1103 $http.post(ConfJuvAppUtils.pathTo('articles/' + $scope.proposal.id), jQuery.param(params), config)
1102 1104 .then(function(resp) {
1103   - $scope.closeEditProposalModal();
1104 1105 var popup = $ionicPopup.alert({ title: 'Alterar proposta', template: 'Proposta alterada com sucesso!' });
1105 1106 popup.then(function() {
1106   - var topic = null;
1107   - for (var i = 0; i < $scope.topics.length; i++) {
1108   - if (data.topic_id.id == $scope.topics[i].id) {
1109   - topic = $scope.topics[i];
1110   - }
1111   - }
1112   -
1113 1107 $scope.proposal.categories[0] = data.city;
1114 1108 $scope.proposal.categories[1] = data.state;
1115 1109 $scope.proposal.title = data.title;
1116 1110 $scope.proposal.body = data.description;
1117   - $scope.proposal.topic = data.topic_id;
1118 1111  
1119 1112 $scope.loading = false;
1120 1113 document.getElementById('save-proposal').innerHTML = 'Salvar';
  1114 + $scope.closeEditProposalModal();
1121 1115 });
1122 1116 }, function(err) {
1123 1117 $scope.closeEditProposalModal();
... ...