Search in sources :

Example 11 with FlexiTableFilter

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

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 12 with FlexiTableFilter

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

the class AbstractFlexiTableRenderer method renderHeaderButtons.

protected void renderHeaderButtons(Renderer renderer, StringOutput sb, FlexiTableElementImpl ftE, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    Component searchCmp = ftE.getExtendedSearchComponent();
    if (searchCmp == null && !ftE.isExtendedSearchExpanded() && !ftE.isNumOfRowsEnabled() && !ftE.isFilterEnabled() && !ftE.isSortEnabled() && !ftE.isExportEnabled() && !ftE.isCustomizeColumns() && ftE.getAvailableRendererTypes().length <= 1) {
        return;
    }
    if (searchCmp != null && ftE.isExtendedSearchExpanded()) {
        renderer.render(searchCmp, sb, args);
    }
    sb.append("<div class='row clearfix o_table_toolbar'>").append("<div class='col-sm-6 col-xs-12 o_table_toolbar_left'>");
    if (searchCmp == null || !ftE.isExtendedSearchExpanded()) {
        renderHeaderSearch(renderer, sb, ftE, ubu, translator, renderResult, args);
    }
    sb.append("</div>");
    sb.append("<div class='col-sm-2 col-xs-4 o_table_row_count'>");
    if (ftE.isNumOfRowsEnabled()) {
        int rowCount = ftE.getTableDataModel().getRowCount();
        if (rowCount == 1) {
            sb.append(rowCount).append(" ").append(ftE.getTranslator().translate("table.entry"));
        } else if (rowCount > 1) {
            sb.append(rowCount).append(" ").append(ftE.getTranslator().translate("table.entries"));
        }
    }
    sb.append("</div><div class='col-sm-4 col-xs-8'><div class='pull-right'><div class='o_table_tools o_noprint'>");
    boolean empty = ftE.getTableDataModel().getRowCount() == 0;
    String filterIndication = null;
    // filter
    if (ftE.isFilterEnabled()) {
        List<FlexiTableFilter> filters = ftE.getFilters();
        if (filters != null && filters.size() > 0) {
            filterIndication = renderFilterDropdown(sb, ftE, filters);
        }
    }
    // sort
    if (ftE.isSortEnabled()) {
        List<FlexiTableSort> sorts = ftE.getSorts();
        if (sorts != null && sorts.size() > 0) {
            renderSortDropdown(sb, ftE, sorts);
        }
    }
    if (ftE.getExportButton() != null && ftE.isExportEnabled()) {
        sb.append("<div class='btn-group'>");
        ftE.getExportButton().setEnabled(!empty);
        renderFormItem(renderer, sb, ftE.getExportButton(), ubu, translator, renderResult, args);
        sb.append("</div> ");
    }
    if (ftE.getCustomButton() != null && ftE.isCustomizeColumns() && (ftE.getRendererType() == null || ftE.getRendererType() == FlexiTableRendererType.classic)) {
        sb.append("<div class='btn-group'>");
        renderFormItem(renderer, sb, ftE.getCustomButton(), ubu, translator, renderResult, args);
        sb.append("</div> ");
    }
    // switch type of tables
    FlexiTableRendererType[] types = ftE.getAvailableRendererTypes();
    if (types.length > 1) {
        sb.append("<div class='btn-group'>");
        for (FlexiTableRendererType type : types) {
            renderHeaderSwitchType(type, renderer, sb, ftE, ubu, translator, renderResult, args);
        }
        sb.append("</div> ");
    }
    sb.append("</div>");
    if (StringHelper.containsNonWhitespace(filterIndication)) {
        Form theForm = ftE.getRootForm();
        String dispatchId = ftE.getFormDispatchId();
        sb.append("<div class='o_table_tools_indications'>").append(filterIndication).append(" <a href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, dispatchId, 1, true, true, true, new NameValuePair("rm-filter", "true"))).append("\" title=\"").append(translator.translate("remove.filters")).append("\">").append("<i class='o_icon o_icon_remove o_icon-fw'> </i></a></div>");
    }
    sb.append("</div>");
    sb.append("</div></div>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) Component(org.olat.core.gui.components.Component) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Example 13 with FlexiTableFilter

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

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 14 with FlexiTableFilter

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

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 15 with FlexiTableFilter

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

the class IdentityListCourseNodeController method loadModel.

protected void loadModel(@SuppressWarnings("unused") UserRequest ureq) {
    SearchAssessedIdentityParams params = getSearchParameters();
    List<Identity> assessedIdentities = assessmentToolManager.getAssessedIdentities(getIdentity(), params);
    List<AssessmentEntry> assessmentEntries = assessmentToolManager.getAssessmentEntries(getIdentity(), params, null);
    Map<Long, AssessmentEntry> entryMap = new HashMap<>();
    assessmentEntries.stream().filter(entry -> entry.getIdentity() != null).forEach((entry) -> entryMap.put(entry.getIdentity().getKey(), entry));
    List<AssessedIdentityElementRow> rows = new ArrayList<>(assessedIdentities.size());
    for (Identity assessedIdentity : assessedIdentities) {
        AssessmentEntry entry = entryMap.get(assessedIdentity.getKey());
        CompletionItem currentCompletion = new CompletionItem("current-completion-" + (++counter), getLocale());
        if (entry != null) {
            currentCompletion.setCompletion(entry.getCurrentRunCompletion());
            AssessmentRunStatus status = entry.getCurrentRunStatus();
            currentCompletion.setEnded(status != null && AssessmentRunStatus.done.equals(status));
        }
        FormLink toolsLink = uifactory.addFormLink("tools_" + (++counter), "tools", "", null, null, Link.NONTRANSLATED);
        toolsLink.setIconLeftCSS("o_icon o_icon_actions o_icon-lg");
        AssessedIdentityElementRow row = new AssessedIdentityElementRow(assessedIdentity, entry, currentCompletion, toolsLink, userPropertyHandlers, getLocale());
        toolsLink.setUserObject(row);
        rows.add(row);
    }
    usersTableModel.setObjects(rows);
    List<FlexiTableFilter> filters = tableEl.getSelectedFilters();
    if (filters != null && filters.size() > 0 && filters.get(0) != null) {
        usersTableModel.filter(Collections.singletonList(filters.get(0)));
    }
    tableEl.reset();
    tableEl.reloadData();
}
Also used : FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement) Util(org.olat.core.util.Util) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) RepositoryService(org.olat.repository.RepositoryService) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) AssessmentToolManager(org.olat.course.assessment.AssessmentToolManager) Role(org.olat.modules.assessment.Role) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) Autowired(org.springframework.beans.factory.annotation.Autowired) CourseNode(org.olat.course.nodes.CourseNode) IdentityRef(org.olat.basesecurity.IdentityRef) AssessmentToolSecurityCallback(org.olat.modules.assessment.ui.AssessmentToolSecurityCallback) CourseNodeFactory(org.olat.course.nodes.CourseNodeFactory) OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentToolOptions(org.olat.modules.assessment.AssessmentToolOptions) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) GenericEventListener(org.olat.core.util.event.GenericEventListener) OresHelper(org.olat.core.util.resource.OresHelper) Map(java.util.Map) SortKey(org.olat.core.commons.persistence.SortKey) Group(org.olat.basesecurity.Group) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ICourse(org.olat.course.ICourse) IdentityCourseElementCols(org.olat.course.assessment.ui.tool.IdentityListCourseNodeTableModel.IdentityCourseElementCols) AssessmentModule(org.olat.course.assessment.AssessmentModule) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) WindowControl(org.olat.core.gui.control.WindowControl) STCourseNode(org.olat.course.nodes.STCourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) AssessmentFormEvent(org.olat.modules.assessment.ui.event.AssessmentFormEvent) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) Set(java.util.Set) AssessedIdentityElementRow(org.olat.modules.assessment.ui.AssessedIdentityElementRow) Component(org.olat.core.gui.components.Component) LinkFactory(org.olat.core.gui.components.link.LinkFactory) AssessedIdentityListState(org.olat.modules.assessment.ui.AssessedIdentityListState) AssessedIdentityController(org.olat.modules.assessment.ui.AssessedIdentityController) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) CalculatedAssessableCourseNode(org.olat.course.nodes.CalculatedAssessableCourseNode) Align(org.olat.core.gui.components.stack.TooledStackedPanel.Align) Identity(org.olat.core.id.Identity) AssessmentRunStatus(org.olat.modules.assessment.model.AssessmentRunStatus) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) BaseSecurity(org.olat.basesecurity.BaseSecurity) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Roles(org.olat.core.id.Roles) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) HashMap(java.util.HashMap) CourseFactory(org.olat.course.CourseFactory) RepositoryEntry(org.olat.repository.RepositoryEntry) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) CompletionItem(org.olat.modules.assessment.ui.component.CompletionItem) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) ContextEntry(org.olat.core.id.context.ContextEntry) PassedCellRenderer(org.olat.course.assessment.bulk.PassedCellRenderer) ScoreCellRenderer(org.olat.modules.assessment.ui.ScoreCellRenderer) BaseSecurityModule(org.olat.basesecurity.BaseSecurityModule) StringHelper(org.olat.core.util.StringHelper) StateEntry(org.olat.core.id.context.StateEntry) FlexiTableDataModelFactory(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) Link(org.olat.core.gui.components.link.Link) CompletionEvent(org.olat.modules.assessment.ui.event.CompletionEvent) ShowDetailsEvent(org.olat.course.assessment.ui.tool.event.ShowDetailsEvent) IdentityRefImpl(org.olat.basesecurity.model.IdentityRefImpl) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent) Controller(org.olat.core.gui.control.Controller) UserManager(org.olat.user.UserManager) SearchAssessedIdentityParams(org.olat.course.assessment.model.SearchAssessedIdentityParams) AssessmentToolContainer(org.olat.modules.assessment.ui.AssessmentToolContainer) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) BusinessGroup(org.olat.group.BusinessGroup) FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) UserRequest(org.olat.core.gui.UserRequest) Collections(java.util.Collections) CoordinatorManager(org.olat.core.util.coordinate.CoordinatorManager) AssessmentRunStatus(org.olat.modules.assessment.model.AssessmentRunStatus) HashMap(java.util.HashMap) AssessedIdentityElementRow(org.olat.modules.assessment.ui.AssessedIdentityElementRow) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) CompletionItem(org.olat.modules.assessment.ui.component.CompletionItem) SearchAssessedIdentityParams(org.olat.course.assessment.model.SearchAssessedIdentityParams) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) Identity(org.olat.core.id.Identity)

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