Search in sources :

Example 41 with FlexiTableFilter

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

the class SharedPagesController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SharePageCols.bookmark));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SharePageCols.userInfosStatus, new SharedPageStatusCellRenderer(getTranslator())));
    FlexiCellRenderer titleRenderer = new BooleanCellRenderer(new StaticFlexiCellRenderer("select", new PageTitleCellRenderer()), new PageTitleCellRenderer());
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, true, "select", SharePageCols.pageName.ordinal(), "select", true, SharePageCols.pageName.sortKey(), FlexiColumnModel.ALIGNMENT_LEFT, titleRenderer));
    SortKey defaultSortKey = null;
    if (isAdministrativeUser) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.username));
        defaultSortKey = new SortKey(Cols.username.name(), true);
    }
    // followed by the users fields
    int colPos = USER_PROPS_OFFSET;
    for (int i = 0; i < userPropertyHandlers.size(); i++) {
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
        String propName = userPropertyHandler.getName();
        if (defaultSortKey == null && i == 0) {
            defaultSortKey = new SortKey(propName, true);
        } else if (UserConstants.LASTNAME.equals(propName) && !isAdministrativeUser) {
            defaultSortKey = new SortKey(propName, true);
        }
        boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, true, propName));
        colPos++;
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SharePageCols.lastChanges));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(SharePageCols.pageStatus, new StatusCellRenderer(getTranslator())));
    model = new SharedPagesDataModel(columnsModel, getLocale());
    tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
    tableEl.setSearchEnabled(true);
    tableEl.setCustomizeColumns(true);
    tableEl.setElementCssClass("o_binder_shared_bookmark_pages_listing");
    tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
    tableEl.setPageSize(24);
    tableEl.setAndLoadPersistedPreferences(ureq, "shared-bookmark-pages");
    if (filters != null && !filters.isEmpty()) {
        List<FlexiTableFilter> tableFilters = new ArrayList<>(filters.size());
        for (PageStatus status : filters) {
            String label = translate(status.i18nKey());
            tableFilters.add(new FlexiTableFilter(label, status.name(), "o_icon ".concat(status.cssClass())));
        }
        tableFilters.add(FlexiTableFilter.SPACER);
        tableFilters.add(new FlexiTableFilter(translate("filter.show.all"), "all", true));
        tableEl.setFilters("Filters", tableFilters, true);
        if (defaultFilter != null) {
            tableEl.setSelectedFilterKey(defaultFilter.name());
        }
    }
}
Also used : PageStatus(org.olat.modules.portfolio.PageStatus) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) FlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiCellRenderer) PageTitleCellRenderer(org.olat.modules.portfolio.ui.renderer.PageTitleCellRenderer) ArrayList(java.util.ArrayList) StatusCellRenderer(org.olat.modules.portfolio.ui.renderer.StatusCellRenderer) SharedPageStatusCellRenderer(org.olat.modules.portfolio.ui.renderer.SharedPageStatusCellRenderer) SortKey(org.olat.core.commons.persistence.SortKey) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) SharedPageStatusCellRenderer(org.olat.modules.portfolio.ui.renderer.SharedPageStatusCellRenderer) 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) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 42 with FlexiTableFilter

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

the class RepositoryEntryListController method initFilters.

private void initFilters(FlexiTableElement tableElement) {
    List<FlexiTableFilter> filters = new ArrayList<>(16);
    filters.add(new FlexiTableFilter(translate("filter.show.all"), Filter.showAll.name(), true));
    filters.add(FlexiTableFilter.SPACER);
    filters.add(new FlexiTableFilter(translate("filter.current.courses"), Filter.currentCourses.name()));
    filters.add(new FlexiTableFilter(translate("filter.upcoming.courses"), Filter.upcomingCourses.name()));
    filters.add(new FlexiTableFilter(translate("filter.old.courses"), Filter.oldCourses.name()));
    filters.add(FlexiTableFilter.SPACER);
    filters.add(new FlexiTableFilter(translate("filter.booked.participant"), Filter.asParticipant.name()));
    filters.add(new FlexiTableFilter(translate("filter.booked.coach"), Filter.asCoach.name()));
    filters.add(new FlexiTableFilter(translate("filter.booked.author"), Filter.asAuthor.name()));
    if (!searchParams.isMembershipMandatory()) {
        filters.add(new FlexiTableFilter(translate("filter.not.booked"), Filter.notBooked.name()));
    }
    filters.add(FlexiTableFilter.SPACER);
    filters.add(new FlexiTableFilter(translate("filter.passed"), Filter.passed.name()));
    filters.add(new FlexiTableFilter(translate("filter.not.passed"), Filter.notPassed.name()));
    filters.add(new FlexiTableFilter(translate("filter.without.passed.infos"), Filter.withoutPassedInfos.name()));
    tableElement.setFilters(null, filters, false);
}
Also used : FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) ArrayList(java.util.ArrayList)

Example 43 with FlexiTableFilter

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

the class SharedBindersController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, ShareItemCols.binderKey, "select"));
    SortKey defaultSortKey = null;
    if (isAdministrativeUser) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.username));
        defaultSortKey = new SortKey(Cols.username.name(), true);
    }
    // followed by the users fields
    int colPos = USER_PROPS_OFFSET;
    for (int i = 0; i < userPropertyHandlers.size(); i++) {
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
        String propName = userPropertyHandler.getName();
        if (defaultSortKey == null && i == 0) {
            defaultSortKey = new SortKey(propName, true);
        } else if (UserConstants.LASTNAME.equals(propName) && !isAdministrativeUser) {
            defaultSortKey = new SortKey(propName, true);
        }
        boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, true, propName));
        colPos++;
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.binderName, "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.courseName, "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.lastModified));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.recentLaunch));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.openSections, "select"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.selectSections, new SelectSectionsCellRenderer()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.newlyPublishedPage));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, ShareItemCols.draftPage));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, ShareItemCols.inRevisionPage));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, ShareItemCols.closedPage));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(ShareItemCols.grading, new AssessmentEntryCellRenderer(getTranslator())));
    StaticFlexiCellRenderer selectRenderer = new StaticFlexiCellRenderer(translate("select"), "select");
    selectRenderer.setIconRightCSS("o_icon-sw o_icon_start");
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, true, "select", -1, "select", false, null, FlexiColumnModel.ALIGNMENT_LEFT, selectRenderer));
    StaticFlexiCellRenderer leaveRenderer = new StaticFlexiCellRenderer(translate("leave"), "leave");
    leaveRenderer.setIconRightCSS("o_icon-sw o_icon_delete");
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, false, "leave", -2, "leave", false, null, FlexiColumnModel.ALIGNMENT_LEFT, leaveRenderer));
    model = new SharedBindersDataModel(columnsModel, getLocale());
    tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
    tableEl.setSearchEnabled(true);
    tableEl.setCustomizeColumns(true);
    tableEl.setElementCssClass("o_binder_shared_items_listing");
    tableEl.setEmtpyTableMessageKey("table.sEmptyTable");
    tableEl.setPageSize(24);
    tableEl.setAndLoadPersistedPreferences(ureq, "shared-items");
    FlexiTableSortOptions options = new FlexiTableSortOptions();
    if (defaultSortKey != null) {
        options.setDefaultOrderBy(defaultSortKey);
    }
    tableEl.setSortSettings(options);
    List<FlexiTableFilter> tableFilters = new ArrayList<>();
    tableFilters.add(new FlexiTableFilter(translate("filter.sections.empty"), SharedBindersDataModel.EMPTY_SECTIONS, true));
    tableFilters.add(FlexiTableFilter.SPACER);
    tableFilters.add(new FlexiTableFilter(translate("filter.show.all"), "all", true));
    tableEl.setFilters("Filters", tableFilters, false);
    tableEl.setSelectedFilterKey(SharedBindersDataModel.EMPTY_SECTIONS);
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) SelectSectionsCellRenderer(org.olat.modules.portfolio.ui.renderer.SelectSectionsCellRenderer) ArrayList(java.util.ArrayList) SortKey(org.olat.core.commons.persistence.SortKey) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) AssessmentEntryCellRenderer(org.olat.modules.portfolio.ui.renderer.AssessmentEntryCellRenderer) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 44 with FlexiTableFilter

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

the class TaxonomyTreeTableController method getFilters.

private List<FlexiTableFilter> getFilters() {
    List<TaxonomyLevelType> types = taxonomyService.getTaxonomyLevelTypes(taxonomy);
    List<FlexiTableFilter> resources = new ArrayList<>(types.size() + 1);
    for (TaxonomyLevelType type : types) {
        resources.add(new FlexiTableFilter(type.getDisplayName(), type.getKey().toString()));
    }
    resources.add(new FlexiTableFilter(translate("filter.no.level.type"), "-"));
    resources.add(FlexiTableFilter.SPACER);
    resources.add(new FlexiTableFilter(translate("show.all"), "all", true));
    return resources;
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) ArrayList(java.util.ArrayList)

Example 45 with FlexiTableFilter

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

the class TaxonomyTreeTableModel method filter.

@Override
public void filter(List<FlexiTableFilter> filters) {
    if (filters != null && filters.size() > 0 && filters.get(0) != null) {
        Set<Long> typeKeys = new HashSet<>();
        boolean noType = false;
        boolean showAll = false;
        for (FlexiTableFilter filter : filters) {
            if ("-".equals(filter.getFilter())) {
                noType = true;
            } else if (StringHelper.isLong(filter.getFilter())) {
                typeKeys.add(new Long(filter.getFilter()));
            } else if (filter.isShowAll()) {
                showAll = true;
            }
        }
        if (showAll) {
            setUnfilteredObjects();
        } else {
            List<TaxonomyLevelRow> filteredRows = new ArrayList<>(backupRows.size());
            for (TaxonomyLevelRow row : backupRows) {
                if (accept(row, typeKeys, noType)) {
                    filteredRows.add(row);
                }
            }
            setFilteredObjects(filteredRows);
        }
    } else {
        setUnfilteredObjects();
    }
}
Also used : FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

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