File

projects/rebirth-ng/src/lib/panel/panel-group.model.ts

Index

Properties
Methods
Inputs

Properties

panels
panels: PanelComponent[]
Type : PanelComponent[]
Default value : []

Methods

$addItem
$addItem(panel: PanelComponent)
Parameters :
Name Type Optional
panel PanelComponent no
Returns : void
$removeItem
$removeItem(panel: PanelComponent)
Parameters :
Name Type Optional
panel PanelComponent no
Returns : void
$removeItemById
$removeItemById(id: )
Parameters :
Name Optional
id no
Returns : void
Protected initPanel
initPanel(panel: PanelComponent)
Parameters :
Name Type Optional
panel PanelComponent no
Returns : any
Private removeItemByIndex
removeItemByIndex(index: number)
Parameters :
Name Type Optional
index number no
Returns : void

Inputs

cssClass

Type: string

type

Type: "default" | "primary" | "success" | "info" | "warning" | "danger"

import { PanelComponent } from './panel.component';
import { Input } from '@angular/core';

export abstract class PanelGroup {
  @Input() type: 'default' | 'primary' | 'success' | 'info' | 'warning' | 'danger';
  @Input() cssClass: string;
  panels: PanelComponent[] = [];

  $addItem(panel: PanelComponent) {
    this.$removeItem(panel);
    if (this.type) {
      panel.type = this.type;
    }
    panel.cssClass = this.cssClass;
    this.initPanel(panel);
    this.panels.push(panel);
  }

  $removeItemById(id) {
    const index = this.panels.findIndex(item => item.id === id);
    this.removeItemByIndex(index);
  }

  $removeItem(panel: PanelComponent) {
    if (panel) {
      const index = this.panels.findIndex(item => item === panel);
      this.removeItemByIndex(index);
    }
  }

  private removeItemByIndex(index: number) {
    if (index !== -1) {
      this.panels.splice(index, 1);
    }
  }

  protected abstract initPanel(panel: PanelComponent) ;
}

results matching ""

    No results matching ""