File

src/app/components/popups/sb-popover/sb-popover.component.ts

Implements

OnDestroy

Metadata

Index

Properties
Methods

Constructor

constructor(navParams: NavParams, platform: Platform, ngZone: NgZone, popoverCtrl: PopoverController, commonUtilService: CommonUtilService)
Parameters :
Name Type Optional
navParams NavParams No
platform Platform No
ngZone NgZone No
popoverCtrl PopoverController No
commonUtilService CommonUtilService No

Methods

Async closePopover
closePopover(closeDeletePopOver: boolean)
Parameters :
Name Type Optional
closeDeletePopOver boolean No
Returns : any
Async deleteContent
deleteContent(canDelete: boolean, btn?)
Parameters :
Name Type Optional Default value
canDelete boolean No false
btn Yes
Returns : unknown
ionViewWillEnter
ionViewWillEnter()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void

Properties

actionsButtons
Type : any
backButtonFunc
Default value : undefined
batchDetails
Type : any
content
Type : any
contentId
Type : string
Public corRelationList
Type : Array<CorrelationData>
data
Type : any
disableDeviceBackButton
Type : boolean
icon
Type : any
img
Type : any
isChild
Default value : false
metaInfo
Type : any
Public navParams
Type : NavParams
Public objRollup
Type : Rollup
pageName
Type : string
Default value : ''
sbPopoverContent
Type : any
Public Optional sbPopoverDynamicButtonDisabledSubscription
Type : Subscription
Public Optional sbPopoverDynamicContent$
Type : Observable<string>
Public Optional sbPopoverDynamicContentSubscription
Type : Subscription
Public Optional sbPopoverDynamicMainTitle$
Type : Observable<string>
Public Optional sbPopoverDynamicMainTitleSubscription
Type : Subscription
sbPopoverHeading
Type : any
Optional sbPopoverHtmlContent
Type : string
sbPopoverInfo
Type : any
sbPopoverMainTitle
Type : any
showCloseBtn
Default value : true
showFlagMenu
Default value : true
userId
Type : string
Default value : ''
import { Component, NgZone, OnDestroy } from '@angular/core';
import { CommonUtilService } from '@app/services/common-util.service';
import { NavParams, Platform, PopoverController } from '@ionic/angular';
import { Observable, Subscription } from 'rxjs';
import { tap } from 'rxjs/operators';
import { CorrelationData, Rollup } from 'sunbird-sdk';

@Component({
  selector: 'sb-popover',
  templateUrl: 'sb-popover.component.html'
})
export class SbPopoverComponent implements OnDestroy {
  sbPopoverHeading: any;
  sbPopoverMainTitle: any;
  sbPopoverContent: any;
  sbPopoverHtmlContent?: string;
  sbPopoverInfo: any;
  actionsButtons: any;
  icon: any;
  metaInfo: any;
  content: any;
  data: any;
  isChild = false;
  contentId: string;
  batchDetails: any;
  backButtonFunc = undefined;
  userId = '';
  pageName = '';
  showFlagMenu = true;
  img: any;
  disableDeviceBackButton: boolean;
  showCloseBtn = true;
  public objRollup: Rollup;

  public corRelationList: Array<CorrelationData>;
  public sbPopoverDynamicMainTitle$?: Observable<string>;
  public sbPopoverDynamicMainTitleSubscription?: Subscription;
  public sbPopoverDynamicContent$?: Observable<string>;
  public sbPopoverDynamicContentSubscription?: Subscription;
  public sbPopoverDynamicButtonDisabledSubscription?: Subscription;

  constructor(
    public navParams: NavParams,
    private platform: Platform,
    private ngZone: NgZone,
    private popoverCtrl: PopoverController,
    private commonUtilService: CommonUtilService
  ) {
    this.content = this.navParams.get('content');
    this.actionsButtons = this.navParams.get('actionsButtons');
    this.icon = this.navParams.get('icon');
    this.metaInfo = this.navParams.get('metaInfo');
    this.sbPopoverContent = this.navParams.get('sbPopoverContent');
    this.sbPopoverHtmlContent = this.navParams.get('sbPopoverHtmlContent');
    this.sbPopoverHeading = this.navParams.get('sbPopoverHeading');
    this.sbPopoverMainTitle = this.navParams.get('sbPopoverMainTitle');
    this.showCloseBtn = this.navParams.get('showCloseBtn');
    this.sbPopoverInfo = this.navParams.get('sbPopoverInfo');


    this.content = this.navParams.get('content');
    this.data = this.navParams.get('data');
    this.batchDetails = this.navParams.get('batchDetails');
    this.pageName = this.navParams.get('pageName');
    this.objRollup = this.navParams.get('objRollup');
    this.corRelationList = this.navParams.get('corRelationList');
    this.img = this.navParams.get('img');
    this.disableDeviceBackButton = this.navParams.get('disableDeviceBackButton');

    // Dynamic
    this.sbPopoverDynamicMainTitle$ = this.navParams.get('sbPopoverDynamicMainTitle');
    this.sbPopoverDynamicContent$ = this.navParams.get('sbPopoverDynamicContent');


    if (this.navParams.get('isChild')) {
      this.isChild = true;
    }

    if (this.sbPopoverDynamicMainTitle$) {
      this.sbPopoverDynamicMainTitleSubscription = this.sbPopoverDynamicMainTitle$.pipe(
        tap((v) => {
          this.ngZone.run(() => {
            this.sbPopoverMainTitle = v;
          });
        })
      )
      .subscribe();
    }

    if (this.sbPopoverDynamicContent$) {
      this.sbPopoverDynamicContentSubscription = this.sbPopoverDynamicContent$.pipe(
        tap((v) => {
          this.ngZone.run(() => {
            this.sbPopoverContent = v;
          });
        })
      )
      .subscribe();
    }
    for (const actionsButton of this.actionsButtons) {
      if (actionsButton.btnDisabled$) {
        this.sbPopoverDynamicButtonDisabledSubscription = actionsButton.btnDisabled$.pipe(
          tap((v) => {
            // this.ngZone.run(() => {
            actionsButton.btnDisabled = v;
            // });
          })
        )
        .subscribe();
      }
    }

    this.contentId = (this.content && this.content.identifier) ? this.content.identifier : '';
  }

  ionViewWillEnter() {
    this.backButtonFunc = this.platform.backButton.subscribeWithPriority(11, () => {
      if (this.disableDeviceBackButton) {
        return;
      }
      this.popoverCtrl.dismiss();
      this.backButtonFunc.unsubscribe();
    });
  }

  ngOnDestroy(): void {
    if (this.sbPopoverDynamicMainTitleSubscription) {
      this.sbPopoverDynamicMainTitleSubscription.unsubscribe();
    }

    if (this.sbPopoverDynamicContentSubscription) {
      this.sbPopoverDynamicContentSubscription.unsubscribe();
    }
    if (this.sbPopoverDynamicButtonDisabledSubscription) {
      this.sbPopoverDynamicButtonDisabledSubscription.unsubscribe();
    }

    if (this.backButtonFunc) {
      this.backButtonFunc.unsubscribe();
    }
  }

  async closePopover(closeDeletePopOver: boolean) {
   await this.popoverCtrl.dismiss({closeDeletePopOver});
  }

  async deleteContent(canDelete: boolean = false, btn?) {
    if (!this.commonUtilService.networkInfo.isNetworkAvailable && btn.isInternetNeededMessage) {
      this.commonUtilService.showToast(btn.isInternetNeededMessage);
      return false;
    }
    this.popoverCtrl.dismiss({ canDelete });
    if (this.navParams.get('handler')) {
      this.navParams.get('handler')(btn.btntext);
    }
  }
}
<ion-header class="sb-popover-header">
  <ion-toolbar class="sb-popover-toolbar">
    <ion-title role="heading" class="sb-popover-title">{{sbPopoverHeading}}
      <ion-icon *ngIf="showCloseBtn" name="close" class="sb-modal-close" (click)="closePopover(true)"></ion-icon>
    </ion-title>
  </ion-toolbar>
</ion-header>

<ion-content class="sb-popover-container ion-no-padding">
  <div class="sb-popover-items">
    <div class="icon-container" *ngIf="icon">
      <ion-icon ios="{{icon?.ios}}" md="{{icon?.md}}"></ion-icon>
    </div>
    <div class="icon-container" *ngIf="img">
      <img [src]=img alt="" />
    </div>

    <div class="sb-popover-content-details" *ngIf="sbPopoverMainTitle || metaInfo || sbPopoverContent || sbPopoverHtmlContent || sbPopoverInfo">
      <div class="main-title">
        {{sbPopoverMainTitle}}
        <div class="meta-info">
          {{metaInfo}}
        </div>
      </div>
      <div class="sb-popover-content" *ngIf="sbPopoverContent">
        {{sbPopoverContent}}
      </div>
      <div *ngIf="sbPopoverHtmlContent" [innerHTML]="sbPopoverHtmlContent">
      </div>
      <div class="sb-popover-information" *ngIf="sbPopoverInfo">
        {{sbPopoverInfo}}
      </div>
    </div>
  </div>
</ion-content>

<ion-footer>
  <div class="sb-popover-footer">
    <button class="sb-popover-action-btn" [ngClass]="btn.btnClass" *ngFor="let btn of actionsButtons"
      (click)='deleteContent(true,btn)' [disabled]='btn.btnDisabled'> {{btn.btntext }}</button>
  </div>
</ion-footer>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""