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;
}
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);
}
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);
}
}
}
}
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);
}
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;
}
Aggregations