File

src/app/modules/workspace/components/update-batch/update-batch.component.ts

Implements

OnInit OnDestroy AfterViewInit

Metadata

Index

Properties
Methods
Accessors

Constructor

constructor(activatedRoute: ActivatedRoute, route: Router, resourceService: ResourceService, userService: UserService, batchService: BatchService, toasterService: ToasterService, navigationhelperService: NavigationHelperService, lazzyLoadScriptService: LazzyLoadScriptService)

Constructor to create injected service(s) object

Parameters :
Name Type Optional Description
activatedRoute ActivatedRoute No

Reference of ActivatedRoute

route Router No
resourceService ResourceService No
userService UserService No
batchService BatchService No
toasterService ToasterService No
navigationhelperService NavigationHelperService No
lazzyLoadScriptService LazzyLoadScriptService No

Methods

Public clearForm
clearForm()
Returns : void
Private fetchBatchDetails
fetchBatchDetails()
Returns : any
Private fetchParticipantDetails
fetchParticipantDetails()

fetch mentors and participant details

Returns : void
Private getUserList
getUserList(query: string, type)

api call to get user list

Parameters :
Name Type Optional Default value
query string No ''
type No
Returns : void
Private getUserListWithQuery
getUserListWithQuery(query, type)
Parameters :
Name Optional
query No
type No
Returns : void
Private getUserOtherDetail
getUserOtherDetail(userData)
Parameters :
Name Optional
userData No
Returns : string
Private initDropDown
initDropDown()
Returns : void
Private initializeUpdateForm
initializeUpdateForm()

initializes 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
Private processParticipantDetails
processParticipantDetails(res)
Parameters :
Name Optional
res No
Returns : void
Public redirect
redirect()
Returns : void
Private reload
reload()
Returns : void
setTelemetryCData
setTelemetryCData(cdata: [])
Parameters :
Name Type Optional
cdata [] No
Returns : void
Private setTelemetryImpressionData
setTelemetryImpressionData()
Returns : void
setTelemetryInteractData
setTelemetryInteractData()
Returns : void
Private sortUsers
sortUsers(res)
Parameters :
Name Optional
res No
Returns : { participantList: any; mentorList: any; }
Public updateBatch
updateBatch()
Returns : void
Private updateParticipantsToBatch
updateParticipantsToBatch(batchId, participants)
Parameters :
Name Optional
batchId No
participants No
Returns : void

Properties

Private activatedRoute
Type : ActivatedRoute

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

Private batchDetails
Type : any

batchDetails for form

Private batchId
Type : string

batchId

Private batchService
Type : BatchService

Refrence of UserService

Public batchUpdateForm
Type : UntypedFormGroup

form group for batchAddUserForm

clearButtonInteractEdata
Type : IInteractEventEdata
Public courseCreator
Default value : false
Public courseDetails
Private courseId
Type : string
Public disableSubmitBtn
Default value : false
Public mentorList
Type : Array<any>
Default value : []

mentorList for mentors in the batch

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

participantList for users

Public pickerMinDate
Default value : new Date(new Date().setHours(0, 0, 0, 0))
Public pickerMinDateForEndDate
Default value : new Date(this.pickerMinDate.getTime() + (24 * 60 * 60 * 1000))
Public pickerMinDateForEnrollmentEndDate
Public resourceService
Type : ResourceService

To call resource service which helps to use language constant

Public router
Type : Router

To navigate to other pages

Public selectedMentors
Type : any
Default value : []
Public selectedParticipants
Type : any
Default value : []
Public showFormInViewMode
Type : boolean
Public showUpdateModal
Default value : false
telemetryCdata
Type : Array<literal type>
Default value : []
Public telemetryImpression
Type : IImpressionEventInput

telemetryImpression object for update 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>()
updateBatchInteractEdata
Type : IInteractEventEdata
Private updateBatchModal
Private userSearchTime
Type : any
Private userService
Type : UserService

Refrence of UserService

Accessors

setBatchModal
setsetBatchModal(element)
Parameters :
Name Optional
element No
Returns : void
import { takeUntil, mergeMap } from 'rxjs/operators';
import { Subject, combineLatest } from 'rxjs';
import { Component, OnInit, ViewChild, OnDestroy, AfterViewInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ResourceService, ToasterService, NavigationHelperService } from '@sunbird/shared';
import { UntypedFormGroup, UntypedFormControl, Validators } from '@angular/forms';
import { UserService } from '@sunbird/core';
import { BatchService } from '../../services';
import { IImpressionEventInput, IInteractEventEdata, IInteractEventObject } from '@sunbird/telemetry';
import * as _ from 'lodash-es';
import dayjs from 'dayjs';
import { LazzyLoadScriptService } from 'LazzyLoadScriptService';

@Component({
  selector: 'app-update-batch',
  templateUrl: './update-batch.component.html',
  styleUrls: ['./update-batch.component.scss']
})
export class UpdateBatchComponent implements OnInit, OnDestroy, AfterViewInit {

  private updateBatchModal;
  @ViewChild('updateBatchModal') set setBatchModal(element) {
    if (element) {
      this.updateBatchModal = element;
    }
    this.initDropDown();
  }
  /**
  * batchId
  */
  private batchId: string;

  public showUpdateModal = false;

  public disableSubmitBtn = false;

  private courseId: string;

  public selectedParticipants: any = [];

  public selectedMentors: any = [];

  private userSearchTime: any;
  /**
  * participantList for users
  */
  public participantList = [];


  public showFormInViewMode: boolean;

  /**
  * batchDetails for form
  */
  private batchDetails: any;
  /**
  * mentorList for mentors in the batch
  */
  public mentorList: Array<any> = [];
  /**
   * form group for batchAddUserForm
  */
  public batchUpdateForm: UntypedFormGroup;
  /**
  * To navigate to other pages
  */
  public router: Router;
  /**
   * To send activatedRoute.snapshot to router navigation
   * service for redirection to update batch  component
  */
  private activatedRoute: ActivatedRoute;
  /**
  * Refrence of UserService
  */
  private userService: UserService;
  /**
  * Refrence of UserService
  */
  private batchService: BatchService;
  /**
  * 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 update batch page
	*/
  public telemetryImpression: IImpressionEventInput;

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

  public pickerMinDateForEnrollmentEndDate;

  public pickerMinDateForEndDate = new Date(this.pickerMinDate.getTime() + (24 * 60 * 60 * 1000));

  public unsubscribe = new Subject<void>();

  public courseCreator = false;
  public courseDetails;

  updateBatchInteractEdata: IInteractEventEdata;
  telemetryInteractObject: IInteractEventObject;
  clearButtonInteractEdata: IInteractEventEdata;
  telemetryCdata: Array<{}> = [];

  /**
	 * Constructor to create injected service(s) object
   * @param {Router} router Reference of Router
   * @param {ActivatedRoute} activatedRoute Reference of ActivatedRoute
   * @param {UserService} UserService Reference of UserService
  */
  constructor(activatedRoute: ActivatedRoute,
    route: Router,
    resourceService: ResourceService, userService: UserService,
    batchService: BatchService,
    toasterService: ToasterService,
    public navigationhelperService: NavigationHelperService,  private lazzyLoadScriptService: LazzyLoadScriptService) {
    this.resourceService = resourceService;
    this.router = route;
    this.activatedRoute = activatedRoute;
    this.userService = userService;
    this.batchService = batchService;
    this.toasterService = toasterService;
  }

  /**
   * Initialize form fields and getuserlist
  */
  ngOnInit() {
    combineLatest(this.activatedRoute.params, this.activatedRoute.parent.params,
      (params, parentParams) => ({ ...params, ...parentParams }))
      .pipe(
        mergeMap((params) => {
          this.batchId = params.batchId;
          this.setTelemetryImpressionData();
          this.setTelemetryInteractData();
          return this.fetchBatchDetails();
        }),
        takeUntil(this.unsubscribe))
      .subscribe((data: any) => {
        this.courseId = data.batchDetails.courseId;
        this.batchService.getCourseHierarchy(this.courseId).subscribe((courseDetails) => {
          if (courseDetails.createdBy === this.userService.userid) {
            this.courseCreator = true;
            this.courseDetails = courseDetails;
          }
        });
        this.showUpdateModal = true;
        this.batchDetails = data.batchDetails;
        if (this.batchDetails.enrollmentType !== 'open' && data.participants && data.participants.length > 0) {
          this.batchDetails.participants = data.participants;
        }
        if (this.batchDetails.createdBy !== this.userService.userid) {
          this.showFormInViewMode = true;
        }
        const userList = this.sortUsers(data.userDetails);
        this.participantList = userList.participantList;
        this.mentorList = userList.mentorList;
        this.initializeUpdateForm();
        this.fetchParticipantDetails();
      }, (err) => {
        if (err.error && err.error.params && err.error.params.errmsg) {
          this.toasterService.error(err.error.params.errmsg);
        } else {
          this.toasterService.error(this.resourceService?.messages?.fmsg?.m0054);
        }
        this.redirect();
      });
  }
  private fetchBatchDetails() {
    const participants = {};
    return combineLatest(
      this.batchService.getUserList(),
      this.batchService.getUpdateBatchDetails(this.batchId),
      (userDetails, batchDetails) => ({userDetails, batchDetails, participants})
    );
  }
  /**
  * initializes form fields and apply field level validation
  */
  private initializeUpdateForm(): void {
    const endDate = this.batchDetails.endDate ? new Date(this.batchDetails.endDate) : null;
    const enrollmentEndDate = this.batchDetails.enrollmentEndDate ? new Date(this.batchDetails.enrollmentEndDate) : null;
    if (!dayjs(this.batchDetails.startDate).isBefore(dayjs(this.pickerMinDate).format('YYYY-MM-DD'))) {
      this.pickerMinDateForEnrollmentEndDate = new Date(new Date(this.batchDetails.startDate).setHours(0, 0, 0, 0));
    } else {
      this.pickerMinDateForEnrollmentEndDate = this.pickerMinDate;
    }
    this.batchUpdateForm = new UntypedFormGroup({
      name: new UntypedFormControl(this.batchDetails.name, [Validators.required]),
      description: new UntypedFormControl(this.batchDetails.description),
      enrollmentType: new UntypedFormControl(this.batchDetails.enrollmentType, [Validators.required]),
      startDate: new UntypedFormControl(new Date(this.batchDetails.startDate), [Validators.required]),
      endDate: new UntypedFormControl(endDate),
      mentors: new UntypedFormControl(),
      users: new UntypedFormControl(),
      enrollmentEndDate: new UntypedFormControl(enrollmentEndDate)
    });
    this.batchUpdateForm.valueChanges.subscribe(val => {
      if (this.batchUpdateForm.status === 'VALID') {
        this.disableSubmitBtn = false;
      } else {
        this.disableSubmitBtn = true;
      }
    });

    this.batchUpdateForm.get('startDate').valueChanges.subscribe(value => {
      const startDate: any = dayjs(value);
      if (startDate.isValid()) {
        if (!dayjs(startDate).isBefore(dayjs(this.pickerMinDate).format('YYYY-MM-DD'))) {
          this.pickerMinDateForEnrollmentEndDate = new Date(new Date(startDate).setHours(0, 0, 0, 0));
        } else {
          this.pickerMinDateForEnrollmentEndDate = this.pickerMinDate;
        }
      }
    });
  }
  /**
  * fetch mentors and participant details
  */
  private fetchParticipantDetails() {
    let userListIdentifier = [];
    if (this.batchDetails.participants || (this.batchDetails.mentors && this.batchDetails.mentors.length > 0)) {
      if (this.batchDetails.participants && this.batchDetails.participants.length > 100) {
        userListIdentifier = this.batchDetails.mentors;
      } else {
        userListIdentifier = _.union(this.batchDetails.participants, this.batchDetails.mentors);
      }
      const request = {
        filters: {
          identifier: userListIdentifier
        }
      };
      this.batchService.getUserList(request).pipe(takeUntil(this.unsubscribe))
        .subscribe((res) => {
          this.processParticipantDetails(res);
        }, (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();
        });
    }
  }
  private processParticipantDetails(res) {
    const users = this.sortUsers(res);
    const participantList = users.participantList;
    const mentorList = users.mentorList;
    _.forEach(this.batchDetails.participants, (value, key) => {
      const user = _.find(participantList, ['id', value]);
      if (user) {
        this.selectedParticipants.push(user);
      }
    });
    _.forEach(this.batchDetails.mentors, (value, key) => {
      const mentor = _.find(mentorList, ['id', value]);
      if (mentor) {
        this.selectedMentors.push(mentor);
      }
    });
    this.selectedParticipants = _.uniqBy(this.selectedParticipants, 'id');
    this.selectedMentors = _.uniqBy(this.selectedMentors, 'id');
  }
  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 ( _.find(this.selectedMentors , {'id': userData.identifier }) ||
          _.find(this.selectedParticipants , {'id': 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.organisations, (userOrgData) => {
            if (_.indexOf(userOrgData.roles, 'COURSE_MENTOR') !== -1) {
              mentorList.push(user);
            }
          });
          participantList.push(user);
        }
      });
    }
    return {
      participantList: _.uniqBy(participantList, 'id'),
      mentorList: _.uniqBy(mentorList, 'id')
    };
  }
  private initDropDown() {
    const count = _.get(this.batchDetails, 'participants') ? _.get(this.batchDetails, 'participants.length') : 0;
    this.lazzyLoadScriptService.loadScript('semanticDropdown.js').subscribe(() => {
      $('#participant').dropdown({
        forceSelection: false,
        fullTextSearch: true,
        maxSelections: 100 - count,
        message: {
          maxSelections : this.resourceService?.messages?.imsg?.m0046
        },
        onAdd: () => {
        }
      });
      $('#mentors').dropdown({
        fullTextSearch: true,
        forceSelection: false,
        onAdd: () => {
        }
      });
      $('#participant input.search').on('keyup', (e) => {
        this.getUserListWithQuery($('#participant input.search').val(), 'participant');
      });
      $('#mentors input.search').on('keyup', (e) => {
        this.getUserListWithQuery($('#mentors input.search').val(), 'mentor');
      });
    });
  }
  private getUserListWithQuery(query, type) {
    if (this.userSearchTime) {
      clearTimeout(this.userSearchTime);
    }
    this.userSearchTime = setTimeout(() => {
      this.getUserList(query, type);
    }, 1000);
  }
  /**
  *  api call to get user list
  */
  private getUserList(query: string = '', type) {
    const requestBody = {
      filters: {},
      query: query
    };
    this.batchService.getUserList(requestBody).pipe(takeUntil(this.unsubscribe))
      .subscribe((res) => {
        const userList = this.sortUsers(res);
        if (type === 'participant') {
          this.participantList = userList.participantList;
        } else {
          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);
          }
        });
  }

  public updateBatch() {
    this.disableSubmitBtn = true;
    let participants = [];
    let mentors = [];
    mentors = $('#mentors').dropdown('get value') ? $('#mentors').dropdown('get value').split(',') : [];
    if (this.batchUpdateForm.value.enrollmentType !== 'open') {
      participants = $('#participant').dropdown('get value') ? $('#participant').dropdown('get value').split(',') : [];
    }
    const startDate = dayjs(this.batchUpdateForm.value.startDate).format('YYYY-MM-DD');
    const endDate = this.batchUpdateForm.value.endDate && dayjs(this.batchUpdateForm.value.endDate).format('YYYY-MM-DD');
    const requestBody = {
      id: this.batchId,
      courseId: this.courseId,
      name: this.batchUpdateForm.value.name,
      description: this.batchUpdateForm.value.description,
      enrollmentType: this.batchUpdateForm.value.enrollmentType,
      startDate: startDate,
      endDate: endDate || null,
      createdFor: this.userService.userProfile.organisationIds,
      mentors: _.compact(mentors)
    };
    if (this.batchUpdateForm.value.enrollmentType === 'open' && this.batchUpdateForm.value.enrollmentEndDate) {
      requestBody['enrollmentEndDate'] = dayjs(this.batchUpdateForm.value.enrollmentEndDate).format('YYYY-MM-DD');
    }
    const selected = [];
    _.forEach(this.selectedMentors, (value) => {
      selected.push(value.id);
    });
    requestBody['mentors'] = _.concat(_.compact(requestBody['mentors']), selected);
    this.batchService.updateBatch(requestBody).pipe(takeUntil(this.unsubscribe))
      .subscribe((response) => {
        if (participants && participants.length > 0) {
          this.updateParticipantsToBatch(this.batchId, participants);
        } else {
          this.disableSubmitBtn = false;
          this.toasterService.success(this.resourceService?.messages?.smsg?.m0034);
          this.reload();
        }
      },
        (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 updateParticipantsToBatch(batchId, participants) {
    const userRequest = {
      userIds: _.compact(participants)
    };
    this.batchService.addUsersToBatch(userRequest, batchId).pipe(takeUntil(this.unsubscribe))
      .subscribe((res) => {
        this.disableSubmitBtn = false;
        this.toasterService.success(this.resourceService?.messages?.smsg?.m0034);
        this.reload();
      },
        (err) => {
          this.disableSubmitBtn = false;
          if (err.params && err.error.params.errmsg) {
            this.toasterService.error(err.error.params.errmsg);
          } else {
            this.toasterService.error(this.resourceService?.messages?.fmsg?.m0053);
          }
        });
  }
  public redirect() {
    this.router.navigate(['.'], { queryParamsHandling: 'merge', relativeTo: this.activatedRoute.parent });
  }
  private reload() {
    setTimeout(() => {
      this.batchService.updateEvent.emit({ event: 'update' });
      this.router.navigate(['.'], { queryParamsHandling: 'merge', relativeTo: this.activatedRoute.parent });
    }, 1000);
  }

  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 + ')';
    }
  }
  // Create the telemetry impression event for update batch page
  private setTelemetryImpressionData() {
    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()
      },
      object: {
        id: this.activatedRoute.snapshot.params.batchId,
        type: this.activatedRoute.snapshot.data.telemetry.object.type,
        ver: this.activatedRoute.snapshot.data.telemetry.object.ver,
        rollup: {
          l1: this.activatedRoute.snapshot.params.batchId
        }
      }
    };
  }
  ngAfterViewInit () {
    setTimeout(() => {
      this.setTelemetryImpressionData();
    });
  }

  setTelemetryInteractData() {
    this.updateBatchInteractEdata = {
      id: 'update-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.batchId,
      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');
  }

  public clearForm() {
    this.batchUpdateForm.controls['name'].reset();
    this.batchUpdateForm.controls['mentors'].reset();
    this.batchUpdateForm.controls['enrollmentEndDate'].reset();
    this.batchUpdateForm.controls['endDate'].reset();
    this.batchUpdateForm.controls['description'].reset();
    this.batchUpdateForm.controls['users'].reset();
  }

  ngOnDestroy() {
    if (this.updateBatchModal && this.updateBatchModal.deny) {
      this.updateBatchModal.deny();
    }
    this.unsubscribe.next();
    this.unsubscribe.complete();
  }
}
<sui-modal [mustScroll]="true" [isClosable]="false" [transitionDuration]="0" [size]="'normal'"
  class="sb-modal sb-batch-modal" appBodyScroll *ngIf='showUpdateModal' (dismissed)="redirect()" #updateBatchModal>
  <!--Header-->
  <i class="close icon" tabindex="0" (click)="redirect()"></i>
  <div class="sb-modal-header">
    <span *ngIf="!showFormInViewMode">{{resourceService?.frmelmnts?.intxt?.t0007}}</span>
    <span *ngIf="showFormInViewMode">{{resourceService?.frmelmnts?.intxt?.t0015}}</span>
  </div>
  <!--/Header-->

  <!--Content-->
  <div class="sb-modal-content o-y-visible" [appTelemetryImpression]="telemetryImpression">
    <form [formGroup]="batchUpdateForm" class="sb-form batchUpdateForm 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]="batchUpdateForm.controls['name'].invalid && batchUpdateForm.controls['name'].errors.required && !batchUpdateForm.controls['name'].pristine ? 'error': ''">
            <label class="required">{{resourceService?.frmelmnts?.lbl?.batchname}}</label>
            <div class="sb-field">
              <input class="sb-form-control" type="text" name="name" formControlName="name"
                [attr.disabled]="(batchDetails.status === 2 || showFormInViewMode ) ? true : null">
            </div>
            <div class="mt-0 mb-8 ui pointing red basic label below"
              *ngIf="batchUpdateForm.controls.name.invalid && batchUpdateForm.controls['name'].errors.required && !batchUpdateForm.controls['name'].pristine">
              {{resourceService?.messages?.stmsg?.m0114}}
            </div>
          </div>
        </div>
      </div>

      <div class="ui stackable grid mt-0">
        <div class="eight wide column">
          <div class="sb-field-group">
            <label>{{resourceService?.frmelmnts?.lbl?.aboutbatch}}</label>
            <div class="sb-field">
              <textarea class="sb-form-control" rows="4" name="description" formControlName="description"
                [attr.disabled]="(batchDetails.status === 2 || showFormInViewMode ) ? true : null"></textarea>
            </div>
          </div>
        </div>

        <div class="four wide column">
          <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" *ngIf="courseCreator">
              <input id="update-open"
                [attr.disabled]="( batchDetails.status !== 0 || showFormInViewMode ) ? true : null" type="radio"
                value='open' name="enrollmentType" formControlName="enrollmentType">
              <label for="update-open">Open</label>
            </div>
          </div>
        </div>
      </div>

      <div class="d-flex flex-w-wrap my-16">
        <div class="sb-field-group pr-8"
          [ngClass]="batchUpdateForm.controls['startDate'].invalid && batchUpdateForm.controls['startDate'].errors.required && !batchUpdateForm.controls['startDate'].pristine ? 'error': ''">
          <label class="required">{{resourceService?.frmelmnts?.lbl?.startdate}}</label>
          <div class="ui read-only calendar rangestartAdd" id="rangestartAdd">
            <div class="sb-field ui left icon input">
              <i class="calendar icon date-calendar"></i>
              <input class="sb-form-control"
                [attr.disabled]="(batchDetails.status !== 0 || showFormInViewMode) ? true : false"
                [pickerMinDate]='batchDetails.status !== 0 ? batchUpdateForm.controls["startDate"].value : pickerMinDate'
                suiDatepicker formControlName="startDate" [pickerMode]="'date'">
            </div>
          </div>
          <div class="mt-0 mb-8 ui pointing red basic label below"
            *ngIf="batchUpdateForm.controls.startDate.invalid && batchUpdateForm.controls['startDate'].errors.required && !batchUpdateForm.controls['startDate'].pristine">
            {{resourceService?.messages?.stmsg?.m0113}}
          </div>
        </div>
        <div class="sb-field-group">
          <label>{{resourceService?.frmelmnts?.lbl?.enddate}}</label>
          <div class="ui calendar rangeendAdd" id="rangeendAdd">
            <div class="sb-field ui left icon input">
              <i class="calendar icon date-calendar"></i>
              <input class="sb-form-control"
                [attr.disabled]="( showFormInViewMode ) ? true : null"
                [pickerMinDate]='pickerMinDateForEndDate' suiDatepicker formControlName="endDate" [pickerMode]="'date'">
            </div>
          </div>
        </div>
        <div class="sb-field-group pl-8" *ngIf="batchUpdateForm.value.enrollmentType === 'open'"
          [ngClass]="batchUpdateForm.controls['enrollmentEndDate'].invalid && !batchUpdateForm.controls['enrollmentEndDate'].pristine ? 'error': ''">
          <label>{{resourceService?.frmelmnts?.lbl?.enrollmentenddate | uppercase}}</label>
          <div class="ui read-only calendar rangeenrollMentEnd" id="rangeenrollMentEnd">
            <div class="sb-field ui input left icon" [ngClass]="{'disabled': !batchUpdateForm.value.startDate}">
              <i class="calendar icon date-calendar"></i>
              <input
                tabindex="0" (click)="setTelemetryCData([{id:'course:enrollment:endDate',type:'Feature'},{id:'SB-13073',type:'Task'}])"
                class="sb-form-control" [pickerMinDate]='pickerMinDateForEnrollmentEndDate'
                [pickerMaxDate]='batchUpdateForm.value.endDate' suiDatepicker formControlName="enrollmentEndDate"
                [pickerMode]="'date'">
            </div>
          </div>
          <div class="mt-0 mb-8 ui pointing red basic label below"
            *ngIf="batchUpdateForm.controls['enrollmentEndDate'].invalid && !batchUpdateForm.controls['enrollmentEndDate'].pristine">
            {{resourceService?.messages?.stmsg?.m0135}}
          </div>
        </div>
      </div>

      <div class="sb-field-group mb-8">
        <label>{{resourceService?.frmelmnts?.lbl?.batchmentors}}</label>
        <div class="createbatchdropdown ui fluid multiple search selection dropdown" id="mentors"
          [ngClass]="{ 'disabled': batchDetails.status === 2 || showFormInViewMode }">
          <input id="mentorSelList" aria-label="mentor list">
          <i class="dropdown icon"></i>
          <div class="default text">{{resourceService?.frmelmnts?.intxt?.t0005}}</div>
          <div class="menu">
            <div class="item" [attr.data-value]="mentor.id" *ngFor="let mentor of mentorList">
              <img class="ui mini avatar image" src="{{mentor.avatar || 'assets/images/user_logo.png' | cdnprefixurl}}" alt="avatar-image">
              {{mentor.name}}{{mentor.otherDetail}}
            </div>
          </div>
        </div>
      </div>
      <div class="sb-field-group mb-8" *ngIf="selectedMentors.length > 0">
        <label>{{resourceService?.frmelmnts?.lbl?.batchselmentors}}</label>
        <a class="ui label mt-5" *ngFor="let selectmentor of selectedMentors">
          <img class="ui right spaced avatar image"
            src="{{selectmentor.avatar || 'assets/images/user_logo.png' | cdnprefixurl}}" alt="avatar-image">
          {{selectmentor.name}}{{selectmentor.otherDetail}}
        </a>
      </div>
      <div class="sb-field-group mb-8" *ngIf="batchUpdateForm.value.enrollmentType !== 'open'">
        <label>{{resourceService?.frmelmnts?.lbl?.bacthmembers}}
          <i *ngIf="batchDetails.participants && batchDetails.participants.length >= 100" 
            matTooltip="{{resourceService?.frmelmnts?.lbl?.contactStateAdminToAdd}}" [matTooltipPosition]="'right'"
            class="sb-icon-info info-icon"></i>
        </label>
        <div class="createbatchdropdown ui fluid multiple search selection dropdown" id="participant"
          [ngClass]="{ 'disabled': batchDetails.status === 2 || showFormInViewMode || (batchDetails.participants && batchDetails.participants.length >= 100) }">
          <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>
        <small *ngIf="batchDetails.participants && batchDetails.participants.length > 100"
          class="sb-color-primary d-flex pt-4">{{resourceService?.frmelmnts?.lbl?.contactStateAdminToAdd}}</small>
      </div>

      <div class="sb-field-group mb-8"
        *ngIf="batchUpdateForm.value.enrollmentType !== 'open' && selectedParticipants.length > 0 && (batchDetails.participants && batchDetails.participants.length <= 100)">
        <label>{{resourceService?.frmelmnts?.lbl?.batchparticipants}}</label>
        <a class="ui label mt-5" *ngFor="let user of selectedParticipants">
          <img class="ui right spaced avatar image"
            src="{{user.avatar || 'assets/images/user_logo.png' | cdnprefixurl}}" alt="avatar-image">
          {{user.name}}{{user.otherDetail}}
        </a>
      </div>

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

  <!--Actions-->
  <div class="sb-modal-actions">
    <button class="sb-btn sb-btn-normal sb-btn-primary"
      [ngClass]="{ 'sb-btn-disabled': batchDetails.status === 2 || disableSubmitBtn || showFormInViewMode }"
      appTelemetryInteract [telemetryInteractObject]="telemetryInteractObject"
      [telemetryInteractEdata]="updateBatchInteractEdata" [telemetryInteractCdata]="telemetryCdata"
      tabindex="0" (click)="updateBatch()">
      {{resourceService?.frmelmnts?.btn?.update}}
    </button>
    <button class="sb-btn sb-btn-normal sb-btn-outline-primary"
      [ngClass]="{ 'sb-btn-disabled': batchDetails.status === 2 || showFormInViewMode}" appTelemetryInteract
      [telemetryInteractObject]="telemetryInteractObject" [telemetryInteractEdata]="clearButtonInteractEdata"
      [telemetryInteractCdata]="telemetryCdata" tabindex="0" (click)="clearForm()">
      {{resourceService?.frmelmnts?.btn?.clear}}
    </button>
  </div>
  <!--/Actions-->
</sui-modal>

./update-batch.component.scss

.ui.selection.dropdown>.dropdown.icon {
    float:right;
 }
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""