Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 14x 14x 14x 14x 367x 367x 367x 367x 367x 367x 367x 367x 367x 367x 367x 367x 369x 369x 1x 369x 359x | import { ChangeDetectionStrategy, Component, OnDestroy, inject, input, output, effect } from '@angular/core';
import { SidebarService } from '@drevo-web/core';
import { SidebarAction, SidebarActionPriority } from '@drevo-web/shared';
let nextId = 0;
@Component({
selector: 'app-sidebar-action',
template: '',
host: {
'[style.display]': '"none"',
},
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SidebarActionComponent implements OnDestroy {
private readonly sidebarService = inject(SidebarService);
private readonly actionId = `sidebar-action-${nextId++}`;
readonly icon = input.required<string>();
readonly svgIcon = input<string>();
readonly label = input.required<string>();
readonly priority = input<SidebarActionPriority>('secondary');
readonly link = input<string>();
readonly order = input<number>();
readonly disabled = input<boolean>();
readonly badge = input<number>();
readonly activated = output<void>();
constructor() {
effect(() => {
const link = this.link();
const action: SidebarAction = {
id: this.actionId,
icon: this.icon(),
svgIcon: this.svgIcon(),
label: this.label(),
priority: this.priority(),
order: this.order(),
link,
disabled: this.disabled(),
badge: this.badge(),
action: link ? undefined : () => this.activated.emit(),
};
this.sidebarService.registerAction(action);
});
}
ngOnDestroy(): void {
this.sidebarService.unregisterAction(this.actionId);
}
}
|