From 1f924fdc2be5ea75d20acfc7b058c773cef9e21a Mon Sep 17 00:00:00 2001 From: uhensler <none@none> Date: Fri, 9 Feb 2018 15:28:59 +0100 Subject: [PATCH] OO-3180: Admin options to hide several portfolio elements --- .../modules/portfolio/PortfolioV2Module.java | 167 +++++++++++++- .../ui/AbstractPageListController.java | 20 +- .../portfolio/ui/BinderController.java | 37 ++- .../ui/TableOfContentController.java | 5 +- .../portfolio/ui/_content/my_pages.html | 2 + .../ui/PortfolioAdminController.java | 211 +++++++++++++++--- .../ui/_i18n/LocalStrings_de.properties | 16 ++ .../ui/_i18n/LocalStrings_en.properties | 19 +- 8 files changed, 416 insertions(+), 61 deletions(-) diff --git a/src/main/java/org/olat/modules/portfolio/PortfolioV2Module.java b/src/main/java/org/olat/modules/portfolio/PortfolioV2Module.java index 554f63bcb80..903d6e7f682 100644 --- a/src/main/java/org/olat/modules/portfolio/PortfolioV2Module.java +++ b/src/main/java/org/olat/modules/portfolio/PortfolioV2Module.java @@ -42,11 +42,22 @@ public class PortfolioV2Module extends AbstractSpringModule implements ConfigOnO public static final String ENTRY_POINT_TOC = "toc"; public static final String ENTRY_POINT_ENTRIES = "entries"; - public static final String PORTFOLIO_ENABLED = "portfoliov2.enabled"; - public static final String PORTFOLIO_LEARNER_CAN_CREATE_BINDERS = "portfoliov2.learner.can.create.binders"; - public static final String PORTFOLIO_CAN_CREATE_BINDERS_FROM_TEMPLATE = "portfoliov2.can.create.binders.from.template"; - public static final String PORTFOLIO_CAN_CREATE_BINDERS_FROM_COURSE = "portfoliov2.can.create.binders.from.course"; - public static final String PORTFOLIO_BINDER_ENTRY_POINT = "portfoliov2.binder.entry.point"; + private static final String PORTFOLIO_ENABLED = "portfoliov2.enabled"; + private static final String PORTFOLIO_LEARNER_CAN_CREATE_BINDERS = "portfoliov2.learner.can.create.binders"; + private static final String PORTFOLIO_CAN_CREATE_BINDERS_FROM_TEMPLATE = "portfoliov2.can.create.binders.from.template"; + private static final String PORTFOLIO_CAN_CREATE_BINDERS_FROM_COURSE = "portfoliov2.can.create.binders.from.course"; + private static final String PORTFOLIO_BINDER_ENTRY_POINT = "portfoliov2.binder.entry.point"; + + private static final String PORTFOLIO_OVERVIEW_ENABLED = "portfoliov2.overview.enabled"; + private static final String PORTFOLIO_OVERVIEW_COMMENTS_ENABLED = "portfoliov2.overview.comments.enabled"; + private static final String PORTFOLIO_ENTRIES_ENABLED = "portfoliov2.entries.enabled"; + private static final String PORTFOLIO_ENTRIES_LIST_ENABLED = "portfoliov2.entries.list.enabled"; + private static final String PORTFOLIO_ENTRIES_TABLE_ENABLED = "portfoliov2.entries.table.enabled"; + private static final String PORTFOLIO_ENTRIES_COMMENTS_ENABLED = "portfoliov2.entries.comments.enabled"; + private static final String PORTFOLIO_ENTRIES_SEARCH_ENABLED = "portfoliov2.entries.search.enabled"; + private static final String PORTFOLIO_ENTRIES_TIMELINE_ENABLED = "portfoliov2.entries.timeline.enabled"; + private static final String PORTFOLIO_HISTORY_ENABLED = "portfoliov2.history.enabled"; + @Value("${portfoliov2.enabled:true}") private boolean enabled; @@ -59,6 +70,26 @@ public class PortfolioV2Module extends AbstractSpringModule implements ConfigOnO @Value("${portfoliov2.binder.entry.point:toc}") private String binderEntryPoint; + @Value("${portfoliov2.overview.enabled:true}") + private boolean overviewEnabled; + @Value("${portfoliov2.overview.comments.enabled:true}") + private boolean overviewCommentsEnabled; + @Value("${portfoliov2.entries.enabled:true}") + private boolean entriesEnabled; + @Value("${portfoliov2.entries.list.enabled:true}") + private boolean entriesListEnabled; + @Value("${portfoliov2.entries.table.enabled:true}") + private boolean entriesTableEnabled; + @Value("${portfoliov2.entries.comments.enabled:true}") + private boolean entriesCommentsEnabled; + @Value("${portfoliov2.entries.search.enabled:true}") + private boolean entriesSearchEnabled; + @Value("${portfoliov2.entries.timeline.enabled:true}") + private boolean entriesTimelineEnabled; + @Value("${portfoliov2.history.enabled:true}") + private boolean historyEnabled; + + @Autowired public PortfolioV2Module(CoordinatorManager coordinatorManager) { super(coordinatorManager); @@ -76,6 +107,51 @@ public class PortfolioV2Module extends AbstractSpringModule implements ConfigOnO learnerCanCreateBinders = "true".equals(learnerCanCreateBindersObj); } + String overviewEnabledObj = getStringPropertyValue(PORTFOLIO_OVERVIEW_ENABLED, true); + if(StringHelper.containsNonWhitespace(overviewEnabledObj)) { + overviewEnabled = "true".equals(overviewEnabledObj); + } + + String overviewCommentsEnabledObj = getStringPropertyValue(PORTFOLIO_OVERVIEW_COMMENTS_ENABLED, true); + if(StringHelper.containsNonWhitespace(overviewCommentsEnabledObj)) { + overviewCommentsEnabled = "true".equals(overviewCommentsEnabledObj); + } + + String entriesEnabledObj = getStringPropertyValue(PORTFOLIO_ENTRIES_ENABLED, true); + if(StringHelper.containsNonWhitespace(entriesEnabledObj)) { + entriesEnabled = "true".equals(entriesEnabledObj); + } + + String entriesListEnabledObj = getStringPropertyValue(PORTFOLIO_ENTRIES_LIST_ENABLED, true); + if(StringHelper.containsNonWhitespace(entriesListEnabledObj)) { + entriesListEnabled = "true".equals(entriesListEnabledObj); + } + + String entriesTableEnabledObj = getStringPropertyValue(PORTFOLIO_ENTRIES_TABLE_ENABLED, true); + if(StringHelper.containsNonWhitespace(entriesTableEnabledObj)) { + entriesTableEnabled = "true".equals(entriesTableEnabledObj); + } + + String entriesCommentsEnabledObj = getStringPropertyValue(PORTFOLIO_ENTRIES_COMMENTS_ENABLED, true); + if(StringHelper.containsNonWhitespace(entriesCommentsEnabledObj)) { + entriesCommentsEnabled = "true".equals(entriesCommentsEnabledObj); + } + + String entriesSearchEnabledObj = getStringPropertyValue(PORTFOLIO_ENTRIES_SEARCH_ENABLED, true); + if(StringHelper.containsNonWhitespace(entriesSearchEnabledObj)) { + entriesSearchEnabled = "true".equals(entriesSearchEnabledObj); + } + + String entriesTimelineEnabledObj = getStringPropertyValue(PORTFOLIO_ENTRIES_TIMELINE_ENABLED, true); + if(StringHelper.containsNonWhitespace(entriesTimelineEnabledObj)) { + entriesTimelineEnabled = "true".equals(entriesTimelineEnabledObj); + } + + String historyEnabledObj = getStringPropertyValue(PORTFOLIO_HISTORY_ENABLED, true); + if(StringHelper.containsNonWhitespace(historyEnabledObj)) { + historyEnabled = "true".equals(historyEnabledObj); + } + RepositoryHandlerFactory.registerHandler(new BinderTemplateHandler(), 40); NewControllerFactory.getInstance().addContextEntryControllerCreator("BinderInvitation", new BinderInvitationContextEntryControllerCreator()); @@ -135,4 +211,85 @@ public class PortfolioV2Module extends AbstractSpringModule implements ConfigOnO this.binderEntryPoint = binderEntryPoint; setStringProperty(PORTFOLIO_BINDER_ENTRY_POINT, binderEntryPoint, true); } + + public boolean isOverviewEnabled() { + return overviewEnabled; + } + + public void setOverviewEnabled(boolean overviewEnabled) { + this.overviewEnabled = overviewEnabled; + setStringProperty(PORTFOLIO_OVERVIEW_ENABLED, Boolean.toString(overviewEnabled), true); + } + + public boolean isOverviewCommentsEnabled() { + return overviewCommentsEnabled; + } + + public void setOverviewCommentsEnabled(boolean overviewCommentsEnabled) { + this.overviewCommentsEnabled = overviewCommentsEnabled; + setStringProperty(PORTFOLIO_OVERVIEW_COMMENTS_ENABLED, Boolean.toString(overviewCommentsEnabled), true); + } + + public boolean isEntriesEnabled() { + return entriesEnabled; + } + + public void setEntriesEnabled(boolean entriesEnabled) { + this.entriesEnabled = entriesEnabled; + setStringProperty(PORTFOLIO_ENTRIES_ENABLED, Boolean.toString(entriesEnabled), true); + } + + public boolean isEntriesListEnabled() { + return entriesListEnabled; + } + + public void setEntriesListEnabled(boolean entriesListEnabled) { + this.entriesListEnabled = entriesListEnabled; + setStringProperty(PORTFOLIO_ENTRIES_LIST_ENABLED, Boolean.toString(entriesListEnabled), true); + } + + public boolean isEntriesTableEnabled() { + return entriesTableEnabled; + } + + public void setEntriesTableEnabled(boolean entriesTableEnabled) { + this.entriesTableEnabled = entriesTableEnabled; + setStringProperty(PORTFOLIO_ENTRIES_TABLE_ENABLED, Boolean.toString(entriesTableEnabled), true); + } + + public boolean isEntriesCommentsEnabled() { + return entriesCommentsEnabled; + } + + public void setEntriesCommentsEnabled(boolean entriesCommentsEnabled) { + this.entriesCommentsEnabled = entriesCommentsEnabled; + setStringProperty(PORTFOLIO_ENTRIES_COMMENTS_ENABLED, Boolean.toString(entriesCommentsEnabled), true); + } + + public boolean isEntriesSearchEnabled() { + return entriesSearchEnabled; + } + + public void setEntriesSearchEnabled(boolean entiresSearchEnabled) { + this.entriesSearchEnabled = entiresSearchEnabled; + setStringProperty(PORTFOLIO_ENTRIES_SEARCH_ENABLED, Boolean.toString(entiresSearchEnabled), true); + } + + public boolean isEntriesTimelineEnabled() { + return entriesTimelineEnabled; + } + + public void setEntriesTimelineEnabled(boolean entriesTimelineEnabled) { + this.entriesTimelineEnabled = entriesTimelineEnabled; + setStringProperty(PORTFOLIO_ENTRIES_TIMELINE_ENABLED, Boolean.toString(entriesTimelineEnabled), true); + } + + public boolean isHistoryEnabled() { + return historyEnabled; + } + + public void setHistoryEnabled(boolean historyEnabled) { + this.historyEnabled = historyEnabled; + setStringProperty(PORTFOLIO_HISTORY_ENABLED, Boolean.toString(historyEnabled), true); + } } diff --git a/src/main/java/org/olat/modules/portfolio/ui/AbstractPageListController.java b/src/main/java/org/olat/modules/portfolio/ui/AbstractPageListController.java index 6b1de4db2fe..e9e9f2aaa4b 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/AbstractPageListController.java +++ b/src/main/java/org/olat/modules/portfolio/ui/AbstractPageListController.java @@ -85,6 +85,7 @@ import org.olat.modules.portfolio.PageImageAlign; import org.olat.modules.portfolio.PageStatus; import org.olat.modules.portfolio.PortfolioLoggingAction; import org.olat.modules.portfolio.PortfolioService; +import org.olat.modules.portfolio.PortfolioV2Module; import org.olat.modules.portfolio.Section; import org.olat.modules.portfolio.SectionStatus; import org.olat.modules.portfolio.ui.PageListDataModel.PageCols; @@ -134,6 +135,8 @@ implements Activateable2, TooledController, FlexiTableComponentDelegate { @Autowired protected PortfolioService portfolioService; + @Autowired + private PortfolioV2Module portfolioV2Module; public AbstractPageListController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel, BinderSecurityCallback secCallback, BinderConfiguration config, String vTemplate, @@ -183,7 +186,7 @@ implements Activateable2, TooledController, FlexiTableComponentDelegate { formLayout.add("timeline", timelineEl); initTimeline(); - if(config.isTimeline()) { + if(portfolioV2Module.isEntriesTimelineEnabled() && config.isTimeline()) { timelineSwitchOnButton = uifactory.addFormLink("timeline.switch.on", formLayout, Link.BUTTON_SMALL); timelineSwitchOnButton.setIconLeftCSS("o_icon o_icon-sm o_icon_toggle_on"); timelineSwitchOnButton.setElementCssClass("o_sel_timeline_on"); @@ -225,9 +228,14 @@ implements Activateable2, TooledController, FlexiTableComponentDelegate { String mapperThumbnailUrl = registerCacheableMapper(ureq, "page-list", new PageImageMapper(model, portfolioService)); tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout); - tableEl.setAvailableRendererTypes(FlexiTableRendererType.custom, FlexiTableRendererType.classic); - tableEl.setRendererType(FlexiTableRendererType.custom); - tableEl.setSearchEnabled(true); + if (portfolioV2Module.isEntriesListEnabled() && portfolioV2Module.isEntriesTableEnabled()) { + tableEl.setAvailableRendererTypes(FlexiTableRendererType.custom, FlexiTableRendererType.classic); + } else if (portfolioV2Module.isEntriesTableEnabled()) { + tableEl.setAvailableRendererTypes(FlexiTableRendererType.classic); + } else { + tableEl.setAvailableRendererTypes(FlexiTableRendererType.custom); + } + tableEl.setSearchEnabled(portfolioV2Module.isEntriesSearchEnabled()); tableEl.setCustomizeColumns(true); tableEl.setElementCssClass("o_binder_page_listing"); tableEl.setEmtpyTableMessageKey("table.sEmptyTable"); @@ -237,6 +245,8 @@ implements Activateable2, TooledController, FlexiTableComponentDelegate { tableEl.setRowRenderer(rowVC, this); tableEl.setCssDelegate(new DefaultFlexiTableCssDelegate()); tableEl.setAndLoadPersistedPreferences(ureq, "page-list"); + FlexiTableRendererType renderType = portfolioV2Module.isEntriesListEnabled()? FlexiTableRendererType.custom: FlexiTableRendererType.classic; + tableEl.setRendererType(renderType); } @Override @@ -450,7 +460,7 @@ implements Activateable2, TooledController, FlexiTableComponentDelegate { } } - if(secCallback.canComment(page)) { + if(portfolioV2Module.isEntriesCommentsEnabled() && secCallback.canComment(page)) { String title; String cssClass = "o_icon o_icon-fw o_icon_comments"; if(row.getNumOfComments() == 1) { diff --git a/src/main/java/org/olat/modules/portfolio/ui/BinderController.java b/src/main/java/org/olat/modules/portfolio/ui/BinderController.java index fa96f59f095..a1aceb519e4 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/BinderController.java +++ b/src/main/java/org/olat/modules/portfolio/ui/BinderController.java @@ -65,8 +65,11 @@ import org.springframework.beans.factory.annotation.Autowired; */ public class BinderController extends BasicController implements TooledController, Activateable2 { - private Link assessmentLink, publishLink; - private final Link overviewLink, entriesLink, historyLink; + private Link overviewLink; + private Link entriesLink; + private Link historyLink; + private Link assessmentLink; + private Link publishLink; private final ButtonGroupComponent segmentButtonsCmp; private final TooledStackedPanel stackPanel; private StackedPanel mainPanel; @@ -98,15 +101,21 @@ public class BinderController extends BasicController implements TooledControlle segmentButtonsCmp = new ButtonGroupComponent("segments"); segmentButtonsCmp.setElementCssClass("o_sel_pf_binder_navigation"); - overviewLink = LinkFactory.createLink("portfolio.overview", getTranslator(), this); - overviewLink.setElementCssClass("o_sel_pf_toc"); - segmentButtonsCmp.addButton(overviewLink, false); - entriesLink = LinkFactory.createLink("portfolio.entries", getTranslator(), this); - entriesLink.setElementCssClass("o_sel_pf_entries"); - segmentButtonsCmp.addButton(entriesLink, false); - historyLink = LinkFactory.createLink("portfolio.history", getTranslator(), this); - historyLink.setElementCssClass("o_sel_pf_history"); - segmentButtonsCmp.addButton(historyLink, false); + if (portfolioModule.isOverviewEnabled()) { + overviewLink = LinkFactory.createLink("portfolio.overview", getTranslator(), this); + overviewLink.setElementCssClass("o_sel_pf_toc"); + segmentButtonsCmp.addButton(overviewLink, false); + } + if (portfolioModule.isEntriesEnabled()) { + entriesLink = LinkFactory.createLink("portfolio.entries", getTranslator(), this); + entriesLink.setElementCssClass("o_sel_pf_entries"); + segmentButtonsCmp.addButton(entriesLink, false); + } + if (portfolioModule.isHistoryEnabled()) { + historyLink = LinkFactory.createLink("portfolio.history", getTranslator(), this); + historyLink.setElementCssClass("o_sel_pf_history"); + segmentButtonsCmp.addButton(historyLink, false); + } if(config.isShareable() && secCallback.canViewAccessRights()) { publishLink = LinkFactory.createLink("portfolio.publish", getTranslator(), this); publishLink.setElementCssClass("o_sel_pf_publication"); @@ -154,7 +163,11 @@ public class BinderController extends BasicController implements TooledControlle if(entries == null || entries.isEmpty()) { String ePoint = portfolioModule.getBinderEntryPoint(); if(binder != null && binder.getBinderStatus() == BinderStatus.deleted) { - doOpenOverview(ureq); + if (PortfolioV2Module.ENTRY_POINT_TOC.equals(ePoint)) { + doOpenOverview(ureq); + } else { + doOpenEntries(ureq); + } } else if(PortfolioV2Module.ENTRY_POINT_TOC.equals(ePoint)) { int numOfSections = doOpenOverview(ureq).getNumOfSections(); if(numOfSections == 0 && !secCallback.canEditBinder()) { diff --git a/src/main/java/org/olat/modules/portfolio/ui/TableOfContentController.java b/src/main/java/org/olat/modules/portfolio/ui/TableOfContentController.java index a405100fafa..c80ae02cd9e 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/TableOfContentController.java +++ b/src/main/java/org/olat/modules/portfolio/ui/TableOfContentController.java @@ -74,6 +74,7 @@ import org.olat.modules.portfolio.PageUserStatus; import org.olat.modules.portfolio.PortfolioLoggingAction; import org.olat.modules.portfolio.PortfolioRoles; import org.olat.modules.portfolio.PortfolioService; +import org.olat.modules.portfolio.PortfolioV2Module; import org.olat.modules.portfolio.Section; import org.olat.modules.portfolio.SectionStatus; import org.olat.modules.portfolio.model.BinderStatistics; @@ -136,6 +137,8 @@ public class TableOfContentController extends BasicController implements TooledC private UserManager userManager; @Autowired private PortfolioService portfolioService; + @Autowired + private PortfolioV2Module portfolioV2Module; public TableOfContentController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel, BinderSecurityCallback secCallback, Binder binder, BinderConfiguration config) { @@ -442,7 +445,7 @@ public class TableOfContentController extends BasicController implements TooledC pageRow.setOpenLink(openLink); Long numOfComments = numberOfCommentsMap.get(page.getKey()); - if(numOfComments != null && numOfComments.longValue() > 0) { + if(portfolioV2Module.isOverviewCommentsEnabled() && numOfComments != null && numOfComments.longValue() > 0) { Link commentLink = LinkFactory.createCustomLink("com_" + (++counter), "comments", "(" + numOfComments + ")", Link.LINK | Link.NONTRANSLATED, mainVC, this); commentLink.setDomReplacementWrapperRequired(false); commentLink.setIconLeftCSS("o_icon o_icon-fw o_icon_comments"); diff --git a/src/main/java/org/olat/modules/portfolio/ui/_content/my_pages.html b/src/main/java/org/olat/modules/portfolio/ui/_content/my_pages.html index 0bc50fa6999..71293f5663c 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/_content/my_pages.html +++ b/src/main/java/org/olat/modules/portfolio/ui/_content/my_pages.html @@ -1,11 +1,13 @@ <div class="o_portfolio_content clearfix"> <div class="o_header_with_buttons"> <h2>$r.translate("my.entries")</h2> + #if($r.available("timeline.switch.on") || $r.available("timeline.switch.off")) <div class="o_button_group"> $r.render("timeline.switch.off") $r.render("timeline.switch.on") $r.contextHelpWithWrapper("My entries") </div> + #end </div> <div class="o_portfolio_entries #if($timelineSwitch) o_portfolio_withtimeline #end"> diff --git a/src/main/java/org/olat/portfolio/ui/PortfolioAdminController.java b/src/main/java/org/olat/portfolio/ui/PortfolioAdminController.java index eda6f9c17fb..cabf030a3a3 100644 --- a/src/main/java/org/olat/portfolio/ui/PortfolioAdminController.java +++ b/src/main/java/org/olat/portfolio/ui/PortfolioAdminController.java @@ -20,7 +20,9 @@ package org.olat.portfolio.ui; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.olat.collaboration.CollaborationToolsFactory; import org.olat.core.gui.UserRequest; @@ -49,6 +51,43 @@ import org.springframework.beans.factory.annotation.Autowired; * @author: srosse */ public class PortfolioAdminController extends FormBasicController { + + private static final String BINDER_CREATE_LEARNER = "portfolio.user.can.create.binder"; + private static final String BINDER_CREATE_TEMPLATE = "portfolio.user.can.create.binder.template"; + private static final String BINDER_CREATE_COURSE = "portfolio.user.can.create.binder.course"; + private static final String[] BINDER_CREATE_KEYS = new String[] { + BINDER_CREATE_LEARNER, + BINDER_CREATE_TEMPLATE, + BINDER_CREATE_COURSE + }; + private static final String SECTION_OVERVIEW_ENABLED = "section.overview.enabled"; + private static final String SECTION_ENTRIES_ENABLED = "section.entries.enabled"; + private static final String SECTION_HISTORY_ENABLED = "section.history.enabled"; + private static final String[] SECTION_VISIBILITY_KEYS = new String[] { + SECTION_OVERVIEW_ENABLED, + SECTION_ENTRIES_ENABLED, + SECTION_HISTORY_ENABLED + }; + private static final String ENTRIES_SEARCH_ENABLED = "entries.search.enabled"; + private static final String ENTRIES_TIMELINE_ENABLED = "entries.timeline.enabled"; + private static final String[] ENTRIES_ELEMENTS_KEYS = new String[] { + ENTRIES_SEARCH_ENABLED, + ENTRIES_TIMELINE_ENABLED + }; + private static final String COMMENTS_OVERVIEW_ENABLED = "comments.overview.enabled"; + private static final String COMMENTS_ENTRIES_ENABLED = "comments.entries.enabled"; + private static final String[] COMMENTS_KEYS = new String[] { + COMMENTS_OVERVIEW_ENABLED, + COMMENTS_ENTRIES_ENABLED + }; + private static final String ENTRIES_BOTH_ENABLED = "entries.both.enabled"; + private static final String ENTRIES_LIST_ENABLED = "entries.list.enabled"; + private static final String ENTRIES_TABLE_ENABLED = "entries.table.enabled"; + private static final String[] ENTRIES_VIEW_KEYS = new String[] { + ENTRIES_TABLE_ENABLED, + ENTRIES_LIST_ENABLED, + ENTRIES_BOTH_ENABLED + }; private static String[] enabledKeys = new String[]{ "on" }; private static String[] enabledPortfolioKeys = new String[]{ "on", "legacy"}; @@ -56,9 +95,14 @@ public class PortfolioAdminController extends FormBasicController { private SingleSelection entryPointEl; private FormLayoutContainer wizardFlc; private MultipleSelectionElement portfoliosEnabled; - private MultipleSelectionElement canCreatePortfolioEnabled; + private MultipleSelectionElement createBinderEl; private final List<MultipleSelectionElement> handlersEnabled = new ArrayList<>(); - private MultipleSelectionElement copyrightStepCB, reflexionStepCB; + private MultipleSelectionElement copyrightStepCB; + private MultipleSelectionElement reflexionStepCB; + private MultipleSelectionElement sectionVisibilityEl; + private MultipleSelectionElement entryElementsVisibilityEl; + private MultipleSelectionElement commentsVisibilityEl; + private SingleSelection entriesViewEl; @Autowired private PortfolioModule portfolioModule; @@ -88,30 +132,14 @@ public class PortfolioAdminController extends FormBasicController { } portfoliosEnabled.addActionListener(FormEvent.ONCHANGE); - String[] createBinderKeys = new String[]{ "learner", "template", "course" }; - String[] createBinderValues = new String[] { - translate("portfolio.user.can.create.binder"), - translate("portfolio.user.can.create.binder.template"), - translate("portfolio.user.can.create.binder.course") - }; - canCreatePortfolioEnabled = uifactory.addCheckboxesVertical("portfolio.user.create.binder", moduleFlc, createBinderKeys, createBinderValues, 1); - if(portfolioV2Module.isLearnerCanCreateBinders()) { - canCreatePortfolioEnabled.select(createBinderKeys[0], portfolioV2Module.isLearnerCanCreateBinders()); - } - if(portfolioV2Module.isCanCreateBindersFromTemplate()) { - canCreatePortfolioEnabled.select(createBinderKeys[1], portfolioV2Module.isCanCreateBindersFromTemplate()); - } - if(portfolioV2Module.isCanCreateBindersFromCourse()) { - canCreatePortfolioEnabled.select(createBinderKeys[2], portfolioV2Module.isCanCreateBindersFromCourse()); - } - canCreatePortfolioEnabled.addActionListener(FormEvent.ONCHANGE); - canCreatePortfolioEnabled.setVisible(portfolioV2Module.isEnabled()); + createBinderEl = uifactory.addCheckboxesVertical("portfolio.user.create.binder", moduleFlc, BINDER_CREATE_KEYS, + translateKeys(BINDER_CREATE_KEYS), 1); + createBinderEl.addActionListener(FormEvent.ONCHANGE); String[] entryPointKeys = new String[] { PortfolioV2Module.ENTRY_POINT_TOC, PortfolioV2Module.ENTRY_POINT_ENTRIES }; String[] entryPointValues = new String[]{ translate("binder.entry.point.toc"), translate("binder.entry.point.entries") }; entryPointEl = uifactory.addDropdownSingleselect("binder.entry.point", "binder.entry.point", moduleFlc, entryPointKeys, entryPointValues, null); entryPointEl.addActionListener(FormEvent.ONCHANGE); - entryPointEl.setVisible(portfolioV2Module.isEnabled()); String entryPoint = portfolioV2Module.getBinderEntryPoint(); for(String entryPointKey:entryPointKeys) { if(entryPointKey.equals(entryPoint)) { @@ -122,6 +150,29 @@ public class PortfolioAdminController extends FormBasicController { entryPointEl.select(entryPointKeys[0], true); } + sectionVisibilityEl = uifactory.addCheckboxesVertical("section.enabled", moduleFlc, SECTION_VISIBILITY_KEYS, + translateKeys(SECTION_VISIBILITY_KEYS), 1); + sectionVisibilityEl.addActionListener(FormEvent.ONCHANGE); + + entryElementsVisibilityEl = uifactory.addCheckboxesVertical("entries.elements.enabled", moduleFlc, + ENTRIES_ELEMENTS_KEYS, translateKeys(ENTRIES_ELEMENTS_KEYS), 1); + entryElementsVisibilityEl.addActionListener(FormEvent.ONCHANGE); + + commentsVisibilityEl = uifactory.addCheckboxesVertical("comments.enabled", moduleFlc, COMMENTS_KEYS, + translateKeys(COMMENTS_KEYS), 1); + commentsVisibilityEl.addActionListener(FormEvent.ONCHANGE); + + entriesViewEl = uifactory.addDropdownSingleselect("entries.view", moduleFlc, ENTRIES_VIEW_KEYS, + translateKeys(ENTRIES_VIEW_KEYS)); + String selectedKey = ENTRIES_BOTH_ENABLED; + if (portfolioV2Module.isEntriesTableEnabled() && !portfolioV2Module.isEntriesListEnabled()) { + selectedKey = ENTRIES_TABLE_ENABLED; + } else if (!portfolioV2Module.isEntriesTableEnabled() && portfolioV2Module.isEntriesListEnabled()) { + selectedKey = ENTRIES_LIST_ENABLED; + } + entriesViewEl.select(selectedKey, true); + entriesViewEl.addActionListener(FormEvent.ONCHANGE); + //handlers configuration FormLayoutContainer handlersFlc = FormLayoutContainer.createDefaultFormLayout("flc_handlers", getTranslator()); formLayout.add(handlersFlc); @@ -149,6 +200,36 @@ public class PortfolioAdminController extends FormBasicController { reflexionStepCB.select(enabledKeys[0], portfolioModule.isReflexionStepEnabled()); reflexionStepCB.addActionListener(FormEvent.ONCHANGE); wizardFlc.setVisible(portfoliosEnabled.isSelected(1)); + + updateV2UI(); + } + + private void updateV2UI() { + boolean enabled = portfolioV2Module.isEnabled(); + entryPointEl.setVisible(enabled); + createBinderEl.setVisible(enabled); + sectionVisibilityEl.setVisible(enabled); + entryElementsVisibilityEl.setVisible(enabled); + commentsVisibilityEl.setVisible(enabled); + entriesViewEl.setVisible(enabled); + if (enabled) { + createBinderEl.select(BINDER_CREATE_LEARNER, portfolioV2Module.isLearnerCanCreateBinders()); + createBinderEl.select(BINDER_CREATE_TEMPLATE, portfolioV2Module.isCanCreateBindersFromTemplate()); + createBinderEl.select(BINDER_CREATE_COURSE, portfolioV2Module.isCanCreateBindersFromCourse()); + sectionVisibilityEl.select(SECTION_OVERVIEW_ENABLED, portfolioV2Module.isOverviewEnabled()); + sectionVisibilityEl.select(SECTION_ENTRIES_ENABLED, portfolioV2Module.isEntriesEnabled()); + sectionVisibilityEl.select(SECTION_HISTORY_ENABLED, portfolioV2Module.isHistoryEnabled()); + entryElementsVisibilityEl.select(ENTRIES_SEARCH_ENABLED, portfolioV2Module.isEntriesSearchEnabled()); + entryElementsVisibilityEl.select(ENTRIES_TIMELINE_ENABLED, portfolioV2Module.isEntriesTimelineEnabled()); + commentsVisibilityEl.select(COMMENTS_OVERVIEW_ENABLED, portfolioV2Module.isOverviewCommentsEnabled()); + commentsVisibilityEl.select(COMMENTS_ENTRIES_ENABLED, portfolioV2Module.isEntriesCommentsEnabled()); + } + } + + private String[] translateKeys(String[] keys) { + return Stream.of(keys) + .map(key -> getTranslator().translate(key)) + .toArray(String[]::new); } @Override @@ -176,36 +257,92 @@ public class PortfolioAdminController extends FormBasicController { // update collaboration tools list wizardFlc.setVisible(portfoliosEnabled.isSelected(1)); - entryPointEl.setVisible(portfolioV2Module.isEnabled()); - canCreatePortfolioEnabled.setVisible(portfolioV2Module.isEnabled()); + updateV2UI(); CollaborationToolsFactory.getInstance().initAvailableTools(); - showInfo("save.admin.settings"); } else if(handlersEnabled.contains(source)) { EPArtefactHandler<?> handler = (EPArtefactHandler<?>)source.getUserObject(); boolean enabled = ((MultipleSelectionElement)source).isSelected(0); portfolioModule.setEnableArtefactHandler(handler, enabled); - showInfo("save.admin.settings"); } else if(source == reflexionStepCB){ boolean enabled = reflexionStepCB.isSelected(0); portfolioModule.setReflexionStepEnabled(enabled); - showInfo("save.admin.settings"); } else if(source == copyrightStepCB){ boolean enabled = copyrightStepCB.isSelected(0); portfolioModule.setCopyrightStepEnabled(enabled); - showInfo("save.admin.settings"); - } else if(canCreatePortfolioEnabled == source) { - boolean enabled = canCreatePortfolioEnabled.isSelected(0); - portfolioV2Module.setLearnerCanCreateBinders(enabled); - boolean enabledTemplate = canCreatePortfolioEnabled.isSelected(1); - portfolioV2Module.setCanCreateBindersFromTemplate(enabledTemplate); - boolean enabledCourse = canCreatePortfolioEnabled.isSelected(2); - portfolioV2Module.setCanCreateBindersFromCourse(enabledCourse); - showInfo("save.admin.settings"); + } else if(createBinderEl == source) { + Collection<String> selectedCreateBinder = createBinderEl.getSelectedKeys(); + boolean learnerCanCreateBinders = selectedCreateBinder.contains(BINDER_CREATE_LEARNER); + portfolioV2Module.setLearnerCanCreateBinders(learnerCanCreateBinders); + boolean canCreateBindersFromTemplate = selectedCreateBinder.contains(BINDER_CREATE_TEMPLATE); + portfolioV2Module.setCanCreateBindersFromTemplate(canCreateBindersFromTemplate); + boolean canCreateBindersFromCourse = selectedCreateBinder.contains(BINDER_CREATE_COURSE); + portfolioV2Module.setCanCreateBindersFromCourse(canCreateBindersFromCourse); } else if(entryPointEl == source) { if(entryPointEl.isOneSelected()) { - portfolioV2Module.setBinderEntryPoint(entryPointEl.getSelectedKey()); - showInfo("save.admin.settings"); + String selectedKey = entryPointEl.getSelectedKey(); + if (validateEntryPoint(selectedKey)) { + portfolioV2Module.setBinderEntryPoint(selectedKey); + } + } + } else if (sectionVisibilityEl == source) { + Collection<String> selectedSectionVisibility = sectionVisibilityEl.getSelectedKeys(); + boolean historyEnabled = selectedSectionVisibility.contains(SECTION_HISTORY_ENABLED); + portfolioV2Module.setHistoryEnabled(historyEnabled); + boolean overviewEnabled = selectedSectionVisibility.contains(SECTION_OVERVIEW_ENABLED); + boolean entriesEnabled = selectedSectionVisibility.contains(SECTION_ENTRIES_ENABLED); + if (validateSectionVisibility(overviewEnabled, entriesEnabled) ) { + portfolioV2Module.setOverviewEnabled(overviewEnabled); + portfolioV2Module.setEntriesEnabled(entriesEnabled); + } + } else if (entryElementsVisibilityEl == source) { + Collection<String> selectedElementsVisibility = entryElementsVisibilityEl.getSelectedKeys(); + boolean entiresSearchEnabled = selectedElementsVisibility.contains(ENTRIES_SEARCH_ENABLED); + portfolioV2Module.setEntriesSearchEnabled(entiresSearchEnabled); + boolean entriesTimelineEnabled = selectedElementsVisibility.contains(ENTRIES_TIMELINE_ENABLED); + portfolioV2Module.setEntriesTimelineEnabled(entriesTimelineEnabled); + } else if (commentsVisibilityEl == source) { + Collection<String> selectedCommentsVisibilty = commentsVisibilityEl.getSelectedKeys(); + boolean overviewCommentsEnabled = selectedCommentsVisibilty.contains(COMMENTS_OVERVIEW_ENABLED); + portfolioV2Module.setOverviewCommentsEnabled(overviewCommentsEnabled); + boolean entriesCommentsEnabled = selectedCommentsVisibilty.contains(COMMENTS_ENTRIES_ENABLED); + portfolioV2Module.setEntriesCommentsEnabled(entriesCommentsEnabled); + } else if(entriesViewEl == source && entriesViewEl.isOneSelected()) { + String selectedKey = entriesViewEl.getSelectedKey(); + boolean entriesTableEnabled = true; + boolean entriesListEnabled = true; + if (ENTRIES_TABLE_ENABLED.equals(selectedKey)) { + entriesListEnabled = false; + } else if (ENTRIES_LIST_ENABLED.equals(selectedKey)) { + entriesTableEnabled = false; } + portfolioV2Module.setEntriesTableEnabled(entriesTableEnabled); + portfolioV2Module.setEntriesListEnabled(entriesListEnabled); + } + } + + private boolean validateEntryPoint(String selectedKey) { + if (PortfolioV2Module.ENTRY_POINT_TOC.equals(selectedKey) && !portfolioV2Module.isOverviewEnabled()) { + entryPointEl.select(PortfolioV2Module.ENTRY_POINT_ENTRIES, true); + showWarning("binder.entry.point.not.available"); + return false; + } else if (PortfolioV2Module.ENTRY_POINT_ENTRIES.equals(selectedKey) && !portfolioV2Module.isEntriesEnabled()) { + entryPointEl.select(PortfolioV2Module.ENTRY_POINT_TOC, true); + showWarning("binder.entry.point.not.available"); + return false; + } + return true; + } + + private boolean validateSectionVisibility(boolean overviewEnabled, boolean entriesEnabled) { + if (!overviewEnabled && entryPointEl.isOneSelected() && PortfolioV2Module.ENTRY_POINT_TOC.equals(entryPointEl.getSelectedKey())) { + sectionVisibilityEl.select(SECTION_OVERVIEW_ENABLED, true); + showWarning("section.disable.not.allowed"); + return false; + } else if (!entriesEnabled && entryPointEl.isOneSelected() && PortfolioV2Module.ENTRY_POINT_ENTRIES.equals(entryPointEl.getSelectedKey())) { + sectionVisibilityEl.select(SECTION_ENTRIES_ENABLED, true); + showWarning("section.disable.not.allowed"); + return false; } + return true; } } diff --git a/src/main/java/org/olat/portfolio/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/portfolio/ui/_i18n/LocalStrings_de.properties index b50130268d6..5ef4959459a 100644 --- a/src/main/java/org/olat/portfolio/ui/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/portfolio/ui/_i18n/LocalStrings_de.properties @@ -2,17 +2,28 @@ EPStructuredMapTemplate=Portfoliovorlage admin.menu.title=ePortfolio admin.menu.title.alt=ePortfolio konfigurieren +binder.entry.point.not.available=Dieser Reiter ist deaktiviert. Bitte aktivieren Sie zuerst den Reiter, bevor Sie ihn als Ankunft in der Mappe ausw\u00e4len. binder.entry.point=Ankunft in Mappe binder.entry.point.entries=Eintr\u00E4ge binder.entry.point.toc=\u00DCberblick choose.artefact.intro=W\u00E4hlen Sie das Artefakt, welches Ihrer Sammelmappe hinzugef\u00FCgt werden soll oder f\u00FCgen Sie ein Neues hinzu. choose.artefact.intro.v2=W\u00E4hlen Sie aus welche Artefakte Sie vom alten Portfoliowerkzeug in das neue Portfoliomanagement importieren wollen. +comments.enabled=Kommentare sichtbar in +comments.entries.enabled=$org.olat.modules.portfolio.ui\:portfolio.entries +comments.overview.enabled=$org.olat.modules.portfolio.ui\:portfolio.overview create.map=Mappe erstellen create.map.default=Sammelmappe erstellen create.map.fromTemplate=Mappe aus Vorlage erstellen create.map.intro=W\u00E4hlen Sie die Art von Sammelmappe, welche Sie erstellen m\u00F6chten. create.map.selectTemplate=Vorlage ausw\u00E4hlen enabled=Ein +entries.both.enabled=Tabellenansicht und Listenansicht +entries.elements.enabled=Sichtbare Elemente +entries.list.enabled=Listenansicht +entries.search.enabled=Suche +entries.table.enabled=Tabellenansicht +entries.timeline.enabled=Zeitstrahl +entries.view=Ansicht der Eintr\u00E4ge eportfolio.menu.title=ePortfolio 1.0 eportfolio.menu.title.alt=ePortfolio mit Artefakten und Sammelmappen handlers.intro=W\u00E4hlen Sie die verf\u00FCgbaren Artefakt-Typen. Ausgeschaltete Artefakte werden angezeigt, k\u00F6nnen aber nicht mehr gesammelt werden. @@ -44,6 +55,11 @@ portfolio.user.can.create.binder.course=Lernende d\u00FCrfen Mappe von Kurse ers portfolio.user.can.create.binder.template=Lernende d\u00FCrfen Mappe von Vorlage erstellen portfolio.user.create.binder=Mappe erstellen portfolio.v1.module.enabled=Altes ePortfolio v1 w\u00E4hrend \u00DCbergangszeit aktivieren +section.enabled=Sichtbare Reiter +section.disable.not.allowed=Der Reiter, der f\u00fcr die Ankunft in der Mappe vorgesehen ist, kann nicht deaktiviert werden! +section.entries.enabled=$org.olat.modules.portfolio.ui\:portfolio.entries +section.history.enabled=$org.olat.modules.portfolio.ui\:portfolio.history +section.overview.enabled=$org.olat.modules.portfolio.ui\:portfolio.overview site.title=$\:admin.menu.title site.title.alt=$\:admin.menu.title view.mode=Ansicht\: diff --git a/src/main/java/org/olat/portfolio/ui/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/portfolio/ui/_i18n/LocalStrings_en.properties index d79e8915621..eed6d1c903d 100644 --- a/src/main/java/org/olat/portfolio/ui/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/portfolio/ui/_i18n/LocalStrings_en.properties @@ -2,17 +2,29 @@ EPStructuredMapTemplate=Portfolio template admin.menu.title=ePortfolio admin.menu.title.alt=Configure ePortfolio -binder.entry.point=landing point in binder +binder.entry.point.not.available=This section is deactivated. Please activate the section before using it as landing page. +binder.entry.point=Ankunft in Mappe +binder.entry.point=Landing point in binder binder.entry.point.entries=Entries binder.entry.point.toc=Overview choose.artefact.intro=Please select an artefact to be added to your binder. You could also create a new one. choose.artefact.intro.v2=Select the artefacts you wish to import from the old portfolio module into the new portfolio management. +comments.enabled=Comments visible in +comments.entries.enabled=$org.olat.modules.portfolio.ui\:portfolio.entries +comments.overview.enabled=$org.olat.modules.portfolio.ui\:portfolio.overview create.map=Create folder create.map.default=Create binder create.map.fromTemplate=Create folder from template create.map.intro=Please select the type of binder to be created create.map.selectTemplate=Select template enabled=Enabled +entries.both.enabled=Table and List +entries.elements.enabled=Visible elements +entries.list.enabled=List +entries.search.enabled=Search +entries.table.enabled=Table +entries.timeline.enabled=Timeline +entries.view=View if the entries eportfolio.menu.title=ePortfolio 1.0 eportfolio.menu.title.alt=ePortfolio along with artefacts and binders handlers.intro=Please select all available artefact types. Deactivated artefacts will be displayed; however, you can no longer collect them. @@ -44,6 +56,11 @@ portfolio.user.can.create.binder.course=Learner are allowed to create binders fr portfolio.user.can.create.binder.template=Learner are allowed to create binders from a template portfolio.user.create.binder=Create binders portfolio.v1.module.enabled=Enable legacy ePortfolio v1 during transition period +section.enabled=Visible sections +section.disable.not.allowed=This section cannot be deactivated. It is selected as the landing page! +section.entries.enabled=$org.olat.modules.portfolio.ui\:portfolio.entries +section.history.enabled=$org.olat.modules.portfolio.ui\:portfolio.history +section.overview.enabled=$org.olat.modules.portfolio.ui\:portfolio.overview site.title=$\:admin.menu.title site.title.alt=$\:admin.menu.title view.mode=View\: -- GitLab