Add update survey
This commit is contained in:
parent
340bfbb67f
commit
300f20affd
|
@ -136,6 +136,31 @@ public class EncuestaResource {
|
|||
.body(result);
|
||||
}
|
||||
|
||||
@PutMapping("/encuestas/update/{id}")
|
||||
public ResponseEntity<Encuesta> updateEncuestaReal(
|
||||
@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);
|
||||
|
||||
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,
|
||||
|
|
|
@ -33,6 +33,13 @@ export class EncuestaService {
|
|||
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
|
||||
}
|
||||
|
||||
updateSurvey(encuesta: IEncuesta): Observable<EntityResponseType> {
|
||||
const copy = this.convertDateFromClient(encuesta);
|
||||
return this.http
|
||||
.put<IEncuesta>(`${this.resourceUrl}/update/${getEncuestaIdentifier(encuesta) as number}`, copy, { observe: 'response' })
|
||||
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
|
||||
}
|
||||
|
||||
partialUpdate(encuesta: IEncuesta): Observable<EntityResponseType> {
|
||||
const copy = this.convertDateFromClient(encuesta);
|
||||
return this.http
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div>
|
||||
<h2 id="page-heading" data-cy="EPreguntaCerradaHeading">
|
||||
<div class="d-flex align-items-center">
|
||||
<p class="ds-title">{{ encuesta!.nombre }}</p>
|
||||
<p class="ds-title ds-title--interactive" contenteditable="true" (blur)="updateSurveyName($event)">{{ encuesta!.nombre }}</p>
|
||||
<fa-icon
|
||||
class="ds-info--icon"
|
||||
[icon]="faQuestion"
|
||||
|
|
|
@ -160,7 +160,7 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
|
|||
}
|
||||
|
||||
ngAfterViewChecked(): void {
|
||||
this.initListeners();
|
||||
// this.initListeners();
|
||||
}
|
||||
|
||||
trackId(index: number, item: IEPreguntaCerrada): number {
|
||||
|
@ -178,18 +178,18 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
|
|||
});
|
||||
}
|
||||
|
||||
initListeners(): void {
|
||||
const checkboxes = document.getElementsByClassName('ds-survey--checkbox');
|
||||
for (let i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].addEventListener('click', e => {
|
||||
if ((e.target as HTMLInputElement).checked) {
|
||||
(e.target as HTMLElement).offsetParent!.classList.add('ds-survey--closed-option--active');
|
||||
} else {
|
||||
(e.target as HTMLElement).offsetParent!.classList.remove('ds-survey--closed-option--active');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// initListeners(): void {
|
||||
// const checkboxes = document.getElementsByClassName('ds-survey--checkbox');
|
||||
// for (let i = 0; i < checkboxes.length; i++) {
|
||||
// checkboxes[i].addEventListener('click', e => {
|
||||
// if ((e.target as HTMLInputElement).checked) {
|
||||
// (e.target as HTMLElement).offsetParent!.classList.add('ds-survey--closed-option--active');
|
||||
// } else {
|
||||
// (e.target as HTMLElement).offsetParent!.classList.remove('ds-survey--closed-option--active');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
previousState(): void {
|
||||
window.history.back();
|
||||
|
@ -416,6 +416,21 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
|
|||
this.isSavingQuestion = false;
|
||||
}
|
||||
|
||||
updateSurveyName(event: any) {
|
||||
const updatedSurveyName = event.target.innerText;
|
||||
if (updatedSurveyName !== this.encuesta?.nombre) {
|
||||
const survey = { ...this.encuesta };
|
||||
survey.nombre = updatedSurveyName;
|
||||
survey.usuarioExtra!.user = null;
|
||||
console.log(survey);
|
||||
|
||||
this.encuestaService.updateSurvey(survey).subscribe(res => {
|
||||
console.log('UPDATED');
|
||||
console.log(res);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// previousState(): void {
|
||||
// window.history.back();
|
||||
// }
|
||||
|
|
|
@ -9,6 +9,20 @@
|
|||
letter-spacing: 0.025rem;
|
||||
text-transform: uppercase;
|
||||
font-size: 1.2rem;
|
||||
|
||||
&--interactive {
|
||||
border: 2.25px solid transparent;
|
||||
border-radius: 3px;
|
||||
outline: 0;
|
||||
|
||||
&:hover {
|
||||
border: 2.25px solid #e5e5e5;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
border: 2.25px solid #2962ff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ds-title--small {
|
||||
|
|
Loading…
Reference in New Issue