Search in sources :

Example 21 with PortfolioElementRow

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);
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) FlexiTableRenderEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableRenderEvent)

Example 22 with PortfolioElementRow

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);
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) AbstractPageListController(org.olat.modules.portfolio.ui.AbstractPageListController) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 23 with PortfolioElementRow

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>");
    }
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow)

Example 24 with PortfolioElementRow

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));
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) PageCols(org.olat.modules.portfolio.ui.PageListDataModel.PageCols)

Example 25 with PortfolioElementRow

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();
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) Category(org.olat.modules.portfolio.Category) OLATResourceable(org.olat.core.id.OLATResourceable) HashMap(java.util.HashMap) CategoryToElement(org.olat.modules.portfolio.CategoryToElement) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Section(org.olat.modules.portfolio.Section) Assignment(org.olat.modules.portfolio.Assignment) ArrayList(java.util.ArrayList) List(java.util.List) TimelinePoint(org.olat.modules.portfolio.ui.component.TimelinePoint)

Aggregations

PortfolioElementRow (org.olat.modules.portfolio.ui.model.PortfolioElementRow)48 ArrayList (java.util.ArrayList)16 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)14 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)12 Section (org.olat.modules.portfolio.Section)12 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)10 OLATResourceable (org.olat.core.id.OLATResourceable)10 List (java.util.List)8 Assignment (org.olat.modules.portfolio.Assignment)8 Category (org.olat.modules.portfolio.Category)8 Page (org.olat.modules.portfolio.Page)8 HashMap (java.util.HashMap)6 Component (org.olat.core.gui.components.Component)6 FlexiTableRenderEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableRenderEvent)6 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)6 ContextEntry (org.olat.core.id.context.ContextEntry)6 CategoryToElement (org.olat.modules.portfolio.CategoryToElement)6 TimelinePoint (org.olat.modules.portfolio.ui.component.TimelinePoint)6 Map (java.util.Map)4 Set (java.util.Set)4