Try sidemenu with internal observable

fix/op-sidemenu-onpush
Benjamin Bädorf 3 years ago
parent 138bd91d05
commit e2992578ff
No known key found for this signature in database
GPG Key ID: 069CA2D117AB5CCF
  1. 31
      frontend/src/app/shared/components/sidemenu/sidemenu.component.html
  2. 15
      frontend/src/app/shared/components/sidemenu/sidemenu.component.ts

@ -1,26 +1,29 @@
<button
class="op-sidemenu--title"
type="button"
(click)="toggleCollapsed()"
*ngIf="title && collapsible"
>
<span class="icon3 icon-small"
[ngClass]="collapsed ? 'icon-arrow-down1' : 'icon-arrow-up1'"
aria-hidden="true">
</span>
{{ title }}
</button>
<ng-container *ngIf="{collapsed: (collapsed$ | async)} as observables">
<button
*ngIf="title && collapsible"
class="op-sidemenu--title"
type="button"
(click)="collapsed$.next(!observables.collapsed)"
>
<span
class="icon3 icon-small"
[ngClass]="(collapsed$ | async) ? 'icon-arrow-down1' : 'icon-arrow-up1'"
aria-hidden="true"
></span>
{{ title }}
</button>
</ng-container>
<div
class="op-sidemenu--title"
*ngIf="title && !collapsible"
class="op-sidemenu--title"
>
{{ title }}
</div>
<ul
class="op-sidemenu--items"
[ngClass]="{'op-sidemenu--items_collapsed' : collapsed}"
[ngClass]="{'op-sidemenu--items_collapsed': (collapsed$ | async)}"
>
<li
class="op-sidemenu--item"

@ -1,11 +1,10 @@
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
Input,
HostBinding,
} from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { Subject } from 'rxjs';
export interface IOpSidemenuItem {
title:string;
@ -27,21 +26,15 @@ export interface IOpSidemenuItem {
export class OpSidemenuComponent {
@HostBinding('class.op-sidemenu') className = true;
@HostBinding('class.op-sidemenu_collapsed') collapsed = false;
@Input() items:IOpSidemenuItem[] = [];
@Input() title:string;
@Input() collapsible = true;
constructor(
readonly cdRef:ChangeDetectorRef,
readonly I18n:I18nService,
) {
}
public collapsed$ = new Subject();
toggleCollapsed():void {
this.collapsed = !this.collapsed;
constructor() {
this.collapsed$.next(false);
}
}

Loading…
Cancel
Save