src/app/modules/sourcing/components/mvc-list/mvc-list.component.ts
selector | app-mvc-list |
styleUrls | mvc-list.component.scss |
templateUrl | mvc-list.component.html |
contentList
|
Type: |
selectedContentId
|
Type: |
sessionContext
|
Type: |
showAddedContent
|
Type: |
contentChangeEvent
|
$event type: EventEmitter
|
moveEvent
|
$event type: EventEmitter
|
constructor(resourceService: any, configService: any, programTelemetryService: ProgramTelemetryService)
|
onContentChange |
onContentChange(selectedContent: any)
|
Returns:
void
|
addToLibrary |
addToLibrary()
|
Returns:
void
|
changeFilter |
changeFilter()
|
Returns:
void
|
onShowAddedContentChange |
onShowAddedContentChange()
|
Returns:
void
|
Public inView |
inView(event: any)
|
Returns:
void
|
updateContentViewed |
updateContentViewed()
|
Returns:
void
|
getTelemetryInteractCdata |
getTelemetryInteractCdata(type: any, id: any)
|
Returns:
void
|
Public addToLibraryBtnVisibility |
addToLibraryBtnVisibility: |
Default value: false
|
configService |
configService: |
Public height |
height: |
Public inViewLogs |
inViewLogs: |
programTelemetryService |
programTelemetryService: |
resourceService |
resourceService: |
Public telemetryPageId |
telemetryPageId: |
Public width |
width: |
import * as _ from 'lodash-es';
import { Component, OnInit, Input, Output, EventEmitter, OnDestroy } from '@angular/core';
import { ResourceService, ConfigService } from '@sunbird/shared';
import { ProgramTelemetryService } from '../../../program/services';
@Component({
selector: 'app-mvc-list',
templateUrl: './mvc-list.component.html',
styleUrls: ['./mvc-list.component.scss']
})
export class MvcListComponent implements OnInit, OnDestroy {
@Input() sessionContext: any;
@Input() showAddedContent: Boolean;
@Input() contentList: any;
@Input() selectedContentId: any;
@Output() contentChangeEvent = new EventEmitter<any>();
@Output() moveEvent = new EventEmitter<any>();
public telemetryPageId: string;
public width: any;
public height: any;
public inViewLogs = [];
public addToLibraryBtnVisibility : Boolean = false;
constructor(public resourceService: ResourceService, public configService: ConfigService,
public programTelemetryService: ProgramTelemetryService) { }
ngOnInit() {
this.telemetryPageId = this.sessionContext.telemetryPageId;
}
ngAfterViewInit () {
setTimeout(() => {
this.inView({ inview: [] });
});
}
onContentChange(selectedContent: any) {
this.contentChangeEvent.emit({content: selectedContent});
}
addToLibrary() {
this.moveEvent.emit({
action: 'beforeMove'
});
}
changeFilter() {
window.scrollTo({
top: 0,
left: 0,
behavior: 'smooth'
});
this.moveEvent.emit({
action: 'showFilter'
});
}
onShowAddedContentChange() {
this.moveEvent.emit({
action: 'showAddedContent',
status: this.showAddedContent
});
}
public inView(event) {
_.forEach(event.inview, (elem, key) => {
const obj = _.find(this.inViewLogs, { objid: elem.data.identifier});
if (!obj) {
this.inViewLogs.push({
objid: elem.data.identifier,
objtype: elem.data.contentType || 'content',
objver: elem.data.pkgVersion.toString(),
index: elem.id
});
}
});
}
updateContentViewed() {
this.moveEvent.emit({
action: 'contentVisits',
visits: this.inViewLogs
});
}
getTelemetryInteractCdata(type, id) {
return [...this.sessionContext.telemetryInteractCdata, { type: type, id: _.toString(id)}];
}
ngOnDestroy() {
this.updateContentViewed();
}
}