Skip to content
Snippets Groups Projects
Commit 7a6ccd98 authored by srosse's avatar srosse
Browse files

OO-1430: reset the columns against the list of default visible columns

parent 11d6f1ea
No related branches found
No related tags found
No related merge requests found
...@@ -109,10 +109,11 @@ public class Table extends AbstractComponent { ...@@ -109,10 +109,11 @@ public class Table extends AbstractComponent {
// order of left-to-right presentation of Columns (visible columndescriptors): // order of left-to-right presentation of Columns (visible columndescriptors):
// list of columndescriptors // list of columndescriptors
List<ColumnDescriptor> columnOrder; // default visibility to improve speed, not private private List<ColumnDescriptor> columnOrder; // default visibility to improve speed, not private
// all column descriptors whether visible or not // all column descriptors whether visible or not
List<ColumnDescriptor> allCDs; // default visibility to improve speed, not private private List<ColumnDescriptor> allCDs; // default visibility to improve speed, not private
private List<ColumnDescriptor> defaultVisibleCDs;
private TableDataModel tableDataModel; private TableDataModel tableDataModel;
// DO NOT REFERENCE filteredTableDataModel directly, use always getFilteredTableDataModel() because lazy init! // DO NOT REFERENCE filteredTableDataModel directly, use always getFilteredTableDataModel() because lazy init!
...@@ -156,6 +157,7 @@ public class Table extends AbstractComponent { ...@@ -156,6 +157,7 @@ public class Table extends AbstractComponent {
super(id, name, translator); super(id, name, translator);
columnOrder = new ArrayList<ColumnDescriptor>(INITIAL_COLUMNSIZE); columnOrder = new ArrayList<ColumnDescriptor>(INITIAL_COLUMNSIZE);
allCDs = new ArrayList<ColumnDescriptor>(INITIAL_COLUMNSIZE); allCDs = new ArrayList<ColumnDescriptor>(INITIAL_COLUMNSIZE);
defaultVisibleCDs = new ArrayList<ColumnDescriptor>(INITIAL_COLUMNSIZE);
sorter = new ArrayList<Integer>(DEFAULT_RESULTS_PER_PAGE); sorter = new ArrayList<Integer>(DEFAULT_RESULTS_PER_PAGE);
selectedRowId = NO_ROW_SELECTED; selectedRowId = NO_ROW_SELECTED;
currentPageId = Integer.valueOf(1); currentPageId = Integer.valueOf(1);
...@@ -281,11 +283,10 @@ public class Table extends AbstractComponent { ...@@ -281,11 +283,10 @@ public class Table extends AbstractComponent {
} else { } else {
columnOrder.add(cd); columnOrder.add(cd);
} }
defaultVisibleCDs.add(cd);
} }
} }
// public boolean isColumnDescriptorVisible()
/** /**
* @param cd * @param cd
*/ */
...@@ -649,6 +650,17 @@ public class Table extends AbstractComponent { ...@@ -649,6 +650,17 @@ public class Table extends AbstractComponent {
protected ChoiceModel createChoiceModel() { protected ChoiceModel createChoiceModel() {
return new ChoiceTableDataModel(isMultiSelect(), allCDs, columnOrder, getTranslator()); return new ChoiceTableDataModel(isMultiSelect(), allCDs, columnOrder, getTranslator());
} }
protected List<Integer> getDefaultVisibleColumns() {
List<Integer> indexList = new ArrayList<>();
for(ColumnDescriptor defaultVisibleCD:defaultVisibleCDs) {
int index = allCDs.indexOf(defaultVisibleCD);
if(index >= 0) {
indexList.add(index);
}
}
return indexList;
}
/** /**
* @param selRows * @param selRows
......
...@@ -338,7 +338,8 @@ public class TableController extends BasicController { ...@@ -338,7 +338,8 @@ public class TableController extends BasicController {
applyAndcheckChangedColumnsChoice(ureq, colsChoice.getSelectedRows()); applyAndcheckChangedColumnsChoice(ureq, colsChoice.getSelectedRows());
} else if (event == Choice.EVNT_FORM_RESETED) { } else if (event == Choice.EVNT_FORM_RESETED) {
//sideeffect on table and prefs //sideeffect on table and prefs
applyAndcheckChangedColumnsChoice(ureq, colsChoice.getAllRows()); List<Integer> visibleCols = table.getDefaultVisibleColumns();
applyAndcheckChangedColumnsChoice(ureq, visibleCols);
} else { // cancelled } else { // cancelled
cmc.deactivate(); cmc.deactivate();
} }
...@@ -515,6 +516,7 @@ public class TableController extends BasicController { ...@@ -515,6 +516,7 @@ public class TableController extends BasicController {
if (tableModel != null) { if (tableModel != null) {
contentVc.contextPut("tableEmpty", tableModel.getRowCount() == 0 ? Boolean.TRUE : Boolean.FALSE); contentVc.contextPut("tableEmpty", tableModel.getRowCount() == 0 ? Boolean.TRUE : Boolean.FALSE);
contentVc.contextPut("numberOfElements", String.valueOf(table.getUnfilteredRowCount())); contentVc.contextPut("numberOfElements", String.valueOf(table.getUnfilteredRowCount()));
contentVc.contextPut("rowCounts", String.valueOf(table.getRowCount()));
if (table.isTableFiltered()) { if (table.isTableFiltered()) {
contentVc.contextPut("numberFilteredElements", String.valueOf(table.getRowCount())); contentVc.contextPut("numberFilteredElements", String.valueOf(table.getRowCount()));
contentVc.contextPut(VC_VAR_IS_FILTERED, Boolean.TRUE); contentVc.contextPut(VC_VAR_IS_FILTERED, Boolean.TRUE);
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
</div> </div>
<div class="col-sm-3 col-xs-4 o_table_row_count"> <div class="col-sm-3 col-xs-4 o_table_row_count">
#if ($tableConfig.isDisplayRowCount()) #if ($tableConfig.isDisplayRowCount())
$numberOfElements $rowCounts
#if ($numberOfElements == "1") #if ($rowCounts == "1")
$r.translate("table.entry") $r.translate("table.entry")
#else #else
$r.translate("table.entries") $r.translate("table.entries")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment