From a3d4571d8e525c6d10a87ef7904d61e703975eb8 Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Wed, 11 Jun 2014 16:58:37 +0200 Subject: [PATCH] OO-1068: make the simple search field work in the group site --- .../components/form/flexible/impl/Form.java | 28 +++++++--- .../flexible/impl/FormLayoutContainer.java | 15 +----- .../ExtendedFlexiTableSearchController.java | 6 +++ .../elements/table/FlexiTableElementImpl.java | 16 ++++-- .../elements/table/FlexiTableSearchEvent.java | 54 +++++++++++++++++++ .../component/FormComponentTraverser.java | 7 --- .../CourseBusinessGroupListController.java | 7 ++- .../AbstractBusinessGroupListController.java | 24 ++++++--- .../ui/main/BusinessGroupListController.java | 7 +-- .../main/BusinessGroupSearchController.java | 14 ++++- .../FavoritBusinessGroupListController.java | 5 +- .../main/OpenBusinessGroupListController.java | 14 ++--- .../OverviewBusinessGroupListController.java | 7 ++- .../SearchBusinessGroupListController.java | 17 ++++-- .../main/SelectBusinessGroupController.java | 6 +-- ...ctBusinessGroupCourseAuthorController.java | 5 +- .../SelectFavoritBusinessGroupController.java | 6 +-- .../SelectOwnedBusinessGroupController.java | 5 +- .../SelectSearchBusinessGroupController.java | 13 +++++ .../ui/metadata/ExtendedSearchController.java | 10 +++- .../ui/author/AuthorSearchController.java | 12 ++++- 21 files changed, 206 insertions(+), 72 deletions(-) create mode 100644 src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/FlexiTableSearchEvent.java diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/Form.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/Form.java index 1fef16f71eb..8e2e1ead54a 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/Form.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/Form.java @@ -51,6 +51,7 @@ import org.olat.core.gui.components.ComponentCollection; import org.olat.core.gui.components.form.flexible.FormBaseComponentIdProvider; import org.olat.core.gui.components.form.flexible.FormItem; import org.olat.core.gui.components.form.flexible.FormItemContainer; +import org.olat.core.gui.components.form.flexible.elements.Submit; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.translator.Translator; @@ -162,7 +163,6 @@ public class Form extends LogDelegator { private boolean hasAlreadyFired; private List<FormBasicController> formListeners; private boolean isValidAndSubmitted=true; - private FormItem submitFormItem; private boolean isDirtyMarking=true; private boolean multipartEnabled = false; private long multipartUploadMaxSizeKB = 0; @@ -238,7 +238,11 @@ public class Form extends LogDelegator { //case if: //enter was pressed in Safari / IE //crawler tries form links - if(submitFormItem != null){ + + SubmitFormComponentVisitor efcv = new SubmitFormComponentVisitor(); + new FormComponentTraverser(efcv, formLayout, false).visitAll(ureq); + Submit submitFormItem = efcv.getSubmit(); + if(submitFormItem != null) { //if we have submit form item //assume a click on this item dispatchUri = FormBaseComponentIdProvider.DISPPREFIX + submitFormItem.getComponent().getDispatchID(); @@ -672,7 +676,23 @@ public class Form extends LogDelegator { fi.evalFormRequest(ureq); return true;// visit further } + } + + private static class SubmitFormComponentVisitor implements FormComponentVisitor { + + private Submit submit; + + public Submit getSubmit() { + return submit; + } + public boolean visit(FormItem fi, UserRequest ureq) { + if(fi instanceof Submit) { + submit = (Submit)fi; + return false; + } + return true; + } } private class FindParentFormComponentVisitor implements FormComponentVisitor { @@ -820,10 +840,6 @@ public class Form extends LogDelegator { return isValidAndSubmitted; } - void registerSubmit(FormItem submFormItem) { - this.submitFormItem = submFormItem; - } - /** * true if the form should not loose unsubmitted changes, if another link * is clicked which throws away the changes. diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/FormLayoutContainer.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/FormLayoutContainer.java index fb669cb849f..6cf446c0da5 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/FormLayoutContainer.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/FormLayoutContainer.java @@ -41,7 +41,6 @@ import org.olat.core.gui.components.form.flexible.FormItemContainer; import org.olat.core.gui.components.form.flexible.FormItemDependencyRule; import org.olat.core.gui.components.form.flexible.FormLayouter; import org.olat.core.gui.components.form.flexible.FormMultipartItem; -import org.olat.core.gui.components.form.flexible.elements.Submit; import org.olat.core.gui.components.velocity.VelocityContainer; import org.olat.core.gui.control.Disposable; import org.olat.core.gui.render.velocity.VelocityRenderDecorator; @@ -202,12 +201,7 @@ public class FormLayoutContainer extends FormItemImpl implements FormItemContain formLayoutContainer.put(formCompName + FormItem.ERRORC, formComp.getErrorC()); formLayoutContainer.put(formCompName + FormItem.EXAMPLEC, formComp.getExampleC()); formLayoutContainer.put(formCompName + FormItem.LABELC, formComp.getLabelC()); - /* - * recognize submits and register it for the IE enter-pressing - */ - if(formComp instanceof Submit){ - getRootForm().registerSubmit(formComp); - } + // Check for multipart data, add upload limit to form if (formComp instanceof FormMultipartItem) { FormMultipartItem mpItem = (FormMultipartItem) formComp; @@ -314,12 +308,7 @@ public class FormLayoutContainer extends FormItemImpl implements FormItemContain formLayoutContainer.put(formCompName + FormItem.ERRORC, with.getErrorC()); formLayoutContainer.put(formCompName + FormItem.EXAMPLEC, with.getExampleC()); formLayoutContainer.put(formCompName + FormItem.LABELC, with.getLabelC()); - /* - * recognize submits and register it for the IE enter-pressing - */ - if(with instanceof Submit){ - getRootForm().registerSubmit(with); - } + // Check for multipart data, add upload limit to form if (with instanceof FormMultipartItem) { FormMultipartItem mpItem = (FormMultipartItem) with; diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/ExtendedFlexiTableSearchController.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/ExtendedFlexiTableSearchController.java index 6abfa4c1712..016fa22a17e 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/ExtendedFlexiTableSearchController.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/ExtendedFlexiTableSearchController.java @@ -32,6 +32,12 @@ import org.olat.core.gui.control.Controller; */ public interface ExtendedFlexiTableSearchController extends Controller { + /** + * Enable or disable the extened search controller. If disabled, + * the controller doesn't catch submit event, or do the validation + */ + public void setEnabled(boolean enable); + public List<String> getConditionalQueries(); public FormItem getInitialFormItem(); diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/FlexiTableElementImpl.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/FlexiTableElementImpl.java index cc1c2452d97..183d78fbc75 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/FlexiTableElementImpl.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/FlexiTableElementImpl.java @@ -582,7 +582,11 @@ public class FlexiTableElementImpl extends FormItemImpl implements FlexiTableEle @Override public Iterable<FormItem> getFormItems() { - return components.values(); + List<FormItem> items = new ArrayList<>(components.values()); + if(extendedSearchCtrl != null && !extendedSearchExpanded) { + items.remove(extendedSearchCtrl.getInitialFormItem()); + } + return items; } @Override @@ -791,6 +795,7 @@ public class FlexiTableElementImpl extends FormItemImpl implements FlexiTableEle component.setDirty(true); } extendedSearchExpanded = true; + extendedSearchCtrl.setEnabled(true); } @Override @@ -799,6 +804,7 @@ public class FlexiTableElementImpl extends FormItemImpl implements FlexiTableEle callout.deactivate(); } extendedSearchExpanded = false; + extendedSearchCtrl.setEnabled(false); } protected void customizeCallout(UserRequest ureq) { @@ -900,7 +906,7 @@ public class FlexiTableElementImpl extends FormItemImpl implements FlexiTableEle search = searchFieldEl.getValue(); } List<String> condQueries = extendedSearchCtrl.getConditionalQueries(); - doSearch(search, condQueries); + doSearch(ureq, search, condQueries); } protected void evalSearchRequest(UserRequest ureq) { @@ -908,7 +914,7 @@ public class FlexiTableElementImpl extends FormItemImpl implements FlexiTableEle searchFieldEl.evalFormRequest(ureq); String search = searchFieldEl.getValue(); if(StringHelper.containsNonWhitespace(search)) { - doSearch(search, null); + doSearch(ureq, search, null); } else { doResetSearch(); } @@ -937,7 +943,7 @@ public class FlexiTableElementImpl extends FormItemImpl implements FlexiTableEle } - protected void doSearch(String search, List<String> condQueries) { + protected void doSearch(UserRequest ureq, String search, List<String> condQueries) { if(condQueries == null || condQueries.isEmpty()) { conditionalQueries = null; } else { @@ -948,6 +954,8 @@ public class FlexiTableElementImpl extends FormItemImpl implements FlexiTableEle resetInternComponents(); dataSource.clear(); dataSource.load(search, conditionalQueries, 0, getPageSize(), orderBy); + } else { + getRootForm().fireFormEvent(ureq, new FlexiTableSearchEvent(this, search, condQueries, FormEvent.ONCLICK)); } } diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/FlexiTableSearchEvent.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/FlexiTableSearchEvent.java new file mode 100644 index 00000000000..1581f38c178 --- /dev/null +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/FlexiTableSearchEvent.java @@ -0,0 +1,54 @@ +/** + * <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> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.core.gui.components.form.flexible.impl.elements.table; + +import java.util.List; + +import org.olat.core.gui.components.form.flexible.FormItem; +import org.olat.core.gui.components.form.flexible.impl.FormEvent; + +/** + * + * Initial date: 11.06.2014<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class FlexiTableSearchEvent extends FormEvent { + + private static final long serialVersionUID = -1977791683080030187L; + public static final String CMD = "ftSearch"; + + private final String search; + private final List<String> condQueries; + + public FlexiTableSearchEvent(FormItem source, String search, List<String> condQueries, int action) { + super("ftSearch", source, action); + this.search = search; + this.condQueries = condQueries; + } + + public String getSearch() { + return search; + } + + public List<String> getCondQueries() { + return condQueries; + } +} diff --git a/src/main/java/org/olat/core/util/component/FormComponentTraverser.java b/src/main/java/org/olat/core/util/component/FormComponentTraverser.java index bc76fb1d4cd..11386bf3e06 100644 --- a/src/main/java/org/olat/core/util/component/FormComponentTraverser.java +++ b/src/main/java/org/olat/core/util/component/FormComponentTraverser.java @@ -69,13 +69,6 @@ public class FormComponentTraverser { for(FormItem item:co.getFormItems()) { doVisit(item, ureq); } - /* - Map<String, FormItem> children = co.getFormComponents(); - Set<FormItem> formItems = new HashSet<FormItem>(children.values()); - for (Iterator<FormItem> iter = formItems.iterator(); iter.hasNext();) { - doVisit(iter.next(), ureq); - } - */ } if (visitChildrenFirst) { v.visit(node, ureq); diff --git a/src/main/java/org/olat/course/member/CourseBusinessGroupListController.java b/src/main/java/org/olat/course/member/CourseBusinessGroupListController.java index 667b27e195f..b340ef7e496 100644 --- a/src/main/java/org/olat/course/member/CourseBusinessGroupListController.java +++ b/src/main/java/org/olat/course/member/CourseBusinessGroupListController.java @@ -272,9 +272,14 @@ public class CourseBusinessGroupListController extends AbstractBusinessGroupList return new SearchBusinessGroupParams(); } + @Override + protected SearchBusinessGroupParams getDefaultSearchParams() { + return new SearchBusinessGroupParams(); + } + @Override protected void reloadModel() { - updateTableModel(new SearchBusinessGroupParams(), false); + doDefaultSearch(); } @Override diff --git a/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java b/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java index e2c303b0cff..91507e98cf8 100644 --- a/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java +++ b/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java @@ -47,6 +47,7 @@ import org.olat.core.gui.components.form.flexible.elements.FormLink; import org.olat.core.gui.components.form.flexible.impl.FormBasicController; import org.olat.core.gui.components.form.flexible.impl.FormEvent; import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel; +import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent; import org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent; import org.olat.core.gui.components.link.Link; import org.olat.core.gui.components.table.ColumnDescriptor; @@ -370,6 +371,8 @@ public abstract class AbstractBusinessGroupListController extends FormBasicContr } else if (TABLE_ACTION_SELECT.equals(cmd)) { doSelect(ureq, businessGroup); } + } else if(event instanceof FlexiTableSearchEvent) { + doSearch((FlexiTableSearchEvent)event); } } super.formInnerEvent(ureq, source, event); @@ -453,7 +456,7 @@ public abstract class AbstractBusinessGroupListController extends FormBasicContr } cmc.deactivate(); cleanUpPopups(); - }else if(source == searchCtrl) { + } else if(source == searchCtrl) { if(event instanceof SearchEvent) { doSearch(ureq, (SearchEvent)event); } @@ -790,8 +793,6 @@ public abstract class AbstractBusinessGroupListController extends FormBasicContr } protected void doSearch(UserRequest ureq, SearchEvent event) { - long start = isLogDebugEnabled() ? System.currentTimeMillis() : 0; - search(event); //back button @@ -800,10 +801,12 @@ public abstract class AbstractBusinessGroupListController extends FormBasicContr currentEntry.setTransientState(event); } addToHistory(ureq, this); - - if(isLogDebugEnabled()) { - logDebug("Group search takes (ms): " + (System.currentTimeMillis() - start), null); - } + } + + protected void doSearch(FlexiTableSearchEvent event) { + SearchBusinessGroupParams params = getDefaultSearchParams(); + params.setNameOrDesc(event.getSearch()); + updateTableModel(params, false); } private void search(SearchEvent event) { @@ -817,6 +820,13 @@ public abstract class AbstractBusinessGroupListController extends FormBasicContr protected abstract SearchBusinessGroupParams getSearchParams(SearchEvent event); + protected abstract SearchBusinessGroupParams getDefaultSearchParams(); + + protected boolean doDefaultSearch() { + SearchBusinessGroupParams params = getDefaultSearchParams(); + return updateTableModel(params, false).isEmpty(); + } + private void doSelect(UserRequest ureq, List<BGTableItem> items) { List<BusinessGroup> selection = toBusinessGroups(ureq, items, false); fireEvent(ureq, new BusinessGroupSelectionEvent(selection)); diff --git a/src/main/java/org/olat/group/ui/main/BusinessGroupListController.java b/src/main/java/org/olat/group/ui/main/BusinessGroupListController.java index 5b34bb6f8a9..8b309696f17 100644 --- a/src/main/java/org/olat/group/ui/main/BusinessGroupListController.java +++ b/src/main/java/org/olat/group/ui/main/BusinessGroupListController.java @@ -60,12 +60,13 @@ public class BusinessGroupListController extends AbstractBusinessGroupListContro return params; } - protected void updateAllGroups() { + @Override + protected SearchBusinessGroupParams getDefaultSearchParams() { SearchBusinessGroupParams params = new SearchBusinessGroupParams(); params.setAttendee(true); params.setOwner(true); params.setWaiting(true); params.setIdentity(getIdentity()); - updateTableModel(params, false); + return params; } -} +} \ No newline at end of file diff --git a/src/main/java/org/olat/group/ui/main/BusinessGroupSearchController.java b/src/main/java/org/olat/group/ui/main/BusinessGroupSearchController.java index 245024689a6..cd2b1a919d7 100644 --- a/src/main/java/org/olat/group/ui/main/BusinessGroupSearchController.java +++ b/src/main/java/org/olat/group/ui/main/BusinessGroupSearchController.java @@ -77,6 +77,7 @@ public class BusinessGroupSearchController extends FormBasicController implement private final boolean showId; private final boolean managedEnable; + private boolean enabled = false; /** * Generic search form. @@ -182,6 +183,11 @@ public class BusinessGroupSearchController extends FormBasicController implement // } + @Override + public void setEnabled(boolean enable) { + this.enabled = enable; + } + public void enableId(boolean enable) { id.setVisible(enable); } @@ -213,6 +219,8 @@ public class BusinessGroupSearchController extends FormBasicController implement @Override protected boolean validateFormLogic(UserRequest ureq) { + if(!enabled) return true; + boolean allOk = true; return allOk & super.validateFormLogic(ureq); @@ -226,8 +234,10 @@ public class BusinessGroupSearchController extends FormBasicController implement } @Override - protected void formOK (UserRequest ureq) { - fireSearchEvent(ureq); + protected void formOK(UserRequest ureq) { + if(enabled) { + fireSearchEvent(ureq); + } } @Override diff --git a/src/main/java/org/olat/group/ui/main/FavoritBusinessGroupListController.java b/src/main/java/org/olat/group/ui/main/FavoritBusinessGroupListController.java index f27047ee658..5a5d117d875 100644 --- a/src/main/java/org/olat/group/ui/main/FavoritBusinessGroupListController.java +++ b/src/main/java/org/olat/group/ui/main/FavoritBusinessGroupListController.java @@ -59,13 +59,14 @@ public class FavoritBusinessGroupListController extends AbstractBusinessGroupLis return params; } - protected boolean updateMarkedGroups() { + @Override + protected SearchBusinessGroupParams getDefaultSearchParams() { SearchBusinessGroupParams params = new SearchBusinessGroupParams(); params.setMarked(Boolean.TRUE); params.setAttendee(true); params.setOwner(true); params.setWaiting(true); params.setIdentity(getIdentity()); - return !updateTableModel(params, true).isEmpty(); + return params; } } diff --git a/src/main/java/org/olat/group/ui/main/OpenBusinessGroupListController.java b/src/main/java/org/olat/group/ui/main/OpenBusinessGroupListController.java index dea3f19d5fc..c8022d803ca 100644 --- a/src/main/java/org/olat/group/ui/main/OpenBusinessGroupListController.java +++ b/src/main/java/org/olat/group/ui/main/OpenBusinessGroupListController.java @@ -78,13 +78,6 @@ public class OpenBusinessGroupListController extends AbstractBusinessGroupListCo return columnsModel; } - public void updateOpenGroups() { - //find all accessible business groups - SearchBusinessGroupParams params = new SearchBusinessGroupParams(); - params.setPublicGroups(Boolean.TRUE); - updateTableModel(params, false); - } - @Override protected void doLaunch(UserRequest ureq, BusinessGroup group) { if(businessGroupService.isIdentityInBusinessGroup(getIdentity(), group)) { @@ -101,4 +94,11 @@ public class OpenBusinessGroupListController extends AbstractBusinessGroupListCo params.setPublicGroups(Boolean.TRUE); return params; } + + @Override + protected SearchBusinessGroupParams getDefaultSearchParams() { + SearchBusinessGroupParams params = new SearchBusinessGroupParams(); + params.setPublicGroups(Boolean.TRUE); + return params; + } } \ No newline at end of file diff --git a/src/main/java/org/olat/group/ui/main/OverviewBusinessGroupListController.java b/src/main/java/org/olat/group/ui/main/OverviewBusinessGroupListController.java index d8d0f367b12..c0ce87e3890 100644 --- a/src/main/java/org/olat/group/ui/main/OverviewBusinessGroupListController.java +++ b/src/main/java/org/olat/group/ui/main/OverviewBusinessGroupListController.java @@ -153,7 +153,7 @@ public class OverviewBusinessGroupListController extends BasicController impleme favoritGroupsCtrl = new FavoritBusinessGroupListController(ureq, bwControl); listenTo(favoritGroupsCtrl); } - favoritGroupsCtrl.updateMarkedGroups(); + favoritGroupsCtrl.doDefaultSearch(); mainVC.put("groupList", favoritGroupsCtrl.getInitialComponent()); addToHistory(ureq, favoritGroupsCtrl); return favoritGroupsCtrl; @@ -167,7 +167,7 @@ public class OverviewBusinessGroupListController extends BasicController impleme myGroupsCtrl = new BusinessGroupListController(ureq, bwControl); listenTo(myGroupsCtrl); } - myGroupsCtrl.updateAllGroups(); + myGroupsCtrl.doDefaultSearch(); mainVC.put("groupList", myGroupsCtrl.getInitialComponent()); addToHistory(ureq, myGroupsCtrl); return myGroupsCtrl; @@ -181,7 +181,7 @@ public class OverviewBusinessGroupListController extends BasicController impleme openGroupsCtrl = new OpenBusinessGroupListController(ureq, bwControl); listenTo(openGroupsCtrl); } - openGroupsCtrl.updateOpenGroups(); + openGroupsCtrl.doDefaultSearch(); mainVC.put("groupList", openGroupsCtrl.getInitialComponent()); addToHistory(ureq, openGroupsCtrl); return openGroupsCtrl; @@ -195,7 +195,6 @@ public class OverviewBusinessGroupListController extends BasicController impleme searchGroupsCtrl = new SearchBusinessGroupListController(ureq, bwControl); listenTo(searchGroupsCtrl); } - searchGroupsCtrl.updateSearch(ureq); mainVC.put("groupList", searchGroupsCtrl.getInitialComponent()); addToHistory(ureq, searchGroupsCtrl); return searchGroupsCtrl; diff --git a/src/main/java/org/olat/group/ui/main/SearchBusinessGroupListController.java b/src/main/java/org/olat/group/ui/main/SearchBusinessGroupListController.java index 3edfdeb5cdd..13bd705eaf6 100644 --- a/src/main/java/org/olat/group/ui/main/SearchBusinessGroupListController.java +++ b/src/main/java/org/olat/group/ui/main/SearchBusinessGroupListController.java @@ -49,10 +49,6 @@ public class SearchBusinessGroupListController extends AbstractBusinessGroupList protected FlexiTableColumnModel initColumnModel() { return BusinessGroupFlexiTableModel.getStandardColumnModel(true, flc, groupModule, getTranslator()); } - - protected void updateSearch(UserRequest ureq) { - doSearch(ureq, null); - } @Override protected SearchBusinessGroupParams getSearchParams(SearchEvent event) { @@ -66,4 +62,17 @@ public class SearchBusinessGroupListController extends AbstractBusinessGroupList } return params; } + + @Override + protected SearchBusinessGroupParams getDefaultSearchParams() { + SearchBusinessGroupParams params = new SearchBusinessGroupParams(); + //security + if(!isAdmin()) { + params.setOwner(true); + params.setAttendee(true); + params.setWaiting(true); + } + params.setIdentity(getIdentity()); + return params; + } } diff --git a/src/main/java/org/olat/group/ui/main/SelectBusinessGroupController.java b/src/main/java/org/olat/group/ui/main/SelectBusinessGroupController.java index 40cb53717d4..64423ee8b60 100644 --- a/src/main/java/org/olat/group/ui/main/SelectBusinessGroupController.java +++ b/src/main/java/org/olat/group/ui/main/SelectBusinessGroupController.java @@ -189,7 +189,7 @@ public class SelectBusinessGroupController extends BasicController { favoritGroupsCtrl.setFilter(filter); listenTo(favoritGroupsCtrl); } - boolean markedFound = favoritGroupsCtrl.updateMarkedGroups(); + boolean markedFound = favoritGroupsCtrl.doDefaultSearch(); mainVC.put("groupList", favoritGroupsCtrl.getInitialComponent()); return markedFound; } @@ -200,7 +200,7 @@ public class SelectBusinessGroupController extends BasicController { ownedGroupsCtrl.setFilter(filter); listenTo(ownedGroupsCtrl); } - ownedGroupsCtrl.updateOwnedGroups(); + ownedGroupsCtrl.doDefaultSearch(); mainVC.put("groupList", ownedGroupsCtrl.getInitialComponent()); } @@ -210,7 +210,7 @@ public class SelectBusinessGroupController extends BasicController { authorGroupsCtrL.setFilter(filter); listenTo(authorGroupsCtrL); } - authorGroupsCtrL.updateOwnedGroups(); + authorGroupsCtrL.doDefaultSearch(); mainVC.put("groupList", authorGroupsCtrL.getInitialComponent()); } diff --git a/src/main/java/org/olat/group/ui/main/SelectBusinessGroupCourseAuthorController.java b/src/main/java/org/olat/group/ui/main/SelectBusinessGroupCourseAuthorController.java index bb13efab246..abc58fc36f6 100644 --- a/src/main/java/org/olat/group/ui/main/SelectBusinessGroupCourseAuthorController.java +++ b/src/main/java/org/olat/group/ui/main/SelectBusinessGroupCourseAuthorController.java @@ -60,9 +60,10 @@ public class SelectBusinessGroupCourseAuthorController extends AbstractBusinessG return params; } - protected void updateOwnedGroups() { + @Override + protected SearchBusinessGroupParams getDefaultSearchParams() { SearchBusinessGroupParams params = new SearchBusinessGroupParams(); - updateTableModel(params, false); + return params; } @Override diff --git a/src/main/java/org/olat/group/ui/main/SelectFavoritBusinessGroupController.java b/src/main/java/org/olat/group/ui/main/SelectFavoritBusinessGroupController.java index 2a6365804fe..4a50502df25 100644 --- a/src/main/java/org/olat/group/ui/main/SelectFavoritBusinessGroupController.java +++ b/src/main/java/org/olat/group/ui/main/SelectFavoritBusinessGroupController.java @@ -64,14 +64,14 @@ public class SelectFavoritBusinessGroupController extends AbstractBusinessGroupL return params; } - - protected boolean updateMarkedGroups() { + @Override + protected SearchBusinessGroupParams getDefaultSearchParams() { SearchBusinessGroupParams params = new SearchBusinessGroupParams(); params.setMarked(Boolean.TRUE); params.setAttendee(true); params.setOwner(true); params.setWaiting(true); params.setIdentity(getIdentity()); - return !updateTableModel(params, true).isEmpty(); + return params; } } diff --git a/src/main/java/org/olat/group/ui/main/SelectOwnedBusinessGroupController.java b/src/main/java/org/olat/group/ui/main/SelectOwnedBusinessGroupController.java index 7c42009f2b5..070d9495513 100644 --- a/src/main/java/org/olat/group/ui/main/SelectOwnedBusinessGroupController.java +++ b/src/main/java/org/olat/group/ui/main/SelectOwnedBusinessGroupController.java @@ -61,12 +61,13 @@ public class SelectOwnedBusinessGroupController extends AbstractBusinessGroupLis return params; } - protected void updateOwnedGroups() { + @Override + protected SearchBusinessGroupParams getDefaultSearchParams() { SearchBusinessGroupParams params = new SearchBusinessGroupParams(); params.setIdentity(getIdentity()); params.setOwner(true); params.setAttendee(false); params.setWaiting(false); - updateTableModel(params, false); + return params; } } diff --git a/src/main/java/org/olat/group/ui/main/SelectSearchBusinessGroupController.java b/src/main/java/org/olat/group/ui/main/SelectSearchBusinessGroupController.java index 1b6b5cd5282..68f683bad2f 100644 --- a/src/main/java/org/olat/group/ui/main/SelectSearchBusinessGroupController.java +++ b/src/main/java/org/olat/group/ui/main/SelectSearchBusinessGroupController.java @@ -66,6 +66,19 @@ public class SelectSearchBusinessGroupController extends AbstractBusinessGroupLi return params; } + @Override + protected SearchBusinessGroupParams getDefaultSearchParams() { + SearchBusinessGroupParams params = new SearchBusinessGroupParams(); + //security + if(restricted) { + params.setOwner(true); + params.setAttendee(true); + params.setWaiting(true); + } + params.setIdentity(getIdentity()); + return params; + } + protected void updateSearch(UserRequest ureq) { doSearch(ureq, null); } diff --git a/src/main/java/org/olat/modules/qpool/ui/metadata/ExtendedSearchController.java b/src/main/java/org/olat/modules/qpool/ui/metadata/ExtendedSearchController.java index 989f649f2a2..795172d87a6 100644 --- a/src/main/java/org/olat/modules/qpool/ui/metadata/ExtendedSearchController.java +++ b/src/main/java/org/olat/modules/qpool/ui/metadata/ExtendedSearchController.java @@ -69,6 +69,7 @@ public class ExtendedSearchController extends FormBasicController implements Ext private final String prefsKey; private ExtendedSearchPrefs prefs; + private boolean enabled = true; private final QPoolService qpoolService; @@ -107,10 +108,17 @@ public class ExtendedSearchController extends FormBasicController implements Ext formLayout.add(buttonsCont); searchButton = uifactory.addFormLink("search", buttonsCont, Link.BUTTON); } + + @Override + public void setEnabled(boolean enable) { + this.enabled = enable; + } @Override protected void formOK(UserRequest ureq) { - doSearch(ureq); + if(enabled) { + doSearch(ureq); + } } @Override diff --git a/src/main/java/org/olat/repository/ui/author/AuthorSearchController.java b/src/main/java/org/olat/repository/ui/author/AuthorSearchController.java index f5cb90c6692..2c297d80d2a 100644 --- a/src/main/java/org/olat/repository/ui/author/AuthorSearchController.java +++ b/src/main/java/org/olat/repository/ui/author/AuthorSearchController.java @@ -62,6 +62,7 @@ public class AuthorSearchController extends FormBasicController implements Exten private String[] limitTypes; private boolean isAdmin; private boolean cancelAllowed; + private boolean enabled = true; @Autowired private RepositoryHandlerFactory repositoryHandlerFactory; @@ -170,8 +171,15 @@ public class AuthorSearchController extends FormBasicController implements Exten return null; } + @Override + public void setEnabled(boolean enable) { + this.enabled = enable; + } + @Override protected boolean validateFormLogic(UserRequest ureq) { + if(!enabled) return true; + if (displayName.isEmpty() && author.isEmpty() && description.isEmpty() && (id != null && id.isEmpty())) { showWarning("cif.error.allempty", null); return false; @@ -181,7 +189,9 @@ public class AuthorSearchController extends FormBasicController implements Exten @Override protected void formOK(UserRequest ureq) { - fireSearchEvent(ureq); + if(enabled) { + fireSearchEvent(ureq); + } } @Override -- GitLab