Commit 81a5c63f3d747ffbacbef1df1d0c67d074d3f743
1 parent
d9f417f7
Exists in
master
and in
8 other branches
Add: handle go-back at article-bar
Showing
4 changed files
with
25 additions
and
7 deletions
Show diff stats
src/app/components/programa/programa.html
1 | 1 | <div ng-if="vm.program"> |
2 | - <article ng-if="vm.isDisplayBox()" ng-click="vm.showContent()"> | |
3 | - <div class="program-box {{::vm.getCategorySlug()}}"> | |
2 | + <article class="program-box" ng-if="vm.isDisplayBox()" ng-click="vm.showContent()"> | |
3 | + <div class="{{::vm.getCategorySlug()}}"> | |
4 | 4 | <h2 class="program-box--category">{{::vm.getCategoryName()}}</h2> |
5 | 5 | <div class="program-box--image-wrapper"> |
6 | 6 | <!-- <img class="program-box--image img-responsive" ng-src="{{::vm.getImageUrl()}}" alt="{{::vm.getImageAlt()}}" /> --> |
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | </div> |
19 | 19 | </article> |
20 | 20 | |
21 | - <article ng-if="vm.isDisplayPreview()"> | |
21 | + <article ng-if="vm.isDisplayPreview()" class="program-preview"> | |
22 | 22 | <header class="program-banner"> |
23 | 23 | <img class="program-banner--image" ng-src="{{vm.getImageUrl()}}" alt="{{::vm.getImageAlt()}}"> |
24 | 24 | <div class="program-banner--strip"> | ... | ... |
src/app/components/programa/programa.scss
... | ... | @@ -4,7 +4,6 @@ $scale: 1.1; |
4 | 4 | $time: .2s; |
5 | 5 | $darken: 15%; |
6 | 6 | |
7 | -// sandbox | |
8 | 7 | .program-box { |
9 | 8 | cursor: pointer; |
10 | 9 | background-color: #fff; |
... | ... | @@ -183,5 +182,10 @@ $darken: 15%; |
183 | 182 | transform: scale($scale); |
184 | 183 | } |
185 | 184 | } |
185 | +} | |
186 | 186 | |
187 | +.program-preview { | |
188 | + .program-banner { | |
189 | + | |
190 | + } | |
187 | 191 | } | ... | ... |
src/app/index.run.js
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | .module('dialoga') |
7 | 7 | .run(runAuth) |
8 | 8 | .run(runAccessibility) |
9 | + .run(runHistory) | |
9 | 10 | .run(runPath) |
10 | 11 | .run(runColorUtils) |
11 | 12 | .run(runBlock); |
... | ... | @@ -75,6 +76,13 @@ |
75 | 76 | } |
76 | 77 | |
77 | 78 | /** @ngInject */ |
79 | + function runHistory($rootScope, $log) { | |
80 | + $rootScope.$on('$stateChangeSuccess', function(event, toState, toStateParams, fromState, fromStateParams) { | |
81 | + $rootScope.$previousState = { state: fromState, params: fromStateParams}; | |
82 | + }); | |
83 | + } | |
84 | + | |
85 | + /** @ngInject */ | |
78 | 86 | function runPath($rootScope, api, $log) { |
79 | 87 | var isProduction = (/^http:\/\/dialoga\.gov\.br\//.test(window.location.href)); |
80 | 88 | $rootScope.basePath = isProduction ? api.hostProd : api.hostHom; | ... | ... |
src/app/partials/programas/programa.controller.js
... | ... | @@ -6,15 +6,16 @@ |
6 | 6 | .controller('ProgramaController', ProgramaController); |
7 | 7 | |
8 | 8 | /** @ngInject */ |
9 | - function ProgramaController(ArticleService, $state, $location, $scope, $log) { | |
9 | + function ProgramaController(ArticleService, $state, $location, $scope, $rootScope, $log) { | |
10 | 10 | $log.debug('ProgramaController'); |
11 | 11 | |
12 | 12 | var vm = this; |
13 | 13 | |
14 | 14 | vm.ArticleService = ArticleService; |
15 | - vm.$scope = $scope; | |
16 | 15 | vm.$state = $state; |
17 | 16 | vm.$location = $location; |
17 | + vm.$scope = $scope; | |
18 | + vm.$rootScope = $rootScope; | |
18 | 19 | vm.$log = $log; |
19 | 20 | |
20 | 21 | vm.init(); |
... | ... | @@ -80,6 +81,11 @@ |
80 | 81 | ProgramaController.prototype.goBack = function () { |
81 | 82 | var vm = this; |
82 | 83 | |
83 | - vm.$log.warn('Not implemented yet!'); | |
84 | + var prevState = vm.$rootScope.$previousState; | |
85 | + if(prevState && prevState.state.name){ | |
86 | + vm.$state.go(prevState.state.name, prevState.params); | |
87 | + } else { | |
88 | + vm.$state.go('inicio'); | |
89 | + } | |
84 | 90 | }; |
85 | 91 | })(); | ... | ... |