/**
  * Sets the filters for year from and year to such that all data is shown.
  */
 showAllData() {
   if (!this.years)
     return;
   
   this.yearFrom.updateValue(this.years[0]);
   this.yearTo.updateValue(this.years[this.years.length-1]);
 }
Example #2
0
 it('resets a control', () => {
   let control: Control = new Control('');
   let returnedControl: AbstractControl = null;
   control.markAsTouched();
   control.updateValue('dave');
   returnedControl = Utils.resetControl(control);
   expect(returnedControl.touched).toBe(false);
   expect(returnedControl.untouched).toBe(true);
   expect(returnedControl.pristine).toBe(true);
   expect(returnedControl.dirty).toBe(false);
   expect(returnedControl.value).toBe('');
 });
        it('should check is value is a valid email', () => {


            let control = new Control('*****@*****.**');

            let result: ValidationResult = FormValidators.isMailAddress(control);

            expect(result).toBeDefined();
            expect(result['mail_format_error']).toBe(false);

            // set value to alphanumeric
            control.updateValue('abc');

            result = FormValidators.isMailAddress(control);
            expect(result['mail_format_error']).toBe(true);
        });
        it('should check is value is a number', () => {


            let control = new Control('123');

           let result: ValidationResult = FormValidators.isNumber(control);

            expect(result).toBeDefined();
            expect(result['nan']).toBe(false);

            // set value to alphanumeric
            control.updateValue('abc');

            result = FormValidators.isNumber(control);
            expect(result['nan']).toBe(true);
        });
    /**
     * Form submit handler.
     * Send a Message to the Room with id.
     */
    send() {
        if (this.message.valid) {
            // Send message to server
            this._roomService.sendMessage(parseInt(this._routeParams.get('id')), this.messageForm.value.message);

            // Reset the form
            this.message.updateValue('');
        }
    }
        setTimeout(()=> {
            this.formDir.form.addControl(this.field.name,this.fieldControl);

            let value:any = '';
            if(this.entity && this.entity.extraFields && this.entity.extraFields[this.field.name]) {
                value = this.entity.extraFields[this.field.name];
            }  else if(this.field.hasValue()) {
                value = this.field.value;
                this.entity.extraFields[this.field.name] = value;
                console.log(this.entity);
            }
            if(!this.field.isTypeFile()) {
                this.fieldControl.updateValue(value);
            }
        }, 0);
Example #7
0
            .catch(error => {
                this.password.updateValue("");

                if (error.code === "auth/invalid-email" || error.code === "auth/wrong-password") {
                    this.showLoginFailure("Email or password invalid");
                    return;
                }
                if (error.code === "auth/user-disabled") {
                    this.showLoginFailure("User has been disabled");
                    return;
                }
                if (error.code === "auth/user-not-found") {
                    this.showLoginFailure("User not found");
                    return;
                }
            });
Example #8
0
            .catch(error => {
                this.password.updateValue("");

                if (error.code === "auth/email-already-in-use") {
                    this.showLoginFailure("Email already exists an account");
                    return;
                }
                if (error.code === "auth/invalid-email") {
                    this.showLoginFailure("Email address is not valid");
                    return;
                }
                if (error.code === "auth/operation-not-allowed") {
                    this.showLoginFailure("Email/password accounts are not enabled");
                    return;
                }
                if (error.code === "auth/weak-password") {
                    this.showLoginFailure("Password is not strong enough");
                    return;
                }
            });
 res => {
     this.ctrlRegPasswordConfirm.updateValue("");
     this.login();
     this.turnOffError();
 },
Example #10
0
 user => {
     this.ctrlEmail.updateValue("");
     this.ctrlPassword.updateValue("");
     this.turnOffError();
 },