252 lines
17 KiB
JavaScript
252 lines
17 KiB
JavaScript
"use strict";
|
|
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
var _, done = false;
|
|
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
var context = {};
|
|
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
if (kind === "accessor") {
|
|
if (result === void 0) continue;
|
|
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
if (_ = accept(result.get)) descriptor.get = _;
|
|
if (_ = accept(result.set)) descriptor.set = _;
|
|
if (_ = accept(result.init)) initializers.unshift(_);
|
|
}
|
|
else if (_ = accept(result)) {
|
|
if (kind === "field") initializers.unshift(_);
|
|
else descriptor[key] = _;
|
|
}
|
|
}
|
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
done = true;
|
|
};
|
|
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
var useValue = arguments.length > 2;
|
|
for (var i = 0; i < initializers.length; i++) {
|
|
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
}
|
|
return useValue ? value : void 0;
|
|
};
|
|
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.AppMenuitemComponent = void 0;
|
|
var core_1 = require("@angular/core");
|
|
var router_1 = require("@angular/router");
|
|
var animations_1 = require("@angular/animations");
|
|
var operators_1 = require("rxjs/operators");
|
|
var role_1 = require("./_models/Authentication/role");
|
|
var AppMenuitemComponent = function () {
|
|
var _classDecorators = [(0, core_1.Component)({
|
|
/* tslint:disable:component-selector */
|
|
selector: '[app-menuitem]',
|
|
/* tslint:enable:component-selector */
|
|
template: "\n <ng-container>\n <div *ngIf=\"root && item.visible !== false\">\n <span class=\"layout-menuitem-text\">{{item.label}}</span>\n </div>\n <a [attr.href]=\"item.url\" (click)=\"itemClick($event)\" *ngIf=\"(!item.routerLink || item.items) && item.visible !== false\"\n (mouseenter)=\"onMouseEnter()\" (keydown.enter)=\"itemClick($event)\" [ngClass]=\"item.class\" pRipple\n [attr.target]=\"item.target\" [attr.tabindex]=\"!visible ? '-1' : 0\">\n <i class=\"layout-menuitem-icon\" [ngClass]=\"item.icon\"></i>\n <span class=\"layout-menuitem-text\">{{item.label}}</span>\n <i class=\"pi pi-fw pi-angle-down layout-submenu-toggler\" *ngIf=\"item.items\"></i>\n <span class=\"menuitem-badge\" *ngIf=\"item.badge\">{{item.badge}}</span>\n </a>\n <a (click)=\"itemClick($event)\" (mouseenter)=\"onMouseEnter()\" *ngIf=\"(item.routerLink && !item.items) && item.visible !== false\"\n [routerLink]=\"item.routerLink\" routerLinkActive=\"active-route\" [ngClass]=\"item.class\" pRipple\n [routerLinkActiveOptions]=\"{exact: true}\" [attr.target]=\"item.target\" [attr.tabindex]=\"!visible ? '-1' : 0\">\n <i class=\"layout-menuitem-icon\" [ngClass]=\"item.icon\"></i>\n <span class=\"layout-menuitem-text\">{{item.label}}</span>\n <i class=\"pi pi-fw pi-angle-down layout-submenu-toggler\" *ngIf=\"item.items\"></i>\n <span class=\"menuitem-badge\" *ngIf=\"item.badge\">{{item.badge}}</span>\n </a>\n <div class=\"layout-menu-tooltip\" *ngIf=\"item.visible !== false\">\n <div class=\"layout-menu-tooltip-arrow\"></div>\n <div class=\"layout-menu-tooltip-text\">{{item.label}}</div>\n </div>\n <ul *ngIf=\"(item?.items || (active || animating)) && item?.visible !== false\" (@children.done)=\"onAnimationDone()\"\n [@children]=\"(root ? 'visible' : active ? 'visibleAnimated' : 'hiddenAnimated')\">\n <ng-template ngFor let-child let-i=\"index\" [ngForOf]=\"item.items\">\n <li app-menuitem *ngIf=\"child.visible!==false\" [item]=\"child\" [visible]=\"active\"\n [index]=\"i\" [parentKey]=\"key\" [class]=\"child.badgeClass\"></li>\n </ng-template>\n </ul>\n </ng-container>\n ",
|
|
host: {
|
|
'[class.active-menuitem]': 'active',
|
|
'[class.layout-root-menuitem]': 'root',
|
|
},
|
|
animations: [
|
|
(0, animations_1.trigger)('children', [
|
|
(0, animations_1.state)('void', (0, animations_1.style)({
|
|
height: '0px'
|
|
})),
|
|
(0, animations_1.state)('hiddenAnimated', (0, animations_1.style)({
|
|
height: '0px'
|
|
})),
|
|
(0, animations_1.state)('visibleAnimated', (0, animations_1.style)({
|
|
height: '*'
|
|
})),
|
|
(0, animations_1.state)('visible', (0, animations_1.style)({
|
|
height: '*',
|
|
'z-index': 100
|
|
})),
|
|
(0, animations_1.state)('hidden', (0, animations_1.style)({
|
|
height: '0px',
|
|
'z-index': '*'
|
|
})),
|
|
(0, animations_1.transition)('visibleAnimated => hiddenAnimated', (0, animations_1.animate)('400ms cubic-bezier(0.86, 0, 0.07, 1)')),
|
|
(0, animations_1.transition)('hiddenAnimated => visibleAnimated', (0, animations_1.animate)('400ms cubic-bezier(0.86, 0, 0.07, 1)')),
|
|
(0, animations_1.transition)('void => visibleAnimated, visibleAnimated => void', (0, animations_1.animate)('400ms cubic-bezier(0.86, 0, 0.07, 1)'))
|
|
])
|
|
], standalone: false,
|
|
})];
|
|
var _classDescriptor;
|
|
var _classExtraInitializers = [];
|
|
var _classThis;
|
|
var _item_decorators;
|
|
var _item_initializers = [];
|
|
var _item_extraInitializers = [];
|
|
var _index_decorators;
|
|
var _index_initializers = [];
|
|
var _index_extraInitializers = [];
|
|
var _root_decorators;
|
|
var _root_initializers = [];
|
|
var _root_extraInitializers = [];
|
|
var _visible_decorators;
|
|
var _visible_initializers = [];
|
|
var _visible_extraInitializers = [];
|
|
var _parentKey_decorators;
|
|
var _parentKey_initializers = [];
|
|
var _parentKey_extraInitializers = [];
|
|
var AppMenuitemComponent = _classThis = /** @class */ (function () {
|
|
function AppMenuitemComponent_1(appMain, router, cd, menuService) {
|
|
var _this = this;
|
|
this.appMain = appMain;
|
|
this.router = router;
|
|
this.cd = cd;
|
|
this.menuService = menuService;
|
|
this.item = __runInitializers(this, _item_initializers, void 0);
|
|
this.index = (__runInitializers(this, _item_extraInitializers), __runInitializers(this, _index_initializers, void 0));
|
|
this.root = (__runInitializers(this, _index_extraInitializers), __runInitializers(this, _root_initializers, false));
|
|
this.visible = (__runInitializers(this, _root_extraInitializers), __runInitializers(this, _visible_initializers, false));
|
|
this.parentKey = (__runInitializers(this, _visible_extraInitializers), __runInitializers(this, _parentKey_initializers, void 0));
|
|
this.animating = (__runInitializers(this, _parentKey_extraInitializers), false);
|
|
this.active = false;
|
|
this.menuSourceSubscription = this.menuService.menuSource$.subscribe(function (key) {
|
|
// deactivate current active menu
|
|
if (_this.active && _this.key !== key && key.indexOf(_this.key) !== 0) {
|
|
_this.active = false;
|
|
}
|
|
});
|
|
this.menuResetSubscription = this.menuService.resetSource$.subscribe(function () {
|
|
_this.active = false;
|
|
});
|
|
this.router.events.pipe((0, operators_1.filter)(function (event) { return event instanceof router_1.NavigationEnd; }))
|
|
.subscribe(function (params) {
|
|
if (_this.appMain.isHorizontal()) {
|
|
_this.active = false;
|
|
}
|
|
else {
|
|
if (_this.item.routerLink) {
|
|
_this.updateActiveStateFromRoute();
|
|
}
|
|
else {
|
|
if (_this.menuService.clickedMenuItem == undefined)
|
|
_this.active = false;
|
|
else {
|
|
// Either side can be null: clickedMenuItem.menuKey is unset until the
|
|
// first menu click, and item.menuCode is null for a menu row that
|
|
// carries no permission code. Both used to throw here on every
|
|
// NavigationEnd, which killed this subscription.
|
|
var clickedKey = _this.menuService.clickedMenuItem.menuKey;
|
|
var myCode = _this.item.menuCode;
|
|
if (clickedKey && myCode && clickedKey.length >= myCode.length
|
|
&& clickedKey.substring(0, myCode.length) == myCode) {
|
|
_this.active = true;
|
|
}
|
|
else {
|
|
_this.active = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
AppMenuitemComponent_1.prototype.ngOnInit = function () {
|
|
if (!this.appMain.isHorizontal() && this.item.routerLink) {
|
|
this.updateActiveStateFromRoute();
|
|
}
|
|
this.key = this.parentKey ? this.parentKey + '-' + this.index : String(this.index);
|
|
};
|
|
AppMenuitemComponent_1.prototype.updateActiveStateFromRoute = function () {
|
|
this.active = this.router.isActive(this.item.routerLink[0], this.item.items ? false : true);
|
|
};
|
|
AppMenuitemComponent_1.prototype.bookmark = function () {
|
|
var _this = this;
|
|
var tempBookmarkMenu = this.menuService.bookMarkpages.find(function (x) { return x.menuCode === _this.menuService.clickedMenuItem.menuKey; });
|
|
this.menuService.clickedMenuItem.isBookmarked = !(tempBookmarkMenu === null || tempBookmarkMenu === undefined);
|
|
};
|
|
AppMenuitemComponent_1.prototype.itemClick = function (event) {
|
|
// avoid processing disabled items
|
|
if (this.item.disabled) {
|
|
event.preventDefault();
|
|
return;
|
|
}
|
|
debugger;
|
|
this.menuService.clickedMenuItem = new role_1.RolePermission();
|
|
this.menuService.clickedMenuItem.menuKey = this.item.menuCode;
|
|
this.menuService.clickedMenuItem.link = this.item.routerLink;
|
|
this.menuService.clickedMenuItem.name = this.item.label;
|
|
// this.menuService.clickedMenuItem.isBookmarked = this.item.isBookmarked;
|
|
this.bookmark();
|
|
localStorage.setItem('selectedMenu', JSON.stringify(this.menuService.clickedMenuItem));
|
|
// navigate with hover in horizontal mode
|
|
if (this.root) {
|
|
this.appMain.menuHoverActive = !this.appMain.menuHoverActive;
|
|
}
|
|
// notify other items
|
|
this.menuService.onMenuStateChange(this.key);
|
|
// execute command
|
|
if (this.item.command) {
|
|
this.item.command({ originalEvent: event, item: this.item });
|
|
}
|
|
// toggle active state
|
|
if (this.item.items) {
|
|
this.active = !this.active;
|
|
this.animating = true;
|
|
}
|
|
else {
|
|
// activate item
|
|
this.active = true;
|
|
// hide overlay menus
|
|
//this.appMain.overlayMenuActive = false;
|
|
//this.appMain.staticMenuMobileActive = false;
|
|
this.appMain.menuHoverActive = !this.appMain.menuHoverActive;
|
|
// reset horizontal menu
|
|
if (this.appMain.isHorizontal() || this.appMain.isSlim()) {
|
|
// this.menuService.reset();
|
|
}
|
|
}
|
|
};
|
|
AppMenuitemComponent_1.prototype.onMouseEnter = function () {
|
|
// activate item on hover
|
|
if (this.root && this.appMain.menuHoverActive &&
|
|
(this.appMain.isHorizontal() || this.appMain.isSlim()) && this.appMain.isDesktop()) {
|
|
this.menuService.onMenuStateChange(this.key);
|
|
this.active = true;
|
|
}
|
|
};
|
|
AppMenuitemComponent_1.prototype.onAnimationDone = function () {
|
|
this.animating = false;
|
|
};
|
|
AppMenuitemComponent_1.prototype.ngOnDestroy = function () {
|
|
if (this.menuSourceSubscription) {
|
|
this.menuSourceSubscription.unsubscribe();
|
|
}
|
|
if (this.menuResetSubscription) {
|
|
this.menuResetSubscription.unsubscribe();
|
|
}
|
|
};
|
|
return AppMenuitemComponent_1;
|
|
}());
|
|
__setFunctionName(_classThis, "AppMenuitemComponent");
|
|
(function () {
|
|
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
_item_decorators = [(0, core_1.Input)()];
|
|
_index_decorators = [(0, core_1.Input)()];
|
|
_root_decorators = [(0, core_1.Input)()];
|
|
_visible_decorators = [(0, core_1.Input)()];
|
|
_parentKey_decorators = [(0, core_1.Input)()];
|
|
__esDecorate(null, null, _item_decorators, { kind: "field", name: "item", static: false, private: false, access: { has: function (obj) { return "item" in obj; }, get: function (obj) { return obj.item; }, set: function (obj, value) { obj.item = value; } }, metadata: _metadata }, _item_initializers, _item_extraInitializers);
|
|
__esDecorate(null, null, _index_decorators, { kind: "field", name: "index", static: false, private: false, access: { has: function (obj) { return "index" in obj; }, get: function (obj) { return obj.index; }, set: function (obj, value) { obj.index = value; } }, metadata: _metadata }, _index_initializers, _index_extraInitializers);
|
|
__esDecorate(null, null, _root_decorators, { kind: "field", name: "root", static: false, private: false, access: { has: function (obj) { return "root" in obj; }, get: function (obj) { return obj.root; }, set: function (obj, value) { obj.root = value; } }, metadata: _metadata }, _root_initializers, _root_extraInitializers);
|
|
__esDecorate(null, null, _visible_decorators, { kind: "field", name: "visible", static: false, private: false, access: { has: function (obj) { return "visible" in obj; }, get: function (obj) { return obj.visible; }, set: function (obj, value) { obj.visible = value; } }, metadata: _metadata }, _visible_initializers, _visible_extraInitializers);
|
|
__esDecorate(null, null, _parentKey_decorators, { kind: "field", name: "parentKey", static: false, private: false, access: { has: function (obj) { return "parentKey" in obj; }, get: function (obj) { return obj.parentKey; }, set: function (obj, value) { obj.parentKey = value; } }, metadata: _metadata }, _parentKey_initializers, _parentKey_extraInitializers);
|
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
AppMenuitemComponent = _classThis = _classDescriptor.value;
|
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
__runInitializers(_classThis, _classExtraInitializers);
|
|
})();
|
|
return AppMenuitemComponent = _classThis;
|
|
}();
|
|
exports.AppMenuitemComponent = AppMenuitemComponent;
|
|
//# sourceMappingURL=app.menuitem.component.js.map
|