File

src/app/modules/learn/components/batch/create-batch/create-batch.component.ts

Implements

OnInit OnDestroy AfterViewInit

Metadata

Index

Properties
Methods

Constructor

constructor(routerNavigationService: RouterNavigationService, activatedRoute: ActivatedRoute, route: Router, resourceService: ResourceService, userService: UserService, courseBatchService: CourseBatchService, toasterService: ToasterService, configService: ConfigService, courseConsumptionService: CourseConsumptionService, navigationhelperService: NavigationHelperService, lazzyLoadScriptService: LazzyLoadScriptService, telemetryService: TelemetryService, csLibInitializerService: CsLibInitializerService, discussionService: DiscussionService)

Constructor to create injected service(s) object

Parameters :
Name Type Optional Description
routerNavigationService RouterNavigationService No

Reference of routerNavigationService

activatedRoute ActivatedRoute No

Reference of ActivatedRoute

route Router No
resourceService ResourceService No
userService UserService No
courseBatchService CourseBatchService No
toasterService ToasterService No
configService ConfigService No
courseConsumptionService CourseConsumptionService No
navigationhelperService NavigationHelperService No
lazzyLoadScriptService LazzyLoadScriptService No
telemetryService TelemetryService No
csLibInitializerService CsLibInitializerService No
discussionService DiscussionService No

Methods

Private addParticipantToBatch
addParticipantToBatch(batchId, participants)
Parameters :
Name Optional
batchId No
participants No
Returns : void
checkEnableDiscussions
checkEnableDiscussions(batchId)
Parameters :
Name Optional
batchId No
Returns : void
checkIssueCertificate
checkIssueCertificate(batchId)
Parameters :
Name Optional
batchId No
Returns : void
Public createBatch
createBatch()
Returns : void
enableDiscussionForum
enableDiscussionForum(batchId)
Parameters :
Name Optional
batchId No
Returns : void
Private fetchBatchDetails
fetchBatchDetails()
Returns : any
fetchForumConfig
fetchForumConfig()
Returns : void
getPickerMinDateForEndDate
getPickerMinDateForEndDate()
Returns : any
Private getUserOtherDetail
getUserOtherDetail(userData)
Parameters :
Name Optional
userData No
Returns : string
handleInputChange
handleInputChange(inputId, cdata)
Parameters :
Name Optional
inputId No
cdata No
Returns : void
Private initializeFormFields
initializeFormFields()

It helps to initialize form fields and apply field level validation

Returns : void
ngAfterViewInit
ngAfterViewInit()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()

Initialize form fields and getuserlist

Returns : void
Public redirect
redirect()
Returns : void
Private reload
reload()
Returns : void
selectedMultiValues
selectedMultiValues(event, field)
Parameters :
Name Optional
event No
field No
Returns : void
setTelemetryCData
setTelemetryCData(cdata: [])
Parameters :
Name Type Optional
cdata [] No
Returns : void
setTelemetryInteractData
setTelemetryInteractData()
Returns : void
Private sortUsers
sortUsers(res)
Parameters :
Name Optional
res No
Returns : { participantList: any; mentorList: any; }

Properties

Private activatedRoute
Type : ActivatedRoute

To send activatedRoute.snapshot to router navigation service for redirection to update batch component

batchData
Type : any

batchData for form

clearButtonInteractEdata
Type : IInteractEventEdata
Public configService
Type : ConfigService
Private courseBatchService
Type : CourseBatchService

Reference of UserService

Public courseConsumptionService
Type : CourseConsumptionService
courseCreator
Default value : false

courseCreator

Private courseId
Type : string
createBatchForm
Type : UntypedFormGroup

form group for batchAddUserForm

createBatchInteractEdata
Type : IInteractEventEdata
Private createBatchModel
Decorators :
@ViewChild('createBatchModel')
createForumRequest
Type : any
disableSubmitBtn
Default value : false
Private discussionCsService
Type : any
instance
Type : string
mentorList
Type : Array<any>
Default value : []

mentorList for mentors in the batch

Public navigationhelperService
Type : NavigationHelperService
participantList
Type : []
Default value : []

participantList for mentorList

pickerMinDate
Default value : new Date(new Date().setHours(0, 0, 0, 0))
Public resourceService
Type : ResourceService

To call resource service which helps to use language constant

router
Type : Router

To navigate to other pages

selectedMentorList
Type : Array<any>
Default value : []
Public selectedMentors
Type : any
Default value : []
selectedParticipantList
Type : Array<any>
Default value : []
Public selectedParticipants
Type : any
Default value : []
showCreateModal
Default value : false
showDiscussionForum
Type : string
telemetryCdata
Type : Array<literal type>
Default value : []
telemetryImpression
Type : IImpressionEventInput

telemetryImpression object for create batch page

telemetryInteractObject
Type : IInteractEventObject
Private toasterService
Type : ToasterService

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

Public unsubscribe
Default value : new Subject<void>()
url
Default value : document.location.origin
Private userSearchTime
Type : any
Private userService
Type : UserService

Reference of UserService

import { Component, OnInit, ViewChild, OnDestroy, AfterViewInit } from '@angular/core';
import { takeUntil, mergeMap } from 'rxjs/operators';
import { ActivatedRoute, Router } from '@angular/router';
import { RouterNavigationService, ResourceService, ToasterService, NavigationHelperService } from '@sunbird/shared';
import { UntypedFormGroup, UntypedFormControl, Validators } from '@angular/forms';
import { UserService } from '@sunbird/core';
import { CourseConsumptionService, CourseBatchService } from './../../../services';
import { IImpressionEventInput, IInteractEventEdata, IInteractEventObject, TelemetryService } from '@sunbird/telemetry';
import * as _ from 'lodash-es';
import dayjs from 'dayjs';
import { Subject, combineLatest } from 'rxjs';
import { LazzyLoadScriptService } from 'LazzyLoadScriptService';
import { ConfigService } from '@sunbird/shared';
import { CsModule } from '@project-sunbird/client-services';
import { CsLibInitializerService } from '../../../../../service/CsLibInitializer/cs-lib-initializer.service';
import { DiscussionService } from '../../../../../../app/modules/discussion/services/discussion/discussion.service';

@Component({
  selector: 'app-create-batch',
  templateUrl: './create-batch.component.html'
})
export class CreateBatchComponent implements OnInit, OnDestroy, AfterViewInit {

  @ViewChild('createBatchModel') private createBatchModel;

  private userSearchTime: any;

  showCreateModal = false;

  disableSubmitBtn = false;

  private courseId: string;
  /**
  * courseCreator
  */
  courseCreator = false;
  /**
  * participantList for mentorList
  */
  participantList = [];

  public selectedParticipants: any = [];

  public selectedMentors: any = [];
  /**
  * batchData for form
  */
  batchData: any;
  /**
  * mentorList for mentors in the batch
  */
  mentorList: Array<any> = [];
  /**
   * form group for batchAddUserForm
  */
  createBatchForm: UntypedFormGroup;
  /**
  * To navigate to other pages
  */
  router: Router;
  /**
   * To send activatedRoute.snapshot to router navigation
   * service for redirection to update batch  component
  */
  private activatedRoute: ActivatedRoute;
  /**
  * Reference of UserService
  */
  private userService: UserService;
  /**
  * Reference of UserService
  */
  private courseBatchService: CourseBatchService;
  /**
  * To call resource service which helps to use language constant
  */
  public resourceService: ResourceService;
  /**
  * To show toaster(error, success etc) after any API calls
  */
  private toasterService: ToasterService;
  /**
	 * telemetryImpression object for create batch page
	*/
  telemetryImpression: IImpressionEventInput;

  public unsubscribe = new Subject<void>();

  public courseConsumptionService: CourseConsumptionService;

  pickerMinDate = new Date(new Date().setHours(0, 0, 0, 0));

  createBatchInteractEdata: IInteractEventEdata;
  telemetryInteractObject: IInteractEventObject;
  clearButtonInteractEdata: IInteractEventEdata;
  telemetryCdata: Array<{}> = [];
  url = document.location.origin;
  instance: string;

  private discussionCsService: any;
  createForumRequest: any;
  showDiscussionForum: string;
  selectedMentorList: Array<any> = []
  selectedParticipantList: Array<any> = []

  /**
	 * Constructor to create injected service(s) object
	 * @param {RouterNavigationService} routerNavigationService Reference of routerNavigationService
   * @param {Router} router Reference of Router
   * @param {ActivatedRoute} activatedRoute Reference of ActivatedRoute
   * @param {UserService} UserService Reference of UserService
  */
  constructor(routerNavigationService: RouterNavigationService,
    activatedRoute: ActivatedRoute,
    route: Router,
    resourceService: ResourceService, userService: UserService,
    courseBatchService: CourseBatchService,
    toasterService: ToasterService,
    public configService: ConfigService,
    courseConsumptionService: CourseConsumptionService,
    public navigationhelperService: NavigationHelperService, private lazzyLoadScriptService: LazzyLoadScriptService,
    private telemetryService: TelemetryService,
    private csLibInitializerService: CsLibInitializerService,
    private discussionService: DiscussionService) {
    this.resourceService = resourceService;
    this.router = route;
    this.activatedRoute = activatedRoute;
    this.userService = userService;
    this.courseBatchService = courseBatchService;
    this.toasterService = toasterService;
    this.courseConsumptionService = courseConsumptionService;
    if (!CsModule.instance.isInitialised) {
      this.csLibInitializerService.initializeCs();
    }
    this.discussionCsService = CsModule.instance.discussionService;
  }

  /**
   * Initialize form fields and getuserlist
  */
  ngOnInit() {
    this.instance = _.upperCase(this.resourceService.instance);
    this.activatedRoute.parent.params.pipe(mergeMap((params) => {
      this.courseId = params.courseId;
      this.initializeFormFields();
      this.setTelemetryInteractData();
      this.showCreateModal = true;
      return this.fetchBatchDetails();
    }),
      takeUntil(this.unsubscribe))
      .subscribe((data) => {
        this.showDiscussionForum = _.get(data.courseDetails, 'discussionForum.enabled');
        if (this.showDiscussionForum === 'Yes') {
          this.fetchForumConfig();
        }
        if (data.courseDetails.createdBy === this.userService.userid) {
          this.courseCreator = true;
        }
        // const userList = this.sortUsers(data.userDetails);
        // this.participantList = userList.participantList;
        // this.mentorList = userList.mentorList;
      }, (err) => {
        if (err.error && err.error?.params?.errmsg) {
          this.toasterService.error(err.error.params.errmsg);
        } else {
          this.toasterService.error(this.resourceService.messages.fmsg.m0056);
        }
        this.redirect();
      });
    this.courseBatchService.getUserList({ filters: { 'status': '1' } })
      .subscribe((res) => {
        const list = this.sortUsers(res);
        this.mentorList = list?.mentorList;
        this.participantList = list?.participantList;
      }, (err) => {
        if (err?.error && err?.error?.params?.errmsg) {
          this.toasterService.error(err.error.params.errmsg);
        } else {
          this.toasterService.error(this.resourceService.messages.fmsg.m0056);
        }
      });
  }

  selectedMultiValues(event, field) {
    const selectedValue = event.value;
    this.selectedMentorList = []
    this.selectedParticipantList = []
    if(selectedValue.length) {
      selectedValue.forEach(userID => {
        const user = this.mentorList.find(item => item.id === userID)
        if (field === 'mentors') {
          this.selectedMentorList.push(`${user.name}${user.otherDetail}`)
        } else {
          this.selectedParticipantList.push(`${user.name}${user.otherDetail}`)
        }
      });
    }
  }

  private fetchBatchDetails() {
    const requestBody = {
      filters: {'status': '1'},
    };
    return combineLatest(
      // this.courseBatchService.getUserList(requestBody),
      this.courseConsumptionService.getCourseHierarchy(this.courseId),
      (courseDetails) => ({ courseDetails })
    );
  }
  /**
  * It helps to initialize form fields and apply field level validation
  */
  private initializeFormFields(): void {
    this.createBatchForm = new UntypedFormGroup({
      name: new UntypedFormControl('', [Validators.required]),
      description: new UntypedFormControl(''),
      enrollmentType: new UntypedFormControl('open', [Validators.required]),
      startDate: new UntypedFormControl(null, [Validators.required]),
      endDate: new UntypedFormControl(),
      mentors: new UntypedFormControl(),
      users: new UntypedFormControl(),
      enrollmentEndDate: new UntypedFormControl(),
      issueCertificate: new UntypedFormControl(null, [Validators.required]),
      tncCheck: new UntypedFormControl(false, [Validators.requiredTrue]),
      enableDiscussions: new UntypedFormControl('false', [Validators.required])
    });
  }
  private sortUsers(res) {
    const participantList = [];
    const mentorList = [];
    if (res.result.response.content && res.result.response.content.length > 0) {
      _.forEach(res.result.response.content, (userData) => {
        if ( _.includes(this.selectedMentors , userData.identifier) ||
          _.includes(this.selectedParticipants , userData.identifier)) {
          return;
        }
        if (userData.identifier !== this.userService.userid) {
          const user = {
            id: userData.identifier,
            name: userData.firstName + (userData.lastName ? ' ' + userData.lastName : ''),
            avatar: userData.avatar,
            otherDetail: this.getUserOtherDetail(userData)
          };
          _.forEach(userData.roles, (roles) => {
            if (roles.role === 'COURSE_MENTOR') {
              mentorList.push(user);
            }
          });
          participantList.push(user);
        }
      });
    }
    return {
      participantList: _.uniqBy(participantList, 'id'),
      mentorList: _.uniqBy(mentorList, 'id')
    };
  }

  public createBatch() {
    this.disableSubmitBtn = true;
    let participants =  this.createBatchForm.value.users || [];
    let mentors = this.createBatchForm.value.mentors || [];
    const startDate = dayjs(this.createBatchForm.value.startDate).format('YYYY-MM-DD');
    const endDate = this.createBatchForm.value.endDate && dayjs(this.createBatchForm.value.endDate).format('YYYY-MM-DD');
    const requestBody = {
      courseId: this.courseId,
      name: this.createBatchForm.value.name,
      description: this.createBatchForm.value.description,
      enrollmentType: this.createBatchForm.value.enrollmentType,
      startDate: startDate,
      endDate: endDate || null,
      createdBy: this.userService.userid,
      createdFor: this.userService.userProfile.organisationIds,
      mentors: _.compact(mentors),
      tandc : this.createBatchForm.value.tncCheck
    };
    if (this.createBatchForm.value.enrollmentType === 'open' && this.createBatchForm.value.enrollmentEndDate) {
      requestBody['enrollmentEndDate'] = dayjs(this.createBatchForm.value.enrollmentEndDate).format('YYYY-MM-DD');
    }
    this.courseBatchService.createBatch(requestBody).pipe(takeUntil(this.unsubscribe))
      .subscribe((response) => {
        if (participants && participants.length > 0) {
          this.addParticipantToBatch(response.result.batchId, participants);
        } else {
          this.toasterService.success(this.resourceService.messages.smsg.m0033);
          this.reload();
          this.checkIssueCertificate(response.result.batchId);
          this.checkEnableDiscussions(response.result.batchId);
        }
      },
        (err) => {
          this.disableSubmitBtn = false;
          if (err.error && err.error.params.errmsg) {
            this.toasterService.error(err.error.params.errmsg);
          } else {
            this.toasterService.error(this.resourceService.messages.fmsg.m0052);
          }
        });
  }
  private addParticipantToBatch(batchId, participants) {
    const userRequest = {
      userIds: _.compact(participants)
    };
    this.courseBatchService.addUsersToBatch(userRequest, batchId).pipe(takeUntil(this.unsubscribe))
      .subscribe((res) => {
        this.toasterService.success(this.resourceService.messages.smsg.m0033);
        this.reload();
        this.checkIssueCertificate(batchId);
      },
        (err) => {
          this.disableSubmitBtn = false;
          if (err.error && err.error.params.errmsg) {
            this.toasterService.error(err.error.params.errmsg);
          } else {
            this.toasterService.error(this.resourceService.messages.fmsg.m0053);
          }
        });
  }
  public redirect() {
    this.createBatchModel.deny();
    this.router.navigate(['./'], { relativeTo: this.activatedRoute.parent });
  }
  private reload() {
    setTimeout(() => {
      this.courseBatchService.updateEvent.emit({ event: 'create' });
      this.router.navigate(['./'], { relativeTo: this.activatedRoute.parent });
    }, 1000);
  }

  checkIssueCertificate(batchId) {
    this.courseBatchService.updateEvent.emit({ event: 'issueCert', value: this.createBatchForm.value.issueCertificate,
    mode: 'create', batchId: batchId });
  }

  private getUserOtherDetail(userData) {
    if (userData.maskedEmail && userData.maskedPhone) {
      return ' (' + userData.maskedEmail + ', ' + userData.maskedPhone + ')';
    }
    if (userData.maskedEmail && !userData.maskedPhone) {
      return ' (' + userData.maskedEmail + ')';
    }
    if (!userData.maskedEmail && userData.maskedPhone) {
      return ' (' + userData.maskedPhone + ')';
    }
  }
 
  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,
          uri: this.router.url,
          duration: this.navigationhelperService.getPageLoadTime()
        }
      };
    });
  }

  setTelemetryInteractData() {
    this.createBatchInteractEdata = {
      id: 'create-batch',
      type: 'click',
      pageid: this.activatedRoute.snapshot.data.telemetry.pageid
    };
    this.clearButtonInteractEdata = {
      id: 'clear-button',
      type: 'click',
      pageid: this.activatedRoute.snapshot.data.telemetry.pageid
    };
    this.telemetryInteractObject = {
      id: this.courseId,
      type: this.activatedRoute.snapshot.data.telemetry.object.type,
      ver: this.activatedRoute.snapshot.data.telemetry.object.ver
    };
  }

  setTelemetryCData(cdata: []) {
    this.telemetryCdata = _.unionBy(this.telemetryCdata, cdata, 'id');
  }

  ngOnDestroy() {
    if (this.createBatchModel && this.createBatchModel.deny) {
      this.createBatchModel.deny();
    }
    this.unsubscribe.next();
    this.unsubscribe.complete();
  }

  fetchForumConfig() {
    this.discussionService.fetchForumConfig('batch').subscribe((formData: any) => {
      this.createForumRequest = formData[0];
    }, error => {
      this.toasterService.error(this.resourceService.messages.emsg.m0005);
    });
  }

  checkEnableDiscussions(batchId) {
    if (this.createBatchForm.value.enableDiscussions === 'true') {
      this.enableDiscussionForum(batchId);
    } else {
      this.handleInputChange('enable-DF-no', {
        id: batchId,
        type: 'Batch'
      });
    }
  }

  enableDiscussionForum(batchId) {
    const fetchForumConfigReq = [{
      type: 'batch',
      identifier: batchId
    }];
    if (this.createForumRequest) {
      this.createForumRequest['category']['context'] =  fetchForumConfigReq;
      this.discussionService.createForum(this.createForumRequest).subscribe(resp => {
        this.handleInputChange('enable-DF-yes', {
          id: batchId,
          type: 'Batch'
        });
        this.toasterService.success(_.get(this.resourceService, 'messages.smsg.m0065'));
      }, error => {
        this.toasterService.error(this.resourceService.messages.emsg.m0005);
      });
    } else {
      this.toasterService.error(this.resourceService.messages.emsg.m0005);
    }
  }

  handleInputChange(inputId, cdata) {
    const telemetryData = {
      context: {
        env:  this.activatedRoute.snapshot.data.telemetry.env,
        cdata: [{
          id: this.courseId,
          type: 'Course'
        }]
      },
      edata: {
        id: inputId,
        type: 'click',
        pageid: this.activatedRoute.snapshot.data.telemetry.pageid
      }
    };
    if (cdata) {
      telemetryData.context.cdata.push(cdata);
    }
    this.telemetryService.interact(telemetryData);
  }

  getPickerMinDateForEndDate() {
    const startDate = this.createBatchForm.controls.startDate.value as Date;
    const oneDayMs = 24 * 60 * 60 * 1000;
    if (startDate) {
      return new Date(startDate.getTime() + oneDayMs);
    }
    return new Date(this.pickerMinDate.getTime() + oneDayMs);
  }
}
<app-modal-wrapper *ngIf="showCreateModal"
  [config]="{disableClose: true, size: 'normal', panelClass: ['overflow-visible', 'material-modal']}" (dismiss)="redirect()"
  #createBatchModel>
  <ng-template sbModalContent>
    <div class="sb-mat__modal">

      <!--Header-->
      <div mat-dialog-title class="mb-0">
        <div class="title">
          {{resourceService?.frmelmnts.lbl.createnewbatch}}
        </div>
        <button aria-label="close dialog" mat-dialog-close class="close-btn"></button>
      </div>
      <!--/Header-->

      <!--Content-->
      <div class="sb-mat__modal__content" [appTelemetryImpression]="telemetryImpression">
        <form [formGroup]="createBatchForm" class="sb-form batchAddUserForm pt-8 px-8">
          <div class="sb-color-primary font-weight-bold pb-24">Batch Details</div>
          <div class="ui stackable grid">
            <div class="eight wide column">
              <div class="sb-field-group"
                [ngClass]="createBatchForm.controls['name'].invalid && createBatchForm.controls['name'].errors.required && !createBatchForm.controls['name'].pristine ? 'error': ''">
                <label class="required">{{resourceService?.frmelmnts?.lbl?.batchname}}</label>
                <div class="sb-field">
                  <input type="text" name="name" formControlName="name" class="sb-form-control" autofocus>
                </div>
                <div class="mt-0 mb-8 ui pointing red basic label below"
                  *ngIf="createBatchForm.controls.name.invalid && createBatchForm.controls['name'].errors.required && !createBatchForm.controls['name'].pristine">
                  {{resourceService?.messages?.stmsg?.m0114}}
                </div>
              </div>
            </div>
            <div class="sb-field-group">
              <div class="four wide column">
                <div>
                  <label class="required">{{resourceService?.frmelmnts?.cert?.lbl?.issueCertificate}}</label>
                  <div class="d-flex py-8 flex-w-wrap">
                    <div class="sb-radio-btn-checkbox sb-radio-btn-primary">
                      <input (change)="handleInputChange('issue-certificate-yes', undefined)"
                        formControlName="issueCertificate" value="yes" type="radio" id="yes">
                      <label for="yes">{{resourceService?.frmelmnts?.btn?.yes}}</label>
                    </div>
                    <div class="sb-radio-btn-checkbox sb-radio-btn-primary">
                      <input (change)="handleInputChange('issue-certificate-no', undefined)"
                        formControlName="issueCertificate" value="no" type="radio" id="no">
                      <label for="no">{{resourceService?.frmelmnts?.btn?.no}}</label>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>

          <div class="ui stackable grid mt-0">
            <div class="eight wide column">
              <div class="sb-field-group">
                <div class="sb-field">
                  <label>{{resourceService?.frmelmnts?.lbl?.aboutbatch}}</label>
                  <textarea rows="4" name="description" formControlName="description"
                    class="sb-form-control"></textarea>
                </div>
              </div>
            </div>
            <div class="four wide column">
              <div *ngIf="showDiscussionForum === 'Yes'">
                <label>{{resourceService?.frmelmnts?.lbl?.enableDiscussions}}</label>
                <div class="d-flex py-8 flex-w-wrap">
                  <div class="sb-radio-btn-checkbox sb-radio-btn-primary">
                    <input formControlName="enableDiscussions" type="radio" id="true" value="true">
                    <label for="true">{{resourceService?.frmelmnts?.btn?.yes}}</label>
                  </div>
                  <div class="sb-radio-btn-checkbox sb-radio-btn-primary">
                    <input formControlName="enableDiscussions" type="radio" id="false" value="false">
                    <label for="false">{{resourceService?.frmelmnts?.btn?.no}}</label>
                  </div>
                </div>
              </div>
              <div class="d-flex flex-dc flex-w-wrap" *ngIf="courseCreator">
                <div class="mr-8">
                  <label for="Enrollment Type">{{resourceService?.frmelmnts?.lbl?.natureofbatch}}</label>
                </div>
                <div class="sb-radio-btn-checkbox sb-radio-btn-primary py-8">
                  <input id="create-open" type="radio" value='open' name="enrollmentType"
                    formControlName="enrollmentType">
                  <label for="create-open">{{resourceService?.frmelmnts?.lbl?.open}}</label>
                </div>
              </div>
            </div>
          </div>

          <div class="d-flex flex-w-wrap my-16">
            <div class="sb-field-group pr-8"
              [ngClass]="createBatchForm.controls['startDate'].invalid && createBatchForm.controls['startDate'].errors.required && !createBatchForm.controls['startDate'].pristine ? 'error': ''">
              <label class="required">{{resourceService?.frmelmnts?.lbl?.startdate}}</label>
              <div class="ui read-only calendar rangestartAdd" id="rangestartAdd">
                <mat-form-field appearance="fill" class="sb-mat__datepicker">
                  <mat-label>{{resourceService?.frmelmnts?.lbl?.startdate}}</mat-label>
                  <input matInput [matDatepicker]="startPicker" formControlName="startDate" [min]="pickerMinDate">
                  <mat-datepicker-toggle matSuffix [for]="startPicker"></mat-datepicker-toggle>
                  <mat-datepicker #startPicker></mat-datepicker>
                </mat-form-field>
              </div>
              <div class="mt-0 mb-8 ui pointing red basic label below"
                *ngIf="createBatchForm.controls.startDate.invalid && createBatchForm.controls['startDate'].errors.required && !createBatchForm.controls['startDate'].pristine">
                {{resourceService?.messages?.stmsg?.m0113}}
              </div>
            </div>
            <div class="sb-field-group">
              <label>{{resourceService?.frmelmnts?.lbl?.enddate}}</label>
              <div apply-script class="ui calendar rangeendAdd" id="rangeendAdd">
                <mat-form-field appearance="fill" class="sb-mat__datepicker">
                  <mat-label>{{resourceService?.frmelmnts?.lbl?.enddate}}</mat-label>
                  <input matInput [matDatepicker]="endDatePicker" formControlName="endDate"
                    [min]="getPickerMinDateForEndDate()">
                  <mat-datepicker-toggle matSuffix [for]="endDatePicker"></mat-datepicker-toggle>
                  <mat-datepicker #endDatePicker></mat-datepicker>
                </mat-form-field>
              </div>
            </div>
            <div class="sb-field-group pl-8" *ngIf="createBatchForm.value.enrollmentType === 'open'"
              [ngClass]="(createBatchForm.controls['enrollmentEndDate'].invalid && !createBatchForm.controls['enrollmentEndDate'].pristine) ? 'error': ''">
              <label>{{resourceService?.frmelmnts?.lbl?.enrollmentenddate | uppercase}}</label>
              <div class="ui read-only calendar rangeenrollMentEnd" id="rangeenrollMentEnd">
                <mat-form-field appearance="fill" class="sb-mat__datepicker" [ngClass]="{'disabled': !createBatchForm.value.startDate}"
                  (click)="setTelemetryCData([{id:'course:enrollment:endDate',type:'Feature'},{id:'SB-13073',type:'Task'}])">
                  <mat-label>{{resourceService?.frmelmnts?.lbl?.enrollmentenddate}}</mat-label>
                  <input matInput [matDatepicker]="enrollmentEndDatePicker" formControlName="enrollmentEndDate"
                    [min]="createBatchForm.value.startDate" [max]="createBatchForm.value.endDate">
                  <mat-datepicker-toggle matSuffix [for]="enrollmentEndDatePicker"></mat-datepicker-toggle>
                  <mat-datepicker #enrollmentEndDatePicker></mat-datepicker>
                </mat-form-field>
              </div>
              <div class="mt-0 mb-8 ui pointing red basic label below"
                *ngIf="createBatchForm.controls['enrollmentEndDate'].invalid && !createBatchForm.controls['enrollmentEndDate'].pristine? 'error': ''">
                {{resourceService?.messages?.stmsg?.m0135}}
              </div>
            </div>
          </div>
          <div class="sb-field-group mb-8">
            <label>{{resourceService?.frmelmnts?.lbl?.batchmentors}}</label>
            <mat-form-field appearance="fill" class="sb-mat__dropdown w-100 mb-16">
              <mat-select formControlName="mentors" role="listbox" multiple aria-label="mentor list"
                class="selection" (selectionChange)="selectedMultiValues($event, 'mentors')">
                <mat-select-trigger>
                  <span>{{selectedMentorList ? selectedMentorList[0] : ''}} </span>
                  <span *ngIf="selectedMentorList?.length >= 2" class="example-additional-selection">
                    (+{{selectedMentorList.length - 1}} {{selectedMentorList?.length === 2 ? 'other' : 'others'}})
                  </span>
                </mat-select-trigger>
                <mat-option class="mat-dropdown__options" role="option" *ngFor="let mentor of mentorList" [value]="mentor.id"
                attr.aria-label="{{mentor.name}}">
                  <img class="ui mini avatar image"
                      src="{{mentor.avatar || 'assets/images/user_logo.png' | cdnprefixurl}}" alt="avatar image">
                  {{mentor.name}}{{mentor.otherDetail}}
                </mat-option>
              </mat-select>
            </mat-form-field>
          </div>

          <div class="sb-field-group " *ngIf="createBatchForm.value.enrollmentType !== 'open'">
            <label>{{resourceService?.frmelmnts?.lbl?.bacthmembers}}</label>
            <mat-form-field appearance="fill" class="sb-mat__dropdown w-100 mb-16">
              <mat-select formControlName="users" role="listbox" multiple aria-label="participant list"
                class="selection" (selectionChange)="selectedMultiValues($event, 'participant')">
                <mat-select-trigger>
                  <span>{{selectedParticipantList ? selectedParticipantList[0] : ''}} </span>
                  <span *ngIf="selectedParticipantList?.length >= 2" class="example-additional-selection">
                    (+{{selectedParticipantList.length - 1}} {{selectedParticipantList?.length === 2 ? 'other' : 'others'}})
                  </span>
                </mat-select-trigger>
                <mat-option class="mat-dropdown__options" role="option" *ngFor="let participant of participantList" [value]="participant.id"
                attr.aria-label="{{participant.name}}">
                  <img class="ui mini avatar image"
                      src="{{mentor.avatar || 'assets/images/user_logo.png' | cdnprefixurl}}" alt="avatar image">
                  {{participant.name}}{{participant.otherDetail}}
                </mat-option>
              </mat-select>
            </mat-form-field>
            
            <div class="createbatchdropdown ui fluid multiple search selection dropdown" id="participants">
              <input id="userSelList">
              <i class="dropdown icon"></i>
              <div class="default text">{{resourceService?.frmelmnts?.intxt?.t0006}}</div>
              <div class="menu">
                <div class="item" *ngFor="let user of participantList" [attr.data-value]="user.id">
                  <img class="ui mini avatar image"
                    src="{{user.avatar || 'assets/images/user_logo.png' | cdnprefixurl}}" alt="avatar image">
                  {{user.name}}{{user.otherDetail}}
                </div>
              </div>
            </div>
          </div>

          <div class="sb-field mt-24 mb-8">
            <label class="d-flex flex-ai-center">
              <input type="checkbox" formControlName="tncCheck" role="checkbox" class="mr-8 cursor-pointer">
              <span class="font-weight-normal fnormal">
                {{resourceService?.frmelmnts?.lbl?.agreeCourseToc | interpolate:'{instance}': instance }} <a
                  href="{{url}}/term-of-use.html#courseGuidelines" target="_blank"
                  class="sb-color-primary">{{resourceService?.frmelmnts?.lbl?.courseGuidelines}}</a></span>
            </label>
            <small class="line-height-normal d-block message sb-color-error font-weight-bold mt-8 pl-20"
              *ngIf="!createBatchForm.get('tncCheck').valid && this.createBatchForm.get('tncCheck').dirty">{{resourceService?.frmelmnts?.lbl?.courseToc}}</small>
          </div>

        </form>
      </div>
      <!--/Content-->

      <!--Actions-->
      <div class="sb-mat__modal__actions">

        <button appTelemetryInteract [telemetryInteractObject]="telemetryInteractObject" tabindex="0"
          [telemetryInteractEdata]="clearButtonInteractEdata" [telemetryInteractCdata]="telemetryCdata"
          class="sb-btn sb-btn-normal sb-btn-outline-primary mr-8" (click)="createBatchForm.reset()">
          {{resourceService?.frmelmnts?.btn?.clear}}
        </button>

        <button class="sb-btn sb-btn-normal sb-btn-primary" tabindex="0"
          [ngClass]="{'sb-btn-disabled': !createBatchForm.valid || disableSubmitBtn}" id="submitbutton"
          [disabled]="!createBatchForm.valid || disableSubmitBtn" (click)="createBatch()" appTelemetryInteract
          [telemetryInteractObject]="telemetryInteractObject" [telemetryInteractEdata]="createBatchInteractEdata"
          [telemetryInteractCdata]="telemetryCdata">
          {{resourceService?.frmelmnts?.btn?.create}}
        </button>

      </div>
      <!--/Actions-->

    </div>
  </ng-template>
</app-modal-wrapper>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""