File

feature-libs/organization/administration/components/user/change-password-form/user-change-password-form.service.ts

Extends

FormService

Index

Properties
Methods

Methods

Protected build
build()
Inherited from FormService
Defined in FormService:16

Adds the password and confirmPassword field. Also adds the customerId field, so that the customerId can be used during persistent.

Returns : void
getForm
getForm(item?: User)
Inherited from FormService
Defined in FormService:39
Parameters :
Name Type Optional
item User Yes
Returns : FormGroup
Protected patchData
patchData(item?: T)
Inherited from FormService
Defined in FormService:33
Parameters :
Name Type Optional
item T Yes
Returns : void
Private toggleFreeze
toggleFreeze(item?: T)
Inherited from FormService
Defined in FormService:38
Parameters :
Name Type Optional
item T Yes
Returns : void

Properties

Protected form
Type : FormGroup
Inherited from FormService
Defined in FormService:7
import { Injectable } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { User } from '@spartacus/core';
import { CustomFormValidators } from '@spartacus/storefront';
import { FormService } from '../../shared/form/form.service';

@Injectable({
  providedIn: 'root',
})
export class UserChangePasswordFormService extends FormService<any> {
  /**
   * @override
   * Adds the password and confirmPassword field. Also adds the customerId field,
   * so that the customerId can be used during persistent.
   */
  protected build() {
    const form = new FormGroup({});
    form.setControl('customerId', new FormControl(''));
    form.setControl(
      'password',
      new FormControl('', [
        Validators.required,
        CustomFormValidators.passwordValidator,
      ])
    );
    form.setControl(
      'confirmPassword',
      new FormControl('', [
        Validators.required,
        CustomFormValidators.passwordValidator,
      ])
    );
    form.setValidators(
      CustomFormValidators.passwordsMustMatch('password', 'confirmPassword')
    );
    this.form = form;
  }

  getForm(item?: User): FormGroup {
    // we need do cleanup, to avoid have filled form after next open of that
    this.form = null;
    return super.getForm(item);
  }
}

result-matching ""

    No results matching ""