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

OO-984: update the number of comments in the details view, in create file of...

OO-984: update the number of comments in the details view, in create file of folder, no extension is html per default
parent e951a2f1
No related branches found
No related tags found
No related merge requests found
......@@ -229,10 +229,10 @@ public class CmdCreateFile extends FormBasicController implements FolderCommand
isInputValid = false;
return isInputValid;
} else if (!fileName.endsWith(".html") && !fileName.endsWith(".htm") && !fileName.endsWith(".txt") && !fileName.endsWith(".css")) {
//add html extension if missing
//add html extension if missing
fileName = fileName + ".html";
}
//ok, file name is sanitized, let's see if a file with this name already exists
//ok, file name is sanitized, let's see if a file with this name already exists
VFSContainer currentContainer = folderComponent.getCurrentContainer();
VFSItem item = currentContainer.resolve(fileName);
if (item != null) {
......@@ -240,6 +240,7 @@ public class CmdCreateFile extends FormBasicController implements FolderCommand
isInputValid = false;
} else {
isInputValid = true;
textElement.setValue(fileName);
}
}
return isInputValid;
......
......@@ -113,6 +113,10 @@ public class UserCommentsController extends BasicController {
public void setUserObject(Object userObject) {
this.userObject = userObject;
}
public int getNumOfComments() {
return commentControllers == null ? 0 : commentControllers.size();
}
/**
* @see org.olat.core.gui.control.DefaultController#doDispose()
......
......@@ -451,15 +451,26 @@ public class RepositoryEntryDetailsController extends FormBasicController {
protected void event(UserRequest ureq, Controller source, Event event) {
if(commentsCtrl == source) {
if(event == Event.CANCELLED_EVENT) {
updateComments(commentsCtrl.getNumOfComments());
cmc.deactivate();
cleanUp();
}
} else if(cmc == source) {
if(commentsCtrl != null) {
updateComments(commentsCtrl.getNumOfComments());
}
cleanUp();
}
super.event(ureq, source, event);
}
private void updateComments(int numOfComments) {
String title = "(" + numOfComments + ")";
commentsLink.setI18nKey(title);
String css = numOfComments > 0 ? "o_icon o_icon_comments o_icon-lg" : "o_icon o_icon_comments_none o_icon-lg";
commentsLink.setIconLeftCSS(css);
}
private void cleanUp() {
removeAsListenerAndDispose(commentsCtrl);
removeAsListenerAndDispose(cmc);
......
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