Search in sources :

Example 21 with FlexiTableFilter

use of org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter in project openolat by klemens.

the class FlexiTableElementImpl method setSelectedFilterKey.

@Override
public void setSelectedFilterKey(String key) {
    if (filters != null) {
        for (FlexiTableFilter filter : filters) {
            boolean selected = (key == null && filter.getFilter() == null) || (key != null && key.equals(filter.getFilter()));
            filter.setSelected(selected);
        }
    }
}
Also used : FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)

Example 22 with FlexiTableFilter

use of org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter in project openolat by klemens.

the class FlexiTableElementImpl method doFilter.

private void doFilter(String filterKey) {
    List<FlexiTableFilter> selectedFilters = new ArrayList<>();
    if (filterKey == null) {
        for (FlexiTableFilter filter : filters) {
            filter.setSelected(false);
        }
    } else if (multiFilterSelection) {
        boolean showAll = false;
        for (FlexiTableFilter filter : filters) {
            if (filter.getFilter().equals(filterKey) && filter.isShowAll()) {
                // Show all is currently not selected, but the event will toggle it
                showAll = !filter.isSelected();
            }
        }
        if (showAll) {
            for (FlexiTableFilter filter : filters) {
                filter.setSelected(filter.isShowAll());
            }
        } else {
            for (FlexiTableFilter filter : filters) {
                if (filter.isShowAll()) {
                    filter.setSelected(false);
                } else if (filter.getFilter().equals(filterKey)) {
                    filter.setSelected(!filter.isSelected());
                }
            }
        }
        for (FlexiTableFilter filter : filters) {
            if (filter.isSelected()) {
                selectedFilters.add(filter);
            }
        }
    } else {
        for (FlexiTableFilter filter : filters) {
            boolean selected = filter.getFilter().equals(filterKey);
            if (selected) {
                if (filter.isSelected()) {
                    filter.setSelected(false);
                } else {
                    filter.setSelected(true);
                    selectedFilters.add(filter);
                }
            } else {
                filter.setSelected(false);
            }
        }
    }
    if (dataModel instanceof FilterableFlexiTableModel) {
        rowCount = -1;
        currentPage = 0;
        doUnSelectAll();
        ((FilterableFlexiTableModel) dataModel).filter(selectedFilters);
    } else if (dataSource != null) {
        rowCount = -1;
        currentPage = 0;
        doUnSelectAll();
        if (dataModel instanceof FlexiTableDataSource) {
            ((FlexiTableDataSource<?>) dataModel).clear();
            ((FlexiTableDataSource<?>) dataModel).load(null, selectedFilters, null, 0, getPageSize(), orderBy);
        } else {
            dataSource.clear();
            dataSource.load(null, selectedFilters, null, 0, getPageSize(), orderBy);
        }
    }
    component.setDirty(true);
}
Also used : FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) ArrayList(java.util.ArrayList)

Example 23 with FlexiTableFilter

use of org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter in project openolat by klemens.

the class ExtendedFilterController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        Object uobject = link.getUserObject();
        if (uobject instanceof FlexiTableFilter) {
            FlexiTableFilter filter = (FlexiTableFilter) uobject;
            filter.setSelected(!filter.isSelected());
        }
    }
    fireEvent(ureq, Event.DONE_EVENT);
    super.formInnerEvent(ureq, source, event);
}
Also used : FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 24 with FlexiTableFilter

use of org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter in project openolat by klemens.

the class ExtendedFilterController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    int count = 0;
    List<ExtendedFilter> filterNames = new ArrayList<>(filters.size());
    for (FlexiTableFilter filter : filters) {
        String name = "f-" + (++count);
        FormLink filterLink = uifactory.addFormLink(name, formLayout, Link.LINK | Link.NONTRANSLATED);
        filterLink.setI18nKey(filter.getLabel());
        filterLink.setIconLeftCSS(filter.getIconLeftCSS());
        filterLink.setUserObject(filter);
        filterNames.add(new ExtendedFilter(filter, name));
    }
    if (formLayout instanceof FormLayoutContainer) {
        ((FormLayoutContainer) formLayout).contextPut("filters", filterNames);
    }
}
Also used : ArrayList(java.util.ArrayList) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 25 with FlexiTableFilter

use of org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter in project openolat by klemens.

the class IdentityAssessmentOverviewController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.node, new IndentedNodeRenderer() {

        @Override
        public boolean isIndentationEnabled() {
            return tableEl.getOrderBy() == null || tableEl.getOrderBy().length == 0;
        }
    }));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.attempts));
    if (!followUserResultsVisibility) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.userVisibility, new UserVisibilityCellRenderer(getTranslator())));
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.score, new ScoreCellRenderer()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.min, new ScoreCellRenderer()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.max, new ScoreCellRenderer()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.passed, new PassedCellRenderer()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.numOfAssessmentDocs));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.status, new AssessmentStatusCellRenderer(getLocale())));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, NodeCols.lastModified));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.lastUserModified));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, NodeCols.lastCoachModified));
    if (nodesSelectable) {
        DefaultFlexiColumnModel selectCol = new DefaultFlexiColumnModel("select", NodeCols.select.ordinal(), CMD_SELECT_NODE, new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("select"), CMD_SELECT_NODE), null));
        selectCol.setExportable(false);
        columnsModel.addFlexiColumnModel(selectCol);
    }
    tableModel = new IdentityAssessmentOverviewTableModel(columnsModel);
    tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 250, false, getTranslator(), formLayout);
    tableEl.setExportEnabled(true);
    tableEl.setEmtpyTableMessageKey("nodesoverview.emptylist");
    tableEl.setBordered(true);
    tableEl.setNumOfRowsEnabled(false);
    if (allowTableFiltering) {
        List<FlexiTableFilter> filters = new ArrayList<>();
        filters.add(new FlexiTableFilter(translate("filter.showAll"), "showAll", true));
        filters.add(FlexiTableFilter.SPACER);
        filters.add(new FlexiTableFilter(translate("filter.passed"), "passed"));
        filters.add(new FlexiTableFilter(translate("filter.failed"), "failed"));
        filters.add(new FlexiTableFilter(translate("filter.inProgress"), "inProgress"));
        filters.add(new FlexiTableFilter(translate("filter.inReview"), "inReview"));
        filters.add(new FlexiTableFilter(translate("filter.done"), "done"));
        tableEl.setFilters("", filters, false);
    }
}
Also used : ArrayList(java.util.ArrayList) IndentedNodeRenderer(org.olat.course.assessment.IndentedNodeRenderer) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) ScoreCellRenderer(org.olat.modules.assessment.ui.ScoreCellRenderer) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) PassedCellRenderer(org.olat.course.assessment.bulk.PassedCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Aggregations

FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)52 ArrayList (java.util.ArrayList)40 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)24 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)24 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)18 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)16 SortKey (org.olat.core.commons.persistence.SortKey)14 FlexiTableSortOptions (org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions)12 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)10 BusinessGroup (org.olat.group.BusinessGroup)10 PassedCellRenderer (org.olat.course.assessment.bulk.PassedCellRenderer)8 Component (org.olat.core.gui.components.Component)6 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)6 FormBasicController (org.olat.core.gui.components.form.flexible.impl.FormBasicController)6 BooleanCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer)6 Controller (org.olat.core.gui.control.Controller)6 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)6 SearchAssessedIdentityParams (org.olat.course.assessment.model.SearchAssessedIdentityParams)6 AssessmentEntryStatus (org.olat.modules.assessment.model.AssessmentEntryStatus)6 Collections (java.util.Collections)4