|
|
@@ -1,69 +0,0 @@
|
|
|
-import { Component, Inject } from '@angular/core';
|
|
|
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
|
-import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
|
|
-import { lastValueFrom } from 'rxjs';
|
|
|
-import { HttpErrorResponse } from '@angular/common/http';
|
|
|
-import { RegisterWorkflowRequest } from '../../../../interfaces/process-managementv/workflow-management.interface';
|
|
|
-import { ProcessManagementService } from '../../../../services/process-management/process-management.service';
|
|
|
-import { ResourcesService, ResponseData } from '../../../../services/resources.service';
|
|
|
-import { InternationalizationService } from '../../../../services/internationalization/internationalization.service';
|
|
|
-
|
|
|
-@Component({
|
|
|
- selector: 'app-register-workflow',
|
|
|
- templateUrl: './register-workflow.component.html',
|
|
|
- styleUrl: './register-workflow.component.css',
|
|
|
- standalone: false,
|
|
|
-})
|
|
|
-export class RegisterWorkflowComponent {
|
|
|
- public formWorkflow: FormGroup;
|
|
|
- public isLoading: boolean = false;
|
|
|
-
|
|
|
- constructor(
|
|
|
- private _fb: FormBuilder,
|
|
|
- private _processManagementService: ProcessManagementService,
|
|
|
- private _resourcesService: ResourcesService,
|
|
|
- public interService: InternationalizationService,
|
|
|
- private _dialogRef: MatDialogRef<RegisterWorkflowComponent>,
|
|
|
- @Inject(MAT_DIALOG_DATA) public data: any
|
|
|
- ) {
|
|
|
- this.formWorkflow = this._fb.group({
|
|
|
- NOMBRE_WORKFLOW: ['', [Validators.required, Validators.maxLength(100)]],
|
|
|
- DESCRIPCION: ['', [Validators.required, Validators.maxLength(500)]]
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- public async onSubmit() {
|
|
|
- if (this.formWorkflow.valid) {
|
|
|
- this.isLoading = true;
|
|
|
-
|
|
|
- const registerRequest: RegisterWorkflowRequest = {
|
|
|
- NOMBRE_WORKFLOW: this.formWorkflow.value.NOMBRE_WORKFLOW,
|
|
|
- DESCRIPCION: this.formWorkflow.value.DESCRIPCION,
|
|
|
- USUARIO: this._resourcesService.getUser(),
|
|
|
- NUMERO_LINEA: this._resourcesService.getLineNumber()
|
|
|
- };
|
|
|
-
|
|
|
- await lastValueFrom(
|
|
|
- this._processManagementService.registerNewWorkflow(registerRequest)
|
|
|
- ).then(
|
|
|
- (responseData: ResponseData) => {
|
|
|
- if (!responseData.error) {
|
|
|
- this._resourcesService.openSnackBar(this.interService.get('registro_exitoso'));
|
|
|
- this._dialogRef.close(true);
|
|
|
- } else {
|
|
|
- this._resourcesService.openSnackBar(`${responseData.msg}`);
|
|
|
- }
|
|
|
- },
|
|
|
- (httpErrorResponse: HttpErrorResponse) => {
|
|
|
- this._resourcesService.checkErrors(httpErrorResponse);
|
|
|
- }
|
|
|
- );
|
|
|
-
|
|
|
- this.isLoading = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public onCancel() {
|
|
|
- this._dialogRef.close(false);
|
|
|
- }
|
|
|
-}
|