Search in sources :

Example 46 with FlexiTableFilter

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

the class OrdersAdminController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.status, new OrderStatusRenderer()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.orderNr));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.creationDate));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.summary));
    if (isAdministrativeUser) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.username));
    }
    int i = 0;
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        int colIndex = USER_PROPS_OFFSET + i++;
        if (userPropertyHandler == null)
            continue;
        String propName = userPropertyHandler.getName();
        boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
        FlexiColumnModel col = new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, true, propName);
        columnsModel.addFlexiColumnModel(col);
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.methods, new AccessMethodRenderer(acModule)));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(OrderCol.total));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.order.details", translate("select"), CMD_SELECT));
    dataSource = new OrdersDataSource(acService, resource, null, userPropertyHandlers);
    if (resource == null) {
        searchForm = new OrdersSearchForm(ureq, getWindowControl(), mainForm);
        listenTo(searchForm);
        formLayout.add("searchForm", searchForm.getInitialFormItem());
        Calendar cal = CalendarUtils.getStartOfDayCalendar(getLocale());
        cal.add(Calendar.MONTH, -1);
        searchForm.setFrom(cal.getTime());
        dataSource.setFrom(cal.getTime());
    }
    dataModel = new OrdersDataModel(dataSource, getLocale(), userManager, columnsModel);
    tableEl = uifactory.addTableElement(getWindowControl(), "orderList", dataModel, 25, true, getTranslator(), formLayout);
    tableEl.setExportEnabled(true);
    List<FlexiTableFilter> filters = new ArrayList<>();
    filters.add(new FlexiTableFilter(translate("order.status.new"), OrderStatus.NEW.name()));
    filters.add(new FlexiTableFilter(translate("order.status.prepayment"), OrderStatus.PREPAYMENT.name()));
    filters.add(new FlexiTableFilter(translate("order.status.payed"), OrderStatus.PAYED.name()));
    filters.add(new FlexiTableFilter(translate("order.status.canceled"), OrderStatus.CANCELED.name()));
    filters.add(new FlexiTableFilter(translate("order.status.error"), OrderStatus.ERROR.name()));
    tableEl.setFilters("", filters, false);
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("title", translate("orders.admin.my"));
        layoutCont.contextPut("description", translate("orders.admin.my.desc"));
    }
}
Also used : DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) 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 47 with FlexiTableFilter

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

the class FlexiTableElementImpl method setSelectedExtendedFilters.

@Override
public void setSelectedExtendedFilters(List<FlexiTableFilter> filters) {
    if (extendedFilters != null && extendedFilters.size() > 0) {
        for (FlexiTableFilter extendedFilter : extendedFilters) {
            boolean selected = false;
            for (FlexiTableFilter filter : filters) {
                if (filter.getFilter() != null && filter.getFilter().equals(extendedFilter.getFilter())) {
                    selected = true;
                }
            }
            extendedFilter.setSelected(selected);
        }
    }
}
Also used : FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)

Example 48 with FlexiTableFilter

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

the class AbstractFlexiTableRenderer method renderFilterDropdown.

protected String renderFilterDropdown(StringOutput sb, FlexiTableElementImpl ftE, List<FlexiTableFilter> filters) {
    Form theForm = ftE.getRootForm();
    String dispatchId = ftE.getFormDispatchId();
    StringBuilder selected = new StringBuilder(256);
    sb.append("<div class='btn-group'>").append("<button id='table-button-filters-").append(dispatchId).append("' type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown'>").append("<i class='o_icon o_icon_filter o_icon-lg'> </i> <b class='caret'></b></button>").append("<div id='table-filters-").append(dispatchId).append("' class='hide'><ul class='o_dropdown list-unstyled' role='menu'>");
    for (FlexiTableFilter filter : filters) {
        if (FlexiTableFilter.SPACER.equals(filter)) {
            sb.append("<li class='divider'></li>");
        } else {
            sb.append("<li><a href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, dispatchId, 1, true, true, true, new NameValuePair("filter", filter.getFilter()))).append("\">").append("<i class='o_icon o_icon_check o_icon-fw'> </i> ", filter.isSelected());
            if (filter.getIconLeftCSS() != null) {
                sb.append("<i class='o_icon ").append(filter.getIconLeftCSS()).append("'> </i> ");
            }
            if (filter.getIconRenderer() != null) {
                filter.getIconRenderer().render(sb, filter, ftE.getComponent(), ftE.getTranslator());
            }
            sb.append(filter.getLabel()).append("</a></li>");
            if (filter.isSelected() && !filter.isShowAll()) {
                if (selected.length() > 0)
                    selected.append(", ");
                selected.append(filter.getLabel());
            }
        }
    }
    sb.append("</ul></div></div> ").append("<script type='text/javascript'>\n").append("/* <![CDATA[ */\n").append("jQuery(function() { o_popover('table-button-filters-").append(dispatchId).append("','table-filters-").append(dispatchId).append("'); });\n").append("/* ]]> */\n").append("</script>");
    return selected.toString();
}
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)

Example 49 with FlexiTableFilter

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

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

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

the class IdentityListCourseNodeController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    String filter = null;
    List<FlexiTableFilter> extendedFilters = null;
    if (state instanceof AssessedIdentityListState) {
        AssessedIdentityListState listState = (AssessedIdentityListState) state;
        if (StringHelper.containsNonWhitespace(listState.getFilter())) {
            filter = listState.getFilter();
        }
        extendedFilters = listState.getExtendedFilters();
    }
    tableEl.setSelectedFilterKey(filter);
    if (extendedFilters != null) {
        tableEl.setSelectedExtendedFilters(extendedFilters);
    }
    loadModel(ureq);
    if (entries != null && entries.size() > 0) {
        ContextEntry entry = entries.get(0);
        String resourceType = entry.getOLATResourceable().getResourceableTypeName();
        if ("Identity".equals(resourceType)) {
            Long identityKey = entries.get(0).getOLATResourceable().getResourceableId();
            for (int i = usersTableModel.getRowCount(); i-- > 0; ) {
                AssessedIdentityElementRow row = usersTableModel.getObject(i);
                if (row.getIdentityKey().equals(identityKey)) {
                    Controller ctrl = doSelect(ureq, row);
                    if (ctrl instanceof Activateable2) {
                        List<ContextEntry> subEntries = entries.subList(1, entries.size());
                        ((Activateable2) ctrl).activate(ureq, subEntries, entry.getTransientState());
                    }
                }
            }
        }
    }
}
Also used : Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) AssessedIdentityElementRow(org.olat.modules.assessment.ui.AssessedIdentityElementRow) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) AssessedIdentityListState(org.olat.modules.assessment.ui.AssessedIdentityListState) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) AssessedIdentityController(org.olat.modules.assessment.ui.AssessedIdentityController) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) Controller(org.olat.core.gui.control.Controller) ContextEntry(org.olat.core.id.context.ContextEntry)

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