Skip to content
Snippets Groups Projects
Commit c1d15e47 authored by gnaegi's avatar gnaegi
Browse files

OO-2395 update title in breadcrumb and nav when changed

parent abc7ff30
No related branches found
No related tags found
No related merge requests found
...@@ -1198,6 +1198,23 @@ public class BaseFullWebappController extends BasicController implements DTabs, ...@@ -1198,6 +1198,23 @@ public class BaseFullWebappController extends BasicController implements DTabs,
return true; return true;
} }
@Override
public void updateDTabTitle(OLATResourceable ores, String newTitle) {
DTab dTab = getDTab(ores);
if (dTab != null) {
dTab.getNavElement().setTitle(newTitle);
// search all dtab links and find the one with the correct dtab as user object
for (int i = 0; i <= dtabCreateCounter; i++) {
Link link = (Link)navTabsVc.getComponent("a" + i);
if (link != null && dTab.equals(link.getUserObject())) {
// correct link found - updte titel and we are done
link.setCustomDisplayText(newTitle);
return;
}
}
}
}
/** /**
* Activating a tab is like focusing a new window - we need to adjust the * Activating a tab is like focusing a new window - we need to adjust the
* guipath since e.g. the button triggering the activation is not * guipath since e.g. the button triggering the activation is not
......
...@@ -80,6 +80,13 @@ public interface DTabs { ...@@ -80,6 +80,13 @@ public interface DTabs {
*/ */
public boolean addDTab(UserRequest ureq, DTab dt); public boolean addDTab(UserRequest ureq, DTab dt);
/**
* Update the title of an already instantiated tab. Use rarely
* @param ores
* @param newTitle
*/
public void updateDTabTitle(OLATResourceable ores, String newTitle);
/** /**
* Remove a tab from tabs-list. * Remove a tab from tabs-list.
* @param dt Remove this tab * @param dt Remove this tab
......
...@@ -43,7 +43,14 @@ public interface NavElement { ...@@ -43,7 +43,14 @@ public interface NavElement {
* @return * @return
*/ */
public String getTitle(); public String getTitle();
/**
* Set a new title for the navigation, e.g. when a resource has been renamed
*
* @param title
*/
public void setTitle(String title);
/**[used by velocity] /**[used by velocity]
* @return * @return
*/ */
......
...@@ -572,8 +572,21 @@ public class RepositoryEntryRuntimeController extends MainLayoutBasicController ...@@ -572,8 +572,21 @@ public class RepositoryEntryRuntimeController extends MainLayoutBasicController
} }
} else if(descriptionCtrl == source) { } else if(descriptionCtrl == source) {
if(event == Event.CHANGED_EVENT) { if(event == Event.CHANGED_EVENT) {
refreshRepositoryEntry(descriptionCtrl.getEntry()); RepositoryEntry entry = descriptionCtrl.getEntry();
handler.onDescriptionChanged(descriptionCtrl.getEntry()); refreshRepositoryEntry(entry);
handler.onDescriptionChanged(entry);
// update name of root bread crumb and opened tabs in top nav in case the title has been modified
if (toolbarPanel.getBreadCrumbs().size() > 0) {
String newTitle = entry.getDisplayname();
String oldTitle = toolbarPanel.getBreadCrumbs().get(0).getCustomDisplayText();
if (!newTitle.equals(oldTitle)) {
// 1: update breadcrumb in toolbar
toolbarPanel.getBreadCrumbs().get(0).setCustomDisplayText(newTitle);
// 2: update dynamic tab in topnav
OLATResourceable reOres = OresHelper.clone(entry);
getWindowControl().getWindowBackOffice().getWindow().getDTabs().updateDTabTitle(reOres, newTitle);
}
}
} else if(event == Event.CLOSE_EVENT) { } else if(event == Event.CLOSE_EVENT) {
doClose(ureq); doClose(ureq);
} }
......
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