Fix context menu and delete survey bug (email)
This commit is contained in:
parent
577ae0e7ee
commit
0201e121df
|
@ -125,6 +125,31 @@ public class EncuestaResource {
|
|||
|
||||
Encuesta result = encuestaService.save(encuesta);
|
||||
|
||||
return ResponseEntity
|
||||
.ok()
|
||||
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, encuesta.getId().toString()))
|
||||
.body(result);
|
||||
}
|
||||
|
||||
@PutMapping("/encuestas/publish/{id}")
|
||||
public ResponseEntity<Encuesta> publishEncuesta(
|
||||
@PathVariable(value = "id", required = false) final Long id,
|
||||
@Valid @RequestBody Encuesta encuesta
|
||||
) throws URISyntaxException {
|
||||
log.debug("REST request to update Encuesta : {}, {}", id, encuesta);
|
||||
if (encuesta.getId() == null) {
|
||||
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
|
||||
}
|
||||
if (!Objects.equals(id, encuesta.getId())) {
|
||||
throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid");
|
||||
}
|
||||
|
||||
if (!encuestaRepository.existsById(id)) {
|
||||
throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound");
|
||||
}
|
||||
|
||||
Encuesta result = encuestaService.save(encuesta);
|
||||
|
||||
if (result.getAcceso().equals(AccesoEncuesta.PRIVATE)) {
|
||||
mailService.sendPublishedPrivateMail(result.getUsuarioExtra(), result.getContrasenna());
|
||||
} else {
|
||||
|
|
|
@ -16,9 +16,9 @@ export class EncuestaDeleteDialogComponent {
|
|||
this.activeModal.dismiss();
|
||||
}
|
||||
|
||||
confirmDelete(encuest: IEncuesta): void {
|
||||
encuest.estado = EstadoEncuesta.DELETED;
|
||||
this.encuestaService.deleteEncuesta(encuest).subscribe(() => {
|
||||
confirmDelete(encuesta: IEncuesta): void {
|
||||
encuesta.estado = EstadoEncuesta.DELETED;
|
||||
this.encuestaService.deleteEncuesta(encuesta).subscribe(() => {
|
||||
this.activeModal.close('deleted');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ export class EncuestaPublishDialogComponent implements OnInit {
|
|||
encuesta.contrasenna = this.generatePassword();
|
||||
}
|
||||
|
||||
this.encuestaService.update(encuesta).subscribe(() => {
|
||||
this.encuestaService.publishEncuesta(encuesta).subscribe(() => {
|
||||
this.activeModal.close('published');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -85,14 +85,8 @@
|
|||
<div class="ds-contextmenu ds-contextmenu--closed" id="contextmenu">
|
||||
<ul id="ds-context-menu__list">
|
||||
<div class="ds-contextmenu__divider ds-contextmenu__divider--separator-bottom" id="contextmenu-create--separator">
|
||||
<li>
|
||||
<button
|
||||
*ngIf="!isAdmin() && isAuthenticated()"
|
||||
type="button"
|
||||
(click)="resetForm()"
|
||||
data-toggle="modal"
|
||||
data-target="#crearEncuesta"
|
||||
>
|
||||
<li *ngIf="!isAdmin() && isAuthenticated()">
|
||||
<button type="button" (click)="resetForm()" data-toggle="modal" data-target="#crearEncuesta">
|
||||
<fa-icon class="contextmenu__icon" [icon]="faPlus"></fa-icon>Crear
|
||||
</button>
|
||||
</li>
|
||||
|
@ -112,15 +106,14 @@
|
|||
(click)="publish()"
|
||||
data-toggle="modal"
|
||||
data-target="#publicarEncuesta"
|
||||
*ngIf="isPublished"
|
||||
>
|
||||
<!--Agarrar el id de la encuesta -->
|
||||
<fa-icon class="contextmenu__icon" [icon]="faUpload"></fa-icon>Publicar
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<!-- <li>
|
||||
<button type="button" id="contextmenu-share"><fa-icon class="contextmenu__icon" [icon]="faShareAlt"></fa-icon>Compartir</button>
|
||||
</li>
|
||||
</li> -->
|
||||
</div>
|
||||
<div class="ds-contextmenu__divider" id="contextmenu-delete--separator">
|
||||
<li>
|
||||
|
|
|
@ -58,7 +58,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
|||
faPlus = faPlus;
|
||||
faStar = faStar;
|
||||
faUpload = faUpload;
|
||||
isPublished = false;
|
||||
isPublished: Boolean = false;
|
||||
successPublished = false;
|
||||
account: Account | null = null;
|
||||
usuarioExtra: UsuarioExtra | null = null;
|
||||
|
@ -73,7 +73,6 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
|||
usuarioExtrasSharedCollection: IUsuarioExtra[] = [];
|
||||
userSharedCollection: IUser[] = [];
|
||||
|
||||
selectedIdSurvey: number | null = null;
|
||||
encuestaencontrada: IEncuesta | null = null;
|
||||
|
||||
public searchString: string;
|
||||
|
@ -98,7 +97,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
|||
});
|
||||
|
||||
createAnother: Boolean = false;
|
||||
selectedSurveyId: Number = 0;
|
||||
selectedSurveyId: number | null = null;
|
||||
|
||||
constructor(
|
||||
protected encuestaService: EncuestaService,
|
||||
|
@ -251,8 +250,8 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
|||
}
|
||||
|
||||
deleteSurvey(): void {
|
||||
if (this.selectedIdSurvey != null) {
|
||||
this.getEncuesta(this.selectedIdSurvey)
|
||||
if (this.selectedSurveyId != null) {
|
||||
this.getEncuesta(this.selectedSurveyId)
|
||||
.pipe(
|
||||
finalize(() => {
|
||||
const modalRef = this.modalService.open(EncuestaDeleteDialogComponent, { size: 'lg', backdrop: 'static' });
|
||||
|
@ -443,38 +442,38 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
|||
}
|
||||
|
||||
async openContextMenu(event: any): Promise<void> {
|
||||
document.querySelectorAll('.ds-list--entity').forEach(e => {
|
||||
e.classList.remove('active');
|
||||
});
|
||||
|
||||
if (event.type === 'contextmenu') {
|
||||
event.preventDefault();
|
||||
this.selectedSurveyId = event.target.dataset.id;
|
||||
|
||||
let res = await this.encuestaService.find(this.selectedSurveyId).toPromise();
|
||||
this.selectedSurvey = res.body;
|
||||
this.isPublished = this.selectedSurvey!.estado === 'DRAFT'; // QUE SE LE MUESTRE CUANDO ESTE EN DRAFT
|
||||
|
||||
document.getElementById('contextmenu-create--separator')!.style.display = 'block';
|
||||
document.getElementById('contextmenu-edit--separator')!.style.display = 'block';
|
||||
document.getElementById('contextmenu-delete--separator')!.style.display = 'block';
|
||||
document.getElementById('contextmenu-edit')!.style.display = 'block';
|
||||
document.getElementById('contextmenu-duplicate')!.style.display = 'block';
|
||||
|
||||
if (this.isPublished) {
|
||||
document.getElementById('contextmenu-publish')!.style.display = 'block'; //cambiar
|
||||
}
|
||||
document.getElementById('contextmenu-share')!.style.display = 'block';
|
||||
if (event.target === null) return;
|
||||
document.querySelectorAll('.ds-list--entity').forEach(e => {
|
||||
e.classList.remove('active');
|
||||
});
|
||||
|
||||
if ((event.target as HTMLElement).classList.contains('ds-list')) {
|
||||
document.getElementById('contextmenu-create--separator')!.style.display = 'block';
|
||||
document.getElementById('contextmenu-edit--separator')!.style.display = 'none';
|
||||
document.getElementById('contextmenu-delete--separator')!.style.display = 'none';
|
||||
} else if ((event.target as HTMLElement).classList.contains('ds-list--entity')) {
|
||||
this.selectedSurveyId = Number(event.target.dataset.id);
|
||||
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;
|
||||
let res = await this.encuestaService.find(this.selectedSurveyId).toPromise();
|
||||
this.selectedSurvey = res.body;
|
||||
this.isPublished = this.selectedSurvey!.estado === 'ACTIVE' || this.selectedSurvey!.estado === 'FINISHED'; // QUE SE LE MUESTRE CUANDO ESTE EN DRAFT
|
||||
|
||||
document.getElementById('contextmenu-create--separator')!.style.display = 'none';
|
||||
document.getElementById('contextmenu-edit--separator')!.style.display = 'block';
|
||||
document.getElementById('contextmenu-delete--separator')!.style.display = 'block';
|
||||
document.getElementById('contextmenu-edit')!.style.display = 'block';
|
||||
document.getElementById('contextmenu-duplicate')!.style.display = 'block';
|
||||
|
||||
if (!this.isPublished) {
|
||||
document.getElementById('contextmenu-publish')!.style.display = 'block';
|
||||
} else {
|
||||
document.getElementById('contextmenu-publish')!.style.display = 'none';
|
||||
}
|
||||
// document.getElementById('contextmenu-share')!.style.display = 'block';
|
||||
document.getElementById('contextmenu-create--separator')!.style.display = 'none';
|
||||
}
|
||||
|
||||
document.getElementById('contextmenu')!.style.top = event.layerY + 'px';
|
||||
|
|
|
@ -61,6 +61,13 @@ export class EncuestaService {
|
|||
return this.http.get<IEncuesta>(`${this.resourceUrl}/${id}`);
|
||||
}
|
||||
|
||||
publishEncuesta(encuesta: IEncuesta): Observable<EntityResponseType> {
|
||||
//const copy = this.convertDateFromClient(encuesta);
|
||||
return this.http.put<IEncuesta>(`${this.resourceUrl}/publish/${getEncuestaIdentifier(encuesta) as number}`, encuesta, {
|
||||
observe: 'response',
|
||||
});
|
||||
}
|
||||
|
||||
deleteEncuesta(encuesta: IEncuesta): Observable<EntityResponseType> {
|
||||
//const copy = this.convertDateFromClient(encuesta);
|
||||
return this.http.put<IEncuesta>(`${this.resourceUrl}/${getEncuestaIdentifier(encuesta) as number}`, encuesta, { observe: 'response' });
|
||||
|
|
Loading…
Reference in New Issue