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

Merge OpenOLAT 10.5 to OpenOLAT default branch with e42d9ce9ea090ab139679eb0289b7f7f1fe22dc0

parents 984a2dff cbace641
No related branches found
No related tags found
No related merge requests found
Showing
with 1830 additions and 962 deletions
......@@ -29,7 +29,6 @@ import org.olat.basesecurity.IdentityShort;
import org.olat.core.CoreSpringFactory;
import org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider;
import org.olat.core.gui.control.generic.ajax.autocompletion.ListReceiver;
import org.olat.core.gui.util.CSSHelper;
import org.olat.core.id.UserConstants;
import org.olat.user.UserManager;
......@@ -52,7 +51,7 @@ public class UserSearchListProvider implements ListProvider {
@Override
public void getResult(String searchValue, ListReceiver receiver) {
Map<String, String> userProperties = new HashMap<String, String>();
Map<String, String> userProperties = new HashMap<>();
// We can only search in mandatory User-Properties due to problems
// with hibernate query with join and not existing rows
userProperties.put(UserConstants.FIRSTNAME, searchValue);
......@@ -70,7 +69,7 @@ public class UserSearchListProvider implements ListProvider {
String key = ident.getKey().toString();
String displayKey = ident.getName();
String displayText = userManager.getUserDisplayName(ident);
receiver.addEntry(key, displayKey, displayText, CSSHelper.CSS_CLASS_USER);
receiver.addEntry(key, displayKey, displayText, null);
}
if(hasMore){
receiver.addEntry(".....",".....");
......
......@@ -113,6 +113,7 @@ public class AutoCompleterController extends BasicController {
myContent.contextPut("showDisplayKey", Boolean.valueOf(showDisplayKey));
myContent.contextPut("inputWidth", Integer.valueOf(inputWidth));
myContent.contextPut("minChars", Integer.valueOf(minChars));
myContent.contextPut("inputValue", "");
// Create a mapper for the server responses for a given input
mapper = new AutoCompleterMapper(noResults, showDisplayKey, gprovider);
......
......@@ -42,7 +42,6 @@ public class AutoCompleterListReceiver extends LogDelegator implements ListRecei
private static final String VALUE = "value";
private static final String CSS_CLASS = "cssClass";
private static final String CSS_CLASS_EMPTY = "";
private static final String CSS_CLASS_WITH_ICON = "o_icon ";
private static final String DISPLAY_KEY = "displayKey";
private static final String DISPLAY_KEY_NO_RESULTS = "-";
......@@ -103,7 +102,7 @@ public class AutoCompleterListReceiver extends LogDelegator implements ListRecei
if (iconCssClass == null) {
object.put(CSS_CLASS, CSS_CLASS_EMPTY);
} else {
object.put(CSS_CLASS, CSS_CLASS_WITH_ICON + iconCssClass);
object.put(CSS_CLASS, iconCssClass);
}
// JSCON object finished
list.put(object);
......
......@@ -34,6 +34,7 @@ import org.olat.core.util.StringHelper;
public class AutoCompleterMapper implements Mapper {
private static final String PARAM_QUERY = "term";
protected static final String PARAM_KEY = "key";
protected static final String PARAM_VALUE = "val";
private final String noResults;
private final boolean showDisplayKey;
......
......@@ -63,6 +63,7 @@ import org.olat.core.gui.control.WindowControl;
public class FlexiAutoCompleterController extends FormBasicController {
protected static final String COMMAND_SELECT = "select";
protected static final String COMMAND_CHANGE = "change";
protected static final String JSNAME_INPUTFIELD = "o_autocomplete_input";
protected static final String JSNAME_DATASTORE = "autocompleterDatastore";
protected static final String JSNAME_COMBOBOX = "autocompleterCombobox";
......@@ -155,6 +156,7 @@ public class FlexiAutoCompleterController extends FormBasicController {
layoutCont.contextPut("inputWidth", Integer.valueOf(inputWidth));
layoutCont.contextPut("minChars", Integer.valueOf(minChars));
layoutCont.contextPut("flexi", Boolean.TRUE);
layoutCont.contextPut("inputValue", "");
layoutCont.getComponent().addListener(this);
// Create a mapper for the server responses for a given input
......@@ -179,17 +181,16 @@ public class FlexiAutoCompleterController extends FormBasicController {
*/
public void event(UserRequest ureq, Component source, Event event) {
if (source == flc.getComponent()) {
String value = getSearchValue(ureq);
flc.contextPut("inputValue", value);
if (event.getCommand().equals(COMMAND_SELECT)) {
doSelect(ureq);
}
} else if(source == mainForm.getInitialComponent()) {
if(allowNewValues) {
String searchValue = getSearchValue(ureq);
List<String> selectedEntries = new ArrayList<String>();
selectedEntries.add(searchValue);
fireEvent(ureq, new EntriesChosenEvent(selectedEntries));
} else {
super.event(ureq, source, event);
} else if (event.getCommand().equals(COMMAND_CHANGE)) {
if(allowNewValues) {
fireEvent(ureq, new NewValueChosenEvent(value));
} else {
super.event(ureq, source, event);
}
}
} else {
super.event(ureq, source, event);
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
*/
package org.olat.core.gui.control.generic.ajax.autocompletion;
import java.util.Collections;
/**
* Description:<br>
* This Event is triggered when a new value is entered into the autocomplete input that is not
* part of the suggested entries.
* <p>
* Initial Date: 31.05.2016 <br>
*
* @author Daniel Haag
*/
public class NewValueChosenEvent extends EntriesChosenEvent {
private static final long serialVersionUID = -7082754083015536137L;
/**
* @param newValue
*/
NewValueChosenEvent(String newValue) {
super(Collections.singletonList(newValue));
}
}
......@@ -8,7 +8,7 @@
$autocompleter_label
#end
<div class="$formElementClass">
<input type="text" size="$inputWidth" class="form-control" name='$r.getId("o_autocomplete_input")' id='$r.getId("o_autocomplete_input")' />
<input type="text" size="$inputWidth" value="$inputValue" class="form-control" name='$r.getId("o_autocomplete_input")' id='$r.getId("o_autocomplete_input")' />
</div>
#if($flexi)
</div>
......@@ -26,9 +26,11 @@ jQuery(function(){
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '${mapuri}?term=%QUERY',
wildcard: '%QUERY',
filter: function ( response ) {
return jQuery.map(response, function (object) {
return {
cssClass: object.cssClass,
value: '' + object.key,
#if($showDisplayKey)
fullName: object.displayKey + ": " + object.value
......@@ -48,9 +50,24 @@ jQuery(function(){
},{
minLength: 3,
displayKey: 'fullName',
source: fullNameTypeahead.ttAdapter()
source: fullNameTypeahead.ttAdapter(),
templates: {
#if ($autocompleter_emptymessage)
empty: [
'<div>','$autocompleter_emptymessage','</div>'
].join('\n'),
#end
suggestion: function(obj) {return "<div class='"+obj.cssClass+"'>"+obj.fullName+"</div>"}
}
}).on('typeahead:render', function (e) {
// disabled and error items should not be selectable
jQuery("div.o_disabled.tt-selectable, div.o_icon_error.tt-selectable").removeClass("tt-selectable");
}).on('typeahead:selected', function (e, object) {
$r.openJavaScriptCommand("select"),'key',object.value);
$r.openJavaScriptCommand("select"),'key',object.value,
'$r.getId("o_autocomplete_input")',jQuery('#$r.getId("o_autocomplete_input")').val());
}).on('typeahead:change', function(e, value) {
$r.openJavaScriptCommand("change"),'key','',
'$r.getId("o_autocomplete_input")',jQuery('#$r.getId("o_autocomplete_input")').val());
});
});
/* ]]> */
......
......@@ -42,6 +42,8 @@ public class CSSHelper {
public static final String CSS_CLASS_INFO = "o_icon_info";
public static final String CSS_CLASS_NEW = "o_icon_new";
public static final String CSS_CLASS_DISABLED = "o_disabled";
/**
* Get the icon css class for a file based on the file ending (e.g. hello.pdf)
*
......
......@@ -61,7 +61,7 @@ public class SortedProperties extends Properties {
public synchronized Enumeration<Object> keys() {
// sort elements based on detector (prop key) names
Set set = keySet();
return (Enumeration<Object>) sortKeys(set);
return sortKeys(set);
}
/**
......
......@@ -88,7 +88,7 @@ import org.olat.repository.controllers.ReferencableEntriesSearchController;
import org.olat.repository.controllers.RepositorySearchController.Can;
import org.olat.repository.handlers.RepositoryHandler;
import org.olat.repository.handlers.RepositoryHandlerFactory;
import org.olat.repository.ui.author.CreateRepositoryEntryController;
import org.olat.repository.ui.author.CreateEntryController;
import org.olat.search.service.indexer.LifeFullIndexer;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -126,7 +126,7 @@ public class QuestionListController extends AbstractItemListController implement
private ImportController importItemCtrl;
private CollectionTargetController listTargetCtrl;
private ShareTargetController shareTargetCtrl;
private CreateRepositoryEntryController addController;
private CreateEntryController addController;
private QuestionItemDetailsController currentDetailsCtrl;
private LayoutMain3ColsController currentMainDetailsCtrl;
private MetadataBulkChangeController bulkChangeCtrl;
......@@ -759,7 +759,7 @@ public class QuestionListController extends AbstractItemListController implement
removeAsListenerAndDispose(addController);
RepositoryHandler handler = repositoryHandlerFactory.getRepositoryHandler(type);
addController = new CreateRepositoryEntryController(ureq, getWindowControl(), handler);
addController = handler.createCreateRepositoryEntryController(ureq, getWindowControl());
addController.setCreateObject(new QItemList(items));
listenTo(addController);
cmc = new CloseableModalController(getWindowControl(), translate("close"), addController.getInitialComponent());
......
......@@ -445,6 +445,28 @@ public class RepositoryManager {
return displaynames.get(0);
}
/**
* Check if (and which) external IDs already exist.
* @param a collection of external IDs to check if already existing
* @return a list of already existing external IDs (or an emtpy list).
*/
public List<String> lookupExistingExternalIds(Collection<String> externalIds) {
if (externalIds == null || externalIds.isEmpty()) {
return Collections.emptyList();
}
StringBuilder query = new StringBuilder();
query.append("select v.externalId from ").append(RepositoryEntry.class.getName()).append(" as v ")
.append("where v.externalId in (:externalIds)");
List<String> existingExternalIds =
dbInstance.getCurrentEntityManager().createQuery(query.toString(), String.class)
.setParameter("externalIds", externalIds)
.getResultList();
return existingExternalIds;
}
/**
* Load a list of repository entry without all the security groups ...
* @param resources
......
......@@ -62,7 +62,7 @@ import org.olat.repository.controllers.RepositorySearchController.Can;
import org.olat.repository.handlers.RepositoryHandler;
import org.olat.repository.handlers.RepositoryHandlerFactory;
import org.olat.repository.ui.RepositoryTableModel;
import org.olat.repository.ui.author.CreateRepositoryEntryController;
import org.olat.repository.ui.author.CreateEntryController;
import org.olat.repository.ui.author.ImportRepositoryEntryController;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -95,7 +95,7 @@ public class ReferencableEntriesSearchController extends BasicController {
private Link importRessourceButton;
private Component createRessourceCmp;
private CreateRepositoryEntryController createController;
private CreateEntryController createController;
private ImportRepositoryEntryController importController;
private CloseableModalController cmc;
......@@ -302,7 +302,7 @@ public class ReferencableEntriesSearchController extends BasicController {
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(createController);
RepositoryHandler handler = (RepositoryHandler)((Link)source).getUserObject();
createController = new CreateRepositoryEntryController(ureq, getWindowControl(), handler);
createController = handler.createCreateRepositoryEntryController(ureq, getWindowControl());
listenTo(createController);
String title = translate(handler.getCreateLabelI18nKey());
......
......@@ -44,6 +44,8 @@ import org.olat.fileresource.types.ResourceEvaluation;
import org.olat.repository.ErrorList;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.model.RepositoryEntrySecurity;
import org.olat.repository.ui.author.CreateEntryController;
import org.olat.repository.ui.author.CreateRepositoryEntryController;
/**
......@@ -160,6 +162,16 @@ public interface RepositoryHandler {
*/
public StepsMainRunController createWizardController(OLATResourceable res, UserRequest ureq, WindowControl wControl);
/**
* Called if a user wants to open the create repository entry dialog for a Resourceable
* @param ureq
* @param wControl
* @return Controller able to create resourceable.
*/
default CreateEntryController createCreateRepositoryEntryController(UserRequest ureq, WindowControl wControl) {
return new CreateRepositoryEntryController(ureq, wControl, this);
}
/**
* Called if a user downloads a Resourceable that this handler can handle.
* @param res
......
......@@ -134,7 +134,7 @@ public class AuthorListController extends FormBasicController implements Activat
private StepsMainRunController closeCtrl;
private ConfirmDeleteController confirmDeleteCtrl;
private ImportRepositoryEntryController importCtrl;
private CreateRepositoryEntryController createCtrl;
private CreateEntryController createCtrl;
private CloseableCalloutWindowController toolsCalloutCtrl;
private boolean hasAuthorRight;
......@@ -594,7 +594,7 @@ public class AuthorListController extends FormBasicController implements Activat
if(createCtrl != null) return;
removeAsListenerAndDispose(createCtrl);
createCtrl = new CreateRepositoryEntryController(ureq, getWindowControl(), handler);
createCtrl = handler.createCreateRepositoryEntryController(ureq, getWindowControl());
listenTo(createCtrl);
removeAsListenerAndDispose(cmc);
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
*/
package org.olat.repository.ui.author;
import org.olat.core.gui.control.Controller;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.handlers.RepositoryHandler;
public interface CreateEntryController extends Controller {
public RepositoryEntry getAddedEntry();
public void setCreateObject(Object userObject);
public RepositoryHandler getHandler();
}
......@@ -52,7 +52,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class CreateRepositoryEntryController extends FormBasicController {
public class CreateRepositoryEntryController extends FormBasicController implements CreateEntryController {
public static final Event CREATION_WIZARD = new Event("start_wizard");
......@@ -74,10 +74,12 @@ public class CreateRepositoryEntryController extends FormBasicController {
initForm(ureq);
}
@Override
public RepositoryHandler getHandler() {
return handler;
}
@Override
public RepositoryEntry getAddedEntry() {
return addedEntry;
}
......@@ -86,6 +88,7 @@ public class CreateRepositoryEntryController extends FormBasicController {
return userObject;
}
@Override
public void setCreateObject(Object userObject) {
this.userObject = userObject;
}
......
......@@ -2,7 +2,7 @@
width: $o-autocomplete-width;
}
.tt-dropdown-menu {
.tt-menu {
width: $o-autocomplete-width;
margin-top: $padding-base-vertical;
padding: 0 0 0;
......@@ -21,11 +21,15 @@
line-height: $o-autocomplete-line-height;
}
.tt-suggestion.tt-cursor {
.tt-suggestion.tt-cursor, .tt-suggestion:hover {
color: $o-autocomplete-suggestion-color;
background-color: $o-autocomplete-suggestion-bg-color;
}
.tt-suggestion p {
margin: 0;
}
\ No newline at end of file
}
.tt-menu div.o_icon_error:before {
content:'';
}
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