Merge pull request #66 from Quantum-P3/feature/US-27
add eliminar encuestas del usuario
This commit is contained in:
		
						commit
						1a42dcbab0
					
				| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
<form *ngIf="encuesta" name="deleteForm" (ngSubmit)="confirmDelete(encuesta)">
 | 
			
		||||
<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>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,8 @@
 | 
			
		|||
import { Component } from '@angular/core';
 | 
			
		||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
 | 
			
		||||
import { EstadoEncuesta } from 'app/entities/enumerations/estado-encuesta.model';
 | 
			
		||||
 | 
			
		||||
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',
 | 
			
		||||
| 
						 | 
				
			
			@ -17,9 +16,9 @@ export class EncuestaDeleteDialogComponent {
 | 
			
		|||
    this.activeModal.dismiss();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  confirmDelete(encuesta: IEncuesta): void {
 | 
			
		||||
    encuesta.estado = EstadoEncuesta.DELETED;
 | 
			
		||||
    this.encuestaService.update(encuesta).subscribe(() => {
 | 
			
		||||
  confirmDelete(encuest: IEncuesta): void {
 | 
			
		||||
    encuest.estado = EstadoEncuesta.DELETED;
 | 
			
		||||
    this.encuestaService.deleteEncuesta(encuest).subscribe(() => {
 | 
			
		||||
      this.activeModal.close('deleted');
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -124,7 +124,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>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,6 +22,7 @@ import { EstadoEncuesta } from 'app/entities/enumerations/estado-encuesta.model'
 | 
			
		|||
import { AccountService } from 'app/core/auth/account.service';
 | 
			
		||||
import { Account } from 'app/core/auth/account.model';
 | 
			
		||||
import { Router } from '@angular/router';
 | 
			
		||||
import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encuesta-publish-dialog.component';
 | 
			
		||||
import { IUser } from '../../user/user.model';
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +40,6 @@ import {
 | 
			
		|||
} from '@fortawesome/free-solid-svg-icons';
 | 
			
		||||
 | 
			
		||||
import * as $ from 'jquery';
 | 
			
		||||
import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encuesta-publish-dialog.component';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'jhi-encuesta',
 | 
			
		||||
| 
						 | 
				
			
			@ -73,6 +73,9 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
 | 
			
		|||
  usuarioExtrasSharedCollection: IUsuarioExtra[] = [];
 | 
			
		||||
  userSharedCollection: IUser[] = [];
 | 
			
		||||
 | 
			
		||||
  selectedIdSurvey: number | null = null;
 | 
			
		||||
  encuestaencontrada: IEncuesta | null = null;
 | 
			
		||||
 | 
			
		||||
  public searchString: string;
 | 
			
		||||
  public accesoEncuesta: string;
 | 
			
		||||
  //public categoriaEncuesta: string;
 | 
			
		||||
| 
						 | 
				
			
			@ -246,6 +249,49 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
 | 
			
		|||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  deleteSurvey(): void {
 | 
			
		||||
    if (this.selectedIdSurvey != null) {
 | 
			
		||||
      this.getEncuesta(this.selectedIdSurvey)
 | 
			
		||||
        .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();
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -431,6 +477,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.selectedIdSurvey = 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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -137,7 +137,7 @@
 | 
			
		|||
      "value": "Valor"
 | 
			
		||||
    },
 | 
			
		||||
    "delete": {
 | 
			
		||||
      "title": "Confirmar operación de borrado",
 | 
			
		||||
      "title": "Confirmar de operación",
 | 
			
		||||
      "status": "Confirmar cambio de estado"
 | 
			
		||||
    },
 | 
			
		||||
    "validation": {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue