Skip to content
Snippets Groups Projects
Commit b865361e authored by srosse's avatar srosse
Browse files

OO-964: implements the business path in the 2 catalog sites (in my courses and...

OO-964: implements the business path in the 2 catalog sites (in my courses and in the independent site)
parent a6112636
No related branches found
No related tags found
No related merge requests found
......@@ -44,17 +44,18 @@ import org.olat.repository.ui.list.CatalogNodeController;
public class CatalogSiteMainController extends BasicController implements Activateable2 {
private CatalogNodeController nodeController;
private final BreadcrumbedStackedPanel stackPanel;
public CatalogSiteMainController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl);
BreadcrumbedStackedPanel stackPanel = new BreadcrumbedStackedPanel("catstack", getTranslator(), this);
stackPanel = new BreadcrumbedStackedPanel("catstack", getTranslator(), this);
putInitialPanel(stackPanel);
CatalogManager catalogManager = CoreSpringFactory.getImpl(CatalogManager.class);
List<CatalogEntry> rootNodes = catalogManager.getRootCatalogEntries();
if(rootNodes.size() == 1) {
nodeController = new CatalogNodeController(ureq, getWindowControl(), rootNodes.get(0), stackPanel, true);
nodeController = new CatalogNodeController(ureq, getWindowControl(), getWindowControl(), rootNodes.get(0), stackPanel, true);
}
stackPanel.pushController("Katalog", nodeController);
}
......@@ -71,6 +72,11 @@ public class CatalogSiteMainController extends BasicController implements Activa
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
//
if(entries == null || entries.isEmpty()) {
return;
}
stackPanel.popUpToRootController(ureq);
nodeController.activate(ureq, entries, state);
}
}
......@@ -21,7 +21,6 @@ package org.olat.repository.site;
import java.util.Locale;
import org.olat.catalog.CatalogEntry;
import org.olat.catalog.ui.CatalogSiteMainController;
import org.olat.core.commons.chiefcontrollers.BaseChiefController;
import org.olat.core.gui.UserRequest;
......@@ -69,7 +68,7 @@ public class CatalogSite extends AbstractSiteInstance {
@Override
protected Controller createController(UserRequest ureq, WindowControl wControl, SiteConfiguration config) {
// for existing controller which are part of the main olat -> use the controllerfactory
OLATResourceable ores = OresHelper.createOLATResourceableInstance(CatalogEntry.class, 0l);
OLATResourceable ores = OresHelper.createOLATResourceableInstance("Catalog", 0l);
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, ores, new StateSite(this), wControl, true);
return new CatalogSiteMainController(ureq, bwControl);
......
......@@ -37,14 +37,20 @@ import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.gui.control.generic.dtabs.Activateable2;
import org.olat.core.id.OLATResourceable;
import org.olat.core.id.context.BusinessControlFactory;
import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.StateEntry;
import org.olat.core.logging.activity.ThreadLocalUserActivityLogger;
import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.core.util.resource.OresHelper;
import org.olat.core.util.vfs.VFSLeaf;
import org.olat.repository.RepositoryManager;
import org.olat.repository.model.SearchMyRepositoryEntryViewParams;
import org.olat.repository.ui.CatalogEntryImageMapper;
import org.olat.util.logging.activity.LoggingResourceable;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
......@@ -58,17 +64,20 @@ public class CatalogNodeController extends BasicController implements Activateab
private BreadcrumbedStackedPanel stackPanel;
private RepositoryEntryListController entryListController;
private final CatalogManager cm;
private final boolean wrapInMainPanel;
private final String mapperThumbnailUrl;
private final WindowControl rootwControl;
public CatalogNodeController(UserRequest ureq, WindowControl wControl, CatalogEntry catalogEntry,
BreadcrumbedStackedPanel stackPanel, boolean wrapInMainPanel) {
@Autowired
private CatalogManager catalogManager;
public CatalogNodeController(UserRequest ureq, WindowControl wControl, WindowControl rootwControl,
CatalogEntry catalogEntry, BreadcrumbedStackedPanel stackPanel, boolean wrapInMainPanel) {
// fallback translator to repository package to reduce redundant translations
super(ureq, wControl, Util.createPackageTranslator(RepositoryManager.class, ureq.getLocale()));
cm = CatalogManager.getInstance();
this.stackPanel = stackPanel;
this.rootwControl = rootwControl;
this.wrapInMainPanel = wrapInMainPanel;
VelocityContainer mainVC = createVelocityContainer("node");
......@@ -89,12 +98,12 @@ public class CatalogNodeController extends BasicController implements Activateab
if(StringHelper.containsNonWhitespace(catalogEntry.getDescription())) {
mainVC.contextPut("catalogEntryDesc", catalogEntry.getDescription());
}
VFSLeaf image = cm.getImage(catalogEntry);
VFSLeaf image = catalogManager.getImage(catalogEntry);
if(image != null) {
mainVC.contextPut("catThumbnail", catalogEntry.getKey());
}
List<CatalogEntry> childCe = cm.getNodesChildrenOf(catalogEntry);
List<CatalogEntry> childCe = catalogManager.getNodesChildrenOf(catalogEntry);
Collections.sort(childCe, new CatalogEntryComparator(getLocale()));
List<String> subCategories = new ArrayList<>();
int count = 0;
......@@ -102,7 +111,7 @@ public class CatalogNodeController extends BasicController implements Activateab
if(entry.getType() == CatalogEntry.TYPE_NODE) {
String cmpId = "cat_" + (++count);
VFSLeaf img = cm.getImage(entry);
VFSLeaf img = catalogManager.getImage(entry);
if(img != null) {
String imgId = "image_" + count;
mainVC.contextPut(imgId, entry.getKey());
......@@ -142,17 +151,29 @@ public class CatalogNodeController extends BasicController implements Activateab
Link link = (Link)source;
if("select_node".equals(link.getCommand())) {
Long categoryNodeKey = (Long)link.getUserObject();
CatalogEntry entry = cm.getCatalogNodeByKey(categoryNodeKey);
if(entry != null && entry.getType() == CatalogEntry.TYPE_NODE) {
removeAsListenerAndDispose(childNodeController);
childNodeController = new CatalogNodeController(ureq, getWindowControl(), entry, stackPanel, wrapInMainPanel);
listenTo(childNodeController);
stackPanel.pushController(entry.getName(), childNodeController);
}
CatalogEntry entry = catalogManager.getCatalogNodeByKey(categoryNodeKey);
selectCatalogEntry(ureq, entry);
}
}
}
private CatalogNodeController selectCatalogEntry(UserRequest ureq, CatalogEntry entry) {
if(entry != null && entry.getType() == CatalogEntry.TYPE_NODE) {
removeAsListenerAndDispose(childNodeController);
OLATResourceable ores = OresHelper.createOLATResourceableInstance("CatalogEntry", entry.getKey());
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, rootwControl);
childNodeController = new CatalogNodeController(ureq, bwControl, rootwControl, entry, stackPanel, wrapInMainPanel);
listenTo(childNodeController);
stackPanel.pushController(entry.getName(), childNodeController);
addToHistory(ureq, childNodeController);
}
return childNodeController;
}
@Override
protected void doDispose() {
//
......@@ -160,7 +181,64 @@ public class CatalogNodeController extends BasicController implements Activateab
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if(entries == null || entries.isEmpty()) return;
if(entries == null || entries.isEmpty()) {
return;
}
ContextEntry entry = entries.get(0);
String type = entry.getOLATResourceable().getResourceableTypeName();
if("CatalogEntry".equalsIgnoreCase(type)) {
Long entryKey = entry.getOLATResourceable().getResourceableId();
if(entryKey != null && entryKey.longValue() > 0) {
activateRoot(ureq, entryKey);
}
} else if("Node".equalsIgnoreCase(type)) {
//the "Node" is only for internal usage
StateEntry stateEntry = entry.getTransientState();
if(stateEntry instanceof CatalogStateEntry) {
CatalogEntry catalogEntry = ((CatalogStateEntry)stateEntry).entry;
CatalogNodeController nextCtrl = selectCatalogEntry(ureq, catalogEntry);
if(nextCtrl != null && entries.size() > 1) {
nextCtrl.activate(ureq, entries.subList(1, entries.size()), null);
}
}
}
}
/**
* Build an internal business path made of "Node" with the category
* as state entry to prevent loading several times the same entries.
*
* @param ureq
* @param entryKey
*/
private void activateRoot(UserRequest ureq, Long entryKey) {
List<ContextEntry> parentLine = new ArrayList<>();
for(CatalogEntry node = catalogManager.getCatalogEntryByKey(entryKey); node.getParent() != null; node=node.getParent()) {
OLATResourceable nodeRes = OresHelper.createOLATResourceableInstance("Node", node.getKey());
ContextEntry ctxEntry = BusinessControlFactory.getInstance().createContextEntry(nodeRes);
ctxEntry.setTransientState(new CatalogStateEntry(node));
parentLine.add(ctxEntry);
}
Collections.reverse(parentLine);
activate(ureq, parentLine, null);
}
//only for internal usage
public static class CatalogStateEntry implements StateEntry {
private static final long serialVersionUID = -5592837683379007704L;
private CatalogEntry entry;
public CatalogStateEntry(CatalogEntry entry) {
this.entry = entry;
}
@Override
public CatalogStateEntry clone() {
CatalogStateEntry clone = new CatalogStateEntry(entry);
return clone;
}
}
}
\ No newline at end of file
......@@ -122,19 +122,20 @@ public class OverviewRepositoryListController extends BasicController implements
ContextEntry entry = entries.get(0);
String segment = entry.getOLATResourceable().getResourceableTypeName();
List<ContextEntry> subEntries = entries.subList(1, entries.size());
if("Favorits".equals(segment)) {
if("Favorits".equalsIgnoreCase(segment)) {
doOpenMark(ureq).activate(ureq, subEntries, entry.getTransientState());
segmentView.select(favoriteLink);
} else if("My".equals(segment)) {
} else if("My".equalsIgnoreCase(segment)) {
doOpenMyCourses(ureq).activate(ureq, subEntries, entry.getTransientState());
segmentView.select(myCourseLink);
} else if("Catalog".equals(segment) && catalogLink != null) {
} else if(("Catalog".equalsIgnoreCase(segment) || "CatalogEntry".equalsIgnoreCase(segment))
&& catalogLink != null) {
CatalogNodeController ctrl = doOpenCatalog(ureq);
if(ctrl != null) {
ctrl.activate(ureq, subEntries, entry.getTransientState());
ctrl.activate(ureq, entries, entry.getTransientState());
segmentView.select(catalogLink);
}
} else if("Search".equals(segment) && searchCourseLink != null) {
} else if("Search".equalsIgnoreCase(segment) && searchCourseLink != null) {
doOpenSearchCourses(ureq);
segmentView.select(searchCourseLink);
} else {
......@@ -238,7 +239,7 @@ public class OverviewRepositoryListController extends BasicController implements
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, getWindowControl());
catalogStackPanel = new BreadcrumbedStackedPanel("catstack", getTranslator(), this);
catalogCtrl = new CatalogNodeController(ureq, bwControl, rootEntry, catalogStackPanel, false);
catalogCtrl = new CatalogNodeController(ureq, bwControl, getWindowControl(), rootEntry, catalogStackPanel, false);
catalogStackPanel.pushController(translate("search.catalog"), catalogCtrl);
listenTo(catalogCtrl);
......
......@@ -88,7 +88,7 @@
bottom: 0;
right: floor($grid-gutter-width / 2);
text-align: center;
z-index: 5;
z-index: 3;
@extend %o_undecorated;
}
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment