Skip to content

Commit

Permalink
MID-9087:fix for reload of items definitions of searched objects
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Sep 20, 2023
1 parent f2ba3ac commit def0584
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5251,12 +5251,20 @@ public Object getDisplayValue(DisplayableValue val) {

@Override
public String getIdValue(DisplayableValue val, int index) {
if (index == -1 && val != null && val.getValue() instanceof QName) {
Optional<DisplayableValue<T>> match = choices.getObject().stream()
.filter(choice -> QNameUtil.match((QName) choice.getValue(), (QName) val.getValue()))
.findFirst();
if (match.isPresent()) {
index = choices.getObject().indexOf(match.get());
}
}
return Integer.toString(index);
}

@Override
public DisplayableValue getObject(String id, IModel<? extends List<? extends DisplayableValue>> choices) {
return StringUtils.isNotBlank(id) ? choices.getObject().get(Integer.parseInt(id)) : null;
return StringUtils.isNotBlank(id) ? choices.getObject().get(Integer.valueOf(id)) : null;
}
}, allowNull);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,18 @@ private <AH extends AssignmentHolderType> Search<AH> createMemberSearch(Class<AH
null, getPageBase(), null, true, true, Search.PanelType.MEMBER_PANEL);
}

if (memberPanelStorage.getSearch() != null) {
if (memberPanelStorage.getSearch() != null && !memberPanelStorage.getSearch().isTypeChanged()) {
return memberPanelStorage.getSearch();
}

SearchBoxConfigurationHelper searchBoxConfig = getSearchBoxConfiguration();
Search<AH> search = SearchFactory.createSearch(createSearchTypeItem(searchBoxConfig), null, null,

ContainerTypeSearchItem newSearchTypeItem = createSearchTypeItem(searchBoxConfig);
if (memberPanelStorage.getSearch() != null && memberPanelStorage.getSearch().isTypeChanged()) {
Class<AH> newType = memberPanelStorage.getSearch().getTypeClass();
newSearchTypeItem.setType(createTypeSearchValue(newType));
}
Search<AH> search = SearchFactory.createSearch(newSearchTypeItem, null, null,
null, getPageBase(), null, true, true, Search.PanelType.MEMBER_PANEL);
search.addCompositedSpecialItem(createMemberSearchPanel(search, searchBoxConfig));

Expand Down Expand Up @@ -488,7 +494,11 @@ protected <AH extends AssignmentHolderType> Class<AH> getChoiceForAllTypes() {

private <AH extends AssignmentHolderType> SearchValue<Class<AH>> createTypeSearchValue(QName type) {
Class<AH> typeClass = ObjectTypes.getObjectTypeClass(type);
return new SearchValue<>(typeClass, "ObjectType." + typeClass.getSimpleName());
return createTypeSearchValue(typeClass);
}

private <AH extends AssignmentHolderType> SearchValue<Class<AH>> createTypeSearchValue(Class<AH> type) {
return new SearchValue<>(type, "ObjectType." + type.getSimpleName());
}

protected LoadableModel<MultiFunctinalButtonDto> loadMultiFunctionalButtonModel(boolean useDefaultObjectRelations) {
Expand Down

0 comments on commit def0584

Please sign in to comment.