Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Oct 20, 2022
2 parents 8a06cb8 + f4d1d93 commit c277db9
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* Popupable panel with listed items which can be searched and selected
* The component can be used as More button popup or saved searches popup on search panel
*/
public abstract class SelectableItemListPopoverPanel<T> extends BasePanel<List<T>> {
public abstract class SelectableItemListPopoverPanel<T extends AbstractSearchItemWrapper> extends BasePanel<List<T>> {

private static final long serialVersionUID = 1L;
private static final String ID_POPOVER = "popover";
Expand Down Expand Up @@ -157,7 +157,7 @@ public String getDataPlacement() {
help.add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(helpText)));
item.add(help);

item.add(new VisibleBehaviour(() -> isPropertyItemVisible(getItemName(item.getModelObject()), searchTextModel.getObject())));
item.add(new VisibleBehaviour(() -> !item.getModelObject().isVisible() && isPropertyItemVisible(getItemName(item.getModelObject()), searchTextModel.getObject())));
}

private boolean isPropertyItemVisible(String itemName, String propertySearchText) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ public Object getDisplayValue(Boolean val) {
}
}, false);
inputPanel.getBaseFormComponent().add(new EnableBehaviour(() -> getModelObject().getSearchConfig().isSearchScope(SearchBoxScopeType.SUBTREE)));
inputPanel.getBaseFormComponent().add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;

@Override
protected void onUpdate(AjaxRequestTarget target) {
searchPerformed(target);
}
});
return inputPanel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ protected Component initSearchItemField() {
DropDownChoicePanel inputPanel = new DropDownChoicePanel(ID_SEARCH_ITEM_FIELD,
new PropertyModel(getModel(), ScopeSearchItemWrapper.F_SEARCH_CONFIG + "." + SearchConfigurationWrapper.F_SCOPE),
Model.of(Arrays.asList(SearchBoxScopeType.values())), new EnumChoiceRenderer(), false);
inputPanel.getBaseFormComponent().add(new OnChangeAjaxBehavior() {

private static final long serialVersionUID = 1L;

@Override
protected void onUpdate(AjaxRequestTarget target) {
SearchPanel panel = findParent(SearchPanel.class);
panel.searchPerformed(target);
}
});
// inputPanel.getBaseFormComponent().add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
// inputPanel.getBaseFormComponent().add(AttributeAppender.append("style", "width: 88px; max-width: 400px !important;"));
inputPanel.setOutputMarkupId(true);
return inputPanel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public abstract class SearchPanel<C extends Containerable> extends BasePanel<Sea
private static final String ID_FULL_TEXT_FIELD = "fullTextField";
private static final String ID_OID_ITEM = "oidItem";

private LoadableModel<List<AbstractSearchItemWrapper>> basicSearchItemsModel;
private LoadableModel<List<AbstractSearchItemWrapper>> morePopupModel;
private LoadableDetachableModel<List<AbstractSearchItemWrapper>> basicSearchItemsModel;
private LoadableDetachableModel<List<AbstractSearchItemWrapper>> morePopupModel;
private LoadableDetachableModel<List<InlineMenuItem>> savedSearchListModel;
private static final Trace LOG = TraceManager.getTrace(SearchPanel.class);

Expand All @@ -142,30 +142,29 @@ protected void onInitialize() {
}

private void initBasicSearchItemsModel() {
basicSearchItemsModel = new LoadableModel<List<AbstractSearchItemWrapper>>(true) {
basicSearchItemsModel = new LoadableDetachableModel<List<AbstractSearchItemWrapper>>() {
private static final long serialVersionUID = 1L;
@Override
protected List<AbstractSearchItemWrapper> load() {
return getModelObject().getItems().stream().filter(item
-> !(item instanceof OidSearchItemWrapper) && item.isVisible())
return getModelObject().getItems()
.stream().filter(item
-> !(item instanceof OidSearchItemWrapper))
.collect(Collectors.toList());
}
};
}

private void initMorePopupModel() {
morePopupModel = new LoadableModel<List<AbstractSearchItemWrapper>>() {
morePopupModel = new LoadableDetachableModel<List<AbstractSearchItemWrapper>>() {
@Override
protected List<AbstractSearchItemWrapper> load() {
return getModelObject().getItems().stream().filter(item
-> !item.isVisible())
.collect(Collectors.toList());
return getModelObject().getItems();
}
};
}

public void displayedSearchItemsModelReset() {
basicSearchItemsModel.reset();
basicSearchItemsModel.detach();
}

private <S extends AbstractSearchItemWrapper, T extends Serializable> void initLayout() {
Expand Down Expand Up @@ -608,7 +607,7 @@ private void addItemPerformed(List<AbstractSearchItemWrapper> itemList, AjaxRequ

void refreshSearchForm(AjaxRequestTarget target) {
displayedSearchItemsModelReset();
morePopupModel.reset();
morePopupModel.detach();
target.add(get(ID_FORM));
saveSearch(getModelObject(), target);
}
Expand Down Expand Up @@ -794,6 +793,7 @@ private <T extends Serializable> void initBasicSearchLayout() {
@Override
protected void populateItem(ListItem<AbstractSearchItemWrapper> item) {
AbstractSearchItemPanel searchItemPanel = createSearchItemPanel(ID_ITEM, item.getModel());
searchItemPanel.add(new VisibleBehaviour(() -> item.getModelObject().isVisible()));
item.add(searchItemPanel);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javax.xml.namespace.QName;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseException;
Expand Down Expand Up @@ -388,11 +389,11 @@ private <AH extends AssignmentHolderType> Search<AH> createMemberSearch(Class<AH
return SearchFactory.createMemberPanelSearch(new SearchConfigurationWrapper<>(type, getPageBase()), getPageBase());
}

if (memberPanelStorage.getSearch() != null) {
if (memberPanelStorage.getSearch() != null && type.equals(memberPanelStorage.getSearch().getSearchConfigurationWrapper().getTypeClass())) {
return memberPanelStorage.getSearch();
}

Search<AH> search = SearchFactory.createMemberPanelSearch(createSearchConfigWrapper(getDefaultObjectType()), getPageBase());
Search<AH> search = SearchFactory.createMemberPanelSearch(createSearchConfigWrapper(type), getPageBase());
memberPanelStorage.setSearch(search);
return search;
}
Expand Down Expand Up @@ -1119,6 +1120,8 @@ protected QName getDefaultObjectType() {
protected IModel<String> getWarningMessageModel() {
if (isSubtreeScope()) {
return getPageBase().createStringResource("abstractRoleMemberPanel.unassign.warning.subtree");
} else if (isIndirect()) {
return getPageBase().createStringResource("abstractRoleMemberPanel.unassign.warning.indirect");
}
return null;
}
Expand Down Expand Up @@ -1184,8 +1187,10 @@ private void executeSimpleUnassignedOperation(IModel<?> rowModel, StringResource

@Override
protected IModel<String> getWarningMessageModel() {
if (isSubtreeScope()) {
if (isSubtreeScope() && rowModel == null) {
return createStringResource("abstractRoleMemberPanel.unassign.warning.subtree");
} else if (isIndirect() && rowModel == null) {
return createStringResource("abstractRoleMemberPanel.unassign.warning.indirect");
}
return null;
}
Expand Down Expand Up @@ -1477,8 +1482,23 @@ private boolean isSubtreeScope() {
return SearchBoxScopeType.SUBTREE == getScopeValue();
}

protected IndirectSearchItemWrapper getSearchIndirect() {
List<AbstractSearchItemWrapper<?>> items = getMemberPanelStorage().getSearch().getItems();
for (AbstractSearchItemWrapper<?> item : items) {
if (item instanceof IndirectSearchItemWrapper) {
return (IndirectSearchItemWrapper) item;
}
}
return null;
}

private boolean isIndirect() {
return getSearchBoxConfiguration().isIndirect();
if (getSearchIndirect() != null) {
if (getSearchIndirect().getValue() != null) {
return BooleanUtils.isTrue(getSearchIndirect().getValue().getValue());
}
}
return false;
}

protected @NotNull QName getSearchType() {
Expand All @@ -1488,8 +1508,8 @@ private boolean isIndirect() {
}

protected ScopeSearchItemWrapper getSearchScope() {
List<AbstractSearchItemWrapper> items = getMemberPanelStorage().getSearch().getItems();
for (AbstractSearchItemWrapper item : items) {
List<AbstractSearchItemWrapper<?>> items = getMemberPanelStorage().getSearch().getItems();
for (AbstractSearchItemWrapper<?> item : items) {
if (item instanceof ScopeSearchItemWrapper) {
return (ScopeSearchItemWrapper) item;
}
Expand All @@ -1505,8 +1525,8 @@ protected SearchBoxScopeType getScopeValue() {
}

protected RelationSearchItemWrapper getSearchRelation() {
List<AbstractSearchItemWrapper> items = getMemberPanelStorage().getSearch().getItems();
for (AbstractSearchItemWrapper item : items) {
List<AbstractSearchItemWrapper<?>> items = getMemberPanelStorage().getSearch().getItems();
for (AbstractSearchItemWrapper<?> item : items) {
if (item instanceof RelationSearchItemWrapper) {
return (RelationSearchItemWrapper) item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private void updateModel(ObjectReferenceType ref, MidpointForm<?> midpointForm,
if (ref == null) {
return;
}
if (getModelObject().getOid() != null && PolyStringUtils.isEmpty(ref.getTargetName()) && ref.getObject() == null){
if (getModelObject() != null && getModelObject().getOid() != null && PolyStringUtils.isEmpty(ref.getTargetName()) && ref.getObject() == null){
ref.setOid(getModelObject().getOid());
}
if (PolyStringUtils.isEmpty(ref.getTargetName())) {
Expand Down

0 comments on commit c277db9

Please sign in to comment.