Skip to content

Commit

Permalink
default collection view identifier while saving the search fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kateryna Honchar committed Jun 7, 2022
1 parent b9a35bc commit 661c4c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ public class SaveSearchPanel<C extends Containerable> extends BasePanel<Search<C
private Class<C> type;
IModel<String> feedbackMessageModel = Model.of();
IModel<String> queryNameModel = Model.of();
public SaveSearchPanel(String id, IModel<Search<C>> searchModel, Class<C> type) {
private String defaultCollectionViewIdentifier = null;
public SaveSearchPanel(String id, IModel<Search<C>> searchModel, Class<C> type, String defaultCollectionViewIdentifier) {
super(id, searchModel);
this.type = type;
this.defaultCollectionViewIdentifier = defaultCollectionViewIdentifier;
}

@Override
Expand Down Expand Up @@ -229,11 +231,8 @@ private void saveSearchItemToAdminConfig(AvailableFilterType availableFilter) {
FocusType principalFocus = getPageBase().getPrincipalFocus();
boolean newObjectListView = WebComponentUtil.getPrincipalUserObjectListView(getPageBase(), principalFocus, type, false) == null;
GuiObjectListViewType view = WebComponentUtil.getPrincipalUserObjectListView(getPageBase(), principalFocus, type, true);
if (view == null) {
view = new GuiObjectListViewType();
view.setType(WebComponentUtil.containerClassToQName(PrismContext.get(), type));
//view.setIdentifier(); //todo set collection view identifier
((UserType)principalFocus).getAdminGuiConfiguration().getObjectCollectionViews().objectCollectionView(view);
if (view.getIdentifier() == null) {
view.setIdentifier(defaultCollectionViewIdentifier);
}
SearchBoxConfigurationType searchConfig = view.getSearchBoxConfiguration();
if (searchConfig == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ public boolean isVisible() {
public void onClick(AjaxRequestTarget target) {
SaveSearchPanel<C> panel = new SaveSearchPanel<>(getPageBase().getMainPopupBodyId(),
Model.of(SearchPanel.this.getModelObject()),
SearchPanel.this.getModelObject().getTypeClass());
SearchPanel.this.getModelObject().getTypeClass(),
getCollectionInstanceDefaultIdentifier());
getPageBase().showMainPopup(panel, target);
}
};
Expand Down Expand Up @@ -318,6 +319,11 @@ private boolean isCollectionInstancePage() {
return getPageBase().getClass().getAnnotation(CollectionInstance.class) != null;
}

private String getCollectionInstanceDefaultIdentifier() {
CollectionInstance collectionInstance = getPageBase().getClass().getAnnotation(CollectionInstance.class);
return collectionInstance != null ? collectionInstance.identifier() : null;
}

private boolean isPopupWindow() {
Component parent = SearchPanel.this.getParent();
while (parent != null) {
Expand Down

0 comments on commit 661c4c4

Please sign in to comment.