All files / components/tek-user-info tek-user-info-list.ts

26.66% Statements 4/15
0% Branches 0/5
0% Functions 0/4
26.66% Lines 4/15

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 55 56 57 58 59 60 61 621x 1x   1x   1x                                                                                                                
import { List } from '@zeedhi/common';
import { Metadata } from '@zeedhi/core';
import { ITekUserInfo, ITekUserInfoList } from './interfaces';
import { TekUserInfo } from './tek-user-info';
 
export class TekUserInfoList extends List implements ITekUserInfoList {
  /**
   * Name of the user info component
   */
  public parentName: string = '';
 
  public dense: boolean = true;
 
  constructor(props: ITekUserInfo) {
    super(props);
    this.parentName = props.parentName || '';
 
    this.items = this.getItems();
  }
 
  protected getItems() {
    const parent = this.parentName ? Metadata.getInstance<TekUserInfo>(this.parentName) : this.parent;
 
    Iif (!(parent instanceof TekUserInfo)) {
      throw Error(`Could not find the TekUserInfo component associated with ${this.name} TekUserInfoList`);
    }
 
    return [
      {
        name: `${parent.name}_version`,
        component: 'ZdListItem',
        title: `{{TekUserInfoController_${parent.componentId}.name}}`,
        subtitle: `{{TekUserInfoController_${parent.componentId}.version}}`,
        isVisible: `{{TekUserInfoController_${parent.componentId}.showVersionInfo}}`,
        cssClass: 'zd-px-2',
      },
      {
        name: `${parent.name}_about`,
        component: 'ZdListItem',
        title: 'TEKUSERINFO_ABOUT',
        prependIcon: 'infoOutline',
        cssClass: 'zd-px-2',
        isVisible: `{{TekUserInfoController_${parent.componentId}.showAbout}}`,
        events: {
          click: () => parent.onAboutClick(),
        },
      },
      {
        name: `${parent.name}_report`,
        component: 'ZdListItem',
        title: 'TEKUSERINFO_REPORT_ERROR',
        prependIcon: 'mdi-ladybug',
        cssClass: 'zd-px-2',
        isVisible: `{{TekUserInfoController_${parent.componentId}.showReportError}}`,
        events: {
          click: () => parent.onReportClick(),
        },
      },
    ];
  }
}