File

src/app/my-groups/view-more-activity/view-more-activity.page.ts

Implements

OnDestroy

Metadata

Index

Properties
Methods

Constructor

constructor(headerService: AppHeaderService, commonUtilService: CommonUtilService, router: Router, platform: Platform, telemetryGeneratorService: TelemetryGeneratorService, location: Location, viewMoreActivityDelegateService: ViewMoreActivityDelegateService)
Parameters :
Name Type Optional
headerService AppHeaderService No
commonUtilService CommonUtilService No
router Router No
platform Platform No
telemetryGeneratorService TelemetryGeneratorService No
location Location No
viewMoreActivityDelegateService ViewMoreActivityDelegateService No

Methods

activityMenuClick
activityMenuClick(event, activity: GroupActivity, i)
Parameters :
Name Type Optional
event No
activity GroupActivity No
i No
Returns : void
handleBackButton
handleBackButton(isNavBack: boolean)
Parameters :
Name Type Optional
isNavBack boolean No
Returns : void
handleDeviceBackButton
handleDeviceBackButton()
Returns : void
handleHeaderEvents
handleHeaderEvents($event)
Parameters :
Name Optional
$event No
Returns : void
ionViewWillEnter
ionViewWillEnter()
Returns : void
ionViewWillLeave
ionViewWillLeave()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
onActivityCardClick
onActivityCardClick(event, activity: GroupActivity)
Parameters :
Name Type Optional
event No
activity GroupActivity No
Returns : void

Properties

activityGroup
Type : ActivitiesGrouped
Public commonUtilService
Type : CommonUtilService
groupId
Type : string
headerObservable
Type : any
Public headerService
Type : AppHeaderService
isMenu
Type : boolean
Optional previousPageId
Type : string
unregisterBackButton
Type : Subscription
import { GroupDetailsPageModule } from './../group-details/group-details.module';
import { Location } from '@angular/common';
import { AppHeaderService } from '../../../services/app-header.service';
import { Component, ViewEncapsulation, OnDestroy, Injectable } from '@angular/core';
import { Platform} from '@ionic/angular';
import { TelemetryGeneratorService, CommonUtilService } from '@app/services';
import {
    Environment,
    ImpressionType,
    PageId
} from '@app/services/telemetry-constants';
import { Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { GroupActivity } from '@project-sunbird/sunbird-sdk';
import { ActivitiesGrouped } from '@project-sunbird/client-services/models';

@Injectable({ providedIn: GroupDetailsPageModule })
export class ViewMoreActivityDelegateService {
    delegate?: ViewMoreActivityActionsDelegate;
}

export interface ViewMoreActivityActionsDelegate {
    onViewMoreCardClick(event: Event, activity: GroupActivity);
    onViewMoreCardMenuClick(event: Event, activity: GroupActivity): Promise<boolean>;
}

@Component({
    selector: 'view-more-activity',
    templateUrl: 'view-more-activity.page.html',
    styleUrls: ['./view-more-activity.page.scss'],
    encapsulation: ViewEncapsulation.None,
})
export class ViewMoreActivityPage implements  OnDestroy {

    unregisterBackButton: Subscription;
    headerObservable: any;
    activityGroup: ActivitiesGrouped;
    groupId: string;
    isMenu: boolean;
    previousPageId?: string;

    constructor(
        public headerService: AppHeaderService,
        public commonUtilService: CommonUtilService,
        private router: Router,
        private platform: Platform,
        private telemetryGeneratorService: TelemetryGeneratorService,
        private location: Location,
        private viewMoreActivityDelegateService: ViewMoreActivityDelegateService
    ) {
        const extras = this.router.getCurrentNavigation().extras.state;
        console.log('extras', extras);
        if (extras) {
            this.activityGroup = extras.activityGroup;
            this.groupId = extras.groupId;
            this.isMenu = extras.isMenu;
            this.previousPageId = extras.previousPageId;
        }
    }


    ionViewWillEnter() {
        this.headerObservable = this.headerService.headerEventEmitted$.subscribe(eventName => {
            this.handleHeaderEvents(eventName);
        });
        this.headerService.showHeaderWithBackButton();
        this.handleDeviceBackButton();
        this.telemetryGeneratorService.generateImpressionTelemetry(
            ImpressionType.VIEW,
            '',
            PageId.ADD_ACTIVITY_TO_GROUP,
            Environment.GROUP
        );
    }

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

    ngOnDestroy() {
    }

    handleBackButton(isNavBack: boolean) {
        this.telemetryGeneratorService.generateBackClickedTelemetry(PageId.ACTIVITY_TOC, Environment.GROUP, isNavBack);
        this.location.back();
    }

    handleDeviceBackButton() {
        this.unregisterBackButton = this.platform.backButton.subscribeWithPriority(10, () => {
          this.handleBackButton(false);
        });
    }

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

    onActivityCardClick(event, activity: GroupActivity) {
        if (this.viewMoreActivityDelegateService.delegate) {
            this.viewMoreActivityDelegateService.delegate.onViewMoreCardClick(event, activity);
        }
    }

    activityMenuClick(event, activity: GroupActivity, i) {
        if (this.viewMoreActivityDelegateService.delegate) {
            this.viewMoreActivityDelegateService.delegate.onViewMoreCardMenuClick(event, activity).then((isRemoved) => {
                if (isRemoved) {
                    this.activityGroup.items.splice(i, 1);
                }
            });
        }
    }

}
<ion-content class="activity-toc-container ion-no-padding">    
    <div class="sb-textbook-container">
      <div class="sb-textbook-items">
        <div class="sb-textbook-title-container">
          <span class="textbook-icon">
            <ion-icon name="albums"></ion-icon>
          </span>
          <span class="textbook-title">
            {{activityGroup.title | translate}}
          </span>
        </div>
        <div class="sb-card-container sb-card-textbook-container">
          <div *ngIf="activityGroup.title === 'COURSES'">
            <div class="sc-content" *ngFor="let activity of activityGroup.items; let i = index;">
              <sb-course-card *ngIf="activity.type === 'Course' && activity.activityInfo" [section]="null"
                [cardImg]="commonUtilService.getContentImg(activity.activityInfo)" [course]="activity.activityInfo"
                (click)="onActivityCardClick($event, activity)" [isMenu]="isMenu"
                (menuClick)="activityMenuClick($event, activity, i)">
              </sb-course-card>
            </div>
          </div>
          <div *ngIf="activityGroup.title !== 'COURSES'">
            <div class="sc-content" *ngFor="let activity of activityGroup.items; let i = index;">
              <sb-library-card [content]="activity.activityInfo" [type]="'mobile_textbook'" (click)="onActivityCardClick($event, activity)"
              [cardImg]="commonUtilService.getContentImg(activity.activityInfo)" [isMenu]="isMenu"
              (menuClick)="activityMenuClick($event, activity, i)">
              </sb-library-card>
            </div>
          </div>
        </div>
      </div>
    </div>
</ion-content>

    

./view-more-activity.page.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""