Search in sources :

Example 11 with PortfolioElementRow

use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project OpenOLAT by OpenOLAT.

the class SharedPageStatusCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator trans) {
    if (cellValue instanceof SharedPageRow) {
        SharedPageRow pageRow = (SharedPageRow) cellValue;
        PageStatus status = pageRow.getStatus();
        PageUserStatus userStatus = pageRow.getUserStatus();
        render(target, status, userStatus);
    } else if (cellValue instanceof PortfolioElementRow) {
        PortfolioElementRow elementRow = (PortfolioElementRow) cellValue;
        if (elementRow.getPage() != null) {
            PageStatus status = elementRow.getPageStatus();
            PageUserStatus userStatus = elementRow.getUserInfosStatus();
            render(target, status, userStatus);
        }
    }
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) PageStatus(org.olat.modules.portfolio.PageStatus) PageUserStatus(org.olat.modules.portfolio.PageUserStatus) SharedPageRow(org.olat.modules.portfolio.ui.shared.SharedPageRow)

Example 12 with PortfolioElementRow

use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project OpenOLAT by OpenOLAT.

the class PageListDataModel method filter.

public List<Section> filter(Section section) {
    if (section == null) {
        super.setObjects(backup);
        return null;
    } else if (backup == null) {
        return new ArrayList<>();
    }
    Set<Section> sectionSet = new HashSet<>();
    List<Section> sectionList = new ArrayList<>();
    List<PortfolioElementRow> sectionRows = new ArrayList<>();
    for (PortfolioElementRow row : backup) {
        if (row.getSection() != null) {
            if (!sectionSet.contains(row.getSection())) {
                sectionSet.add(row.getSection());
                sectionList.add(row.getSection());
            }
            if (section.equals(row.getSection())) {
                sectionRows.add(row);
            }
        }
    }
    super.setObjects(sectionRows);
    return sectionList;
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) ArrayList(java.util.ArrayList) Section(org.olat.modules.portfolio.Section) HashSet(java.util.HashSet)

Example 13 with PortfolioElementRow

use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project OpenOLAT by OpenOLAT.

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 14 with PortfolioElementRow

use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project openolat by klemens.

the class AbstractPageListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (tableEl == source) {
        if (event instanceof FlexiTableSearchEvent) {
            FlexiTableSearchEvent se = (FlexiTableSearchEvent) event;
            loadModel(ureq, se.getSearch());
        } else if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            if ("up".equals(cmd)) {
                PortfolioElementRow row = model.getObject(se.getIndex());
                if (row.isPendingAssignment()) {
                    doMoveUpAssignment(ureq, row);
                }
            } else if ("down".equals(cmd)) {
                PortfolioElementRow row = model.getObject(se.getIndex());
                if (row.isPendingAssignment()) {
                    doMoveDownAssignment(ureq, row);
                }
            }
        }
    } else if (timelineSwitchOnButton == source) {
        doSwitchTimelineOff();
    } else if (timelineSwitchOffButton == source) {
        doSwitchTimelineOn();
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if ("open.full".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doOpenRow(ureq, row, false);
        } else if ("comment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doComment(ureq, row.getPage());
        } else if ("close.section".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doConfirmCloseSection(ureq, row);
        } else if ("reopen.section".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doConfirmReopenSection(ureq, row);
        } else if ("edit.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doEditAssignment(ureq, row);
        } else if ("delete.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doConfirmDeleteAssignment(ureq, row);
        } else if ("move.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doMoveAssignment(ureq, row);
        } else if ("start.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doStartAssignment(ureq, row);
        } else if ("open.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doOpenAssignment(ureq, row);
        } else if ("up.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doMoveUpAssignment(ureq, row);
        } else if ("down.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doMoveDownAssignment(ureq, row);
        }
    } else if (source instanceof SingleSelection) {
        SingleSelection startAssignment = (SingleSelection) source;
        if (startAssignment.isOneSelected()) {
            String selectedKey = startAssignment.getSelectedKey();
            try {
                Long key = Long.parseLong(selectedKey);
                doStartAssignment(ureq, key);
            } catch (Exception e) {
            // 
            }
        }
    } else if (source == flc) {
        if ("ONCLICK".equals(event.getCommand())) {
            String category = ureq.getParameter("tag_select");
            if (StringHelper.containsNonWhitespace(category)) {
                tableEl.quickSearch(ureq, category);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 15 with PortfolioElementRow

use of org.olat.modules.portfolio.ui.model.PortfolioElementRow in project openolat by klemens.

the class AbstractPageListController method forgePageRow.

protected PortfolioElementRow forgePageRow(UserRequest ureq, Page page, AssessmentSection assessmentSection, List<Assignment> assignments, Map<OLATResourceable, List<Category>> categorizedElementMap, Map<Long, Long> numberOfCommentsMap, boolean selectElement) {
    Section section = page.getSection();
    PortfolioElementRow row = new PortfolioElementRow(page, assessmentSection, config.isAssessable());
    String openLinkId = "open_" + (++counter);
    FormLink openLink = uifactory.addFormLink(openLinkId, "open.full", "open.full.page", null, flc, Link.BUTTON_SMALL);
    openLink.setIconRightCSS("o_icon o_icon_start");
    openLink.setEnabled(selectElement);
    openLink.setPrimary(true);
    row.setOpenFormLink(openLink);
    openLink.setUserObject(row);
    addCategoriesToRow(row, categorizedElementMap);
    if (assignments != null) {
        for (Assignment assignment : assignments) {
            if (page.equals(assignment.getPage())) {
                row.setAssignment(assignment);
            }
        }
    }
    decorateImage(ureq, row, page);
    if (numberOfCommentsMap != null) {
        Long numOfComments = numberOfCommentsMap.get(page.getKey());
        if (numOfComments != null) {
            row.setNumOfComments(numOfComments.longValue());
        } else {
            row.setNumOfComments(0);
        }
    } else {
        row.setNumOfComments(0);
    }
    if (secCallback.canCloseSection(section)) {
        if (SectionStatus.isClosed(section)) {
            FormLink reopenLink = uifactory.addFormLink("ropens_" + (++counter), "reopen.section", "reopen.section", null, flc, Link.BUTTON_SMALL);
            reopenLink.setUserObject(row);
            row.setReopenSectionLink(reopenLink);
        } else {
            FormLink closeLink = uifactory.addFormLink("closes_" + (++counter), "close.section", "close.section", null, flc, Link.BUTTON_SMALL);
            closeLink.setUserObject(row);
            row.setCloseSectionLink(closeLink);
        }
    }
    if (portfolioV2Module.isEntriesCommentsEnabled() && secCallback.canComment(page)) {
        String title;
        String cssClass = "o_icon o_icon-fw o_icon_comments";
        if (row.getNumOfComments() == 1) {
            title = translate("comment.one");
        } else if (row.getNumOfComments() > 1) {
            title = translate("comment.several", new String[] { Long.toString(row.getNumOfComments()) });
        } else {
            title = translate("comment.zero");
            cssClass += "_none";
        }
        FormLink commentLink = uifactory.addFormLink("com_" + (++counter), "comment", title, null, flc, Link.LINK | Link.NONTRANSLATED);
        commentLink.setIconLeftCSS(cssClass);
        commentLink.setUserObject(row);
        row.setCommentFormLink(commentLink);
    }
    return row;
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) Assignment(org.olat.modules.portfolio.Assignment) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

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