Search in sources :

Example 26 with PortfolioElementRow

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

the class PageListDataModel method sort.

@Override
public void sort(SortKey orderBy) {
    PageListSortableDataModelDelegate sorter = new PageListSortableDataModelDelegate(orderBy, this, locale);
    List<PortfolioElementRow> rows;
    try {
        rows = sorter.sort();
    } catch (IllegalArgumentException e) {
        log.error("Cannot sort with: " + orderBy, e);
        return;
    }
    // This say where is the link to create a new entry
    // if a section has assignments, it's at the end of
    // the section. If there isn't any assignment, it
    // under the section.
    boolean lastNewEntry = false;
    PortfolioElementRow previousRow = null;
    for (PortfolioElementRow row : rows) {
        if (row.isSection()) {
            if (lastNewEntry && previousRow != null) {
                previousRow.setNewEntry(true);
            }
            if (row.isAssignments()) {
                lastNewEntry = true;
            } else {
                lastNewEntry = false;
                row.setNewEntry(true);
            }
        } else {
            row.setNewEntry(false);
        }
        previousRow = row;
    }
    if (lastNewEntry && previousRow != null) {
        previousRow.setNewEntry(true);
    }
    super.setObjects(rows);
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow)

Example 27 with PortfolioElementRow

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

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

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

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

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

the class AbstractPageListController method forgeSectionRow.

protected PortfolioElementRow forgeSectionRow(Section section, AssessmentSection assessmentSection, List<Assignment> assignments, Map<OLATResourceable, List<Category>> categorizedElementMap) {
    PortfolioElementRow row = new PortfolioElementRow(section, assessmentSection, config.isAssessable(), (assignments != null && assignments.size() > 0));
    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.setPrimary(true);
    row.setOpenFormLink(openLink);
    openLink.setUserObject(row);
    addCategoriesToRow(row, categorizedElementMap);
    if (assignments != null && secCallback.canViewPendingAssignments(section) && secCallback.canInstantiateAssignment()) {
        List<Assignment> startableAssignments = assignments.stream().filter(ass -> ass.getAssignmentStatus() == AssignmentStatus.notStarted).filter(ass -> ass.getPage() == null).collect(Collectors.toList());
        if (!startableAssignments.isEmpty()) {
            String[] keys = new String[startableAssignments.size() + 1];
            String[] values = new String[startableAssignments.size() + 1];
            keys[0] = "start.assignment.hint";
            values[0] = translate("start.assignment.hint");
            int count = 1;
            for (Assignment assignment : startableAssignments) {
                keys[count] = Long.toString(assignment.getKey());
                values[count] = assignment.getTitle();
                count++;
            }
            SingleSelection startEl = uifactory.addDropdownSingleselect("assignments_" + (++counter), "", flc, keys, values, null);
            startEl.setDomReplacementWrapperRequired(false);
            startEl.addActionListener(FormEvent.ONCHANGE);
            row.setStartSelection(startEl);
        }
    }
    return row;
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) Assignment(org.olat.modules.portfolio.Assignment) FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) PortfolioV2Module(org.olat.modules.portfolio.PortfolioV2Module) TimelineElement(org.olat.modules.portfolio.ui.component.TimelineElement) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) Autowired(org.springframework.beans.factory.annotation.Autowired) ThreadLocalUserActivityLogger(org.olat.core.logging.activity.ThreadLocalUserActivityLogger) PageRemovedEvent(org.olat.modules.portfolio.ui.event.PageRemovedEvent) MediaResource(org.olat.core.gui.media.MediaResource) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) OLATResourceable(org.olat.core.id.OLATResourceable) StatusCellRenderer(org.olat.modules.portfolio.ui.renderer.StatusCellRenderer) BinderConfiguration(org.olat.modules.portfolio.BinderConfiguration) Category(org.olat.modules.portfolio.Category) OresHelper(org.olat.core.util.resource.OresHelper) Assignment(org.olat.modules.portfolio.Assignment) Map(java.util.Map) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) SectionStatus(org.olat.modules.portfolio.SectionStatus) AssignmentStatus(org.olat.modules.portfolio.AssignmentStatus) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) Page(org.olat.modules.portfolio.Page) CommentAndRatingDefaultSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) PortfolioLoggingAction(org.olat.modules.portfolio.PortfolioLoggingAction) WindowControl(org.olat.core.gui.control.WindowControl) FlexiTableRendererType(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableRendererType) Set(java.util.Set) AssignmentType(org.olat.modules.portfolio.AssignmentType) Component(org.olat.core.gui.components.Component) Collectors(java.util.stream.Collectors) Mapper(org.olat.core.dispatcher.mapper.Mapper) DefaultFlexiTableCssDelegate(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiTableCssDelegate) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) PortfolioElementCellRenderer(org.olat.modules.portfolio.ui.renderer.PortfolioElementCellRenderer) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) UserCommentsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsController) TooledController(org.olat.core.gui.components.stack.TooledController) LoggingResourceable(org.olat.util.logging.activity.LoggingResourceable) ImageComponent(org.olat.core.gui.components.image.ImageComponent) SharedPageStatusCellRenderer(org.olat.modules.portfolio.ui.renderer.SharedPageStatusCellRenderer) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) FileMediaResource(org.olat.core.gui.media.FileMediaResource) Section(org.olat.modules.portfolio.Section) CategoriesCellRenderer(org.olat.modules.portfolio.ui.component.CategoriesCellRenderer) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) PageDeletedEvent(org.olat.modules.portfolio.ui.event.PageDeletedEvent) ReadOnlyCommentsSecurityCallback(org.olat.modules.portfolio.ui.model.ReadOnlyCommentsSecurityCallback) HttpServletRequest(javax.servlet.http.HttpServletRequest) Calendar(java.util.Calendar) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) ContextEntry(org.olat.core.id.context.ContextEntry) StringHelper(org.olat.core.util.StringHelper) StateEntry(org.olat.core.id.context.StateEntry) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) FlexiTableDataModelFactory(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory) PageCols(org.olat.modules.portfolio.ui.PageListDataModel.PageCols) PortfolioService(org.olat.modules.portfolio.PortfolioService) Link(org.olat.core.gui.components.link.Link) FlexiTableComponentDelegate(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableComponentDelegate) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent) Controller(org.olat.core.gui.control.Controller) File(java.io.File) NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) PageImageAlign(org.olat.modules.portfolio.PageImageAlign) DialogBoxUIFactory(org.olat.core.gui.control.generic.modal.DialogBoxUIFactory) UserRequest(org.olat.core.gui.UserRequest) PageStatus(org.olat.modules.portfolio.PageStatus) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 30 with PortfolioElementRow

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

the class AbstractPageListController method getSelectedRows.

protected List<PortfolioElementRow> getSelectedRows() {
    Set<Integer> indexes = tableEl.getMultiSelectedIndex();
    List<PortfolioElementRow> selectedRows = new ArrayList<>(indexes.size());
    for (Integer index : indexes) {
        PortfolioElementRow row = model.getObject(index.intValue());
        selectedRows.add(row);
    }
    return selectedRows;
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) ArrayList(java.util.ArrayList)

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