File

src/app/collection-detail-etb/textbook-toc/textbook-toc.ts

Implements

OnInit OnDestroy

Metadata

Index

Properties
Methods

Constructor

constructor(router: Router, headerService: AppHeaderService, platform: Platform, commonUtilService: CommonUtilService, popoverCtrl: PopoverController, textbookTocService: TextbookTocService, telemetryService: TelemetryGeneratorService, location: Location, events: Events)
Parameters :
Name Type Optional
router Router No
headerService AppHeaderService No
platform Platform No
commonUtilService CommonUtilService No
popoverCtrl PopoverController No
textbookTocService TextbookTocService No
telemetryService TelemetryGeneratorService No
location Location No
events Events No

Methods

getChildDataIdScrollEvent
getChildDataIdScrollEvent()
Returns : void
handleBackButton
handleBackButton(isNavBack: boolean)
Parameters :
Name Type Optional
isNavBack boolean No
Returns : void
handleHeaderEvents
handleHeaderEvents($event)
Parameters :
Name Optional
$event No
Returns : void
ionViewWillEnter
ionViewWillEnter()
Returns : void
ionViewWillLeave
ionViewWillLeave()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
setContentId
setContentId(id: string, content)
Parameters :
Name Type Optional
id string No
content No
Returns : void
Async showCommingSoonPopup
showCommingSoonPopup(childData: any)
Parameters :
Name Type Optional
childData any No
Returns : any

Properties

activeMimeTypeFilter
Type : []
Default value : ['all']
backButtonFunc
Default value : undefined
childrenData
Type : Array<any>
content
Type : IonContent
Decorators :
@ViewChild(IonContent, {static: false})
headerObservable
Type : any
Public headerService
Type : AppHeaderService
isDownloadStarted
Default value : false
isTextbookTocPage
Default value : false
latestParentName
Type : any
latestParentNodes
Type : any
Static pageName
Type : string
Default value : 'TextBookTocPage'
parentId
Type : any
showLoading
Default value : false
stckyindex
Type : any
Optional stckyUnitTitle
Type : string
import { Location } from '@angular/common';
import { Component, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { Router } from '@angular/router';
import { EventTopics } from '@app/app/app.constant';
import { CommonUtilService } from '@app/services/common-util.service';
import {
    Environment,
    ImpressionSubtype,
    ImpressionType,
    InteractSubtype,
    InteractType,
    PageId
} from '@app/services/telemetry-constants';
import { TelemetryGeneratorService } from '@app/services/telemetry-generator.service';
import { IonContent, Platform, PopoverController } from '@ionic/angular';
import { Events } from '@app/util/events';
import { AppHeaderService } from './../../../services/app-header.service';
import { SbGenericPopoverComponent } from './../../components/popups/sb-generic-popover/sb-generic-popover.component';
import { TextbookTocService } from './../textbook-toc-service';

@Component({
    selector: 'textbook-toc',
    templateUrl: 'textbook-toc.html',
    styleUrls: ['./textbook-toc.scss'],
    encapsulation: ViewEncapsulation.None,
})
export class TextBookTocPage implements OnInit, OnDestroy {

    static pageName = 'TextBookTocPage';

    headerObservable: any;
    backButtonFunc = undefined;
    childrenData: Array<any>;
    activeMimeTypeFilter = ['all'];
    parentId: any;
    showLoading = false;
    isDownloadStarted = false;
    isTextbookTocPage = false;
    stckyUnitTitle?: string;
    @ViewChild(IonContent, { static: false }) content: IonContent;
    stckyindex: any;
    latestParentNodes: any;
    latestParentName: any;

    constructor(
        private router: Router,
        public headerService: AppHeaderService,
        private platform: Platform,
        private commonUtilService: CommonUtilService,
        private popoverCtrl: PopoverController,
        private textbookTocService: TextbookTocService,
        private telemetryService: TelemetryGeneratorService,
        private location: Location,
        private events: Events,
    ) {
        const extras = this.router.getCurrentNavigation().extras.state;
        if (extras) {
            this.childrenData = extras.childrenData;
            this.parentId = extras.parentId;
            this.isTextbookTocPage = extras.isTextbookTocPage;
            if (extras.stckyUnitTitle) {
                this.stckyUnitTitle = extras.stckyUnitTitle;
                this.stckyindex = extras.stckyindex;
                this.latestParentNodes = extras.latestParentNodes;
                this.latestParentName =  extras.latestParentNodes ? this.latestParentNodes[this.stckyindex].contentData.name : '';
            }
        }
    }

    ngOnInit() {
        this.getChildDataIdScrollEvent();
    }

    ionViewWillEnter() {
        this.headerObservable = this.headerService.headerEventEmitted$.subscribe(eventName => {
            this.handleHeaderEvents(eventName);
        });
        this.headerService.showHeaderWithBackButton();
        this.backButtonFunc = this.platform.backButton.subscribeWithPriority(11, () => {
            this.handleBackButton(false);
            this.backButtonFunc();
        });
        this.textbookTocService.setTextbookIds({ contentId: undefined, rootUnitId: undefined });
    }

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

    handleBackButton(isNavBack: boolean) {
        this.telemetryService.generateBackClickedTelemetry(PageId.TEXTBOOK_TOC, Environment.HOME, isNavBack);
        this.location.back();
    }

    handleHeaderEvents($event) {
        if($event.name == 'back') {
                this.handleBackButton(true);
        }
    }

    async showCommingSoonPopup(childData: any) {
        if (childData.contentData.mimeType === 'application/vnd.ekstep.content-collection' && !childData.children) {
            const popover = await this.popoverCtrl.create({
                component: SbGenericPopoverComponent,
                componentProps: {
                    sbPopoverHeading: this.commonUtilService.translateMessage('CONTENT_COMMING_SOON'),
                    sbPopoverMainTitle: this.commonUtilService.translateMessage('CONTENT_IS_BEEING_ADDED',
                        {content_name : childData.contentData.name }),
                    actionsButtons: [
                        {
                            btntext: this.commonUtilService.translateMessage('OKAY'),
                            btnClass: 'popover-color'
                        }
                    ],
                },
                cssClass: 'sb-popover warning',
            });
            await popover.present();
        }
        this.telemetryService.generateImpressionTelemetry(
            ImpressionType.VIEW,
            ImpressionSubtype.COMINGSOON_POPUP,
            PageId.TEXTBOOK_TOC,
            Environment.HOME,
        );
    }

    // set textbook unit and contentids for scrolling to particular unit in etb page
    setContentId(id: string, content) {
        const values = new Map();
        values['unitClicked'] = id;
        values['parentId'] = this.parentId;
        this.telemetryService.generateInteractTelemetry(
            InteractType.TOUCH,
            InteractSubtype.UNIT_CLICKED,
            Environment.HOME,
            PageId.TEXTBOOK_TOC,
            undefined,
            values
        );

        this.textbookTocService.setTextbookIds({ rootUnitId: id, contentId: id, content });
        this.location.back();
    }

    getChildDataIdScrollEvent() {
        const headerSpaceHeight = 58;
        const deviceHeight = this.platform.height();
        this.events.subscribe(EventTopics.TOC_COLLECTION_CHILD_ID, (event) => {
            setTimeout(() => {
                const idVal: any  = document.getElementById(event.id);
                if (idVal) {
                    const offSetIdVal = idVal.offsetTop;
                    if (offSetIdVal && (deviceHeight - headerSpaceHeight) < offSetIdVal) {
                        this.content.scrollToPoint(0, offSetIdVal, 500);
                    }
                }
            }, 1000);
        });
    }

    ngOnDestroy() {
        this.events.unsubscribe(EventTopics.TOC_COLLECTION_CHILD_ID);
    }

}
<ion-content [scrollEvents]="true" class="sb-textbook-toc ion-no-padding">
  <section *ngIf=" childrenData && childrenData?.length">
    <ion-card class="sb-accordian-card" *ngFor="let item of childrenData;  let i = index;">
      <ion-grid class="sb-accordian-header">
        <ion-row *ngIf="item?.children">
          <ion-col size="11">
            <div class="sb-topic-text" (click)="setContentId(item.identifier, item)"> {{item?.contentData?.name}} </div>
          </ion-col>
        </ion-row>
        <ion-row *ngIf="item?.contentData?.mimeType !== 'application/vnd.ekstep.content-collection' && !item?.children"
          (click)="setContentId(item.identifier, item)">
          <ion-col size="11">
            <div [ngClass]="{'sb-accordian-grey-text': !commonUtilService.networkInfo.isNetworkAvailable && !item?.isAvailableLocally,
                'sb-play-selected':item?.isAvailableLocally,'sb-play-unselected':!item?.isAvailableLocally}">
              {{item?.contentData?.name}}
            </div>
          </ion-col>
        </ion-row>
        <div class="sb-accordian-grey-text" (click)="showCommingSoonPopup(item)"
          *ngIf="item?.contentData?.mimeType === 'application/vnd.ekstep.content-collection' && !item?.children">
          {{item?.contentData?.name}}
          <span class="grey-icon-span">
            <ion-icon name="alert" class="grey-icon ML5"></ion-icon>
          </span>
        </div>
      </ion-grid>
      <div class="sb-hidden-content px-16 pt-8" *ngIf="(item?.children && item?.children?.length)">
        <div *ngFor="let firstChildren of item?.children; let j = index;">
          <div class="sb-topics-container sb-topics-container-toc">
            <app-collection-child [childData]="firstChildren" [index]="j" [depth]="depth" [rootUnitId]="item.identifier"
              [isTextbookTocPage]="true" [corRelationList]="corRelationList" [isDepthChild]="isDepthChild"
              [breadCrumb]="breadCrumb" [stckyUnitTitle]="stckyUnitTitle" [stckyindex]="stckyindex"
              [latestParentName]="latestParentName" [latestParentNodes]="latestParentNodes"></app-collection-child>
          </div>
        </div>
      </div>
    </ion-card>
  </section>
</ion-content>

<ion-backdrop class="loading-backdrop ion-text-center" *ngIf="showLoading && !isDownloadStarted">
  <div class="backdrop-container">
    <ion-label>{{ 'LOADING_CONTENTS' | translate: {'%s': downloadProgress ? downloadProgress : 0} }}</ion-label>
    <app-pb-horizontal [progress]="downloadProgress" isOnBoardCard="false"></app-pb-horizontal>
  </div>

  <div class="backdrop-footer">
    <ion-button size="small" (click)="cancelDownload()">{{ 'CANCEL' | translate }}</ion-button>
  </div>
</ion-backdrop>

./textbook-toc.scss

@import "src/assets/styles/base/_variables.scss";
@import "src/assets/styles/_variables.scss";
:host {
  .scroll-content {
    padding-bottom: 20% !important;
  }
  .sb-topic-text{
    width: 90.28%;
    color: $blue;
    font-size: $font-size-base;
    font-weight: bold;
    line-height: 1.25rem;
  }
  .sb-topic-item {
    color: $primary-color;
    padding: 8px;
  }
  .sb-accordian-card {
    margin: 0 !important;
    box-shadow: none;
    border-bottom: 1px solid map-get($colors, medium_gray);
  }
  .sb-play-selected{
    font-weight: normal;
    color: $blue;
    ion-icon {
      display: none;
    }
  }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""