File

src/app/modules/player-helper/components/content-credits/content-credits.component.ts

Metadata

selector app-content-credits
styleUrls content-credits.component.scss
templateUrl content-credits.component.html

Inputs

contentData

input for content credits;

Type: any

Outputs

close

Output for close popup;

$event type: EventEmitter

Constructor

constructor(resourceService: any)

Methods

Public closeModal
closeModal(contentCreditsModal: any)
Returns: void

Properties

Public contentCreditsData
contentCreditsData: any
instance
instance: string

Refrence of UserService
Constructor to create injected service(s) object
Default method of unpublished Component class

Public resourceService
resourceService: any

To call resource service which helps to use language constant

showContentCreditModal
showContentCreditModal: boolean
Default value: false

To show / hide modal

import { Component, OnInit, Input, EventEmitter, Output, OnChanges } from '@angular/core';
import { ResourceService } from '@sunbird/shared';
import * as _ from 'lodash-es';
import { ContentData, ContentCreditsData } from '@sunbird/shared';

@Component({
  selector: 'app-content-credits',
  templateUrl: './content-credits.component.html',
  styleUrls: ['./content-credits.component.scss']
})
export class ContentCreditsComponent implements OnInit, OnChanges {
   /**
   * To show / hide modal
  */
  showContentCreditModal = false;
  /**
  *input for content credits;
  */
  @Input() contentData: ContentData;
  /**
  *Output for close popup;
  */
  @Output() close = new EventEmitter<any>();
  /**
  * To call resource service which helps to use language constant
  */
  public resourceService: ResourceService;

  public contentCreditsData: ContentCreditsData;
  /**
  * Refrence of UserService
  */
  /**
  * Constructor to create injected service(s) object
  *Default method of unpublished Component class
  *@param {ResourceService} SearchService Reference of SearchService
  *@param {WorkSpaceService} WorkSpaceService Reference of SearchService
  */
 instance: string;

  constructor(resourceService: ResourceService) {
    this.resourceService = resourceService;
  }

  ngOnInit() {
    this.instance = _.upperCase(this.resourceService.instance);
  }

  ngOnChanges() {
    this.contentCreditsData = { contributors: '', creators: '', attributions: '', copyright: '' };
    if (this.contentData) {
      if (this.contentData.copyright) {
        this.contentCreditsData['copyright'] = this.contentData.copyright;
      }
      // contributors , it is a combination of content credits names, creators, and owner
      const contentCredits = _.get(this.contentData, 'contentCredits');
      const contentCreditNames = contentCredits && contentCredits.length ? _.map(contentCredits, 'name') : [];
      const contirbutors = this.contentData['contributors'] ? this.contentData['contributors'].split(',') : [];
      if (this.contentData['owner']) {
        contirbutors.push(this.contentData['owner']);
      }
      this.contentCreditsData['contributors'] = (_.compact(_.uniq(_.union(contentCreditNames, contirbutors).sort())).join(', '));
      // creators is a combination of creators and creator
      const creators = this.contentData['creators'] ? this.contentData['creators'].split(',') : [];
      if (this.contentData['creator']) {
        creators.push(this.contentData['creator']);
      }
      // attributors
      const attributions = _.isString(_.get(this.contentData, 'attributions')) ?
      _.get(this.contentData, 'attributions').split(',') : _.get(this.contentData, 'attributions');
      this.contentCreditsData['attributions'] =
      (_.compact(_.uniq(_.union(contentCreditNames, contirbutors, attributions, creators).sort())).join(', '));
    }
  }

  public closeModal(contentCreditsModal) {
    contentCreditsModal.deny();
    this.close.emit();
  }
}

results matching ""

    No results matching ""