Search in sources :

Example 1 with AlertSva

use of fr.univlorraine.ecandidat.entities.ecandidat.AlertSva in project esup-ecandidat by EsupPortail.

the class CandidatureViewTemplate method getStyleSva.

/**
 * @param  candidature
 * @param  listeAlerteSva
 * @param  dateSva
 * @param  definitifSva
 * @return                le style sva correspondand
 */
public String getStyleSva(final Candidature candidature, final List<AlertSva> listeAlerteSva, final String dateSva, final Boolean definitifSva) {
    if (dateSva.equals(NomenclatureUtils.CAND_DAT_NO_DAT) || listeAlerteSva.size() == 0) {
        return null;
    }
    final TypeDecisionCandidature typeDecisionCandidature = candidature.getLastTypeDecision();
    // dans le cas de seulement les avis définitif
    if (definitifSva) {
        if (typeDecisionCandidature != null && typeDecisionCandidature.getTemValidTypeDecCand() && typeDecisionCandidature.getTypeDecision().getTemDefinitifTypDec()) {
            return null;
        }
    } else // autres cas
    {
        if (typeDecisionCandidature != null && typeDecisionCandidature.getTemValidTypeDecCand()) {
            return null;
        }
    }
    /* On cherche la date à utiliser */
    LocalDate dateToUse = null;
    switch(dateSva) {
        case NomenclatureUtils.CAND_DAT_CRE:
            dateToUse = MethodUtils.convertLocalDateTimeToDate(candidature.getDatCreCand());
            break;
        case NomenclatureUtils.CAND_DAT_ANNUL:
            dateToUse = MethodUtils.convertLocalDateTimeToDate(candidature.getDatAnnulCand());
            break;
        case NomenclatureUtils.CAND_DAT_ACCEPT:
            dateToUse = MethodUtils.convertLocalDateTimeToDate(candidature.getDatAcceptCand());
            break;
        case NomenclatureUtils.CAND_DAT_TRANS:
            dateToUse = MethodUtils.convertLocalDateTimeToDate(candidature.getDatTransDossierCand());
            break;
        case NomenclatureUtils.CAND_DAT_RECEPT:
            dateToUse = candidature.getDatReceptDossierCand();
            break;
        case NomenclatureUtils.CAND_DAT_COMPLET:
            dateToUse = candidature.getDatCompletDossierCand();
            break;
        case NomenclatureUtils.CAND_DAT_INCOMPLET:
            dateToUse = candidature.getDatIncompletDossierCand();
            break;
        default:
            dateToUse = null;
            break;
    }
    if (dateToUse == null) {
        return null;
    }
    /* Calcul le nombre de jour */
    final Long nbDays = ChronoUnit.DAYS.between(dateToUse, LocalDate.now());
    Integer nbJourSva = null;
    for (final AlertSva alert : listeAlerteSva) {
        if (nbDays >= alert.getNbJourSva() && (nbJourSva == null || nbJourSva < alert.getNbJourSva())) {
            nbJourSva = alert.getNbJourSva();
        }
    }
    /* On renvoi la couleur de la ligne */
    if (nbJourSva != null) {
        return StyleConstants.GRID_ROW_SVA + "-" + nbJourSva;
    }
    return null;
}
Also used : AlertSva(fr.univlorraine.ecandidat.entities.ecandidat.AlertSva) LocalDate(java.time.LocalDate) TypeDecisionCandidature(fr.univlorraine.ecandidat.entities.ecandidat.TypeDecisionCandidature)

Example 2 with AlertSva

use of fr.univlorraine.ecandidat.entities.ecandidat.AlertSva in project esup-ecandidat by EsupPortail.

the class ScolAlertSvaView method init.

/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    /* Style */
    setSizeFull();
    setMargin(true);
    setSpacing(true);
    /* Titre */
    Label titleParam = new Label(applicationContext.getMessage("alertSva.title", null, UI.getCurrent().getLocale()));
    titleParam.addStyleName(StyleConstants.VIEW_TITLE);
    addComponent(titleParam);
    CustomPanel panelMessage = new CustomPanel(applicationContext.getMessage("informations", null, UI.getCurrent().getLocale()), FontAwesome.INFO_CIRCLE);
    panelMessage.setMessage(applicationContext.getMessage("alertSva.info", null, UI.getCurrent().getLocale()));
    panelMessage.setWidthMax();
    panelMessage.setMargin(true);
    addComponent(panelMessage);
    /* Choix de la date */
    HorizontalLayout paramLayout = new HorizontalLayout();
    paramLayout.setSpacing(true);
    addComponent(paramLayout);
    /* Table des parametres */
    TableFormating table = new TableFormating(null, parametreContainer);
    table.addBooleanColumn(SimpleTablePresentation.CHAMPS_VALUE, false);
    String[] FIELDS_ORDER_PARAM = { SimpleTablePresentation.CHAMPS_TITLE, SimpleTablePresentation.CHAMPS_VALUE };
    table.setVisibleColumns((Object[]) FIELDS_ORDER_PARAM);
    table.setColumnCollapsingAllowed(false);
    table.setColumnReorderingAllowed(false);
    table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
    table.setSelectable(false);
    table.setImmediate(true);
    table.setPageLength(2);
    table.setWidth(100, Unit.PERCENTAGE);
    table.setColumnWidth(SimpleTablePresentation.CHAMPS_TITLE, 350);
    table.setColumnWidth(SimpleTablePresentation.CHAMPS_VALUE, 200);
    table.setCellStyleGenerator((components, itemId, columnId) -> {
        if (columnId != null && columnId.equals(SimpleTablePresentation.CHAMPS_TITLE)) {
            return (ValoTheme.LABEL_BOLD);
        }
        return null;
    });
    paramLayout.addComponent(table);
    paramLayout.setComponentAlignment(table, Alignment.MIDDLE_CENTER);
    OneClickButton buttonDate = new OneClickButton(applicationContext.getMessage("btnModifier", null, UI.getCurrent().getLocale()), FontAwesome.CALENDAR);
    buttonDate.addClickListener(e -> {
        parametreController.changeSVAParametre(this, parametreDateSva, parametreDefinitif);
    });
    paramLayout.addComponent(buttonDate);
    paramLayout.setComponentAlignment(buttonDate, Alignment.MIDDLE_CENTER);
    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    addComponent(buttonsLayout);
    OneClickButton btnNew = new OneClickButton(applicationContext.getMessage("alertSva.btnNouveau", null, UI.getCurrent().getLocale()), FontAwesome.PLUS);
    btnNew.setEnabled(true);
    btnNew.addClickListener(e -> {
        alertSvaController.editNewAlertSva();
    });
    buttonsLayout.addComponent(btnNew);
    buttonsLayout.setComponentAlignment(btnNew, Alignment.MIDDLE_LEFT);
    OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
    btnEdit.setEnabled(false);
    btnEdit.addClickListener(e -> {
        if (alertSvaTable.getValue() instanceof AlertSva) {
            alertSvaController.editAlertSva((AlertSva) alertSvaTable.getValue());
        }
    });
    buttonsLayout.addComponent(btnEdit);
    buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_CENTER);
    OneClickButton btnDelete = new OneClickButton(applicationContext.getMessage("btnDelete", null, UI.getCurrent().getLocale()), FontAwesome.TRASH_O);
    btnDelete.setEnabled(false);
    btnDelete.addClickListener(e -> {
        if (alertSvaTable.getValue() instanceof AlertSva) {
            alertSvaController.deleteAlertSva((AlertSva) alertSvaTable.getValue());
        }
    });
    buttonsLayout.addComponent(btnDelete);
    buttonsLayout.setComponentAlignment(btnDelete, Alignment.MIDDLE_RIGHT);
    /* Table des alertSvas */
    BeanItemContainer<AlertSva> container = new BeanItemContainer<>(AlertSva.class, cacheController.getAlertesSva());
    alertSvaTable.setContainerDataSource(container);
    alertSvaTable.addBooleanColumn(AlertSva_.tesSva.getName());
    alertSvaTable.setSizeFull();
    alertSvaTable.setVisibleColumns((Object[]) FIELDS_ORDER);
    for (String fieldName : FIELDS_ORDER) {
        alertSvaTable.setColumnHeader(fieldName, applicationContext.getMessage("alertSva.table." + fieldName, null, UI.getCurrent().getLocale()));
    }
    alertSvaTable.addGeneratedColumn(AlertSva_.colorSva.getName(), new ColumnGenerator() {

        @Override
        public Object generateCell(final Table source, final Object itemId, final Object columnId) {
            AlertSva alertSva = (AlertSva) itemId;
            HorizontalLayout hlColor = new HorizontalLayout();
            hlColor.setSpacing(true);
            Label labelColor = new Label("<div style='border:1px solid;width:20px;height:20px;background:" + alertSva.getColorSva() + ";'></div>", ContentMode.HTML);
            Label labelTxt = new Label(alertSva.getColorSva());
            hlColor.addComponent(labelColor);
            hlColor.setComponentAlignment(labelColor, Alignment.MIDDLE_LEFT);
            hlColor.addComponent(labelTxt);
            hlColor.setComponentAlignment(labelTxt, Alignment.MIDDLE_LEFT);
            return hlColor;
        }
    });
    alertSvaTable.setSortContainerPropertyId(AlertSva_.nbJourSva.getName());
    alertSvaTable.setColumnCollapsingAllowed(true);
    alertSvaTable.setColumnReorderingAllowed(true);
    alertSvaTable.setSelectable(true);
    alertSvaTable.setImmediate(true);
    alertSvaTable.addItemSetChangeListener(e -> alertSvaTable.sanitizeSelection());
    alertSvaTable.addValueChangeListener(e -> {
        /* Les boutons d'édition et de suppression de alertSva sont actifs seulement si une alertSva est sélectionnée. */
        boolean alertSvaIsSelectedEdit = alertSvaTable.getValue() instanceof AlertSva;
        btnEdit.setEnabled(alertSvaIsSelectedEdit);
        btnDelete.setEnabled(alertSvaIsSelectedEdit);
    });
    alertSvaTable.addItemClickListener(e -> {
        if (e.isDoubleClick()) {
            alertSvaTable.select(e.getItemId());
            btnEdit.click();
        }
    });
    addComponent(alertSvaTable);
    setExpandRatio(alertSvaTable, 1);
    /* Inscrit la vue aux mises à jour de alerteSva */
    alertSvaEntityPusher.registerEntityPushListener(this);
}
Also used : AlertSva(fr.univlorraine.ecandidat.entities.ecandidat.AlertSva) Table(com.vaadin.ui.Table) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) Label(com.vaadin.ui.Label) BeanItemContainer(com.vaadin.data.util.BeanItemContainer) CustomPanel(fr.univlorraine.ecandidat.vaadin.components.CustomPanel) HorizontalLayout(com.vaadin.ui.HorizontalLayout) TableFormating(fr.univlorraine.ecandidat.vaadin.components.TableFormating) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) PostConstruct(javax.annotation.PostConstruct)

Example 3 with AlertSva

use of fr.univlorraine.ecandidat.entities.ecandidat.AlertSva in project esup-ecandidat by EsupPortail.

the class AlertSvaController method getListAlertSvaCss.

/**
 * @return la liste des style scc a renvoyer
 */
public List<String> getListAlertSvaCss() {
    List<String> liste = new ArrayList<>();
    List<AlertSva> listeAlerteSva = getAlertSvaEnService();
    /* On ajoute les css colorisant les lignes pour sva */
    for (AlertSva alert : listeAlerteSva) {
        liste.add("." + StyleConstants.GRID + " ." + StyleConstants.GRID_ROW_SVA + "-" + alert.getNbJourSva() + " ." + StyleConstants.GRID_CELL + " { background-color: " + alert.getColorSva() + "; }");
    }
    return liste;
}
Also used : AlertSva(fr.univlorraine.ecandidat.entities.ecandidat.AlertSva) ArrayList(java.util.ArrayList)

Aggregations

AlertSva (fr.univlorraine.ecandidat.entities.ecandidat.AlertSva)3 BeanItemContainer (com.vaadin.data.util.BeanItemContainer)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Label (com.vaadin.ui.Label)1 Table (com.vaadin.ui.Table)1 ColumnGenerator (com.vaadin.ui.Table.ColumnGenerator)1 TypeDecisionCandidature (fr.univlorraine.ecandidat.entities.ecandidat.TypeDecisionCandidature)1 CustomPanel (fr.univlorraine.ecandidat.vaadin.components.CustomPanel)1 OneClickButton (fr.univlorraine.ecandidat.vaadin.components.OneClickButton)1 TableFormating (fr.univlorraine.ecandidat.vaadin.components.TableFormating)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 PostConstruct (javax.annotation.PostConstruct)1