|
|
@ -20,11 +20,15 @@ import mx.gob.jumapacelaya.Application; |
|
|
|
import mx.gob.jumapacelaya.api.RedmineClient; |
|
|
|
import mx.gob.jumapacelaya.api.ServerPrpperties; |
|
|
|
import mx.gob.jumapacelaya.models.Ticket; |
|
|
|
import mx.gob.jumapacelaya.models.TicketComment; |
|
|
|
import mx.gob.jumapacelaya.services.UserService; |
|
|
|
import mx.gob.jumapacelaya.views.MainLayout; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.time.ZonedDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
@ -105,10 +109,10 @@ public class MisTicketsView extends VerticalLayout { |
|
|
|
textEditor.setValue(ticket.getDescription()); |
|
|
|
textEditor.setReadOnly(true); |
|
|
|
|
|
|
|
Button verNotas = new Button("Comentarios"); |
|
|
|
Button verNotas = new Button("Comentarios", VaadinIcon.COMMENTS.create()); |
|
|
|
verNotas.addClickListener(event -> showComents(ticket)); |
|
|
|
|
|
|
|
Button closeButton = new Button("Cerrar"); |
|
|
|
Button closeButton = new Button("Cerrar", VaadinIcon.CLOSE_SMALL.create()); |
|
|
|
closeButton.addThemeVariants(ButtonVariant.LUMO_ERROR); |
|
|
|
closeButton.addClickListener(e -> dialog.close()); |
|
|
|
|
|
|
@ -133,21 +137,43 @@ public class MisTicketsView extends VerticalLayout { |
|
|
|
layout.setSpacing(true); |
|
|
|
|
|
|
|
// Obtenemos los comentarios desde Proyman |
|
|
|
List<String> comentarios = redmineClient.getTicketComments(ticket.getId(), userService.getRedmineUser()); |
|
|
|
List<TicketComment> comentarios = redmineClient.getTicketComments(ticket.getId(), userService.getRedmineUser()); |
|
|
|
|
|
|
|
if (comentarios != null && !comentarios.isEmpty()) { |
|
|
|
for (String comentario : comentarios) { |
|
|
|
Span commentSpan = new Span(comentario); |
|
|
|
commentSpan.getElement().getStyle().set("background", "#f1f1f1"); |
|
|
|
commentSpan.getElement().getStyle().set("padding", "10px"); |
|
|
|
commentSpan.getElement().getStyle().set("border-radius", "5px"); |
|
|
|
layout.add(commentSpan); |
|
|
|
DateTimeFormatter inputFormatter = DateTimeFormatter.ISO_DATE_TIME; |
|
|
|
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"); |
|
|
|
|
|
|
|
for (TicketComment comentario : comentarios) { |
|
|
|
String formattedDate = "Fecha desconocida"; |
|
|
|
|
|
|
|
try { |
|
|
|
ZonedDateTime dateTime = ZonedDateTime.parse(comentario.getDate(), inputFormatter); |
|
|
|
formattedDate = dateTime.withZoneSameInstant(ZoneId.systemDefault()).format(outputFormatter); |
|
|
|
} catch (Exception e) { |
|
|
|
System.err.println("Error al parsear la fecha: " + comentario.getDate()); |
|
|
|
} |
|
|
|
|
|
|
|
VerticalLayout commentLayout = new VerticalLayout(); |
|
|
|
commentLayout.getElement().getStyle().set("background", "#DDC9A3"); |
|
|
|
commentLayout.getElement().getStyle().set("padding", "10px"); |
|
|
|
commentLayout.getElement().getStyle().set("border-radius", "5px"); |
|
|
|
commentLayout.getElement().getStyle().set("margin-bottom", "5px"); |
|
|
|
|
|
|
|
Span dateSpan = new Span("📆 " + formattedDate); |
|
|
|
dateSpan.getElement().getStyle().set("font-weight", "bold"); |
|
|
|
dateSpan.getElement().getStyle().set("color", "#333"); |
|
|
|
|
|
|
|
Span commentSpan = new Span(comentario.getComment()); |
|
|
|
commentSpan.getElement().getStyle().set("margin-top", "5px"); |
|
|
|
|
|
|
|
commentLayout.add(dateSpan, commentSpan); |
|
|
|
layout.add(commentLayout); |
|
|
|
} |
|
|
|
} else { |
|
|
|
layout.add(new Span("No hay comentarios para este ticket.")); |
|
|
|
} |
|
|
|
|
|
|
|
Button closeButton = new Button("Cerrar", event -> comentDialog.close()); |
|
|
|
Button closeButton = new Button("Cerrar", VaadinIcon.CLOSE_SMALL.create(), event -> comentDialog.close()); |
|
|
|
closeButton.addThemeVariants(ButtonVariant.LUMO_ERROR); |
|
|
|
|
|
|
|
layout.add(closeButton); |
|
|
|