All files / components/tek-notifications notifications.ts

20% Statements 2/10
100% Branches 0/0
0% Functions 0/4
20% Lines 2/10

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 62 631x           1x                                                                                                                
import { Iterable } from '@zeedhi/common';
import { INotifications, INotificationsEvents } from './interfaces';
 
/**
 * Notifications component is used to show notifications
 */
export class Notifications extends Iterable implements INotifications {
  public allNotificationsPath: string = '';
 
  /**
   * Defines grid events.
   */
  public events!: INotificationsEvents;
 
  public cardTitle = {
    name: 'notification-card-title',
    component: 'TekCardTitle',
    title: 'NOTIFICATIONS',
    rightSlot: [
      {
        name: 'mark-read-tag',
        component: 'ZdTag',
        tag: 'a',
        events: {
          click: this.markAsRead.bind(this),
        },
        children: [
          {
            name: 'mark-read-text',
            cssClass: 'mark-read-text',
            component: 'ZdText',
            text: 'MARK_ALL_AS_READ',
          },
        ],
      },
    ],
  };
 
  constructor(props: INotifications) {
    super(props);
    this.allNotificationsPath = this.getInitValue(
      'allNotificationsPath',
      props.allNotificationsPath,
      this.allNotificationsPath,
    );
    this.createAccessors();
  }
 
  public markAsRead({ event, element }: any) {
    this.callEvent('markAllAsReadClick', { event, element, component: this });
  }
 
  public showAll(event: Event, element: HTMLElement) {
    this.callEvent('showAllClick', { event, element, component: this });
  }
 
  public notificationClick(event: Event, notification: any, element: HTMLElement) {
    this.callEvent('notificationClick', {
      event, notification, element, component: this,
    });
  }
}