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);
|
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)) {
|
if (result.getAcceso().equals(AccesoEncuesta.PRIVATE)) {
|
||||||
mailService.sendPublishedPrivateMail(result.getUsuarioExtra(), result.getContrasenna());
|
mailService.sendPublishedPrivateMail(result.getUsuarioExtra(), result.getContrasenna());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,9 +16,9 @@ export class EncuestaDeleteDialogComponent {
|
||||||
this.activeModal.dismiss();
|
this.activeModal.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmDelete(encuest: IEncuesta): void {
|
confirmDelete(encuesta: IEncuesta): void {
|
||||||
encuest.estado = EstadoEncuesta.DELETED;
|
encuesta.estado = EstadoEncuesta.DELETED;
|
||||||
this.encuestaService.deleteEncuesta(encuest).subscribe(() => {
|
this.encuestaService.deleteEncuesta(encuesta).subscribe(() => {
|
||||||
this.activeModal.close('deleted');
|
this.activeModal.close('deleted');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ export class EncuestaPublishDialogComponent implements OnInit {
|
||||||
encuesta.contrasenna = this.generatePassword();
|
encuesta.contrasenna = this.generatePassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.encuestaService.update(encuesta).subscribe(() => {
|
this.encuestaService.publishEncuesta(encuesta).subscribe(() => {
|
||||||
this.activeModal.close('published');
|
this.activeModal.close('published');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,14 +85,8 @@
|
||||||
<div class="ds-contextmenu ds-contextmenu--closed" id="contextmenu">
|
<div class="ds-contextmenu ds-contextmenu--closed" id="contextmenu">
|
||||||
<ul id="ds-context-menu__list">
|
<ul id="ds-context-menu__list">
|
||||||
<div class="ds-contextmenu__divider ds-contextmenu__divider--separator-bottom" id="contextmenu-create--separator">
|
<div class="ds-contextmenu__divider ds-contextmenu__divider--separator-bottom" id="contextmenu-create--separator">
|
||||||
<li>
|
<li *ngIf="!isAdmin() && isAuthenticated()">
|
||||||
<button
|
<button type="button" (click)="resetForm()" data-toggle="modal" data-target="#crearEncuesta">
|
||||||
*ngIf="!isAdmin() && isAuthenticated()"
|
|
||||||
type="button"
|
|
||||||
(click)="resetForm()"
|
|
||||||
data-toggle="modal"
|
|
||||||
data-target="#crearEncuesta"
|
|
||||||
>
|
|
||||||
<fa-icon class="contextmenu__icon" [icon]="faPlus"></fa-icon>Crear
|
<fa-icon class="contextmenu__icon" [icon]="faPlus"></fa-icon>Crear
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
@ -112,15 +106,14 @@
|
||||||
(click)="publish()"
|
(click)="publish()"
|
||||||
data-toggle="modal"
|
data-toggle="modal"
|
||||||
data-target="#publicarEncuesta"
|
data-target="#publicarEncuesta"
|
||||||
*ngIf="isPublished"
|
|
||||||
>
|
>
|
||||||
<!--Agarrar el id de la encuesta -->
|
<!--Agarrar el id de la encuesta -->
|
||||||
<fa-icon class="contextmenu__icon" [icon]="faUpload"></fa-icon>Publicar
|
<fa-icon class="contextmenu__icon" [icon]="faUpload"></fa-icon>Publicar
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<!-- <li>
|
||||||
<button type="button" id="contextmenu-share"><fa-icon class="contextmenu__icon" [icon]="faShareAlt"></fa-icon>Compartir</button>
|
<button type="button" id="contextmenu-share"><fa-icon class="contextmenu__icon" [icon]="faShareAlt"></fa-icon>Compartir</button>
|
||||||
</li>
|
</li> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="ds-contextmenu__divider" id="contextmenu-delete--separator">
|
<div class="ds-contextmenu__divider" id="contextmenu-delete--separator">
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -58,7 +58,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
||||||
faPlus = faPlus;
|
faPlus = faPlus;
|
||||||
faStar = faStar;
|
faStar = faStar;
|
||||||
faUpload = faUpload;
|
faUpload = faUpload;
|
||||||
isPublished = false;
|
isPublished: Boolean = false;
|
||||||
successPublished = false;
|
successPublished = false;
|
||||||
account: Account | null = null;
|
account: Account | null = null;
|
||||||
usuarioExtra: UsuarioExtra | null = null;
|
usuarioExtra: UsuarioExtra | null = null;
|
||||||
|
@ -73,7 +73,6 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
||||||
usuarioExtrasSharedCollection: IUsuarioExtra[] = [];
|
usuarioExtrasSharedCollection: IUsuarioExtra[] = [];
|
||||||
userSharedCollection: IUser[] = [];
|
userSharedCollection: IUser[] = [];
|
||||||
|
|
||||||
selectedIdSurvey: number | null = null;
|
|
||||||
encuestaencontrada: IEncuesta | null = null;
|
encuestaencontrada: IEncuesta | null = null;
|
||||||
|
|
||||||
public searchString: string;
|
public searchString: string;
|
||||||
|
@ -98,7 +97,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
||||||
});
|
});
|
||||||
|
|
||||||
createAnother: Boolean = false;
|
createAnother: Boolean = false;
|
||||||
selectedSurveyId: Number = 0;
|
selectedSurveyId: number | null = null;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected encuestaService: EncuestaService,
|
protected encuestaService: EncuestaService,
|
||||||
|
@ -251,8 +250,8 @@ export class EncuestaComponent implements OnInit, AfterViewInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteSurvey(): void {
|
deleteSurvey(): void {
|
||||||
if (this.selectedIdSurvey != null) {
|
if (this.selectedSurveyId != null) {
|
||||||
this.getEncuesta(this.selectedIdSurvey)
|
this.getEncuesta(this.selectedSurveyId)
|
||||||
.pipe(
|
.pipe(
|
||||||
finalize(() => {
|
finalize(() => {
|
||||||
const modalRef = this.modalService.open(EncuestaDeleteDialogComponent, { size: 'lg', backdrop: 'static' });
|
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> {
|
async openContextMenu(event: any): Promise<void> {
|
||||||
|
if (event.type === 'contextmenu') {
|
||||||
|
event.preventDefault();
|
||||||
|
if (event.target === null) return;
|
||||||
document.querySelectorAll('.ds-list--entity').forEach(e => {
|
document.querySelectorAll('.ds-list--entity').forEach(e => {
|
||||||
e.classList.remove('active');
|
e.classList.remove('active');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (event.type === 'contextmenu') {
|
if ((event.target as HTMLElement).classList.contains('ds-list')) {
|
||||||
event.preventDefault();
|
document.getElementById('contextmenu-create--separator')!.style.display = 'block';
|
||||||
this.selectedSurveyId = event.target.dataset.id;
|
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');
|
||||||
|
|
||||||
let res = await this.encuestaService.find(this.selectedSurveyId).toPromise();
|
let res = await this.encuestaService.find(this.selectedSurveyId).toPromise();
|
||||||
this.selectedSurvey = res.body;
|
this.selectedSurvey = res.body;
|
||||||
this.isPublished = this.selectedSurvey!.estado === 'DRAFT'; // QUE SE LE MUESTRE CUANDO ESTE EN DRAFT
|
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 = 'block';
|
document.getElementById('contextmenu-create--separator')!.style.display = 'none';
|
||||||
document.getElementById('contextmenu-edit--separator')!.style.display = 'block';
|
document.getElementById('contextmenu-edit--separator')!.style.display = 'block';
|
||||||
document.getElementById('contextmenu-delete--separator')!.style.display = 'block';
|
document.getElementById('contextmenu-delete--separator')!.style.display = 'block';
|
||||||
document.getElementById('contextmenu-edit')!.style.display = 'block';
|
document.getElementById('contextmenu-edit')!.style.display = 'block';
|
||||||
document.getElementById('contextmenu-duplicate')!.style.display = 'block';
|
document.getElementById('contextmenu-duplicate')!.style.display = 'block';
|
||||||
|
|
||||||
if (this.isPublished) {
|
if (!this.isPublished) {
|
||||||
document.getElementById('contextmenu-publish')!.style.display = 'block'; //cambiar
|
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-share')!.style.display = 'block';
|
||||||
|
|
||||||
if ((event.target as HTMLElement).classList.contains('ds-list')) {
|
|
||||||
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')) {
|
|
||||||
event.target.classList.add('active');
|
|
||||||
document.getElementById('contextmenu-create--separator')!.style.display = 'none';
|
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';
|
document.getElementById('contextmenu')!.style.top = event.layerY + 'px';
|
||||||
|
|
|
@ -61,6 +61,13 @@ export class EncuestaService {
|
||||||
return this.http.get<IEncuesta>(`${this.resourceUrl}/${id}`);
|
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> {
|
deleteEncuesta(encuesta: IEncuesta): Observable<EntityResponseType> {
|
||||||
//const copy = this.convertDateFromClient(encuesta);
|
//const copy = this.convertDateFromClient(encuesta);
|
||||||
return this.http.put<IEncuesta>(`${this.resourceUrl}/${getEncuestaIdentifier(encuesta) as number}`, encuesta, { observe: 'response' });
|
return this.http.put<IEncuesta>(`${this.resourceUrl}/${getEncuestaIdentifier(encuesta) as number}`, encuesta, { observe: 'response' });
|
||||||
|
|
Loading…
Reference in New Issue