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>");
}
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);
}
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>");
}
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());
}
}
}
}
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);
}
Aggregations