use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project openolat by klemens.
the class DeletedPageListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (tableEl == source) {
if (event instanceof FlexiTableRenderEvent) {
FlexiTableRenderEvent se = (FlexiTableRenderEvent) event;
deleteButton.setVisible(se.getRendererType() == FlexiTableRendererType.classic && model.getRowCount() > 0);
tableEl.setSelectAllEnable(tableEl.getRendererType() == FlexiTableRendererType.classic);
} else if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
if ("select-page".equals(cmd)) {
PortfolioElementRow row = model.getObject(se.getIndex());
doOpenRow(ureq, row, false);
} else if ("restore".equals(cmd)) {
PortfolioElementRow row = model.getObject(se.getIndex());
if (row.isPage()) {
doRestorePage(ureq, row);
}
}
}
} else if (deleteButton == source) {
doConfirmDelete(ureq);
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project openolat by klemens.
the class ExportBinderAsCPResource method exportSection.
private void exportSection(Section section, ZipOutputStream zout) throws IOException {
String pagePath = Util.getPackageVelocityRoot(AbstractPageListController.class) + "/portfolio_element_row.html";
VelocityContainer rowVC = new VelocityContainer("html", pagePath, translator, null);
AssessmentSection assessmentSection = null;
PortfolioElementRow row = new PortfolioElementRow(section, assessmentSection, false, false);
rowVC.contextPut("row", row);
rowVC.contextPut("rowIndex", 0);
String html = createResultHTML(null, rowVC, null, "o_section_export");
convertToZipEntry(zout, sectionFilename(section), html);
}
use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project openolat by klemens.
the class PortfolioElementCellRenderer method render.
@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
if (cellValue instanceof String) {
Object objRow = source.getFlexiTableElement().getTableDataModel().getObject(row);
target.append("<span class='");
if (objRow instanceof PortfolioElementRow) {
PortfolioElementRow elRow = (PortfolioElementRow) objRow;
if (elRow.isSection()) {
target.append("o_pf_section'><i class='o_icon o_icon-fw o_icon_pf_section'> </i> ");
} else if (elRow.isPage()) {
target.append("o_pf_page'><i class='o_icon o_icon-fw o_icon_pf_page'> </i> ");
} else if (elRow.isPendingAssignment()) {
target.append("o_pf_assignment'><i class='o_icon o_icon-fw o_icon_assignment'> </i> ");
} else {
target.append("'>");
}
} else {
target.append("'>");
}
target.append(StringHelper.escapeHtml((String) cellValue)).append("</span>");
}
}
use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project openolat by klemens.
the class PageListSortableDataModelDelegate method sort.
@Override
protected void sort(List<PortfolioElementRow> rows) {
Comparator<PortfolioElementRow> comparator = new PageCreationDateComparator();
if (getOrderBy() != null) {
int columnIndex = getColumnIndex();
PageCols column = PageCols.values()[columnIndex];
switch(column) {
case key:
comparator = new PageCreationDateComparator();
break;
case status:
comparator = new StatusComparator();
break;
case comment:
comparator = new CommentsComparator();
break;
default:
comparator = new DefaultComparator();
break;
}
}
if (!isAsc()) {
comparator = new ReverseComparator(comparator);
}
Collections.sort(rows, new ClassicComparator(comparator));
}
use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project openolat by klemens.
the class MyPageListController method loadModel.
@Override
protected void loadModel(UserRequest ureq, String searchString) {
Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfCommentsOnOwnedPage(getIdentity());
List<CategoryToElement> categorizedElements = portfolioService.getCategorizedOwnedPages(getIdentity());
Map<OLATResourceable, List<Category>> categorizedElementMap = new HashMap<>();
for (CategoryToElement categorizedElement : categorizedElements) {
List<Category> categories = categorizedElementMap.get(categorizedElement.getCategorizedResource());
if (categories == null) {
categories = new ArrayList<>();
categorizedElementMap.put(categorizedElement.getCategorizedResource(), categories);
}
categories.add(categorizedElement.getCategory());
}
List<Assignment> assignments = portfolioService.searchOwnedAssignments(getIdentity());
Map<Page, List<Assignment>> pageToAssignments = new HashMap<>();
for (Assignment assignment : assignments) {
Page page = assignment.getPage();
List<Assignment> assignmentList;
if (pageToAssignments.containsKey(page)) {
assignmentList = pageToAssignments.get(page);
} else {
assignmentList = new ArrayList<>();
pageToAssignments.put(page, assignmentList);
}
assignmentList.add(assignment);
}
FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
newEntryButton.setCustomEnabledLinkCSS("btn btn-primary");
List<Page> pages = portfolioService.searchOwnedPages(getIdentity(), searchString);
List<PortfolioElementRow> rows = new ArrayList<>(pages.size());
List<TimelinePoint> points = new ArrayList<>(pages.size());
for (Page page : pages) {
if (page.getPageStatus() == PageStatus.deleted) {
continue;
}
List<Assignment> assignmentList = pageToAssignments.get(page);
PortfolioElementRow row = forgePageRow(ureq, page, null, assignmentList, categorizedElementMap, numberOfCommentsMap, true);
rows.add(row);
if (page.getSection() != null) {
Section section = page.getSection();
row.setMetaSectionTitle(section.getTitle());
if (section.getBinder() != null) {
row.setMetaBinderTitle(section.getBinder().getTitle());
}
}
row.setNewFloatingEntryLink(newEntryButton);
String s = page.getPageStatus() == null ? "draft" : page.getPageStatus().name();
points.add(new TimelinePoint(page.getKey().toString(), page.getTitle(), page.getCreationDate(), s));
}
timelineEl.setPoints(points);
// clean up the posters
disposeRows();
model.setObjects(rows);
tableEl.reset();
tableEl.reloadData();
}
Aggregations