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

no-jira: add sort to the efficiency / certificate table in user's home

parent cbbb3a1c
No related branches found
No related tags found
No related merge requests found
......@@ -172,15 +172,18 @@ public class CertificateAndEfficiencyStatementListController extends FormBasicCo
}
FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.displayName.i18n(), Cols.displayName.ordinal()));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.score.i18n(), Cols.score.ordinal()));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.displayName.i18n(), Cols.displayName.ordinal(),
true, Cols.displayName.name()));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.score.i18n(), Cols.score.ordinal(),
true, Cols.score.name()));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.passed.i18n(), Cols.passed.ordinal(),
new PassedCellRenderer()));
true, Cols.passed.name(), new PassedCellRenderer()));
tableColumnModel.addFlexiColumnModel(new StaticFlexiColumnModel("table.header.show",
translate("table.header.show"), CMD_SHOW));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.lastModified.i18n(), Cols.lastModified.ordinal()));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.lastModified.i18n(), Cols.lastModified.ordinal(),
true, Cols.lastModified.name()));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.certificate.i18n(), Cols.certificate.ordinal(),
new DownloadCertificateCellRenderer(assessedIdentity)));
true, Cols.certificate.name(), new DownloadCertificateCellRenderer(assessedIdentity)));
tableColumnModel.addFlexiColumnModel(new StaticFlexiColumnModel("table.header.launchcourse",
translate("table.header.launchcourse"), CMD_LAUNCH_COURSE));
tableColumnModel.addFlexiColumnModel(new StaticFlexiColumnModel("table.header.delete",
......@@ -194,7 +197,7 @@ public class CertificateAndEfficiencyStatementListController extends FormBasicCo
new StaticFlexiCellRenderer(CMD_ARTEFACT, new AsArtefactCellRenderer())));
}
tableModel = new CertificateAndEfficiencyStatementListModel(tableColumnModel);
tableModel = new CertificateAndEfficiencyStatementListModel(tableColumnModel, getLocale());
loadModel();
tableEl = uifactory.addTableElement(getWindowControl(), "certificates", tableModel, getTranslator(), formLayout);
tableEl.setElementCssClass("o_sel_certificates_table");
......
......@@ -20,9 +20,13 @@
package org.olat.course.certificate.ui;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import org.olat.core.commons.persistence.SortKey;
import org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiTableDataModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.SortableFlexiTableDataModel;
import org.olat.course.assessment.AssessmentHelper;
import org.olat.course.certificate.CertificateLight;
import org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement;
......@@ -33,20 +37,39 @@ import org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class CertificateAndEfficiencyStatementListModel extends DefaultFlexiTableDataModel<CertificateAndEfficiencyStatement> {
public class CertificateAndEfficiencyStatementListModel extends DefaultFlexiTableDataModel<CertificateAndEfficiencyStatement>
implements SortableFlexiTableDataModel<CertificateAndEfficiencyStatement> {
public CertificateAndEfficiencyStatementListModel(FlexiTableColumnModel columnModel) {
private final Locale locale;
public CertificateAndEfficiencyStatementListModel(FlexiTableColumnModel columnModel, Locale locale) {
super(columnModel);
this.locale = locale;
}
@Override
public DefaultFlexiTableDataModel<CertificateAndEfficiencyStatement> createCopyWithEmptyList() {
return new CertificateAndEfficiencyStatementListModel(getTableColumnModel());
return new CertificateAndEfficiencyStatementListModel(getTableColumnModel(), locale);
}
@Override
public void sort(SortKey orderBy) {
if(orderBy != null) {
List<CertificateAndEfficiencyStatement> views = new CertificateAndEfficiencyStatementListSort(orderBy, this, locale).sort();
super.setObjects(views);
}
}
@Override
public Object getValueAt(int row, int col) {
CertificateAndEfficiencyStatement statement = getObject(row);
return getValueAt(statement, col);
}
@Override
public Object getValueAt(CertificateAndEfficiencyStatement statement, int col) {
switch(Cols.values()[col]) {
case displayName: return statement.getDisplayName();
case score:
......@@ -60,7 +83,7 @@ public class CertificateAndEfficiencyStatementListModel extends DefaultFlexiTabl
}
return null;
}
public static enum Cols {
displayName("table.header.course"),
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.course.certificate.ui;
import java.util.List;
import java.util.Locale;
import org.olat.core.commons.persistence.SortKey;
import org.olat.core.gui.components.form.flexible.impl.elements.table.SortableFlexiTableDataModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.SortableFlexiTableModelDelegate;
import org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement;
import org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.Cols;
/**
*
* Initial date: 30.03.2016<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class CertificateAndEfficiencyStatementListSort extends SortableFlexiTableModelDelegate<CertificateAndEfficiencyStatement> {
public CertificateAndEfficiencyStatementListSort(SortKey orderBy,
SortableFlexiTableDataModel<CertificateAndEfficiencyStatement> tableModel, Locale locale) {
super(orderBy, tableModel, locale);
}
@Override
protected void sort(List<CertificateAndEfficiencyStatement> rows) {
int columnIndex = getColumnIndex();
Cols column = Cols.values()[columnIndex];
switch(column) {
default: {
super.sort(rows);
}
}
}
}
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