File

src/app/modules/learn/components/course-consumption/certificate-name-update-popup/certificate-name-update-popup.component.ts

Implements

OnInit OnDestroy

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(userService: UserService, resourceService: ResourceService, toasterService: ToasterService, learnerService: LearnerService, profileService: ProfileService)
Parameters :
Name Type Optional
userService UserService No
resourceService ResourceService No
toasterService ToasterService No
learnerService LearnerService No
profileService ProfileService No

Inputs

profileInfo
Type : any
showProfileUpdatePopup
Type : any

Outputs

close
Type : EventEmitter

Methods

allowToEdit
allowToEdit(inputType)
Parameters :
Name Optional
inputType No
Returns : void
closePopup
closePopup()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
onClickCheckbox
onClickCheckbox(tncChecked)
Parameters :
Name Optional
tncChecked No
Returns : void
updateProfileName
updateProfileName()

This method used to submit profile Update

Returns : void

Properties

certificateNameChecked
Default value : false
courseInteractObject
Type : IInteractEventObject
disableContinueBtn
Default value : false
fNameInputEl
Type : ElementRef
Decorators :
@ViewChild('crtFirstName')
instance
Type : string
isLastNameEditable
Default value : false
isNameEditable
Default value : false
Public learner
Type : LearnerService
Public learnerService
Type : LearnerService
lNameInputEl
Type : ElementRef
Decorators :
@ViewChild('crtLastName')
modal
Decorators :
@ViewChild('modal')
Public resourceService
Type : ResourceService
Public userService
Type : UserService
import { Component, Input, Output, OnInit, ViewChild, EventEmitter, ElementRef, OnDestroy } from '@angular/core';
import { ToasterService, ResourceService} from '@sunbird/shared';
import { UserService, LearnerService } from '@sunbird/core';
import * as _ from 'lodash-es';
import { ProfileService } from '@sunbird/profile';
import { IInteractEventObject } from '@sunbird/telemetry';

@Component({
  selector: 'app-certificate-name-update-popup',
  templateUrl: './certificate-name-update-popup.component.html',
  styleUrls: ['./certificate-name-update-popup.component.scss']
})
export class CertificateNameUpdatePopupComponent implements OnInit, OnDestroy {
  @Input() showProfileUpdatePopup;
  @Input() profileInfo;
  @ViewChild('modal') modal;
  @Output() close = new EventEmitter();
  @ViewChild('crtFirstName') fNameInputEl: ElementRef;
  @ViewChild('crtLastName') lNameInputEl: ElementRef;


  disableContinueBtn = false;
  isNameEditable = false;
  isLastNameEditable = false;
  certificateNameChecked = false;
  instance: string;
  public learner: LearnerService;
  courseInteractObject: IInteractEventObject;

  constructor( public userService: UserService,
    public resourceService: ResourceService,
    private toasterService: ToasterService,
    public learnerService: LearnerService,
    private profileService: ProfileService) { }

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

  onClickCheckbox(tncChecked) {
    this.disableContinueBtn = !tncChecked;
    this.isNameEditable = false;
    this.isLastNameEditable = false;
  }

  closePopup() {
    this.modal.deny();
    this.close.emit();
  }

  allowToEdit(inputType) {
    if (inputType === 'firstName') {
      this.isNameEditable = true;
      setTimeout(() => {
        this.fNameInputEl.nativeElement.focus();
      }, 100);
    } else if (inputType === 'lastName') {
      this.isLastNameEditable = true;
      setTimeout(() => {
        this.lNameInputEl.nativeElement.focus();
      }, 100);
    }
  }

  /**
   * This method used to submit profile Update
   */
  updateProfileName() {
    const data = {
      firstName: _.trim(this.profileInfo.firstName),
      lastName: _.trim(this.profileInfo.lastName)
    };
    this.disableContinueBtn = true;
    localStorage.setItem('isCertificateNameUpdated_' + this.profileInfo.id, 'true');

    this.profileService.updateProfile(data).subscribe(res => {
      this.closePopup();
    }, err => {
      this.disableContinueBtn = false;
      this.toasterService.error(this.resourceService.messages.fmsg.m0085);
    });
  }

  ngOnDestroy() {
    if (_.get(this.modal, 'deny')) {
      this.modal.deny();
    }
  }
}
<app-modal-wrapper [config]="{disableClose: true, size: 'normal', panelClass: 'material-modal'}" (dismiss)="closePopup()" #modal>
  <ng-template sbModalContent>
    <div class="sb-mat__modal">

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

      <!--Content-->
      <div class="sb-mat__modal__content">
        <div class="d-flex flex-jc-center">
          <img src="./assets/images/profile-certificate.svg" alt="">
        </div>
        <div class="profile-section-content">
          <div class="profile-info d-flex flex-dc">
            <span
              class="text-center d-flex flex-ai-center flex-jc-center mb-8">{{resourceService?.frmelmnts?.lbl?.firstName}}:
              <span *ngIf="!isNameEditable" class="font-weight-bold ml-8">{{profileInfo.firstName }} <img
                  src="./assets/images/edit-icon.svg" alt="edit-icon" class="cursor-pointer ml-8" tabindex="0"
                  (click)="allowToEdit('firstName')" appTelemetryInteract
                  [telemetryInteractObject]="courseInteractObject"
                  [telemetryInteractEdata]="{id:'certificatefNameChangeEdit' , type: 'click' , pageid:'course-consumption'}"></span>
              <span *ngIf="isNameEditable" class="pt-8"><input class="sb-form-control ml-8"
                  [(ngModel)]="profileInfo.firstName" (blur)="isNameEditable = false" #crtFirstName /></span>
            </span>
            <span
              class="text-center d-flex flex-ai-center flex-jc-center">{{resourceService?.frmelmnts?.lbl?.lastName}}:
              <span *ngIf="!isLastNameEditable" class="font-weight-bold ml-8">{{profileInfo.lastName }} <img
                  src="./assets/images/edit-icon.svg" alt="edit-icon" class="cursor-pointer ml-8" tabindex="0"
                  (click)="allowToEdit('lastName')" appTelemetryInteract
                  [telemetryInteractObject]="courseInteractObject"
                  [telemetryInteractEdata]="{id:'certificatelNameChangeEdit' , type: 'click' , pageid:'course-consumption'}"></span>
              <span *ngIf="isLastNameEditable" class="pt-8"><input class="sb-form-control ml-8"
                  [(ngModel)]="profileInfo.lastName" (blur)="isLastNameEditable = false" #crtLastName /></span>
            </span>
          </div>
          <div class="profile-info-para mt-8 text-center">
            <p class="mb-8">
              {{resourceService?.frmelmnts?.lbl?.nameUpdateConfirmation | interpolate:'{instance}': instance}}
            </p>
            <p class="mb-0 fnormal font-weight-normal">
              <input class="mr-8 cursor-pointer" type="checkbox" [(ngModel)]="certificateNameChecked" value="true"
                tabindex="0" (click)="onClickCheckbox(certificateNameChecked)" appTelemetryInteract
                [telemetryInteractObject]="courseInteractObject"
                [telemetryInteractEdata]="{id:'certificateNameUpdateConfirmation' , type: 'click' , pageid:'course-consumption'}">
              {{resourceService?.frmelmnts?.lbl?.certificateNameUpdate}}
            </p>
          </div>
        </div>
      </div>
      <!--/Content-->

      <!--Actions-->
      <div class="sb-mat__modal__actions text-center">
        <button appTelemetryInteract [telemetryInteractObject]="courseInteractObject" tabindex="0"
          [telemetryInteractEdata]="{id:'viewCertificateNameChangedPopupSubmit' , type: 'click' , pageid:'course-consumption'}"
          [ngClass]="certificateNameChecked ? '' : 'sb-btn-disabled'" [disabled]="!disableContinueBtn" tabindex="0"
          (click)="updateProfileName()" class="sb-btn sb-btn-normal sb-btn-primary" type="button">
          {{resourceService.frmelmnts.lbl.continue}} </button>
      </div>
      <!-- pass "sb-btn-disabled" class for button disabled -->
      <!--/Actions-->

    </div>
  </ng-template>
</app-modal-wrapper>

./certificate-name-update-popup.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""