Search in sources :

Example 6 with FlexiTableSort

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

the class AbstractFlexiTableRenderer method renderSortDropdown.

protected void renderSortDropdown(StringOutput sb, FlexiTableElementImpl ftE, List<FlexiTableSort> sorts) {
    Form theForm = ftE.getRootForm();
    String dispatchId = ftE.getFormDispatchId();
    sb.append("<div class='btn-group'>").append("<button id='table-button-sorters-").append(dispatchId).append("' type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown'>").append("<i class='o_icon o_icon_sort_menu o_icon-lg'> </i> <b class='caret'></b></button>").append("<div id='table-sorters-").append(dispatchId).append("' class='hide'><ul class='o_dropdown list-unstyled' role='menu'>");
    for (FlexiTableSort sort : sorts) {
        if (FlexiTableSort.SPACER.equals(sort)) {
            sb.append("<li class='divider'></li>");
        } else {
            sb.append("<li><a href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, dispatchId, 1, true, true, true, new NameValuePair("sort", sort.getSortKey().getKey()), new NameValuePair("asc", sort.getSortKey().isAsc() ? "desc" : "asc"))).append("\">");
            if (sort.isSelected()) {
                if (sort.getSortKey().isAsc()) {
                    sb.append("<i class='o_icon o_icon_sort_desc o_icon-fw'> </i> ");
                } else {
                    sb.append("<i class='o_icon o_icon_sort_asc o_icon-fw'> </i> ");
                }
            }
            sb.append(sort.getLabel()).append("</a></li>");
        }
    }
    sb.append("</ul></div></div> ").append("<script type='text/javascript'>\n").append("/* <![CDATA[ */\n").append("jQuery(function() { o_popover('table-button-sorters-").append(dispatchId).append("','table-sorters-").append(dispatchId).append("'); });\n").append("/* ]]> */\n").append("</script>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Example 7 with FlexiTableSort

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

the class MediaCenterController method initSorters.

private void initSorters(FlexiTableElement tableElement) {
    List<FlexiTableSort> sorters = new ArrayList<>(14);
    sorters.add(new FlexiTableSort(translate(MediaCols.key.i18nHeaderKey()), MediaCols.key.name()));
    sorters.add(new FlexiTableSort(translate(MediaCols.type.i18nHeaderKey()), MediaCols.type.name()));
    sorters.add(new FlexiTableSort(translate(MediaCols.title.i18nHeaderKey()), MediaCols.title.name()));
    sorters.add(new FlexiTableSort(translate(MediaCols.collectionDate.i18nHeaderKey()), MediaCols.collectionDate.name()));
    sorters.add(FlexiTableSort.SPACER);
    FlexiTableSortOptions options = new FlexiTableSortOptions(sorters);
    options.setDefaultOrderBy(new SortKey(OrderBy.title.name(), true));
    tableElement.setSortSettings(options);
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) ArrayList(java.util.ArrayList) SortKey(org.olat.core.commons.persistence.SortKey) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Example 8 with FlexiTableSort

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

the class AbstractFlexiTableRenderer method renderSortDropdown.

protected void renderSortDropdown(StringOutput sb, FlexiTableElementImpl ftE, List<FlexiTableSort> sorts) {
    Form theForm = ftE.getRootForm();
    String dispatchId = ftE.getFormDispatchId();
    sb.append("<div class='btn-group'>").append("<button id='table-button-sorters-").append(dispatchId).append("' type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown'>").append("<i class='o_icon o_icon_sort_menu o_icon-lg'> </i> <b class='caret'></b></button>").append("<div id='table-sorters-").append(dispatchId).append("' class='hide'><ul class='o_dropdown list-unstyled' role='menu'>");
    for (FlexiTableSort sort : sorts) {
        if (FlexiTableSort.SPACER.equals(sort)) {
            sb.append("<li class='divider'></li>");
        } else {
            sb.append("<li><a href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, dispatchId, 1, true, true, true, new NameValuePair("sort", sort.getSortKey().getKey()), new NameValuePair("asc", sort.getSortKey().isAsc() ? "desc" : "asc"))).append("\">");
            if (sort.isSelected()) {
                if (sort.getSortKey().isAsc()) {
                    sb.append("<i class='o_icon o_icon_sort_desc o_icon-fw'> </i> ");
                } else {
                    sb.append("<i class='o_icon o_icon_sort_asc o_icon-fw'> </i> ");
                }
            }
            sb.append(sort.getLabel()).append("</a></li>");
        }
    }
    sb.append("</ul></div></div> ").append("<script type='text/javascript'>\n").append("/* <![CDATA[ */\n").append("jQuery(function() { o_popover('table-button-sorters-").append(dispatchId).append("','table-sorters-").append(dispatchId).append("'); });\n").append("/* ]]> */\n").append("</script>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Example 9 with FlexiTableSort

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

the class FlexiTableElementImpl method loadCustomSettings.

private void loadCustomSettings(UserRequest ureq) {
    if (StringHelper.containsNonWhitespace(persistentId)) {
        Preferences prefs = ureq.getUserSession().getGuiPreferences();
        FlexiTablePreferences tablePrefs = (FlexiTablePreferences) prefs.get(FlexiTableElement.class, persistentId);
        if (tablePrefs != null) {
            if (tablePrefs.getPageSize() != getDefaultPageSize() && tablePrefs.getPageSize() != 0) {
                setPageSize(tablePrefs.getPageSize());
            }
            if (tablePrefs.getEnabledColumnKeys() != null) {
                enabledColumnIndex.clear();
                enabledColumnIndex.addAll(convertColumnKeysToIndex(tablePrefs.getEnabledColumnKeys()));
            }
            if (StringHelper.containsNonWhitespace(tablePrefs.getSortedColumnKey())) {
                String sortKey = null;
                String columnKey = tablePrefs.getSortedColumnKey();
                FlexiTableColumnModel colModel = dataModel.getTableColumnModel();
                for (int i = colModel.getColumnCount(); i-- > 0; ) {
                    FlexiColumnModel col = colModel.getColumnModel(i);
                    if (columnKey.equals(col.getColumnKey()) && col.isSortable()) {
                        sortKey = col.getSortKey();
                    }
                }
                if (sortKey == null && sortOptions != null && sortOptions.getSorts() != null) {
                    for (FlexiTableSort sortOption : sortOptions.getSorts()) {
                        if (sortOption.getSortKey().getKey().equals(columnKey)) {
                            sortKey = columnKey;
                        }
                    }
                }
                if (sortKey != null) {
                    orderBy = new SortKey[] { new SortKey(sortKey, tablePrefs.isSortDirection()) };
                    selectSortOption(sortKey, tablePrefs.isSortDirection());
                }
            }
            if (tablePrefs.getRendererType() != null) {
                setRendererType(tablePrefs.getRendererType());
            }
        }
    }
}
Also used : SortKey(org.olat.core.commons.persistence.SortKey) Preferences(org.olat.core.util.prefs.Preferences) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort) FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)

Example 10 with FlexiTableSort

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

the class VideoListingController method initSorters.

private void initSorters(FlexiTableElement tableElement) {
    List<FlexiTableSort> sorters = new ArrayList<>(8);
    sorters.add(new FlexiTableSort(translate("orderby.automatic"), OrderBy.automatic.name()));
    sorters.add(new FlexiTableSort(translate("orderby.title"), OrderBy.title.name()));
    sorters.add(new FlexiTableSort(translate("orderby.author"), OrderBy.author.name()));
    sorters.add(new FlexiTableSort(translate("orderby.creationDate"), OrderBy.creationDate.name()));
    sorters.add(new FlexiTableSort(translate("orderby.launchCounter"), OrderBy.launchCounter.name()));
    if (repositoryModule.isRatingEnabled()) {
        sorters.add(new FlexiTableSort(translate("orderby.rating"), OrderBy.rating.name()));
    }
    FlexiTableSortOptions options = new FlexiTableSortOptions(sorters);
    options.setDefaultOrderBy(new SortKey(OrderBy.creationDate.name(), false));
    tableElement.setSortSettings(options);
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) ArrayList(java.util.ArrayList) SortKey(org.olat.core.commons.persistence.SortKey) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Aggregations

FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)20 ArrayList (java.util.ArrayList)8 SortKey (org.olat.core.commons.persistence.SortKey)8 FlexiTableSortOptions (org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions)8 Form (org.olat.core.gui.components.form.flexible.impl.Form)4 NameValuePair (org.olat.core.gui.components.form.flexible.impl.NameValuePair)4 Preferences (org.olat.core.util.prefs.Preferences)4 Component (org.olat.core.gui.components.Component)2 FlexiTableElement (org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)2 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)2 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)2 FlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel)2 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)2 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)2 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)2 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)2