From d9e4ff6772d223a96f642b067c475c1e3cca0a93 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 28 Nov 2022 11:48:25 +0100 Subject: [PATCH] fix: use $location --- front/core/lib/component.js | 7 ++++--- front/salix/components/app/app.js | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/front/core/lib/component.js b/front/core/lib/component.js index f17db68a2..5695d9449 100644 --- a/front/core/lib/component.js +++ b/front/core/lib/component.js @@ -12,9 +12,10 @@ export default class Component extends EventEmitter { * @param {HTMLElement} $element The main component element * @param {$rootScope.Scope} $scope The element scope * @param {Function} $transclude The transclusion function + * @param {Function} $location The location function */ - constructor($element, $scope, $transclude) { - super(); + constructor($element, $scope, $transclude, $location) { + super($element, $scope, $transclude, $location); this.$ = $scope; if (!$element) return; @@ -164,7 +165,7 @@ export default class Component extends EventEmitter { $transclude.$$boundTransclude.$$slots[slot]; } } -Component.$inject = ['$element', '$scope']; +Component.$inject = ['$element', '$scope', '$location', '$state']; /* * Automatically adds the most used services to the prototype, so they are diff --git a/front/salix/components/app/app.js b/front/salix/components/app/app.js index 035c11d22..20f0ad969 100644 --- a/front/salix/components/app/app.js +++ b/front/salix/components/app/app.js @@ -9,12 +9,18 @@ import Component from 'core/lib/component'; * @property {SideMenu} rightMenu The left menu, if it's present */ export default class App extends Component { + constructor($element, $, $location, $state) { + super($element, $, $location, $state); + this.$location = $location; + this.$state = $state; + } + $postLink() { this.vnApp.logger = this; } get showLayout() { - const state = this.$state.current.name; + const state = this.$state.current.name || this.$location.$$path.substring(1).replace('/', '.'); const outLayout = ['login', 'recoverPassword', 'resetPassword']; return state && !outLayout.some(ol => ol == state); }