File
Implements
Index
Properties
|
|
Methods
|
|
Inputs
|
|
Outputs
|
|
HostListeners
|
|
Outputs
handleEvent
|
Type : EventEmitter
|
|
handleGroupTnc
|
Type : EventEmitter
|
|
HostListeners
window:popstate
|
Arguments : '$event'
|
window:popstate(event)
|
|
Methods
acceptGroupTnc
|
acceptGroupTnc()
|
|
|
Private
closeDialog
|
closeDialog(modalId: string)
|
|
Parameters :
Name |
Type |
Optional |
modalId |
string
|
No
|
|
emitEvent
|
emitEvent(value)
|
|
|
ngAfterViewInit
|
ngAfterViewInit()
|
|
|
onPopState
|
onPopState(event)
|
Decorators :
@HostListener('window:popstate', ['$event'])
|
|
|
setTelemetryImpression
|
setTelemetryImpression(edata?)
|
|
|
acceptTncType
|
Default value : acceptTnc
|
|
checked
|
Default value : false
|
|
Public
router
|
Type : Router
|
|
url
|
Default value : document.location.origin
|
|
import { GroupsService } from './../../services';
import { ResourceService } from '@sunbird/shared';
import { acceptTnc } from './../../interfaces/group';
import { Component, Input, EventEmitter, Output, HostListener, AfterViewInit } from '@angular/core';
import * as _ from 'lodash-es';
import { IImpressionEventInput, TelemetryService } from '@sunbird/telemetry';
import { Router, ActivatedRoute } from '@angular/router';
import { NavigationHelperService } from '@sunbird/shared';
import { DELETE_POPUP, POP_DEACTIVATE } from '../../interfaces/telemetryConstants';
import { MatDialog } from '@angular/material/dialog';
@Component({
selector: 'app-modal',
templateUrl: './popup.component.html',
styleUrls: ['./popup.component.scss']
})
export class PopupComponent implements AfterViewInit {
@Input() title: string;
@Input() msg: string;
@Input() name: string;
@Input() type: acceptTnc;
@Output() handleGroupTnc = new EventEmitter();
@Output() handleEvent = new EventEmitter();
channel: string;
acceptTncType = acceptTnc;
checked = false;
url = document.location.origin;
telemetryImpression: IImpressionEventInput;
@HostListener('window:popstate', ['$event'])
onPopState(event) {
this.closeDialog('groupsModal');
this.closeDialog('groupTncModal');
}
constructor(public resourceService: ResourceService,
private groupService: GroupsService,
public router: Router,
private activatedRoute: ActivatedRoute,
private telemetryService: TelemetryService,
public navigationHelperService: NavigationHelperService,
private matDialog: MatDialog
) {
this.groupService.emitMenuVisibility('activate');
this.channel = _.upperCase(this.resourceService.instance);
}
/**
* @description - It will trigger impression telemetry event once the view is ready.
*/
ngAfterViewInit() {
if (this.name === 'delete') {
this.setTelemetryImpression({ type: DELETE_POPUP });
}
if (this.name === 'deActivate') {
this.setTelemetryImpression({ type: POP_DEACTIVATE });
}
}
emitEvent(value) {
this.handleEvent.emit({ name: this.name, action: value });
this.closeDialog('groupsModal');
}
acceptGroupTnc() {
this.closeDialog('groupTncModal');
this.handleGroupTnc.emit({ type: this.type });
}
closeModal() {
this.closeDialog('groupTncModal');
this.handleGroupTnc.emit();
}
setTelemetryImpression(edata?) {
this.telemetryImpression = {
context: {
env: this.activatedRoute.snapshot.data.telemetry.env,
cdata: [{
type: 'Group',
id: _.get(this.groupService, 'groupData.id')
}]
},
edata: {
type: this.activatedRoute.snapshot.data.telemetry.type,
subtype: this.activatedRoute.snapshot.data.telemetry.subtype,
pageid: this.activatedRoute.snapshot.data.telemetry.pageid,
uri: this.router.url,
duration: this.navigationHelperService.getPageLoadTime()
}
};
if (edata) {
this.telemetryImpression.edata.type = edata.type;
}
this.telemetryService.impression(this.telemetryImpression);
}
private closeDialog(modalId: string) {
const dialogRef = this.matDialog.getDialogById(modalId);
dialogRef && dialogRef.close();
}
}
<app-modal-wrapper *ngIf="!type"
[config]="{disableClose: true, size: 'small', id: 'groupsModal', panelClass: 'material-modal'}"
(dismiss)="emitEvent(false);">
<ng-template sbModalContent let-data>
<div class="sb-mat__modal" [ngClass]="{'sb-error': (name !== 'activate')}">
<div mat-dialog-title class="mb-0">
<div class="title" tabindex="0">{{title}}</div>
<button aria-label="close dialog" mat-dialog-close class="close-btn"></button>
</div>
<div class="sb-mat__modal__content">
<p> {{msg}} ?</p>
</div>
<mat-dialog-actions class="sb-mat__modal__actions">
<button *ngIf="name === 'delete'" class="sb-btn sb-btn-normal
sb-btn-outline-error mx-8" (click)="emitEvent(true)"
tabindex="0">{{resourceService?.frmelmnts?.btn?.delete}}</button>
<button *ngIf="name === 'deActivate'" class="sb-btn sb-btn-normal
sb-btn-outline-error mx-8" (click)="emitEvent(true)"
tabindex="0">{{resourceService?.frmelmnts?.btn?.deactivategrp}}</button>
<button *ngIf="name === 'activate'" class="sb-btn sb-btn-normal sb-btn-primary mx-8" (click)="emitEvent(true)"
tabindex="0">{{resourceService?.frmelmnts?.lbl?.activategrp}}</button>
<button *ngIf="name === 'disableDiscussionForum'" class="sb-btn sb-btn-normal sb-btn-primary mx-8"
(click)="emitEvent(true)" tabindex="0">{{resourceService?.frmelmnts?.lbl?.disableDiscussionForum}}</button>
<button class="sb-btn sb-btn-normal" [ngClass]="{'sb-btn-error': (name !== 'activate'),
'sb-btn-outline-primary': (name === 'activate')}" (click)="emitEvent(false)"
tabindex="0">{{resourceService?.frmelmnts?.btn?.no}}</button>
</mat-dialog-actions>
</div>
</ng-template>
</app-modal-wrapper>
<app-modal-wrapper *ngIf="type"
[config]="{disableClose: true, size: 'small', id: 'groupTncModal', panelClass: ['overflow-visible', 'material-modal']}"
(dismiss)="closeModal()">
<ng-template sbModalContent let-data>
<div class="sb-mat__modal">
<div mat-dialog-title class="mb-0">
<div class="title" tabindex="0">{{resourceService?.frmelmnts?.lbl?.groupGuidelinesold}}</div>
<button aria-label="close dialog" mat-dialog-close class="close-btn" *ngIf="type === acceptTncType.GROUP">
</button>
</div>
<div class="sb-mat__modal__content o-y-visible">
<input [(ngModel)]="checked" type="checkbox" role="checkbox" class="mr-8 cursor-pointer">
{{resourceService?.frmelmnts?.lbl?.agreeGroupToc | interpolate:'{instance}': channel }} <a
href="{{url}}/term-of-use.html#groupGuidelines" target="_blank"
class="sb-color-primary">{{resourceService?.frmelmnts?.lbl?.groupGuidelines}}</a>
</div>
<mat-dialog-actions class="sb-mat__modal__actions">
<button class="sb-btn sb-btn-normal sb-btn-primary" tabindex="0" [disabled]="!checked"
[ngClass]="{'sb-btn-disabled': !checked}"
(click)="acceptGroupTnc();">{{resourceService?.frmelmnts?.btn?.yes}}</button>
</mat-dialog-actions>
</div>
</ng-template>
</app-modal-wrapper>
Legend
Html element with directive