File

src/app/modules/workspace/components/data-driven/data-driven.component.ts

Extends

WorkSpace

Implements

OnInit OnDestroy AfterViewInit

Metadata

Index

Properties
Methods

Constructor

constructor(searchService: SearchService, workSpaceService: WorkSpaceService, activatedRoute: ActivatedRoute, frameworkService: FrameworkService, router: Router, resourceService: ResourceService, toasterService: ToasterService, editorService: EditorService, userService: UserService, configService: ConfigService, formService: FormService, _cacheService: CacheService, navigationHelperService: NavigationHelperService, browserCacheTtlService: BrowserCacheTtlService, telemetryService: TelemetryService, publicDataService: PublicDataService, contentService: ContentService)
Parameters :
Name Type Optional
searchService SearchService No
workSpaceService WorkSpaceService No
activatedRoute ActivatedRoute No
frameworkService FrameworkService No
router Router No
resourceService ResourceService No
toasterService ToasterService No
editorService EditorService No
userService UserService No
configService ConfigService No
formService FormService No
_cacheService CacheService No
navigationHelperService NavigationHelperService No
browserCacheTtlService BrowserCacheTtlService No
telemetryService TelemetryService No
publicDataService PublicDataService No
contentService ContentService No

Methods

checkForPreviousRouteForRedirect
checkForPreviousRouteForRedirect()

Issue #SB-1448, If previous url is not from create page, redirect current page to 'workspace/content/create'

Returns : void
createContent
createContent(modal)
Parameters :
Name Optional
modal No
Returns : void
createLockAndNavigateToEditor
createLockAndNavigateToEditor(content)
Parameters :
Name Optional
content No
Returns : void
fetchFrameworkMetaData
fetchFrameworkMetaData()

fetchFrameworkMetaData is gives form config data

Returns : void
generateData
generateData(data)

requestBody is returned of type object

Parameters :
Name Optional
data No
Returns : any
generateQuestionSetData
generateQuestionSetData()
Returns : { questionset: { name: string; mimeType: string; primaryCategory: string; createdBy: any; createdFor: {}; framework: string; code: any; }; }
getCategoryList
getCategoryList(type: string)
Parameters :
Name Type Optional
type string No
Returns : object
getFormConfig
getFormConfig()
Returns : void
getFrameworkDataByType
getFrameworkDataByType(channel?, type?, identifer?, systemDefault?)
Parameters :
Name Optional
channel Yes
type Yes
identifer Yes
systemDefault Yes
Returns : any
goToCreate
goToCreate()

Redirects to workspace create section

Returns : void
logTelemetry
logTelemetry(contentId)
Parameters :
Name Optional
contentId No
Returns : void
ngAfterViewInit
ngAfterViewInit()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
redirect
redirect()
Returns : void
selectFramework
selectFramework()
           shown while creating any resource (only course as of now)
           2. It also logs interact telemetry on card click.
Returns : void
setTargetFramework
setTargetFramework(categoryDefinitionData, targetFWIdentifiers, channelFrameworksType, channelFrameworks)
Parameters :
Name Optional
categoryDefinitionData No
targetFWIdentifiers No
channelFrameworksType No
channelFrameworks No
Returns : void
showCategoryConfigError
showCategoryConfigError()
Returns : void
delete
delete(contentIds)
Inherited from WorkSpace
Defined in WorkSpace:111

Delete Api call .

Parameters :
Name Optional
contentIds No
Returns : any
getBatches
getBatches(searchParams)
Inherited from WorkSpace
Defined in WorkSpace:128

Batchlist Api call

Parameters :
Name Optional
searchParams No
Returns : any
getChannelDetails
getChannelDetails(channelId)
Inherited from WorkSpace
Defined in WorkSpace:164

get channel Api call

Parameters :
Name Optional
channelId No
Returns : any
getLinkedCollections
getLinkedCollections(contentId: ContentIDParam)
Inherited from WorkSpace
Defined in WorkSpace:157

search collection Api call

Parameters :
Name Type Optional
contentId ContentIDParam No
Returns : any
handleContentLockError
handleContentLockError(errObj)
Inherited from WorkSpace
Defined in WorkSpace:142

handle content lock api error

Parameters :
Name Optional
errObj No
Returns : string
lockContent
lockContent(content)
Inherited from WorkSpace
Defined in WorkSpace:97

this call will prepare reuest object and call lock api

Parameters :
Name Optional
content No
Returns : any
removeContent
removeContent(contentList, requestData)
Inherited from WorkSpace
Defined in WorkSpace:120

Method to remove content localcaly

Parameters :
Name Optional
contentList No
requestData No
Returns : any
search
search(searchParams)
Inherited from WorkSpace
Defined in WorkSpace:33

Search Api call

Parameters :
Name Optional
searchParams No
Returns : any
searchContentWithLockStatus
searchContentWithLockStatus(searchParams)
Inherited from WorkSpace
Defined in WorkSpace:40

Search Api call and returns contents with lock status of each one

Parameters :
Name Optional
searchParams No
Returns : any
UserList
UserList(searchParams)
Inherited from WorkSpace
Defined in WorkSpace:135

userList Api call

Parameters :
Name Optional
searchParams No
Returns : any

Properties

Public activatedRoute
Type : ActivatedRoute

To send activatedRoute.snapshot to routerNavigationService

Public browserCacheTtlService
Type : BrowserCacheTtlService
Public categoryMasterList
Type : any
Public configService
Type : ConfigService

Contains config service reference

Public contentService
Type : ContentService
Public contentType

contentType is creation type, fected from url

Public creationForm
Type : UntypedFormGroup

userForm name creation

Public creationFormLable
Type : string
Public description
Type : string
Private editorService
Type : EditorService

To make inbox API calls

Public enableCreateButton
Default value : false
Public formAction
Type : string
Default value : 'create'
formData
Type : DefaultTemplateComponent
Decorators :
@ViewChild('formData')
Public formFieldProperties
Type : any
Public formService
Type : FormService
Public formType
Type : string
Default value : 'content'
Public framework
Type : string
Public frameworkCardData
Type : []
Default value : []
Public frameworkService
Type : FrameworkService
Public getFormFields
Type : any
Public isCachedDataExists
Type : boolean
Public isSubmit
Default value : false
loaderMessage
Type : ILoaderMessage

loader message

modal
Decorators :
@ViewChild('modal')
Public name
Type : string
Public navigationHelperService
Type : NavigationHelperService
Public orgFWType
Public primaryCategory
Type : string
Public publicDataService
Type : PublicDataService
Public resourceService
Type : ResourceService

To call resource service which helps to use language constant

Public resourceType

resourceType is resource type

Public searchService
Type : SearchService
Inherited from WorkSpace
Defined in WorkSpace:127
Public selectedCard
Type : any
Public showFrameworkSelection
Type : boolean
showLoader
Default value : true

This variable hepls to show and hide page loader. It is kept true by default as at first when we comes to a page the loader should be displayed before showing any data

Public targetFramework
Type : string
Public targetFWType
telemetryImpression
Type : IImpressionEventInput

telemetryImpression

Public telemetryService
Type : TelemetryService
Private toasterService
Type : ToasterService

To show toaster(error, success etc) after any API calls

Public unsubscribe
Default value : new Subject<void>()
Private urlString

urlString for get url details

Public userChannelData
Public userService
Type : UserService
Inherited from WorkSpace
Defined in WorkSpace:72

To call resource service which helps to use language constant

Public workSpaceService
Type : WorkSpaceService
Inherited from WorkSpace
Defined in WorkSpace:128
import { Component, OnInit, ViewChild, OnDestroy, AfterViewInit } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import {
  ResourceService, ConfigService, ToasterService, ServerResponse, Framework,
  ILoaderMessage, NavigationHelperService , BrowserCacheTtlService
} from '@sunbird/shared';
import { ActivatedRoute, Router } from '@angular/router';
import { EditorService } from './../../services';
import { SearchService, UserService, FrameworkService, FormService, PublicDataService, ContentService } from '@sunbird/core';
import * as _ from 'lodash-es';
import { CacheService } from '../../../shared/services/cache-service/cache.service';
import { DefaultTemplateComponent } from '../content-creation-default-template/content-creation-default-template.component';
import { IImpressionEventInput, TelemetryService } from '@sunbird/telemetry';
import { WorkSpace } from '../../classes/workspace';
import { WorkSpaceService } from '../../services';
import { Subject } from 'rxjs';
import { takeUntil} from 'rxjs/operators';
import { v4 as UUID } from 'uuid';

@Component({
  selector: 'app-data-driven',
  templateUrl: './data-driven.component.html',
  styleUrls: ['./data-driven.component.scss']
})
export class DataDrivenComponent extends WorkSpace implements OnInit, OnDestroy, AfterViewInit {
  @ViewChild('formData') formData: DefaultTemplateComponent;
  @ViewChild('modal') modal;

  /**
	 * This variable hepls to show and hide page loader.
   * It is kept true by default as at first when we comes
   * to a page the loader should be displayed before showing
   * any data
	 */
  showLoader = true;
  /**
* To show toaster(error, success etc) after any API calls
*/
  private toasterService: ToasterService;

  /**
* urlString for get url details
*/
  private urlString;
  /**
* contentType is creation type, fected from url
*/
  public contentType;
  /**
   * resourceType is resource type
   */
  public resourceType;
  /**
 * userForm name creation
 */
  public creationForm: UntypedFormGroup;
  /**
* Contains config service reference
*/
  public configService: ConfigService;
  /**
 * To make inbox API calls
 */
  private editorService: EditorService;
  /**
  * To call resource service which helps to use language constant
  */
  public resourceService: ResourceService;
  /**
 * To call resource service which helps to use language constant
 */
  public userService: UserService;
  /**
 * To send activatedRoute.snapshot to routerNavigationService
 */
  public activatedRoute: ActivatedRoute;
  /**
  * loader message
  */
  loaderMessage: ILoaderMessage;

  public frameworkService: FrameworkService;

  public formService: FormService;

  public formType = 'content';

  public formAction = 'create';

  public getFormFields: any;

  public formFieldProperties: any;

  public categoryMasterList: any;

  public creationFormLable: string;

  public name: string;

  public description: string;

  public isCachedDataExists: boolean;

  public framework: string;
  /**
	* telemetryImpression
	*/
  telemetryImpression: IImpressionEventInput;

  public showFrameworkSelection: boolean;

  public frameworkCardData = [];

  public selectedCard: any;

  public enableCreateButton = false;

  public isSubmit = false;
  public orgFWType;
  public targetFWType;

  public unsubscribe = new Subject<void>();
  public targetFramework: string;
  public primaryCategory: string;
  public userChannelData;
  constructor(
    public searchService: SearchService,
    public workSpaceService: WorkSpaceService,
    activatedRoute: ActivatedRoute,
    frameworkService: FrameworkService,
    private router: Router,
    resourceService: ResourceService,
    toasterService: ToasterService,
    editorService: EditorService,
    userService: UserService,
    configService: ConfigService,
    formService: FormService,
    private _cacheService: CacheService,
    public navigationHelperService: NavigationHelperService,
    public browserCacheTtlService: BrowserCacheTtlService,
    public telemetryService: TelemetryService,
    public publicDataService: PublicDataService,
    public contentService: ContentService
  ) {
    super(searchService, workSpaceService, userService);
    this.activatedRoute = activatedRoute;
    this.resourceService = resourceService;
    this.toasterService = toasterService;
    this.editorService = editorService;
    this.userService = userService;
    this.configService = configService;
    this.frameworkService = frameworkService;
    this.formService = formService;
    this.activatedRoute.url.subscribe(url => {
      this.contentType = url[0].path;
    });
    this.resourceType = this.configService.appConfig.resourceType[this.contentType];
    this.creationFormLable = this.configService.appConfig.contentCreateTypeLable[this.contentType];
    this.name = this.configService.appConfig.contentName[this.contentType] ?
                this.configService.appConfig.contentName[this.contentType] : 'Untitled';
   this.description = this.configService.appConfig.contentDescription[this.contentType] ?
   this.configService.appConfig.contentDescription[this.contentType] : 'Untitled';
  }
  ngOnInit() {
    this.activatedRoute.queryParams.subscribe(queryParams => {
      this.showFrameworkSelection = _.get(queryParams, 'showFrameworkSelection');
    });
    this.userService.userOrgDetails$.subscribe(() => { // wait for user organization details
      this.checkForPreviousRouteForRedirect();
      if (this.showFrameworkSelection) {
        this.frameworkService.getChannel(this.userService.hashTagId).pipe(takeUntil(this.unsubscribe)).subscribe(data => {
          this.userChannelData = data;
          this.selectFramework();
        }, err => {
          this.toasterService.error(this.resourceService.messages.emsg.m0005);
        });
      } else {
        /**
       * fetchFrameworkMetaData is called to config the form data and framework data
       */
        this.fetchFrameworkMetaData();
      }
    });
  }

  ngOnDestroy() {
    if (this.modal && this.modal.deny) {
      this.modal.deny();
    }
  }
  /**
  * fetchFrameworkMetaData is gives form config data
  */
  fetchFrameworkMetaData() {

    this.frameworkService.frameworkData$.subscribe((frameworkData: Framework) => {
      if (!frameworkData.err) {
        this.categoryMasterList = _.cloneDeep(frameworkData.frameworkdata['defaultFramework'].categories);
        if (_.lowerCase(this.contentType) !== 'course') {
          this.framework = frameworkData.frameworkdata['defaultFramework'].code;
        }
        if (_.lowerCase(this.contentType) === 'questionset') {
          const reqData = this.generateQuestionSetData();
          this.workSpaceService.createQuestionSet(reqData).subscribe(res => {
            // tslint:disable-next-line:max-line-length
            this.router.navigate(['workspace/edit/', 'QuestionSet', res.result.identifier, 'allcontent', 'Draft']);
          }, err => {
            this.toasterService.error(this.resourceService.messages.fmsg.m0102);
          });
        } else {
          const categoryList = {
            'code' : 'primaryCategory',
            'identifier': 'sb_primaryCategory',
            'description': 'Primary Category',
            'terms' : this.getCategoryList(this.contentType)
          };
          this.categoryMasterList.push(categoryList);
          /**
          * isCachedDataExists will check data is exists in cache or not. If exists should not call
          * form api otherwise call form api and get form data
          */
          this.isCachedDataExists = this._cacheService.exists(this.contentType + this.formAction);
          if (this.isCachedDataExists) {
            const data: any | null = this._cacheService.get(this.contentType + this.formAction);
            this.formFieldProperties = data;
          } else {
            const formServiceInputParams = {
              formType: this.formType,
              formAction: this.formAction,
              contentType: this.contentType,
              framework: this.framework
            };
            this.formService.getFormConfig(formServiceInputParams).subscribe(
              (data: ServerResponse) => {
                this.formFieldProperties = data;
                this.getFormConfig();
              },
              (err: ServerResponse) => {
                this.toasterService.error(this.resourceService.messages.emsg.m0005);
              }
            );
          }
        }
      } else if (frameworkData && frameworkData.err) {
        this.toasterService.error(this.resourceService.messages.emsg.m0005);
      }
    });
  }

  /**
   * @description            - Which is used to config the form field vlaues
   * @param {formFieldProperties} formFieldProperties  - Field information
   */
  getFormConfig() {
    _.forEach(this.categoryMasterList, (category) => {
      _.forEach(this.formFieldProperties, (formFieldCategory) => {
        if (category.code === formFieldCategory.code) {
          formFieldCategory.range = category.terms;
        }
        return formFieldCategory;
      });
    });
    this.formFieldProperties = _.sortBy(_.uniqBy(this.formFieldProperties, 'code'), 'index');
    this._cacheService.set(this.contentType + this.formAction, this.formFieldProperties,
      {
        maxAge: this.configService.appConfig.cacheServiceConfig.setTimeInMinutes *
          this.configService.appConfig.cacheServiceConfig.setTimeInSeconds
      });
  }
  /****
* Redirects to workspace create section
*/
  goToCreate() {
    this.router.navigate(['/workspace/content/create']);
  }

  /**
* requestBody is returned of type object
*/
  generateData(data) {
    this.showLoader = true;
    const requestData = _.cloneDeep(data);
    requestData.name = data.name ? data.name : this.name,
      requestData.description = data.description ? data.description : this.description,
      requestData.createdBy = this.userService.userProfile.id,
      requestData.organisation = _.uniq(this.userService.orgNames),
      requestData.createdFor = this.userService?.userProfile?.rootOrgId ? [this.userService?.userProfile?.rootOrgId] : [];
    if (this.framework) {
      requestData.framework = this.framework;
    }
    if (this.contentType === 'studymaterial' && data.contentType) {
      requestData.contentType = data.contentType;
    }
    if (requestData.year) {
      requestData.year = requestData.year.toString();
    }
    if (requestData.maxAttempts) {
      requestData.maxAttempts = _.parseInt(requestData.maxAttempts);
    }
    if (this.contentType === 'studymaterial' || this.contentType === 'assessment') {
      requestData.mimeType = this.configService.appConfig.CONTENT_CONST.CREATE_LESSON;
    } else {
      requestData.mimeType = this.configService.urlConFig.URLS.CONTENT_COLLECTION;
    }
    if (data.resourceType) {
      requestData.resourceType = data.resourceType;
    } else if (this.resourceType) {
      requestData.resourceType = this.resourceType;
    }
    if (!_.isEmpty(this.userService.userProfile.lastName)) {
      requestData.creator = this.userService.userProfile.firstName + ' ' + this.userService.userProfile.lastName;
    } else {
      requestData.creator = this.userService.userProfile.firstName;
    }

    if (this.targetFramework) {
      requestData.targetFWIds = _.castArray(this.targetFramework);
    }
    if (this.primaryCategory) {
      requestData.primaryCategory = this.primaryCategory;
    }

    if (data.primaryCategory && data.primaryCategory === 'Digital Textbook') {
      requestData.contentType = this.configService.appConfig.contentCreateTypeForEditors['textbook'];
    } else {
      requestData.contentType = this.configService.appConfig.contentCreateTypeForEditors[this.contentType];
    }

    return requestData;
  }

  createContent(modal) {
    let requiredFields = [];
    requiredFields = _.map(_.filter(this.formFieldProperties, { 'required': true }), field => field.code );
    const requestData = {
      content: this.generateData(_.pickBy(this.formData.formInputData))
    };
    for (let i = 0; i < requiredFields.length; i++) {
      if (_.isUndefined(requestData.content[requiredFields[i]])) {
        this.toasterService.error(this.resourceService.messages.fmsg.m0101);
        return;
      }
    }
    if (!_.isUndefined(modal)) {
      modal.deny();
    }
    if (this.contentType === 'studymaterial' || this.contentType === 'assessment') {
      this.editorService.create(requestData).subscribe(res => {
        this.createLockAndNavigateToEditor({identifier: res.result.content_id});
      }, err => {
        this.toasterService.error(this.resourceService.messages.fmsg.m0078);
      });
    } else {
      this.editorService.create(requestData).subscribe(res => {
        this.createLockAndNavigateToEditor({identifier: res.result.content_id});
      }, err => {
        this.toasterService.error(this.resourceService.messages.fmsg.m0010);
      });
    }
  }

  createLockAndNavigateToEditor (content) {
    const state = 'draft';
    const framework = this.framework;
    if (this.contentType === 'studymaterial' || this.contentType === 'assessment') {
      this.router.navigate(['/workspace/content/edit/content/', content.identifier, state, framework, 'Draft']);
    }  else if (this.contentType === 'course' || this.contentType === 'collection' || this.contentType === 'textbook') {
      const contentType = this.configService.appConfig.contentCreateTypeForEditors[this.contentType];
      this.router.navigate(['workspace/edit/', contentType, content.identifier, state, 'Draft']);
    } else {
      const type = this.configService.appConfig.contentCreateTypeForEditors[this.contentType];
      this.router.navigate(['/workspace/content/edit/collection', content.identifier, type, state, framework, 'Draft']);
    }
    this.logTelemetry(content.identifier);
  }

  /**
    * Issue #SB-1448,  If previous url is not from create page, redirect current page to 'workspace/content/create'
  */
 checkForPreviousRouteForRedirect() {
  const previousUrlObj = this.navigationHelperService.getPreviousUrl();
    if (previousUrlObj && previousUrlObj.url && (previousUrlObj.url !== '/workspace/content/create')) {
      this.redirect();
    }
  }

  setTargetFramework(categoryDefinitionData, targetFWIdentifiers, channelFrameworksType, channelFrameworks) {
    if (_.isEmpty(targetFWIdentifiers)) {
      this.targetFWType = _.get(categoryDefinitionData, 'result.objectCategoryDefinition.objectMetadata.config.frameworkMetadata.targetFWType');
      const difference =  _.difference(this.targetFWType, _.uniq(channelFrameworksType));

      if (this.targetFWType && channelFrameworksType && _.isEmpty(difference)) {
          this.targetFramework =  _.get(_.first(_.filter(channelFrameworks, framework => {
            return framework.type === _.first(this.targetFWType);
          })), 'identifier');
          if (_.isEmpty(this.targetFramework)) {
            this.showCategoryConfigError();
          } else {
            this.createContent(undefined);
          }
      } else if ((this.targetFWType && channelFrameworksType && !_.isEmpty(difference))  || _.isEmpty(channelFrameworksType)) {
        this.getFrameworkDataByType(undefined, difference, undefined, 'Yes').subscribe(
          (targetResponse) => {
            this.targetFramework = _.get(_.first(_.get(targetResponse, 'result.Framework')), 'identifier');
            if (_.isEmpty(this.targetFramework)) {
              this.showCategoryConfigError();
            } else {
              this.createContent(undefined);
            }
          }, (error) => {
            this.showCategoryConfigError();
          }
        );
      }
      if (_.isEmpty(this.orgFWType) || _.isEmpty(this.targetFWType)) {
        this.showCategoryConfigError();
      }
    } else {
      this.targetFramework = _.isArray(targetFWIdentifiers) ? _.first(targetFWIdentifiers) : targetFWIdentifiers;
      this.createContent(undefined);
    }
  }

  showCategoryConfigError() {
    this.toasterService.error(`Unknown framework category ${this.primaryCategory || 'Course'}. Please check the configuration.`);
    this.redirect();
    return ;
  }

/**
   * @since - #SH-403
   * @param  {} cardData
   * @description - 1. It selects a card from the framework selection popup
   *                shown while creating any resource (only course as of now)
   *                2. It also logs interact telemetry on card click.
   */
  selectFramework() {
    this.primaryCategory = 'Course';
    this.workSpaceService.getCategoryDefinition('Collection', this.primaryCategory, this.userService.channel)
    .subscribe(categoryDefinitionData => {
      this.orgFWType = _.get(categoryDefinitionData, 'result.objectCategoryDefinition.objectMetadata.schema.properties.framework.enum') ||
      _.get(categoryDefinitionData, 'result.objectCategoryDefinition.objectMetadata.schema.properties.framework.default');
      const targetFWIdentifiers = _.get(categoryDefinitionData, 'result.objectCategoryDefinition.objectMetadata.schema.properties.targetFWIds.default');
      const channelFrameworks = _.get(this.userChannelData, 'result.channel.frameworks');
      const channelFrameworksType = _.compact(_.map(channelFrameworks, 'type'));

      if (_.isEmpty(this.orgFWType)) {
        this.orgFWType = _.get(categoryDefinitionData, 'result.objectCategoryDefinition.objectMetadata.config.frameworkMetadata.orgFWType');
        const difference = _.difference(this.orgFWType, _.uniq(channelFrameworksType));

        if ((!_.isEmpty(this.orgFWType) && !_.isEmpty(channelFrameworksType) && !_.isEmpty(difference)) ||
        _.isEmpty(channelFrameworksType)) {
          this.getFrameworkDataByType(undefined, difference, undefined, 'Yes').subscribe(
            (response) => {
              if (!_.get(response, 'result.count')) {
                this.showCategoryConfigError();
              } else {
                this.setTargetFramework(categoryDefinitionData, targetFWIdentifiers, channelFrameworksType, channelFrameworks);
              }
            }, (error) => {
              this.showCategoryConfigError();
            }
          );
        } else {
          this.setTargetFramework(categoryDefinitionData, targetFWIdentifiers, channelFrameworksType, channelFrameworks);
        }
      } else {
        this.setTargetFramework(categoryDefinitionData, targetFWIdentifiers, channelFrameworksType, channelFrameworks);
      }
    }, err => {
      this.toasterService.error(this.resourceService.messages.emsg.m0024);
    });
  }

  redirect() {
    this.router.navigate(['/workspace/content/create']);
  }

  ngAfterViewInit () {
    setTimeout(() => {
      this.telemetryImpression = {
        context: {
          env: this.activatedRoute.snapshot.data.telemetry.env
        },
        edata: {
          type: this.activatedRoute.snapshot.data.telemetry.type,
          pageid: this.activatedRoute.snapshot.data.telemetry.pageid,
          subtype: this.activatedRoute.snapshot.data.telemetry.subtype,
          uri: this.activatedRoute.snapshot.data.telemetry.uri,
          duration: this.navigationHelperService.getPageLoadTime()
        }
      };
    });
  }

  getFrameworkDataByType(channel?, type?, identifer?, systemDefault?) {
    const option = {
      url: `${this.configService.urlConFig.URLS.COMPOSITE.SEARCH}`,
      data: {
        request: {
            filters: {
                objectType: 'Framework',
                status: ['Live'],
                ...(type && {type}),
                ...(identifer && {identifer}),
                ...(channel && {channel}),
                ...(systemDefault && {systemDefault})
            }
        }
    }
      };
      return this.contentService.post(option);
  }


  /**
   * @since - #SH-403
   * @param  {string} contentId
   * @description - it triggers an interact event when Start creating button is clicked.
   */
  logTelemetry(contentId) {
    const telemetryData = {
      context: {
        env: _.get(this.activatedRoute, 'snapshot.data.telemetry.env'),
        cdata: []
      },
      edata: {
        id: 'start-creating-' + this.contentType,
        type: 'click',
        pageid: _.get(this.activatedRoute, 'snapshot.data.telemetry.pageid')
      },
      object: {
        id: contentId,
        type: this.contentType,
        ver: '1.0',
        rollup: {},
      }
    };
    if (this.framework) {
      telemetryData.context.cdata.push({
        type: 'framework',
        id: this.framework
      });
    }
    if (this.targetFramework) {
      telemetryData.context.cdata.push({
        type: 'targetFW',
        id: this.targetFramework
      });
    }
    this.telemetryService.interact(telemetryData);
  }

  getCategoryList(type: string): object {
    const primaryCategoryList = [];
      if (type === 'collection' || type === 'lessonplan') {
        if (!_.isEmpty(this.frameworkService['_channelData'].collectionPrimaryCategories)) {
          _.forEach(this.frameworkService['_channelData'].collectionPrimaryCategories, (field) => {
            if (_.lowerCase(field) === _.lowerCase('Course')) {
              return;
            }
            const categoryTemplateObject = {
               'identifier' : field,
               'name' : field,
               'description': field
            };
            primaryCategoryList.push(categoryTemplateObject);
        });
        }
      } else if (type === 'studymaterial' || type === 'assessment') {
        if (!_.isEmpty(this.frameworkService['_channelData'].contentPrimaryCategories)) {
          _.forEach(this.frameworkService['_channelData'].contentPrimaryCategories, (field) => {
            if (_.lowerCase(field) === _.lowerCase('Course Assessment')) {
              return;
            }
            const categoryTemplateObject = {
               'identifier' : field,
               'name' : field,
               'description': field
            };
            primaryCategoryList.push(categoryTemplateObject);
        });
      }
    }
    return primaryCategoryList;
  }

  generateQuestionSetData() {
    let name = this.userService.userProfile.firstName;
    if (!_.isEmpty(this.userService.userProfile.lastName)) {
      name = this.userService.userProfile.firstName + ' ' + this.userService.userProfile.lastName;
    }
    return {
        'questionset': {
          name: 'Untitled QuestionSet',
          mimeType: 'application/vnd.sunbird.questionset',
          primaryCategory: 'Practice Question Set',
          createdBy: this.userService.userProfile.id,
          // organisation: _.uniq(this.userService.orgNames),
          createdFor: this.userService?.userProfile?.rootOrgId ? [this.userService?.userProfile?.rootOrgId] : [],
          framework: this.framework,
          // creator: name,
          code: UUID()
        }
    };
  }
}

  <div *ngIf="showFrameworkSelection" #formData>
  </div>
  <sui-modal *ngIf="!showFrameworkSelection" [mustScroll]="true" [isClosable]="false" [transitionDuration]="0" [size]="'normal'"
  class="sb-modal sb-course-modal" appBodyScroll (dismissed)="goToCreate();" #modal
  [appTelemetryImpression]="telemetryImpression">

  <i class="icon close" (click)="modal.deny('denied')" tabindex="0"></i>

  <!-- This section will show as usual creation popup -->
  <div>
    <!--Header-->
    <div class="sb-modal-header">
      {{resourceService?.frmelmnts?.lbl[creationFormLable]}}
    </div>
    <!--/Header-->
  
    <!--Content-->
    <div class="sb-modal-content o-y-visible" *ngIf="formFieldProperties && categoryMasterList">
      <app-content-creation-default-template #formData [formFieldProperties]="formFieldProperties"
        [categoryMasterList]="categoryMasterList">
      </app-content-creation-default-template>
    </div>
    <!--/Content-->
  
    <!--Actions-->
    <div class="sb-modal-actions">
      <button class="sb-btn sb-btn-normal sb-btn-primary" tabindex="0" (click)="createContent(modal)">
        {{resourceService?.frmelmnts?.btn?.startcreating}}
      </button>
    </div>
  </div>

  <!--/Actions-->
</sui-modal>


./data-driven.component.scss

@use "@project-sunbird/sb-styles/assets/mixins/mixins" as *;
// In workspace, course card modal 
.sb-modal.sb-course-modal .sb-modal-content {
  .sbgrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(291.98px, 1fr));
    grid-gap: 1.5rem;
    grid-row-gap: 1.5rem;
    .sb-education-card {
      padding: calculateRem(16px);
      border: calculateRem(1px) solid var(--gray-100);
      border-radius: calculateRem(4px);
      position: relative;
      &:hover {
        cursor: pointer;
        border: calculateRem(1px) solid var(--gray-200);
        .checkbox-img {
          position: absolute;
          top: calculateRem(8px);
          right: calculateRem(8px);
          display: inline;
          width: calculateRem(20px);
          height: calculateRem(20px);
          background: var(--gray-200);
          -webkit-mask-image: url(../../../../../assets/images/checkbox-icon.svg);
          mask-image: url(../../../../../assets/images/checkbox-icon.svg);
          -webkit-mask-size: contain;
          -webkit-mask-position: 50% 50%;
          -webkit-mask-repeat: no-repeat;
          mask-size: contain;
          mask-position: 50% 50%;
          mask-repeat: no-repeat;
        }
      }
      &.active {
        background: var(--rc-bfe1cf);
        border: calculateRem(1px) solid var(--secondary-color);
        cursor: pointer;
        .checkbox-img {
          position: absolute;
          top: calculateRem(8px);
          right: calculateRem(8px);
          display: inline;
          width: calculateRem(20px);
          height: calculateRem(20px);
          background-color: var(--secondary-400);
          -webkit-mask-image: url(../../../../../assets/images/checkbox-icon.svg);
          mask-image: url(../../../../../assets/images/checkbox-icon.svg);
          -webkit-mask-size: contain;
          -webkit-mask-position: 50% 50%;
          -webkit-mask-repeat: no-repeat;
          mask-size: contain;
          mask-position: 50% 50%;
          mask-repeat: no-repeat;
        }
      }
      .checkbox-img {
        display: none;
      }
      &__title {
        color: var(--black);
        font-weight: bold;
      }
      &__text {
        font-size: calculateRem(12px);
        color: var(--gray-400);
      }
    }
  }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""