Commit 98f2f8f7e257268e8a9a27c54e10876f7222d3ff
1 parent
3ea656df
Exists in
master
and in
4 other branches
Fixes #139. Show selected theme when the list is collapsed
Showing
3 changed files
with
66 additions
and
40 deletions
Show diff stats
src/app/components/category-list/category-list.directive.js
@@ -28,19 +28,18 @@ | @@ -28,19 +28,18 @@ | ||
28 | CategoryListController.prototype.init = function() { | 28 | CategoryListController.prototype.init = function() { |
29 | var vm = this; | 29 | var vm = this; |
30 | 30 | ||
31 | - vm.pathUrl = vm.$location.path(); | ||
32 | - | ||
33 | - vm.showCloseBtn = true; | 31 | + vm.isRankingPage = (vm.$location.path() === '/ranking'); |
34 | 32 | ||
35 | // Disable button 'remove' of page ranking | 33 | // Disable button 'remove' of page ranking |
36 | - if (vm.pathUrl === '/ranking') { | 34 | + vm.showCloseBtn = true; |
35 | + if (vm.isRankingPage) { | ||
37 | vm.showCloseBtn = false; | 36 | vm.showCloseBtn = false; |
38 | } | 37 | } |
39 | 38 | ||
40 | // Default values | 39 | // Default values |
41 | - if (!vm.isCollapsed) { | ||
42 | - vm.isCollapsed = false; | ||
43 | - } | 40 | + vm.isCollapsed = false; |
41 | + | ||
42 | + // vm.$element.find('.js-selected-category').hide(); | ||
44 | 43 | ||
45 | }; | 44 | }; |
46 | 45 | ||
@@ -63,7 +62,11 @@ | @@ -63,7 +62,11 @@ | ||
63 | if (category !== vm.selectedCategory) { | 62 | if (category !== vm.selectedCategory) { |
64 | vm.selectedCategory = category; | 63 | vm.selectedCategory = category; |
65 | 64 | ||
66 | - }else { | 65 | + if (vm.isRankingPage) { |
66 | + vm._getListGroup().slideUp(); | ||
67 | + vm.isCollapsed = true; | ||
68 | + } | ||
69 | + } else { | ||
67 | 70 | ||
68 | if (vm._disableUnselect()) { | 71 | if (vm._disableUnselect()) { |
69 | vm.$log.info('Unselect is disabled.'); | 72 | vm.$log.info('Unselect is disabled.'); |
@@ -80,10 +83,23 @@ | @@ -80,10 +83,23 @@ | ||
80 | CategoryListController.prototype.toogleList = function() { | 83 | CategoryListController.prototype.toogleList = function() { |
81 | var vm = this; | 84 | var vm = this; |
82 | 85 | ||
86 | + if (vm.isCollapsed) { | ||
87 | + vm._getListGroup().slideDown(); | ||
88 | + } else { | ||
89 | + vm._getListGroup().slideUp(); | ||
90 | + } | ||
91 | + vm.isCollapsed = !vm.isCollapsed; | ||
92 | + }; | ||
93 | + | ||
94 | + CategoryListController.prototype._getListGroup = function() { | ||
95 | + var vm = this; | ||
96 | + | ||
83 | if (!vm._listGroup) { | 97 | if (!vm._listGroup) { |
84 | - vm._listGroup = vm.$element.find('.list-group'); | 98 | + vm._listGroup = vm.$element.find('.js-list-group'); |
85 | } | 99 | } |
86 | - vm._listGroup.slideToggle(); | 100 | + |
101 | + return vm._listGroup; | ||
102 | + | ||
87 | }; | 103 | }; |
88 | 104 | ||
89 | var directive = { | 105 | var directive = { |
src/app/components/category-list/category-list.html
1 | -<div class="category-list"> | 1 | +<div class="category-list" ng-class="vm.selectedCategory.slug"> |
2 | <nav class="navigation"> | 2 | <nav class="navigation"> |
3 | <h3 class="category-list--title" ng-click="vm.toogleList()"> | 3 | <h3 class="category-list--title" ng-click="vm.toogleList()"> |
4 | <!-- <span class="hidden-xs"><b>Programas</b> por Tema</span> --> | 4 | <!-- <span class="hidden-xs"><b>Programas</b> por Tema</span> --> |
5 | <!-- <span class="visible-xs"><b>Filtrar</b> por Tema <span class="glyphicon glyphicon-filter pull-right"></span></span> --> | 5 | <!-- <span class="visible-xs"><b>Filtrar</b> por Tema <span class="glyphicon glyphicon-filter pull-right"></span></span> --> |
6 | <b>Filtrar</b> por Tema <span class="glyphicon glyphicon-filter pull-right"></span> | 6 | <b>Filtrar</b> por Tema <span class="glyphicon glyphicon-filter pull-right"></span> |
7 | </h3> | 7 | </h3> |
8 | - <!-- <div class="list-group ng-hide" ng-show="!vm.isCollapsed" ng-class="vm.selectedCategory.slug"> --> | ||
9 | - <div class="list-group is-mobile" ng-class="vm.selectedCategory.slug"> | 8 | + |
9 | + <div class="list-group is-mobile js-list-group"> | ||
10 | <button type="button" class="list-group-item category-list--item" | 10 | <button type="button" class="list-group-item category-list--item" |
11 | ng-repeat="category in vm.categories" | 11 | ng-repeat="category in vm.categories" |
12 | ng-class="{active: vm.selectedCategory.slug === category.slug}" | 12 | ng-class="{active: vm.selectedCategory.slug === category.slug}" |
@@ -22,5 +22,17 @@ | @@ -22,5 +22,17 @@ | ||
22 | </div> | 22 | </div> |
23 | </button> | 23 | </button> |
24 | </div> | 24 | </div> |
25 | + | ||
26 | + <div class="list-group is-mobile js-selected-category"> | ||
27 | + <button type="button" class="list-group-item category-list--item active" ng-if="vm.isCollapsed"> | ||
28 | + <span class="category-list--icon-circle" aria-hidden="true" ng-class="vm.selectedCategory.slug"></span> | ||
29 | + <span class="category-list--icon icon" aria-hidden="true" ng-class="'icon-tema-' + vm.selectedCategory.slug + '-small'"></span> | ||
30 | + <span class="category-list--label">{{vm.selectedCategory.name}}</span> | ||
31 | + <span class="category-list--icon--right glyphicon glyphicon-chevron-right hidden-xs"></span> | ||
32 | + <div ng-if="vm.selectedCategory.archived" class="category-list--icon-archived"> | ||
33 | + <span class="glyphicon glyphicon-ok" aria-hidden="true"></span> | ||
34 | + </div> | ||
35 | + </button> | ||
36 | + </div> | ||
25 | </nav> | 37 | </nav> |
26 | </div> | 38 | </div> |
27 | \ No newline at end of file | 39 | \ No newline at end of file |
src/app/pages/ranking/ranking.controller.js
@@ -24,7 +24,7 @@ | @@ -24,7 +24,7 @@ | ||
24 | $log.debug('RankingPageController'); | 24 | $log.debug('RankingPageController'); |
25 | } | 25 | } |
26 | 26 | ||
27 | - RankingPageController.prototype.init = function () { | 27 | + RankingPageController.prototype.init = function() { |
28 | var vm = this; | 28 | var vm = this; |
29 | 29 | ||
30 | vm.page = 1; | 30 | vm.page = 1; |
@@ -39,7 +39,6 @@ | @@ -39,7 +39,6 @@ | ||
39 | //Remove "X" from the theme at the ranking page | 39 | //Remove "X" from the theme at the ranking page |
40 | vm.slug = vm.$location.$$path; | 40 | vm.slug = vm.$location.$$path; |
41 | 41 | ||
42 | - | ||
43 | if (vm.search.tema) { | 42 | if (vm.search.tema) { |
44 | vm._filtredByThemeSlug = vm.search.tema; | 43 | vm._filtredByThemeSlug = vm.search.tema; |
45 | } | 44 | } |
@@ -56,7 +55,7 @@ | @@ -56,7 +55,7 @@ | ||
56 | vm.error = null; | 55 | vm.error = null; |
57 | }; | 56 | }; |
58 | 57 | ||
59 | - RankingPageController.prototype.loadData = function () { | 58 | + RankingPageController.prototype.loadData = function() { |
60 | var vm = this; | 59 | var vm = this; |
61 | 60 | ||
62 | vm.loading = true; | 61 | vm.loading = true; |
@@ -71,40 +70,39 @@ | @@ -71,40 +70,39 @@ | ||
71 | 70 | ||
72 | // 1. Load themes | 71 | // 1. Load themes |
73 | vm.loadingThemes = true; | 72 | vm.loadingThemes = true; |
74 | - vm.DialogaService.getThemes(function(themes){ | 73 | + vm.DialogaService.getThemes(function(themes) { |
75 | vm.themes = themes; | 74 | vm.themes = themes; |
76 | vm.loadingThemes = false; | 75 | vm.loadingThemes = false; |
77 | 76 | ||
78 | // 2. Select a Random Theme (T) | 77 | // 2. Select a Random Theme (T) |
79 | var selectedTheme = null; | 78 | var selectedTheme = null; |
80 | - if(vm.search.tema || vm._filtredByThemeSlug){ | 79 | + if (vm.search.tema || vm._filtredByThemeSlug) { |
81 | 80 | ||
82 | // vanilla filter | 81 | // vanilla filter |
83 | - var results = vm.themes.filter(function(t){ | 82 | + var results = vm.themes.filter(function(t) { |
84 | return (t.slug === vm.search.tema || (t.slug === vm._filtredByThemeSlug)); | 83 | return (t.slug === vm.search.tema || (t.slug === vm._filtredByThemeSlug)); |
85 | }); | 84 | }); |
86 | 85 | ||
87 | - if(results && results.length > 0){ | 86 | + if (results && results.length > 0) { |
88 | selectedTheme = results[0]; | 87 | selectedTheme = results[0]; |
89 | vm.selectedTheme = selectedTheme; | 88 | vm.selectedTheme = selectedTheme; |
90 | } | 89 | } |
91 | 90 | ||
92 | - | ||
93 | } | 91 | } |
94 | 92 | ||
95 | - if(!selectedTheme){ | 93 | + if (!selectedTheme) { |
96 | vm.selectedTheme = vm.themes[Math.floor(Math.random() * vm.themes.length)]; | 94 | vm.selectedTheme = vm.themes[Math.floor(Math.random() * vm.themes.length)]; |
97 | } | 95 | } |
98 | 96 | ||
99 | // 3. Load programs of T | 97 | // 3. Load programs of T |
100 | // (AND 4) | 98 | // (AND 4) |
101 | var themeId = vm.selectedTheme.id; | 99 | var themeId = vm.selectedTheme.id; |
102 | - vm.loadPrograms(themeId, function(){ | 100 | + vm.loadPrograms(themeId, function() { |
103 | // vm.loadProposals(); | 101 | // vm.loadProposals(); |
104 | vm.loading = false; | 102 | vm.loading = false; |
105 | vm.loadingFilter = false; | 103 | vm.loadingFilter = false; |
106 | }); | 104 | }); |
107 | - }, function (error) { | 105 | + }, function(error) { |
108 | vm.error = error; | 106 | vm.error = error; |
109 | vm.$log.error(error); | 107 | vm.$log.error(error); |
110 | vm.loadingThemes = false; | 108 | vm.loadingThemes = false; |
@@ -112,38 +110,38 @@ | @@ -112,38 +110,38 @@ | ||
112 | }); | 110 | }); |
113 | }; | 111 | }; |
114 | 112 | ||
115 | - RankingPageController.prototype.loadPrograms = function (themeId, cb) { | 113 | + RankingPageController.prototype.loadPrograms = function(themeId, cb) { |
116 | var vm = this; | 114 | var vm = this; |
117 | 115 | ||
118 | - vm.DialogaService.getProgramsByThemeId(themeId, function (programs){ | 116 | + vm.DialogaService.getProgramsByThemeId(themeId, function(programs) { |
119 | 117 | ||
120 | vm.filtredPrograms = programs; | 118 | vm.filtredPrograms = programs; |
121 | 119 | ||
122 | // 4. Select a random program of T | 120 | // 4. Select a random program of T |
123 | var selectedProgram = null; | 121 | var selectedProgram = null; |
124 | - if(vm.search.programa || vm._filtredByProgramSlug){ | 122 | + if (vm.search.programa || vm._filtredByProgramSlug) { |
125 | 123 | ||
126 | // vanilla filter | 124 | // vanilla filter |
127 | - var results = vm.filtredPrograms.filter(function(p){ | 125 | + var results = vm.filtredPrograms.filter(function(p) { |
128 | return (p.slug === vm.search.programa || (p.slug === vm._filtredByProgramSlug)); | 126 | return (p.slug === vm.search.programa || (p.slug === vm._filtredByProgramSlug)); |
129 | }); | 127 | }); |
130 | 128 | ||
131 | - if(results && results.length > 0){ | 129 | + if (results && results.length > 0) { |
132 | selectedProgram = results[0]; | 130 | selectedProgram = results[0]; |
133 | vm.selectedProgram = selectedProgram; | 131 | vm.selectedProgram = selectedProgram; |
134 | } | 132 | } |
135 | } | 133 | } |
136 | 134 | ||
137 | - if(!selectedProgram){ | 135 | + if (!selectedProgram) { |
138 | vm.selectedProgram = vm.filtredPrograms[Math.floor(Math.random() * vm.filtredPrograms.length)]; | 136 | vm.selectedProgram = vm.filtredPrograms[Math.floor(Math.random() * vm.filtredPrograms.length)]; |
139 | } | 137 | } |
140 | 138 | ||
141 | - if(cb){ | 139 | + if (cb) { |
142 | cb(); | 140 | cb(); |
143 | } | 141 | } |
144 | - }, function(error){ | 142 | + }, function(error) { |
145 | vm.$log.error(error); | 143 | vm.$log.error(error); |
146 | - if(cb){ | 144 | + if (cb) { |
147 | cb(); | 145 | cb(); |
148 | } | 146 | } |
149 | }); | 147 | }); |
@@ -152,7 +150,7 @@ | @@ -152,7 +150,7 @@ | ||
152 | RankingPageController.prototype.attachListeners = function() { | 150 | RankingPageController.prototype.attachListeners = function() { |
153 | var vm = this; | 151 | var vm = this; |
154 | 152 | ||
155 | - vm.$scope.$on('change-selectedCategory', function (event, selectedCategory) { | 153 | + vm.$scope.$on('change-selectedCategory', function(event, selectedCategory) { |
156 | vm.selectedTheme = selectedCategory; | 154 | vm.selectedTheme = selectedCategory; |
157 | }); | 155 | }); |
158 | 156 | ||
@@ -160,14 +158,14 @@ | @@ -160,14 +158,14 @@ | ||
160 | vm.search.tema = newValue ? newValue.slug : null; | 158 | vm.search.tema = newValue ? newValue.slug : null; |
161 | vm.$location.search('tema', vm.search.tema); | 159 | vm.$location.search('tema', vm.search.tema); |
162 | 160 | ||
163 | - if(!vm.loadingFilter && vm.selectedTheme && vm.selectedTheme.id){ | ||
164 | - vm.loadPrograms(vm.selectedTheme.id, function(){ | 161 | + if (!vm.loadingFilter && vm.selectedTheme && vm.selectedTheme.id) { |
162 | + vm.loadPrograms(vm.selectedTheme.id, function() { | ||
165 | vm.filterProposals(); | 163 | vm.filterProposals(); |
166 | }); | 164 | }); |
167 | } | 165 | } |
168 | }); | 166 | }); |
169 | 167 | ||
170 | - vm.$scope.$on('change-selectedTopic', function (event, selectedTopic) { | 168 | + vm.$scope.$on('change-selectedTopic', function(event, selectedTopic) { |
171 | vm.selectedProgram = selectedTopic; | 169 | vm.selectedProgram = selectedTopic; |
172 | }); | 170 | }); |
173 | 171 | ||
@@ -207,7 +205,7 @@ | @@ -207,7 +205,7 @@ | ||
207 | RankingPageController.prototype.filterProposals = function(_page, _per_page) { | 205 | RankingPageController.prototype.filterProposals = function(_page, _per_page) { |
208 | var vm = this; | 206 | var vm = this; |
209 | 207 | ||
210 | - if (vm.loadingProposals){ | 208 | + if (vm.loadingProposals) { |
211 | vm.$log.debug('Content is not loaded yet.'); | 209 | vm.$log.debug('Content is not loaded yet.'); |
212 | return; | 210 | return; |
213 | } | 211 | } |
@@ -228,11 +226,11 @@ | @@ -228,11 +226,11 @@ | ||
228 | if (query) {params.query = query; } | 226 | if (query) {params.query = query; } |
229 | 227 | ||
230 | vm.loadingProposals = true; | 228 | vm.loadingProposals = true; |
231 | - vm.DialogaService.searchProposals(params, function(data){ | 229 | + vm.DialogaService.searchProposals(params, function(data) { |
232 | vm.total_proposals = parseInt(data._obj.headers('total')); | 230 | vm.total_proposals = parseInt(data._obj.headers('total')); |
233 | vm.filtredProposals = data.articles; | 231 | vm.filtredProposals = data.articles; |
234 | vm.loadingProposals = false; | 232 | vm.loadingProposals = false; |
235 | - }, function (error) { | 233 | + }, function(error) { |
236 | vm.error = error; | 234 | vm.error = error; |
237 | vm.$log.error(error); | 235 | vm.$log.error(error); |
238 | vm.loadingProposals = false; | 236 | vm.loadingProposals = false; |