Skip to content

Commit

Permalink
MID-7976 panel details now passed from menu to details popup, wip
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Aug 1, 2022
1 parent c3f79a2 commit 69f7320
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public class RoleCatalogPanel extends WizardStepPanel<RequestAccess> implements

private PageBase page;

private IModel<Search> searchModel;

private IModel<ListGroupMenu<RoleCatalogQueryItem>> menuModel;

public RoleCatalogPanel(IModel<RequestAccess> model, PageBase page) {
super(model);

Expand All @@ -106,6 +110,7 @@ public String getStepId() {
protected void onInitialize() {
super.onInitialize();

initModels();
initLayout();
}

Expand Down Expand Up @@ -186,17 +191,15 @@ private ObjectQuery createQueryFromCollectionUri(String collectionUri) {
.build();
}

private void initLayout() {
setOutputMarkupId(true);

IModel<Search> searchModel = new LoadableModel<>(false) {
private void initModels() {
searchModel = new LoadableModel<>(false) {
@Override
protected Search load() {
return SearchFactory.createSearch(RoleType.class, page);
}
};

IModel<ListGroupMenu<RoleCatalogQueryItem>> menuModel = new LoadableModel<>(false) {
menuModel = new LoadableModel<>(false) {
@Override
protected ListGroupMenu<RoleCatalogQueryItem> load() {
ListGroupMenu<RoleCatalogQueryItem> menu = loadRoleCatalogMenu();
Expand All @@ -205,6 +208,10 @@ protected ListGroupMenu<RoleCatalogQueryItem> load() {
return menu;
}
};
}

private void initLayout() {
setOutputMarkupId(true);

ObjectDataProvider provider = new ObjectDataProvider(this, searchModel) {

Expand All @@ -222,10 +229,15 @@ protected ObjectQuery getCustomizeContentQuery() {
return createQueryFromOrgRef(item.orgRef(), item.scopeOne());
}

if (item.collectionRef() != null) {
return createQueryFromCollectionRef(item.collectionRef());
} else if (item.collectionUri() != null) {
return createQueryFromCollectionUri(item.collectionUri());
RoleCollectionViewType collection = item.collection();
if (collection == null) {
return null;
}

if (collection.getCollectionRef() != null) {
return createQueryFromCollectionRef(collection.getCollectionRef());
} else if (collection.getCollectionUri() != null) {
return createQueryFromCollectionUri(collection.getCollectionUri());
}

return null;
Expand Down Expand Up @@ -437,20 +449,19 @@ private List<ListGroupMenuItem<RoleCatalogQueryItem>> createMenuFromRoleCollecti
try {
String name = null;
RoleCatalogQueryItem rcq = new RoleCatalogQueryItem();
rcq.collection(collection);

ObjectReferenceType collectionRef = collection.getCollectionRef();
if (collectionRef != null) {
PrismObject<ObjectCollectionType> objectCollection = WebModelServiceUtils.loadObject(collectionRef, page);

rcq.collectionRef(collectionRef);
name = WebComponentUtil.getDisplayNameOrName(objectCollection, true);
}

String collectionUri = collection.getCollectionUri();
if (StringUtils.isNotEmpty(collectionUri)) {
AssignmentViewType view = AssignmentViewType.getViewByUri(collectionUri);
if (view != null) {
rcq.collectionUri(collectionUri);
name = getString(view);
}
}
Expand Down Expand Up @@ -581,8 +592,8 @@ public void onClick(AjaxRequestTarget target) {
return columns;
}

private void itemDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
// todo this configuration has to go from menu -> item xml
// todo create default container panel configuration
private ContainerPanelConfigurationType createDefaultContainerPanelConfiguration() {
ContainerPanelConfigurationType c = new ContainerPanelConfigurationType();
c.identifier("some-panel");
c.type(RoleType.COMPLEX_TYPE);
Expand All @@ -597,7 +608,30 @@ private void itemDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
vcs.identifier("some-container");
vcs.beginItem().path(new ItemPathType(ItemPath.create(RoleType.F_NAME))).end();

CatalogItemDetailsPanel panel = new CatalogItemDetailsPanel(() -> Arrays.asList(c), Model.of(object)) {
return c;
}

private void itemDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
ContainerPanelConfigurationType config;

ListGroupMenuItem<RoleCatalogQueryItem> selectedMenu = menuModel.getObject().getActiveMenu();

RoleCatalogQueryItem item = selectedMenu != null ? selectedMenu.getValue() : null;
if (item == null || item.collection() == null) {
config = createDefaultContainerPanelConfiguration();
} else {
RoleCollectionViewType view = item.collection();
config = view.getDetails() != null ? view.getDetails() : createDefaultContainerPanelConfiguration();
}

List<ContainerPanelConfigurationType> finalConfig = new ArrayList<>();
if (!config.getPanel().isEmpty()) {
finalConfig.addAll(config.getPanel());
} else {
finalConfig.add(config);
}

CatalogItemDetailsPanel panel = new CatalogItemDetailsPanel(() -> finalConfig, Model.of(object)) {

@Override
protected void addPerformed(AjaxRequestTarget target, IModel<ObjectType> model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.evolveum.midpoint.gui.impl.page.self.requestAccess;

import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleCollectionViewType;

import java.io.Serializable;

Expand All @@ -20,25 +21,23 @@ public class RoleCatalogQueryItem implements Serializable {

private boolean scopeOne;

private ObjectReferenceType collectionRef;
private RoleCollectionViewType collection;

private String collectionUri;

public ObjectReferenceType orgRef() {
return orgRef;
public RoleCollectionViewType collection() {
return collection;
}

public RoleCatalogQueryItem orgRef(ObjectReferenceType orgRef) {
this.orgRef = orgRef;
public RoleCatalogQueryItem collection(RoleCollectionViewType collection) {
this.collection = collection;
return this;
}

public ObjectReferenceType collectionRef() {
return collectionRef;
public ObjectReferenceType orgRef() {
return orgRef;
}

public RoleCatalogQueryItem collectionRef(ObjectReferenceType collectionRef) {
this.collectionRef = collectionRef;
public RoleCatalogQueryItem orgRef(ObjectReferenceType orgRef) {
this.orgRef = orgRef;
return this;
}

Expand All @@ -50,13 +49,4 @@ public RoleCatalogQueryItem scopeOne(boolean scopeOne) {
this.scopeOne = scopeOne;
return this;
}

public String collectionUri() {
return collectionUri;
}

public RoleCatalogQueryItem collectionUri(String collectionUri) {
this.collectionUri = collectionUri;
return this;
}
}

0 comments on commit 69f7320

Please sign in to comment.