|
|
@ -3,17 +3,22 @@ package mx.gob.jumapacelaya.ui; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import org.springframework.security.core.Authentication; |
|
|
|
import org.springframework.cglib.core.Local; |
|
|
|
import org.springframework.security.core.context.SecurityContextHolder; |
|
|
|
import org.vaadin.lineawesome.LineAwesomeIcon; |
|
|
|
|
|
|
|
import com.nimbusds.jose.proc.SecurityContext; |
|
|
|
import com.vaadin.flow.component.button.Button; |
|
|
|
import com.vaadin.flow.component.combobox.ComboBox; |
|
|
|
import com.vaadin.flow.component.confirmdialog.ConfirmDialog; |
|
|
|
import com.vaadin.flow.component.dependency.CssImport; |
|
|
|
import com.vaadin.flow.component.dialog.Dialog; |
|
|
|
import com.vaadin.flow.component.grid.Grid; |
|
|
|
import com.vaadin.flow.component.grid.GridVariant; |
|
|
|
import com.vaadin.flow.component.gridpro.GridPro; |
|
|
|
import com.vaadin.flow.component.html.H3; |
|
|
|
import com.vaadin.flow.component.html.Span; |
|
|
|
import com.vaadin.flow.component.icon.Icon; |
|
|
|
import com.vaadin.flow.component.icon.VaadinIcon; |
|
|
|
import com.vaadin.flow.component.notification.Notification; |
|
|
@ -63,7 +68,7 @@ public class DetallesMantView extends VerticalLayout implements BeforeEnterObser |
|
|
|
private Button btnGuardar; |
|
|
|
private int planAnualIdActual; |
|
|
|
private int mantenimientoIdActual; |
|
|
|
private ConfirmDialog confirmDialog; |
|
|
|
private Dialog confirmDialog; |
|
|
|
|
|
|
|
DatabaseService service = new DatabaseService(); |
|
|
|
|
|
|
@ -199,14 +204,43 @@ public class DetallesMantView extends VerticalLayout implements BeforeEnterObser |
|
|
|
|
|
|
|
|
|
|
|
// Dialogo de confirmación de actualización |
|
|
|
confirmDialog = new ConfirmDialog(); |
|
|
|
confirmDialog.setHeader("Actualizar Mantenimiento"); |
|
|
|
confirmDialog.setText("¿Estás seguro de que deseas actualizar el mantenimiento?"); |
|
|
|
confirmDialog.setCancelable(true); |
|
|
|
confirmDialog.setConfirmText("Actualizar"); |
|
|
|
confirmDialog.setCancelText("Cancelar"); |
|
|
|
confirmDialog.addConfirmListener(event -> realizarActualizacion()); |
|
|
|
confirmDialog.addCancelListener( event -> { |
|
|
|
confirmDialog = new Dialog(); |
|
|
|
confirmDialog.setHeaderTitle("Actualizar Mantenimiento"); |
|
|
|
|
|
|
|
TextField txtJustificacion = new TextField("Justificacion"); |
|
|
|
txtJustificacion.setWidthFull(); |
|
|
|
txtJustificacion.setRequired(true); |
|
|
|
|
|
|
|
confirmDialog.add( |
|
|
|
new VerticalLayout( |
|
|
|
new Span("¿Estás seguro de que deseas actualizar el mantenimiento?"), |
|
|
|
txtJustificacion |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
Button btnConfirmar = new Button("Actualizar", event -> { |
|
|
|
String justificacion = txtJustificacion.getValue(); |
|
|
|
if (justificacion.isEmpty()) { |
|
|
|
txtJustificacion.setErrorMessage("Por favor, ingresa una justificación."); |
|
|
|
txtJustificacion.setInvalid(true); |
|
|
|
return; |
|
|
|
} |
|
|
|
txtJustificacion.setInvalid(false); |
|
|
|
confirmDialog.close(); |
|
|
|
|
|
|
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
|
|
|
String usuarioId = authentication != null ? authentication.getName().toUpperCase() : "DESCONOCIDO"; |
|
|
|
|
|
|
|
LocalDate fecha = LocalDate.now(); |
|
|
|
|
|
|
|
service.insertarBitacora(mantenimientoIdActual, usuarioId, fecha, justificacion); |
|
|
|
|
|
|
|
realizarActualizacion(); |
|
|
|
txtJustificacion.clear(); |
|
|
|
}); |
|
|
|
|
|
|
|
Button btnCancelarDialog = new Button("Cancelar", event -> { |
|
|
|
confirmDialog.close(); |
|
|
|
txtEquipo.setReadOnly(true); |
|
|
|
cbTipo.setReadOnly(true); |
|
|
|
txtFecha.setReadOnly(true); |
|
|
@ -221,13 +255,17 @@ public class DetallesMantView extends VerticalLayout implements BeforeEnterObser |
|
|
|
gridHardware.getEditor().cancel(); |
|
|
|
}); |
|
|
|
|
|
|
|
HorizontalLayout dialogButtons = new HorizontalLayout(btnConfirmar, btnCancelarDialog); |
|
|
|
confirmDialog.getFooter().add(dialogButtons); |
|
|
|
|
|
|
|
|
|
|
|
mainLayout.add(headerLayout,layout2,fechasLayout,layout3,gridHardware,botonesLayout); |
|
|
|
add(mainLayout); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void realizarActualizacion() { |
|
|
|
boolean exito = true; |
|
|
|
boolean exito = true; |
|
|
|
|
|
|
|
// Obtén los objetos seleccionados |
|
|
|
TiposMantenimiento tipoSeleccionado = cbTipo.getValue(); |
|
|
|