add Eliminar encuesta
This commit is contained in:
parent
593905bf01
commit
9f4f87ef41
|
@ -1,6 +1,6 @@
|
|||
<form *ngIf="encuesta" name="deleteForm" (ngSubmit)="confirmDelete(encuesta.id!)">
|
||||
<form class="ds-form" *ngIf="encuesta" name="deleteForm" (ngSubmit)="confirmDelete(encuesta!)">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" data-cy="encuestaDeleteDialogHeading" jhiTranslate="entity.delete.title">Confirm delete operation</h4>
|
||||
<h2 class="ds-title" data-cy="encuestaDeleteDialogHeading" jhiTranslate="entity.delete.title">Confirm delete operation</h2>
|
||||
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="cancel()">×</button>
|
||||
</div>
|
||||
|
@ -14,11 +14,11 @@
|
|||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="cancel()">
|
||||
<fa-icon icon="ban"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||
<button type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal" (click)="cancel()">
|
||||
<fa-icon icon="arrow-left"></fa-icon> <span jhiTranslate="entity.action.cancel">Cancel</span>
|
||||
</button>
|
||||
|
||||
<button id="jhi-confirm-delete-encuesta" data-cy="entityConfirmDeleteButton" type="submit" class="btn btn-danger">
|
||||
<button id="jhi-confirm-delete-encuesta" data-cy="entityConfirmDeleteButton" type="submit" class="ds-btn ds-btn--danger">
|
||||
<fa-icon icon="times"></fa-icon> <span jhiTranslate="entity.action.delete">Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -3,6 +3,7 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
|||
|
||||
import { IEncuesta } from '../encuesta.model';
|
||||
import { EncuestaService } from '../service/encuesta.service';
|
||||
import { EstadoEncuesta } from 'app/entities/enumerations/estado-encuesta.model';
|
||||
|
||||
@Component({
|
||||
templateUrl: './encuesta-delete-dialog.component.html',
|
||||
|
@ -16,8 +17,9 @@ export class EncuestaDeleteDialogComponent {
|
|||
this.activeModal.dismiss();
|
||||
}
|
||||
|
||||
confirmDelete(id: number): void {
|
||||
this.encuestaService.delete(id).subscribe(() => {
|
||||
confirmDelete(encuest: IEncuesta): void {
|
||||
encuest.estado = EstadoEncuesta.DELETED;
|
||||
this.encuestaService.deleteEncuesta(encuest).subscribe(() => {
|
||||
this.activeModal.close('deleted');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -71,7 +71,9 @@
|
|||
</div>
|
||||
<div class="ds-contextmenu__divider" id="contextmenu-delete--separator">
|
||||
<li>
|
||||
<button type="button"><fa-icon class="contextmenu__icon" [icon]="faTrashAlt"></fa-icon>Eliminar</button>
|
||||
<button type="button" (click)="deleteSurvey()">
|
||||
<fa-icon class="contextmenu__icon" [icon]="faTrashAlt"></fa-icon>Eliminar
|
||||
</button>
|
||||
</li>
|
||||
</div>
|
||||
</ul>
|
||||
|
@ -82,6 +84,7 @@
|
|||
*ngFor="let encuesta of encuestas; trackBy: trackId"
|
||||
(dblclick)="openSurvey($event)"
|
||||
(click)="selectSurvey($event)"
|
||||
[hidden]="encuesta.estado == 'DELETED'"
|
||||
[attr.data-id]="encuesta.id"
|
||||
>
|
||||
<div class="entity-header">
|
||||
|
|
|
@ -66,6 +66,9 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
|||
categoriasSharedCollection: ICategoria[] = [];
|
||||
usuarioExtrasSharedCollection: IUsuarioExtra[] = [];
|
||||
|
||||
selectedSurvey: number | null = null;
|
||||
encuestaencontrada: IEncuesta | null = null;
|
||||
|
||||
editForm = this.fb.group({
|
||||
id: [],
|
||||
nombre: [null, [Validators.required, Validators.minLength(1), Validators.maxLength(50)]],
|
||||
|
@ -178,6 +181,49 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
|||
});
|
||||
}
|
||||
|
||||
deleteSurvey(): void {
|
||||
if (this.selectedSurvey != null) {
|
||||
this.getEncuesta(this.selectedSurvey)
|
||||
.pipe(
|
||||
finalize(() => {
|
||||
const modalRef = this.modalService.open(EncuestaDeleteDialogComponent, { size: 'lg', backdrop: 'static' });
|
||||
modalRef.componentInstance.encuesta = this.encuestaencontrada;
|
||||
|
||||
modalRef.closed.subscribe(reason => {
|
||||
if (reason === 'deleted') {
|
||||
this.loadAll();
|
||||
}
|
||||
});
|
||||
})
|
||||
)
|
||||
.subscribe(data => {
|
||||
console.log(data);
|
||||
this.encuestaencontrada = data;
|
||||
});
|
||||
|
||||
/*const modalRef = this.modalService.open(EncuestaDeleteDialogComponent, { size: 'lg', backdrop: 'static' });
|
||||
modalRef.componentInstance.encuesta = this.getEncuesta(this.selectedSurvey)
|
||||
.pipe(finalize(() =>
|
||||
modalRef.closed.subscribe(reason => {
|
||||
if (reason === 'deleted') {
|
||||
this.loadAll();
|
||||
}
|
||||
})
|
||||
))
|
||||
.subscribe(data=> {
|
||||
console.log(data);
|
||||
//this.encuestaencontrada = data;
|
||||
});
|
||||
*/
|
||||
|
||||
// unsubscribe not needed because closed completes on modal close
|
||||
}
|
||||
}
|
||||
|
||||
getEncuesta(id: number) {
|
||||
return this.encuestaService.findEncuesta(id);
|
||||
}
|
||||
|
||||
previousState(): void {
|
||||
window.history.back();
|
||||
}
|
||||
|
@ -350,6 +396,9 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
|||
} else if ((event.target as HTMLElement).classList.contains('ds-list--entity')) {
|
||||
event.target.classList.add('active');
|
||||
document.getElementById('contextmenu-create--separator')!.style.display = 'none';
|
||||
|
||||
this.selectedSurvey = Number(event.target.dataset.id);
|
||||
//this.selectedSurvey = event.target.dataset.encuesta;
|
||||
}
|
||||
|
||||
document.getElementById('contextmenu')!.style.top = event.layerY + 'px';
|
||||
|
|
|
@ -45,6 +45,15 @@ export class EncuestaService {
|
|||
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
|
||||
}
|
||||
|
||||
findEncuesta(id: number): Observable<IEncuesta> {
|
||||
return this.http.get<IEncuesta>(`${this.resourceUrl}/${id}`);
|
||||
}
|
||||
|
||||
deleteEncuesta(encuesta: IEncuesta): Observable<EntityResponseType> {
|
||||
//const copy = this.convertDateFromClient(encuesta);
|
||||
return this.http.put<IEncuesta>(`${this.resourceUrl}/${getEncuestaIdentifier(encuesta) as number}`, encuesta, { observe: 'response' });
|
||||
}
|
||||
|
||||
query(req?: any): Observable<EntityArrayResponseType> {
|
||||
const options = createRequestOption(req);
|
||||
return this.http
|
||||
|
|
|
@ -136,7 +136,7 @@
|
|||
"value": "Valor"
|
||||
},
|
||||
"delete": {
|
||||
"title": "Confirmar operación de borrado"
|
||||
"title": "Confirmar de operación"
|
||||
},
|
||||
"validation": {
|
||||
"required": "Este campo es obligatorio.",
|
||||
|
|
Loading…
Reference in New Issue