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