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

OO-5144: close the panel after closing the roll call

And better order of unauthorized absences, reload the statistics after
closing the roll call
parent 75d75ba5
No related branches found
No related tags found
No related merge requests found
...@@ -82,7 +82,7 @@ public class LecturesListController extends FormBasicController { ...@@ -82,7 +82,7 @@ public class LecturesListController extends FormBasicController {
private final String propsIdentifier; private final String propsIdentifier;
private final boolean authorizedAbsenceEnabled; private final boolean authorizedAbsenceEnabled;
private final List<UserPropertyHandler> userPropertyHandlers; private final List<UserPropertyHandler> userPropertyHandlers;
private final List<LectureBlockIdentityStatistics> statistics; private List<LectureBlockIdentityStatistics> statistics;
private LectureBlocksCallout lectureBlocksListCtrl; private LectureBlocksCallout lectureBlocksListCtrl;
private CloseableCalloutWindowController lectureBlocksListCalloutCtrl; private CloseableCalloutWindowController lectureBlocksListCalloutCtrl;
...@@ -147,6 +147,12 @@ public class LecturesListController extends FormBasicController { ...@@ -147,6 +147,12 @@ public class LecturesListController extends FormBasicController {
tableEl.setFooter(true); tableEl.setFooter(true);
} }
public void reloadModel(List<LectureBlockIdentityStatistics> statistics) {
this.statistics = new ArrayList<>(statistics);
loadModel();
tableEl.reset(false, false, true);
}
private void loadModel() { private void loadModel() {
AggregatedLectureBlocksStatistics total = lectureService.aggregatedStatistics(statistics); AggregatedLectureBlocksStatistics total = lectureService.aggregatedStatistics(statistics);
List<LectureBlockIdentityStatisticsRow> rows = statistics.stream() List<LectureBlockIdentityStatisticsRow> rows = statistics.stream()
......
...@@ -27,7 +27,6 @@ import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiSorta ...@@ -27,7 +27,6 @@ import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiSorta
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel; import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableFooterModel; import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableFooterModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.SortableFlexiTableDataModel; 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.core.gui.translator.Translator; import org.olat.core.gui.translator.Translator;
import org.olat.modules.lecture.model.AggregatedLectureBlocksStatistics; import org.olat.modules.lecture.model.AggregatedLectureBlocksStatistics;
import org.olat.modules.lecture.model.LectureBlockIdentityStatistics; import org.olat.modules.lecture.model.LectureBlockIdentityStatistics;
...@@ -53,10 +52,10 @@ implements SortableFlexiTableDataModel<LectureBlockIdentityStatisticsRow>, Flexi ...@@ -53,10 +52,10 @@ implements SortableFlexiTableDataModel<LectureBlockIdentityStatisticsRow>, Flexi
@Override @Override
public void sort(SortKey orderBy) { public void sort(SortKey orderBy) {
SortableFlexiTableModelDelegate<LectureBlockIdentityStatisticsRow> sorter if(orderBy != null) {
= new SortableFlexiTableModelDelegate<>(orderBy, this, null); List<LectureBlockIdentityStatisticsRow> views = new LecturesListDataSortDelegate(orderBy, this, null).sort();
List<LectureBlockIdentityStatisticsRow> views = sorter.sort(); super.setObjects(views);
super.setObjects(views); }
} }
@Override @Override
......
/**
* <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.modules.lecture.ui.coach;
import java.util.Collections;
import java.util.Comparator;
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.SortableFlexiTableModelDelegate;
import org.olat.modules.lecture.ui.coach.LecturesListDataModel.StatsCols;
/**
*
* Initial date: 10 déc. 2020<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class LecturesListDataSortDelegate extends SortableFlexiTableModelDelegate<LectureBlockIdentityStatisticsRow> {
public LecturesListDataSortDelegate(SortKey orderBy, LecturesListDataModel tableModel, Locale locale) {
super(orderBy, tableModel, locale);
}
@Override
protected void sort(List<LectureBlockIdentityStatisticsRow> rows) {
int columnIndex = getColumnIndex();
if(columnIndex == StatsCols.unauthorizedAbsenceLectures.ordinal() || columnIndex == StatsCols.absentLectures.ordinal()) {
Collections.sort(rows, new AbsenceComparator());
} else {
super.sort(rows);
}
}
private class AbsenceComparator implements Comparator<LectureBlockIdentityStatisticsRow> {
@Override
public int compare(LectureBlockIdentityStatisticsRow o1, LectureBlockIdentityStatisticsRow o2) {
if(o1 == null || o2 == null) {
return compareNullObjects(o1, o2);
}
long block1 = o1.getStatistics().getTotalAbsentLectures();
long block2 = o2.getStatistics().getTotalAbsentLectures();
return Long.compare(block1, block2);
}
}
}
...@@ -121,6 +121,15 @@ public class LecturesListSegmentController extends BasicController { ...@@ -121,6 +121,15 @@ public class LecturesListSegmentController extends BasicController {
// //
} }
public void reloadModel(List<LectureBlockIdentityStatistics> statistics) {
if(aggregatedListCtrl != null) {
aggregatedListCtrl.reloadModel(statistics);
}
if(detailledListCtrl != null) {
detailledListCtrl.reloadModel(statistics);
}
}
private Controller doOpenAggregatedListController(UserRequest ureq) { private Controller doOpenAggregatedListController(UserRequest ureq) {
if(aggregatedListCtrl == null) { if(aggregatedListCtrl == null) {
List<LectureBlockIdentityStatistics> aggregatedStatistics = lectureService.groupByIdentity(statistics); List<LectureBlockIdentityStatistics> aggregatedStatistics = lectureService.groupByIdentity(statistics);
......
...@@ -113,15 +113,27 @@ public class LecturesSearchController extends BasicController implements Activat ...@@ -113,15 +113,27 @@ public class LecturesSearchController extends BasicController implements Activat
doSelectLectureBlock(ureq, slbe.getLectureBlock()); doSelectLectureBlock(ureq, slbe.getLectureBlock());
} }
} else if(rollCallCtrl == source) { } else if(rollCallCtrl == source) {
if(event == Event.CANCELLED_EVENT) { if(event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT) {
stackPanel.popController(rollCallCtrl); doCloseRollCall();
removeAsListenerAndDispose(rollCallCtrl);// don't clean up the others
rollCallCtrl = null;
} }
} }
super.event(ureq, source, event); super.event(ureq, source, event);
} }
private void doCloseRollCall() {
stackPanel.popController(rollCallCtrl);
removeAsListenerAndDispose(rollCallCtrl);// don't clean up the others
rollCallCtrl = null;
List<LectureBlockIdentityStatistics> statistics = searchStatistics();
if(listCtrl != null) {
listCtrl.reloadModel(statistics);
}
if(multipleUsersCtrl != null) {
multipleUsersCtrl.reloadModel(statistics);
}
}
private void cleanUp() { private void cleanUp() {
removeAsListenerAndDispose(multipleUsersCtrl); removeAsListenerAndDispose(multipleUsersCtrl);
removeAsListenerAndDispose(rollCallCtrl); removeAsListenerAndDispose(rollCallCtrl);
...@@ -131,12 +143,16 @@ public class LecturesSearchController extends BasicController implements Activat ...@@ -131,12 +143,16 @@ public class LecturesSearchController extends BasicController implements Activat
listCtrl = null; listCtrl = null;
} }
private void doSearch(UserRequest ureq) { private List<LectureBlockIdentityStatistics> searchStatistics() {
LectureStatisticsSearchParameters params = searchForm.getSearchParameters(); LectureStatisticsSearchParameters params = searchForm.getSearchParameters();
List<UserPropertyHandler> userPropertyHandlers = searchForm.getUserPropertyHandlers(); List<UserPropertyHandler> userPropertyHandlers = searchForm.getUserPropertyHandlers();
List<LectureBlockIdentityStatistics> statistics = lectureService return lectureService
.getLecturesStatistics(params, userPropertyHandlers, getIdentity()); .getLecturesStatistics(params, userPropertyHandlers, getIdentity());
}
private void doSearch(UserRequest ureq) {
List<UserPropertyHandler> userPropertyHandlers = searchForm.getUserPropertyHandlers();
List<LectureBlockIdentityStatistics> statistics = searchStatistics();
Set<Long> identities = statistics.stream().map(LectureBlockIdentityStatistics::getIdentityKey) Set<Long> identities = statistics.stream().map(LectureBlockIdentityStatistics::getIdentityKey)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
......
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