Skip to main content

< p : schedule con filtros>

Mostrare como implementar un < p: schedule > de Primefaces con filtros usando jmoordbcore


Se cuenta con una pagina Jakarta Server Faces



En el Controller en el init definimos una operacion

 @PostConstruct

    public void init() {

        try {

 }

}


MƩtodo refresh() , obtiene el primer dƭa de la semana y el ultimo dƭa de la semana actual, se invoca al loadSchedule()



    public String refresh() {

        try {   

            Date start = DateUtil.convertirLocalDateToJavaDate(DateUtil.primerDiaSemanaActual(Boolean.FALSE));

            Date end = DateUtil.convertirLocalDateToJavaDate(DateUtil.ultimoDiaSemanaActual(Boolean.FALSE));

             tarjetaFinalizadoList = new ArrayList<>();

            tarjetaPendienteList = new ArrayList<>();

            tarjetaProgresoList = new ArrayList<>();

            loadSchedule();

            PrimeFaces.current().ajax().update(":form:schedule");

        } catch (Exception e) {

            FacesUtil.errorMessage(FacesUtil.nameOfClassAndMethod() + " " + e.getLocalizedMessage());

        }

        return "";

    }


    private Boolean loadTarjetaPendiente(Date start, Date end) {

        Boolean result = Boolean.FALSE;

        tarjetaPendienteList = new ArrayList<>();

        try {

            Integer page = 0;

            Integer size = 0;

            Document sortTarjeta = new Document("idtarjeta", 1).append("prioridad", 1);

             Bson filterDate = DocumentUtil.createBsonBetweenDateWithoutHours(

                    "fechainicial", start, "fechainicial", end);

            if (isPropietario) {

                Bson filter0 = eq("idproyecto", proyectoSelected.getIdproyecto());


                Bson filter = and(filter0,

                        filterDate,

                        eq("active", Boolean.TRUE),

                        eq("columna", "pendiente"));

              


                tarjetaPendienteList = tarjetaServices.lookup(filter, sortTarjeta, page, size);

            } else {

                Bson filter0 = eq("idproyecto", proyectoSelected.getIdproyecto());

                Bson filter = and(filter0,

                        filterDate,

                        eq("active", Boolean.TRUE),

                        eq("columna", "pendiente"),

                        eq("user.iduser", userLogged.getIduser()));


                tarjetaPendienteList = tarjetaServices.lookup(filter, sortTarjeta, page, size);

            }

        } catch (Exception e) {

            FacesUtil.errorMessage(FacesUtil.nameOfClassAndMethod() + " " + e.getLocalizedMessage());

        }

        return result;

    }




Cree el mĆ©todo loadSchedule()

Procesa el evento loadEvents del schedule mediante la implementación de lazyEventModel


    public void loadSchedule() {

        try {

            lazyEventModel = new LazyScheduleModel() {

                List<Tarjeta> list = new ArrayList<>();

                @Override

                public void loadEvents(LocalDateTime start, LocalDateTime end) {

                    loadTarjetaPendiente(DateUtil.convertLocalDateTimeToJavaDate(start), DateUtil.convertLocalDateTimeToJavaDate(end));

                    loadTarjetaProgreso(DateUtil.convertLocalDateTimeToJavaDate(start), DateUtil.convertLocalDateTimeToJavaDate(end));

                    loadTarjetaFinalizado(DateUtil.convertLocalDateTimeToJavaDate(start), DateUtil.convertLocalDateTimeToJavaDate(end));

                    tarjetaPendienteList.forEach((a) -> {

                        if (!a.getBacklog()) {

                            DefaultScheduleEvent event = DefaultScheduleEvent.builder()

                                    .title(a.getTarjeta() + " / " + siglasColaboradores(a.getUserView()))

                                    .startDate(JmoordbCoreDateUtil.convertToLocalDateTimeViaInstant(a.getFechainicial()))

                                    .endDate(JmoordbCoreDateUtil.convertToLocalDateTimeViaInstant(a.getFechafinal()))

                                    .description(a.getDescripcion())

                                    .id(a.getIdtarjeta().toString())

                                    .backgroundColor("red")

                                    .build();


                            addEvent(event);

                        } else {

                            DefaultScheduleEvent event = DefaultScheduleEvent.builder()

                                    .title("(R) " + a.getTarjeta() + " / " + siglasColaboradores(a.getUserView()))

                                    .startDate(JmoordbCoreDateUtil.convertToLocalDateTimeViaInstant(a.getFechainicial()))

                                    .endDate(JmoordbCoreDateUtil.convertToLocalDateTimeViaInstant(a.getFechafinal()))

                                    .description(a.getDescripcion())

                                    .id(a.getIdtarjeta().toString())

                                    .backgroundColor("blue")

                                    .build();

                            addEvent(event);

                        }

                    });

               }

            };

        } catch (Exception e) {

            FacesUtil.errorMessage(FacesUtil.nameOfClassAndMethod() + " " + e.getLocalizedMessage());

        }

    }


El mĆ©todo actionCommandButton() se invoca desde el botón


    public String actionCommandButton() {

        try {

            showSchedule = Boolean.TRUE;

            refresh();

        } catch (Exception e) {

            FacesUtil.errorMessage(FacesUtil.nameOfClassAndMethod() + " " + e.getLocalizedMessage());

        }

        return "";

    }

  

Comments

Popular posts from this blog

Primefaces v13

 La versión nueva de primefaces v13.0 elimina el componente <p:repeat>  Consulte los cambios en  https://github.com/primefaces/primefaces/releases/tag/13.0.0 por lo tanto si necesita una solución similar considere utilizar  <p:carousel>  o  <ui:repeat> En la versión 13 genera una excepción

Jmoordb-Core @UpdateMany y @DeleteMany

 Jmoordb-Core @UpdateMany y @DeleteMany Estoy trabajando en una versión nueva de jmoordb-core en la cual se estarĆ” implementando nuevas funcionalidades como lo son @DeleteMany y    @UpdateMany con la finalidad de hacer operaciones sobre mĆŗltiples documentos de la colección.