Merge pull request #113 from Quantum-P3/feature/US-34

add eliminar plantilla
This commit is contained in:
Eduardo Quiros 2021-08-08 06:42:22 +00:00 committed by GitHub
commit 956f7e58fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 31 deletions

View File

@ -1,21 +1,20 @@
<form *ngIf="plantilla" name="deleteForm" (ngSubmit)="confirmDelete(plantilla.id!)"> <form class="ds-form" *ngIf="plantilla" name="deleteForm" (ngSubmit)="confirmDelete(plantilla)">
<div class="modal-header">
<h4 class="modal-title" data-cy="plantillaDeleteDialogHeading" jhiTranslate="entity.delete.title">Confirm delete operation</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="cancel()">&times;</button>
</div>
<div class="modal-body"> <div class="modal-body">
<jhi-alert-error></jhi-alert-error> <jhi-alert-error></jhi-alert-error>
<p class="ds-title--small">Eliminar plantilla</p>
<p id="jhi-delete-plantilla-heading" jhiTranslate="dataSurveyApp.plantilla.delete.question" [translateValues]="{ id: plantilla.id }"> <p
class="ds-subtitle"
id="jhi-delete-plantilla-heading"
jhiTranslate="dataSurveyApp.plantilla.delete.question"
[translateValues]="{ id: plantilla.id }"
>
Are you sure you want to delete this Plantilla? Are you sure you want to delete this Plantilla?
</p> </p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="cancel()"> <button type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal" (click)="cancel()">
<fa-icon icon="ban"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span> <fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button> </button>
<button id="jhi-confirm-delete-plantilla" data-cy="entityConfirmDeleteButton" type="submit" class="btn btn-danger"> <button id="jhi-confirm-delete-plantilla" data-cy="entityConfirmDeleteButton" type="submit" class="btn btn-danger">

View File

@ -1,6 +1,5 @@
jest.mock('@ng-bootstrap/ng-bootstrap'); import { Plantilla } from '../plantilla.model';
import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http'; import { HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing';
import { of } from 'rxjs'; import { of } from 'rxjs';
@ -9,6 +8,9 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { PlantillaService } from '../service/plantilla.service'; import { PlantillaService } from '../service/plantilla.service';
import { PlantillaDeleteDialogComponent } from './plantilla-delete-dialog.component'; import { PlantillaDeleteDialogComponent } from './plantilla-delete-dialog.component';
import { EstadoPlantilla } from '../../enumerations/estado-plantilla.model';
jest.mock('@ng-bootstrap/ng-bootstrap');
describe('Component Tests', () => { describe('Component Tests', () => {
describe('Plantilla Management Delete Component', () => { describe('Plantilla Management Delete Component', () => {
@ -37,9 +39,12 @@ describe('Component Tests', () => {
fakeAsync(() => { fakeAsync(() => {
// GIVEN // GIVEN
jest.spyOn(service, 'delete').mockReturnValue(of(new HttpResponse({}))); jest.spyOn(service, 'delete').mockReturnValue(of(new HttpResponse({})));
const pPlantilla = new Plantilla();
pPlantilla.id = 123;
pPlantilla.estado = EstadoPlantilla.DELETED;
// WHEN // WHEN
comp.confirmDelete(123); comp.confirmDelete(pPlantilla);
tick(); tick();
// THEN // THEN

View File

@ -3,6 +3,7 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { IPlantilla } from '../plantilla.model'; import { IPlantilla } from '../plantilla.model';
import { PlantillaService } from '../service/plantilla.service'; import { PlantillaService } from '../service/plantilla.service';
import { EstadoPlantilla } from '../../enumerations/estado-plantilla.model';
@Component({ @Component({
templateUrl: './plantilla-delete-dialog.component.html', templateUrl: './plantilla-delete-dialog.component.html',
@ -16,8 +17,9 @@ export class PlantillaDeleteDialogComponent {
this.activeModal.dismiss(); this.activeModal.dismiss();
} }
confirmDelete(id: number): void { confirmDelete(pPlantilla: IPlantilla): void {
this.plantillaService.delete(id).subscribe(() => { pPlantilla.estado = EstadoPlantilla.DELETED;
this.plantillaService.update(pPlantilla).subscribe(() => {
this.activeModal.close('deleted'); this.activeModal.close('deleted');
}); });
} }

View File

@ -39,7 +39,6 @@
<thead> <thead>
<tr> <tr>
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.nombre">Nombre</span></th> <th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.nombre">Nombre</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.descripcion">Descripcion</span></th>
<!-- <th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.fechaCreacion">Fecha Creacion</span></th> --> <!-- <th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.fechaCreacion">Fecha Creacion</span></th> -->
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.fechaPublicacionTienda">Fecha Publicacion Tienda</span></th> <th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.fechaPublicacionTienda">Fecha Publicacion Tienda</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.estado">Estado</span></th> <th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.estado">Estado</span></th>
@ -51,7 +50,6 @@
<tbody> <tbody>
<tr *ngFor="let plantilla of plantillas; trackBy: trackId" data-cy="entityTable"> <tr *ngFor="let plantilla of plantillas; trackBy: trackId" data-cy="entityTable">
<td>{{ plantilla.nombre }}</td> <td>{{ plantilla.nombre }}</td>
<td>{{ plantilla.descripcion }}</td>
<!-- <td>{{ plantilla.fechaCreacion | formatMediumDatetime }}</td> --> <!-- <td>{{ plantilla.fechaCreacion | formatMediumDatetime }}</td> -->
<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>
@ -61,16 +59,6 @@
<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">
<button
type="submit"
[routerLink]="['/plantilla', plantilla.id, 'view']"
class="ds-btn ds-btn--secondary btn-sm"
data-cy="entityDetailsButton"
>
<fa-icon icon="eye"></fa-icon>
<span class="d-none d-md-inline">Vista previa</span>
</button>
<button <button
type="submit" type="submit"
[routerLink]="['/plantilla', plantilla.id, 'edit']" [routerLink]="['/plantilla', plantilla.id, 'edit']"

View File

@ -53,7 +53,8 @@ export class PlantillaComponent implements OnInit {
this.plantillaService.query().subscribe( this.plantillaService.query().subscribe(
(res: HttpResponse<IPlantilla[]>) => { (res: HttpResponse<IPlantilla[]>) => {
this.isLoading = false; this.isLoading = false;
this.plantillas = res.body ?? []; const tempPlantillas = res.body ?? [];
this.plantillas = tempPlantillas.filter(p => p.estado !== EstadoPlantilla.DELETED);
}, },
() => { () => {
this.isLoading = false; this.isLoading = false;

View File

@ -12,7 +12,7 @@
"updated": "Una plantilla ha sido actualizada con el identificador {{ param }}", "updated": "Una plantilla ha sido actualizada con el identificador {{ param }}",
"deleted": "Una plantilla ha sido eliminada con el identificador {{ param }}", "deleted": "Una plantilla ha sido eliminada con el identificador {{ param }}",
"delete": { "delete": {
"question": "¿Seguro que quiere eliminar Plantilla {{ id }}?", "question": "¿Seguro que quiere eliminar esta plantilla?",
"deletefromstore": "¿Seguro que quiere eliminar esta plantilla de la tienda?" "deletefromstore": "¿Seguro que quiere eliminar esta plantilla de la tienda?"
}, },
"publish": { "publish": {