Merge pull request #108 from Quantum-P3/fix/templates-register

Fix survey template registration validations
This commit is contained in:
Eduardo Quiros 2021-08-02 03:41:37 +00:00 committed by GitHub
commit 6c668c8c3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 9 deletions

View File

@ -26,9 +26,9 @@
</div> </div>
</h2> </h2>
<jhi-alert-error></jhi-alert-error> <!-- <jhi-alert-error></jhi-alert-error>
<jhi-alert></jhi-alert> <jhi-alert></jhi-alert> -->
<div class="alert alert-warning" id="no-result" *ngIf="plantillas?.length === 0"> <div class="alert alert-warning" id="no-result" *ngIf="plantillas?.length === 0">
<span jhiTranslate="dataSurveyApp.plantilla.home.notFound">No templates found</span> <span jhiTranslate="dataSurveyApp.plantilla.home.notFound">No templates found</span>
@ -56,7 +56,8 @@
<td *ngIf="plantilla.fechaPublicacionTienda">{{ plantilla.fechaPublicacionTienda | formatShortDatetime | titlecase }}</td> <td *ngIf="plantilla.fechaPublicacionTienda">{{ plantilla.fechaPublicacionTienda | formatShortDatetime | titlecase }}</td>
<td *ngIf="!plantilla.fechaPublicacionTienda">No establecida</td> <td *ngIf="!plantilla.fechaPublicacionTienda">No establecida</td>
<td jhiTranslate="{{ 'dataSurveyApp.EstadoPlantilla.' + plantilla.estado }}">{{ plantilla.estado }}</td> <td jhiTranslate="{{ 'dataSurveyApp.EstadoPlantilla.' + plantilla.estado }}">{{ plantilla.estado }}</td>
<td>{{ plantilla.precio | currency: 'USD':'symbol-narrow' }}</td> <td *ngIf="plantilla.precio! > 0">${{ plantilla.precio | number: '1.2' }}</td>
<td *ngIf="plantilla.precio! === 0">Gratis</td>
<td>{{ plantilla.categoria?.nombre }}</td> <td>{{ plantilla.categoria?.nombre }}</td>
<td class="text-right"> <td class="text-right">
<div class="btn-group"> <div class="btn-group">
@ -168,7 +169,7 @@
<div class="form-group"> <div class="form-group">
<label class="form-control-label" jhiTranslate="dataSurveyApp.plantilla.precio" for="field_precio">Precio</label> <label class="form-control-label" jhiTranslate="dataSurveyApp.plantilla.precio" for="field_precio">Precio</label>
<input type="number" class="form-control" name="precio" id="field_precio" data-cy="precio" formControlName="precio" /> <input type="number" min="0" class="form-control" name="precio" id="field_precio" data-cy="precio" formControlName="precio" />
<div <div
*ngIf=" *ngIf="
templateCreateForm.get('precio')!.invalid && templateCreateForm.get('precio')!.invalid &&
@ -189,6 +190,13 @@
> >
This field should be a number. This field should be a number.
</small> </small>
<small
class="form-text text-danger"
[hidden]="!templateCreateForm.get('precio')?.errors?.min"
jhiTranslate="entity.validation.minoigual"
>
This field should be great than or equals to 0.
</small>
</div> </div>
</div> </div>
@ -207,6 +215,20 @@
{{ categoriaOption.nombre }} {{ categoriaOption.nombre }}
</option> </option>
</select> </select>
<div
*ngIf="
templateCreateForm.get('categoria')!.invalid &&
(templateCreateForm.get('categoria')!.dirty || templateCreateForm.get('categoria')!.touched)
"
>
<small
class="form-text text-danger"
*ngIf="templateCreateForm.get('categoria')?.errors?.required"
jhiTranslate="entity.validation.required"
>
This field is required.
</small>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -33,10 +33,10 @@ export class PlantillaComponent implements OnInit {
templateCreateForm = this.fb.group({ templateCreateForm = this.fb.group({
id: [], id: [],
nombre: [null, [Validators.minLength(1), Validators.maxLength(50)]], nombre: [null, [Validators.required, Validators.minLength(1), Validators.maxLength(50)]],
descripcion: [], descripcion: [[Validators.required]],
precio: [null, [Validators.required]], precio: [null, [Validators.required, Validators.min(0)]],
categoria: [], categoria: [null, [Validators.required]],
}); });
constructor( constructor(

View File

@ -151,7 +151,8 @@
"pattern": "Este campo debe seguir el patrón {{pattern}}.", "pattern": "Este campo debe seguir el patrón {{pattern}}.",
"number": "Este campo debe ser un número.", "number": "Este campo debe ser un número.",
"integerNumber": "Este campo debe ser un número entero.", "integerNumber": "Este campo debe ser un número entero.",
"datetimelocal": "Este campo debe ser una fecha y hora." "datetimelocal": "Este campo debe ser una fecha y hora.",
"minoigual": "Este campo debe ser mayor o igual que 0."
}, },
"publish": { "publish": {
"title": "Publicar encuesta", "title": "Publicar encuesta",