Skip to content
Snippets Groups Projects
Commit 4bc90983 authored by fkiefer's avatar fkiefer
Browse files

OO-2581 make course search icon in course toolbar respond immediately after switch

parent 44b2922a
No related branches found
No related tags found
No related merge requests found
......@@ -82,6 +82,7 @@ public enum ActionObject {
resource,
rights,
rightsempty,
search,
sharedfolder,
spgetfile,
statistic,
......
......@@ -86,6 +86,10 @@ public class LearningResourceLoggingAction extends BaseLoggingAction {
new LearningResourceLoggingAction(ActionType.admin, CrudAction.update, ActionVerb.add, ActionObject.chat).setTypeList(LEARNING_RESOURCE_OPEN_CLOSE_LIST);
public static final ILoggingAction REPOSITORY_ENTRY_PROPERTIES_IM_DISABLED =
new LearningResourceLoggingAction(ActionType.admin, CrudAction.update, ActionVerb.remove, ActionObject.chat).setTypeList(LEARNING_RESOURCE_OPEN_CLOSE_LIST);
public static final ILoggingAction REPOSITORY_ENTRY_PROPERTIES_COURSESEARCH_ENABLED =
new LearningResourceLoggingAction(ActionType.admin, CrudAction.update, ActionVerb.add, ActionObject.search).setTypeList(LEARNING_RESOURCE_OPEN_CLOSE_LIST);
public static final ILoggingAction REPOSITORY_ENTRY_PROPERTIES_COURSESEARCH_DISABLED =
new LearningResourceLoggingAction(ActionType.admin, CrudAction.update, ActionVerb.remove, ActionObject.search).setTypeList(LEARNING_RESOURCE_OPEN_CLOSE_LIST);
public static final ILoggingAction REPOSITORY_ENTRY_PROPERTIES_GLOSSARY_ENABLED =
new LearningResourceLoggingAction(ActionType.admin, CrudAction.update, ActionVerb.add, ActionObject.glossar).setTypeList(LEARNING_RESOURCE_OPEN_CLOSE_LIST);
public static final ILoggingAction REPOSITORY_ENTRY_PROPERTIES_GLOSSARY_DISABLED =
......
......@@ -271,7 +271,7 @@ public class CourseConfig implements Serializable, Cloneable {
}
if (version == 11) {
if (!configuration.containsKey(COURSESEARCH_ENABLED)) configuration.put(COURSESEARCH_ENABLED, Boolean.TRUE);
if (!configuration.containsKey(COURSESEARCH_ENABLED)) configuration.put(COURSESEARCH_ENABLED, Boolean.FALSE);
this.version = 12;
}
......
......@@ -59,6 +59,7 @@ public class CourseConfigEvent extends MultiUserEvent {
public static enum CourseConfigType {
efficiencyStatement,
calendar,
search,
chat,
glossary,
layout
......
......@@ -94,7 +94,7 @@ public class CourseOptionsController extends FormBasicController {
private FormLink addGlossaryCommand, removeGlossaryCommand;
private StaticTextElement glossaryNameEl;
private FormLink saveButton;
private FormLayoutContainer saveCont, calendarCont, chatCont, glossaryCont, sharedFolderCont;
private FormLayoutContainer saveCont, calendarCont, searchCont, chatCont, glossaryCont, sharedFolderCont;
private FormLink addFolderCommand, removeFolderCommand;
private StaticTextElement folderNameEl;
......@@ -211,9 +211,20 @@ public class CourseOptionsController extends FormBasicController {
}
}
//searchbar
searchEl = uifactory.addCheckboxesHorizontal("searchIsOn", "chkbx.search.onoff", menuCont, onKeys, onValues);
searchEl.select(onKeys[0], courseConfig.isCourseSearchEnabled());
searchCont = FormLayoutContainer.createDefaultFormLayout("search", getTranslator());
searchCont.setRootForm(mainForm);
formLayout.add(searchCont);
boolean searchEnabled = courseConfig.isCourseSearchEnabled();
boolean managedSearch = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.search);
searchEl = uifactory.addCheckboxesHorizontal("searchIsOn", "chkbx.search.onoff", searchCont, onKeys, onValues);
searchEl.addActionListener(FormEvent.ONCHANGE);
searchEl.select(onKeys[0], searchEnabled);
searchEl.setEnabled(editable && !managedSearch);
if(managedSearch && searchEnabled) {
canHideToolbar &= false;
}
//chat
chatCont = FormLayoutContainer.createDefaultFormLayout("chat", getTranslator());
......@@ -383,6 +394,7 @@ public class CourseOptionsController extends FormBasicController {
calendarCont.setVisible(enabled);
}
chatCont.setVisible(enabled);
searchCont.setVisible(enabled);
glossaryCont.setVisible(enabled);
}
......@@ -457,13 +469,14 @@ public class CourseOptionsController extends FormBasicController {
boolean toolbarEnabled = toolbarEl.isSelected(0);
courseConfig.setToolbarEnabled(toolbarEnabled);
boolean enableSearch = searchEl.isSelected(0);
boolean updateSearch = courseConfig.isCourseSearchEnabled() != enableSearch;
courseConfig.setCourseSearchEnabled(enableSearch && toolbarEnabled);
boolean enableChat = chatEl.isSelected(0);
boolean updateChat = courseConfig.isChatEnabled() != enableChat;
courseConfig.setChatIsEnabled(enableChat && toolbarEnabled);
boolean enableSearch = searchEl.isSelected(0);
courseConfig.setCourseSearchEnabled(enableSearch && toolbarEnabled);
boolean enableCalendar = calendarEl == null ? false : calendarEl.isSelected(0);
boolean updateCalendar = courseConfig.isCalendarEnabled() != enableCalendar && calendarModule.isEnableCourseToolCalendar();
courseConfig.setCalendarEnabled(enableCalendar && toolbarEnabled);
......@@ -494,6 +507,16 @@ public class CourseOptionsController extends FormBasicController {
CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
if(updateSearch) {
ILoggingAction loggingAction = enableSearch ?
LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_COURSESEARCH_ENABLED :
LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_COURSESEARCH_DISABLED;
ThreadLocalUserActivityLogger.log(loggingAction, getClass());
CoordinatorManager.getInstance().getCoordinator().getEventBus()
.fireEventToListenersOf(new CourseConfigEvent(CourseConfigType.search, course.getResourceableId()), course);
}
if(updateChat) {
ILoggingAction loggingAction = enableChat ?
......
......@@ -779,9 +779,10 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
}
// add course search to toolbox
if (!assessmentLock && cc.isCourseSearchEnabled() && !isGuestOnly) {
boolean isSearchEnabled = !assessmentLock && !isGuestOnly;
if (isSearchEnabled) {
searchLink = LinkFactory.createToolLink("coursesearch", translate("command.coursesearch"), this, "o_icon_search");
searchLink.setVisible(imModule.isCourseEnabled() && cc.isChatEnabled());
searchLink.setVisible(cc.isCourseSearchEnabled());
toolbarPanel.addTool(searchLink);
}
......@@ -1704,6 +1705,15 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
}
break;
}
case search: {
if(searchLink != null) {
ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
CourseConfig cc = course.getCourseEnvironment().getCourseConfig();
searchLink.setVisible(cc.isCourseSearchEnabled());
toolbarPanel.setDirty(true);
}
break;
}
case chat: {
if(chatLink != null) {
ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
......
......@@ -45,6 +45,7 @@ public enum RepositoryEntryManagedFlag {
location(details,all),
settings(all),//max num of participants...
access(settings,all),
search(settings, all),
chat(settings,all),
layout(settings,all),
resourcefolder(settings,all),
......
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