Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
commit
b3c7073587
|
@ -2,7 +2,9 @@ import ngModule from '../../module';
|
|||
import './style.scss';
|
||||
|
||||
export default class LeftMenu {
|
||||
constructor($state, $transitions, aclService) {
|
||||
constructor($state, $transitions, aclService, $timeout, $element) {
|
||||
this.$element = $element;
|
||||
this.$timeout = $timeout;
|
||||
this.$state = $state;
|
||||
this.deregisterCallback = $transitions.onSuccess({},
|
||||
() => this.activateItem());
|
||||
|
@ -89,13 +91,19 @@ export default class LeftMenu {
|
|||
setActive(item) {
|
||||
if (item.state) return;
|
||||
item.active = !item.active;
|
||||
|
||||
this.$timeout(() => {
|
||||
let element = this.$element[0].querySelector('a[class="expanded"]');
|
||||
if (element)
|
||||
element.scrollIntoView();
|
||||
});
|
||||
}
|
||||
|
||||
$onDestroy() {
|
||||
this.deregisterCallback();
|
||||
}
|
||||
}
|
||||
LeftMenu.$inject = ['$state', '$transitions', 'aclService'];
|
||||
LeftMenu.$inject = ['$state', '$transitions', 'aclService', '$timeout', '$element'];
|
||||
|
||||
ngModule.component('vnLeftMenu', {
|
||||
template: require('./left-menu.html'),
|
||||
|
|
|
@ -2,16 +2,18 @@ import './left-menu.js';
|
|||
|
||||
describe('Component vnLeftMenu', () => {
|
||||
let controller;
|
||||
let $element;
|
||||
|
||||
beforeEach(angular.mock.module('salix', $translateProvider => {
|
||||
$translateProvider.translations('en', {});
|
||||
}));
|
||||
|
||||
beforeEach(angular.mock.inject(($componentController, $state, $window) => {
|
||||
$element = angular.element('<div></div>');
|
||||
$state.current.name = 'client.card.summary';
|
||||
$state.current.data = {moduleIndex: 0};
|
||||
$window.routes = [{menu: []}];
|
||||
controller = $componentController('vnLeftMenu', {$state, $window});
|
||||
controller = $componentController('vnLeftMenu', {$state, $window, $element});
|
||||
controller.items = [
|
||||
{description: 'Client', state: 'client', icon: null, childs: []},
|
||||
{description: 'Client', state: 'client.card', icon: null, childs: []},
|
||||
|
|
Loading…
Reference in New Issue