Explorar o código

Modificación de validaciones en formulario de politicas

JeanBenitez %!s(int64=3) %!d(string=hai) anos
pai
achega
e03117e961

+ 11 - 1
vacaciones/src/app/components/mco/mcompv/mcompv-form/mcompv-form.component.html

@@ -17,7 +17,7 @@
             }}</mat-error>
         </mat-form-field>
       </mat-grid-tile>
-     
+
       <mat-grid-tile colspan="6">
         <mat-form-field appearance="standard">
           <mat-label>Días de descanso</mat-label>
@@ -56,6 +56,11 @@
                 {{ item.anio }}
               </mat-option>
             </mat-select>
+            <mat-error *ngIf="data_anio!.invalid">{{
+              data_anio!.hasError("required")
+              ? "Debe ingresar este campo"
+              : ""
+              }}</mat-error>
             <mat-icon matSuffix>event</mat-icon>
           </mat-form-field>
         </mat-grid-tile>
@@ -66,6 +71,11 @@
           <mat-form-field>
             <input matInput type="number" min="1" formControlName="data_dias" placeholder="Ingrese los días" required />
             <mat-icon matSuffix>event</mat-icon>
+            <mat-error *ngIf="data_dias!.invalid">{{
+              data_dias!.hasError("required")
+              ? "Debe ingresar este campo"
+              : ""
+              }}</mat-error>
           </mat-form-field>
         </mat-grid-tile>
         <mat-grid-tile colspan="4">

+ 2 - 25
vacaciones/src/app/components/mco/mcompv/mcompv-form/mcompv-form.component.ts

@@ -146,8 +146,8 @@ export class MCOMPVFORMComponent implements AfterViewInit {
 
   private createFormGroupTable() {
     return new FormGroup({
-      data_anio: new FormControl(),
-      data_dias: new FormControl(),
+      data_anio: new FormControl([], Validators.required),
+      data_dias: new FormControl('',  Validators.required),
     });
   }
 
@@ -372,29 +372,6 @@ export class MCOMPVFORMComponent implements AfterViewInit {
     this.formGroupTable.reset();
     this.orderTable();
   }
-  /*  public agregar_tabla() {
-    this.dataSource.data = this.modificar_anios_tabla(
-      this.data_anio?.value.anio,
-      this.data_dias?.value
-    );
-
-    let filtro = this.anios_vacaciones.filter(
-      (element) => element.anio <= this.data_anio?.value.anio
-    );
-
-    if (filtro.length !== 0) {
-      filtro.forEach((element0) => {
-        let index = this.anios_vacaciones.findIndex(
-          (element1) => element1.anio == element0.anio
-        );
-        this.anios_vacaciones.splice(index, 1);
-      });
-    }
-
-    this.orderTable();
-    this.formGroupTable.reset();
-    this.ngAfterViewInit();
-  } */
 
   private modificar_anios_tabla(anio: number, dias: number) {
     let obj_add: any = {};