use of org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter in project openolat by klemens.
the class FlexiTableElementImpl method setSelectedFilterKey.
@Override
public void setSelectedFilterKey(String key) {
if (filters != null) {
for (FlexiTableFilter filter : filters) {
boolean selected = (key == null && filter.getFilter() == null) || (key != null && key.equals(filter.getFilter()));
filter.setSelected(selected);
}
}
}
use of org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter in project openolat by klemens.
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 klemens.
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 klemens.
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 klemens.
the class IdentityAssessmentOverviewController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.node, new IndentedNodeRenderer() {
@Override
public boolean isIndentationEnabled() {
return tableEl.getOrderBy() == null || tableEl.getOrderBy().length == 0;
}
}));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.attempts));
if (!followUserResultsVisibility) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.userVisibility, new UserVisibilityCellRenderer(getTranslator())));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.score, new ScoreCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.min, new ScoreCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.max, new ScoreCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.passed, new PassedCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.numOfAssessmentDocs));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.status, new AssessmentStatusCellRenderer(getLocale())));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, NodeCols.lastModified));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(NodeCols.lastUserModified));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, NodeCols.lastCoachModified));
if (nodesSelectable) {
DefaultFlexiColumnModel selectCol = new DefaultFlexiColumnModel("select", NodeCols.select.ordinal(), CMD_SELECT_NODE, new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("select"), CMD_SELECT_NODE), null));
selectCol.setExportable(false);
columnsModel.addFlexiColumnModel(selectCol);
}
tableModel = new IdentityAssessmentOverviewTableModel(columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "table", tableModel, 250, false, getTranslator(), formLayout);
tableEl.setExportEnabled(true);
tableEl.setEmtpyTableMessageKey("nodesoverview.emptylist");
tableEl.setBordered(true);
tableEl.setNumOfRowsEnabled(false);
if (allowTableFiltering) {
List<FlexiTableFilter> filters = new ArrayList<>();
filters.add(new FlexiTableFilter(translate("filter.showAll"), "showAll", true));
filters.add(FlexiTableFilter.SPACER);
filters.add(new FlexiTableFilter(translate("filter.passed"), "passed"));
filters.add(new FlexiTableFilter(translate("filter.failed"), "failed"));
filters.add(new FlexiTableFilter(translate("filter.inProgress"), "inProgress"));
filters.add(new FlexiTableFilter(translate("filter.inReview"), "inReview"));
filters.add(new FlexiTableFilter(translate("filter.done"), "done"));
tableEl.setFilters("", filters, false);
}
}
Aggregations