Search in sources :

Example 1 with PortfolioElementRow

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

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)

Example 2 with PortfolioElementRow

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

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

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

the class AbstractPageListController method disposeRows.

protected void disposeRows() {
    List<PortfolioElementRow> rows = model.getObjects();
    if (rows != null && rows.size() > 0) {
        for (PortfolioElementRow row : rows) {
            if (row.getPoster() != null) {
                row.getPoster().dispose();
                row.setPoster(null);
            }
        }
    }
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow)

Example 4 with PortfolioElementRow

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

the class AbstractPageListController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (pageCtrl == source) {
        if (event == Event.CHANGED_EVENT) {
            loadModel(ureq, null);
            fireEvent(ureq, Event.CHANGED_EVENT);
        } else if (event instanceof PageRemovedEvent) {
            loadModel(ureq, null);
            stackPanel.popUpToController(this);
            fireEvent(ureq, Event.CHANGED_EVENT);
        } else if (event instanceof PageDeletedEvent) {
            loadModel(ureq, null);
            fireEvent(ureq, event);
        }
    } else if (commentsCtrl == source) {
        if (event == Event.CHANGED_EVENT || "comment_count_changed".equals(event.getCommand())) {
            loadModel(ureq, null);
            fireEvent(ureq, Event.CHANGED_EVENT);
        }
        cmc.deactivate();
        cleanUp();
    } else if (editAssignmentCtrl == source || moveAssignmentCtrl == source) {
        if (event == Event.CHANGED_EVENT || event == Event.DONE_EVENT) {
            loadModel(ureq, null);
            fireEvent(ureq, Event.CHANGED_EVENT);
        }
        cmc.deactivate();
        cleanUp();
    } else if (confirmCloseSectionCtrl == source) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            PortfolioElementRow row = (PortfolioElementRow) confirmCloseSectionCtrl.getUserObject();
            doClose(ureq, row);
        }
    } else if (confirmReopenSectionCtrl == source) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            PortfolioElementRow row = (PortfolioElementRow) confirmReopenSectionCtrl.getUserObject();
            doReopen(ureq, row);
        }
    } else if (confirmDeleteAssignmentCtrl == source) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            PortfolioElementRow row = (PortfolioElementRow) confirmDeleteAssignmentCtrl.getUserObject();
            doDelete(row);
            loadModel(ureq, null);
        }
    } else if (cmc == source) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) PageDeletedEvent(org.olat.modules.portfolio.ui.event.PageDeletedEvent) PageRemovedEvent(org.olat.modules.portfolio.ui.event.PageRemovedEvent)

Example 5 with PortfolioElementRow

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

the class AbstractPageListController method getComponents.

@Override
public final Iterable<Component> getComponents(int row, Object rowObject) {
    PortfolioElementRow elRow = model.getObject(row);
    List<Component> components = new ArrayList<>(4);
    if (elRow.getNewEntryLink() != null) {
        components.add(elRow.getNewEntryLink().getComponent());
    }
    if (elRow.getNewFloatingEntryLink() != null) {
        components.add(elRow.getNewFloatingEntryLink().getComponent());
    }
    if (elRow.getNewAssignmentLink() != null) {
        components.add(elRow.getNewAssignmentLink().getComponent());
    }
    if (elRow.getOpenFormItem() != null) {
        components.add(elRow.getOpenFormItem().getComponent());
    }
    if (elRow.getReopenSectionLink() != null) {
        components.add(elRow.getReopenSectionLink().getComponent());
    }
    if (elRow.getCloseSectionLink() != null) {
        components.add(elRow.getCloseSectionLink().getComponent());
    }
    if (elRow.getEditAssignmentLink() != null) {
        components.add(elRow.getEditAssignmentLink().getComponent());
    }
    if (elRow.getDeleteAssignmentLink() != null) {
        components.add(elRow.getDeleteAssignmentLink().getComponent());
    }
    if (elRow.getUpAssignmentLink() != null) {
        components.add(elRow.getUpAssignmentLink().getComponent());
    }
    if (elRow.getDownAssignmentLink() != null) {
        components.add(elRow.getDownAssignmentLink().getComponent());
    }
    if (elRow.getMoveAssignmentLink() != null) {
        components.add(elRow.getMoveAssignmentLink().getComponent());
    }
    if (elRow.getInstantiateAssignmentLink() != null) {
        components.add(elRow.getInstantiateAssignmentLink().getComponent());
    }
    if (elRow.getCommentFormLink() != null) {
        components.add(elRow.getCommentFormLink().getComponent());
    }
    if (elRow.getPoster() != null) {
        components.add(elRow.getPoster());
    }
    if (elRow.getStartSelection() != null) {
        components.add(elRow.getStartSelection().getComponent());
    }
    return components;
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) ArrayList(java.util.ArrayList) Component(org.olat.core.gui.components.Component) ImageComponent(org.olat.core.gui.components.image.ImageComponent)

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